R/000-wrappers.R

Defines functions `vbrt` `[[<-.savvy_vibrrt__sealed` `$<-.savvy_vibrrt__sealed` .savvy_extract_ptr

# Generated by savvy: do not edit by hand
#
# Note:
#   This wrapper file is named as `000-wrappers.R` so that this file is loaded
#   first, which allows users to override the functions defined here (e.g., a
#   print() method for an enum).

#' @useDynLib vibrrt, .registration = TRUE
#' @keywords internal
NULL

# Check class and extract the external pointer embedded in the environment
.savvy_extract_ptr <- function(e, class) {
  if(is.null(e)) {
    return(NULL)
  }

  if(inherits(e, class)) {
    e$.ptr
  } else {
    msg <- paste0("Expected ", class, ", got ", class(e)[1])
    stop(msg, call. = FALSE)
  }
}

# Prohibit modifying environments

#' @export
`$<-.savvy_vibrrt__sealed` <- function(x, name, value) {
  class <- gsub("__bundle$", "", class(x)[1])
  stop(class, " cannot be modified", call. = FALSE)
}

#' @export
`[[<-.savvy_vibrrt__sealed` <- function(x, i, value) {
  class <- gsub("__bundle$", "", class(x)[1])
  stop(class, " cannot be modified", call. = FALSE)
}

#' Call vibrato tokenizer
#' @noRd
`vbrt` <- function(`x`, `sys_dic`, `user_dic`, `max_grouping_len`) {
  .Call(savvy_vbrt__impl, `x`, `sys_dic`, `user_dic`, `max_grouping_len`)
}
paithiov909/kagomer documentation built on June 12, 2025, 7:44 a.m.