R/native-bindings.R

Defines functions .onLoad .interface_negotiate .interface_error .native_live_handles .native_interface_handshake .native_selftest_summary .native_selftest_info .native_selftest_cases .native_selftest_status .native_selftest .native_info .native_conditions .native_schema .native_lint .native_submission_summary .native_submission_save .native_submission_timings .native_submission_issues .native_submission_created .native_submission_status .native_project_submission .native_project_run_summary .native_project_run_save .native_project_run_timings .native_project_run_report .native_project_run_issues .native_project_run_member_summary .native_project_run_member_timings .native_project_run_member_report .native_project_run_member_issues .native_project_run_output .native_project_run_member_status .native_project_run_names .native_project_run_status .native_project_run .native_project_check .native_project_names .native_project_summary .native_project_spec .native_run_observations .native_run_summary .native_run_save .native_run_timings .native_run_report .native_run_issues .native_run_output .native_run_status .native_read_odm .native_spec_resolve .native_spec_run .native_plans .native_spec_summary .native_check_summary .native_check_timings .native_check_issues .native_check_status .native_spec_check .native_core_version

# Generated by tools/packaging/generate_bindings.py --write. Do not edit.
# Authoritative source: rust/interface/bindings.yaml (see rust/interface/README.md).

.native_core_version <- function() {
  .Call(wrap__core_version)
}

.native_spec_check <- function(specification, project, parent, version, progress) {
  .Call(wrap__spec_check, specification, project, parent, version, progress)
}

.native_check_status <- function(handle) {
  .Call(wrap__check_status, handle)
}

.native_check_issues <- function(handle) {
  .Call(wrap__check_issues, handle)
}

.native_check_timings <- function(handle) {
  .Call(wrap__check_timings, handle)
}

.native_check_summary <- function(handle) {
  .Call(wrap__check_summary, handle)
}

.native_spec_summary <- function(specification) {
  .Call(wrap__spec_summary, specification)
}

.native_plans <- function(handle) {
  .Call(wrap__plans, handle)
}

.native_spec_run <- function(specification, project, version, capabilities, plans, stream, progress) {
  .Call(wrap__spec_run, specification, project, version, capabilities, plans, stream, progress)
}

.native_spec_resolve <- function(specification, project, version) {
  .Call(wrap__spec_resolve, specification, project, version)
}

.native_read_odm <- function(source, archive_member, max_archive_members, max_expanded_bytes, max_xml_depth) {
  .Call(wrap__read_odm, source, archive_member, max_archive_members, max_expanded_bytes, max_xml_depth)
}

.native_run_status <- function(handle) {
  .Call(wrap__run_status, handle)
}

.native_run_output <- function(handle) {
  .Call(wrap__run_output, handle)
}

.native_run_issues <- function(handle) {
  .Call(wrap__run_issues, handle)
}

.native_run_report <- function(handle) {
  .Call(wrap__run_report, handle)
}

.native_run_timings <- function(handle) {
  .Call(wrap__run_timings, handle)
}

.native_run_save <- function(handle) {
  .Call(wrap__run_save, handle)
}

.native_run_summary <- function(handle) {
  .Call(wrap__run_summary, handle)
}

.native_run_observations <- function(handle, include_measurements) {
  .Call(wrap__run_observations, handle, include_measurements)
}

.native_project_spec <- function(project, name, version) {
  .Call(wrap__project_spec, project, name, version)
}

.native_project_summary <- function(project) {
  .Call(wrap__project_summary, project)
}

.native_project_names <- function(project, version) {
  .Call(wrap__project_names, project, version)
}

.native_project_check <- function(project, version, progress) {
  .Call(wrap__project_check, project, version, progress)
}

.native_project_run <- function(project, section, version, capabilities, plans, progress) {
  .Call(wrap__project_run, project, section, version, capabilities, plans, progress)
}

.native_project_run_status <- function(handle) {
  .Call(wrap__project_run_status, handle)
}

.native_project_run_names <- function(handle) {
  .Call(wrap__project_run_names, handle)
}

.native_project_run_member_status <- function(handle, name) {
  .Call(wrap__project_run_member_status, handle, name)
}

.native_project_run_output <- function(handle, name) {
  .Call(wrap__project_run_output, handle, name)
}

.native_project_run_member_issues <- function(handle, name) {
  .Call(wrap__project_run_member_issues, handle, name)
}

.native_project_run_member_report <- function(handle, name) {
  .Call(wrap__project_run_member_report, handle, name)
}

.native_project_run_member_timings <- function(handle, name) {
  .Call(wrap__project_run_member_timings, handle, name)
}

.native_project_run_member_summary <- function(handle, name) {
  .Call(wrap__project_run_member_summary, handle, name)
}

.native_project_run_issues <- function(handle) {
  .Call(wrap__project_run_issues, handle)
}

.native_project_run_report <- function(handle) {
  .Call(wrap__project_run_report, handle)
}

.native_project_run_timings <- function(handle) {
  .Call(wrap__project_run_timings, handle)
}

.native_project_run_save <- function(handle) {
  .Call(wrap__project_run_save, handle)
}

.native_project_run_summary <- function(handle) {
  .Call(wrap__project_run_summary, handle)
}

.native_project_submission <- function(project, section, created, version, progress) {
  .Call(wrap__project_submission, project, section, created, version, progress)
}

.native_submission_status <- function(handle) {
  .Call(wrap__submission_status, handle)
}

.native_submission_created <- function(handle) {
  .Call(wrap__submission_created, handle)
}

.native_submission_issues <- function(handle) {
  .Call(wrap__submission_issues, handle)
}

.native_submission_timings <- function(handle) {
  .Call(wrap__submission_timings, handle)
}

.native_submission_save <- function(handle) {
  .Call(wrap__submission_save, handle)
}

.native_submission_summary <- function(handle) {
  .Call(wrap__submission_summary, handle)
}

.native_lint <- function(paths, fix) {
  .Call(wrap__lint, paths, fix)
}

.native_schema <- function(file_type) {
  .Call(wrap__schema, file_type)
}

.native_conditions <- function() {
  .Call(wrap__conditions)
}

.native_info <- function(version) {
  .Call(wrap__info, version)
}

.native_selftest <- function(version) {
  .Call(wrap__selftest, version)
}

.native_selftest_status <- function(handle) {
  .Call(wrap__selftest_status, handle)
}

.native_selftest_cases <- function(handle) {
  .Call(wrap__selftest_cases, handle)
}

.native_selftest_info <- function(handle) {
  .Call(wrap__selftest_info, handle)
}

.native_selftest_summary <- function(handle) {
  .Call(wrap__selftest_summary, handle)
}

.native_interface_handshake <- function(request) {
  .Call(wrap__interface_handshake, request)
}

.native_live_handles <- function() {
  .Call(wrap__live_handles)
}

# The interface handshake (rust/interface/README.md): .onLoad sends this
# request before any other native call, and a refusal stops the load.
.interface_request <- list(
  version = 1L,
  required = c("structured_records", "arrow_c_stream", "plan_reuse"),
  optional = c("format_yaml", "format_parquet", "format_readstat", "format_odm")
)

# One message per reason, filled from the refusal envelope.
.interface_messages <- c(
  version_mismatch = "yamaa's native module has interface version {supported_version}, but its code needs version {requested_version}: reinstall yamaa",
  malformed_request = "yamaa's native module refused its code's interface request as malformed: reinstall yamaa",
  missing_feature = "yamaa's native module lacks the interface features {missing_features} that its code needs: reinstall yamaa",
  missing_interface = "yamaa's native module has no interface handshake, but its code needs interface version {requested_version}: reinstall yamaa"
)

# The yamaa_interface_error of a refused handshake, carrying the
# envelope's fields.
.interface_error <- function(outcome) {
  message <- .interface_messages[[outcome$reason]]
  for (field in c("requested_version", "supported_version")) {
    if (!is.null(outcome[[field]])) {
      message <- gsub(paste0("{", field, "}"),
        format(outcome[[field]], scientific = FALSE), message, fixed = TRUE)
    }
  }
  message <- gsub("{missing_features}",
    paste(outcome$missing_features, collapse = ", "), message, fixed = TRUE)
  structure(c(list(message = message, call = NULL), outcome),
    class = c("yamaa_interface_error", "error", "condition"))
}

# Negotiate through `routine`, which gives the function that calls one of
# this package's native routines, or NULL where its library has none.
.interface_negotiate <- function(routine) {
  handshake <- routine("interface_handshake")
  if (is.null(handshake)) {
    outcome <- list(accepted = FALSE, requested_version = .interface_request$version,
      supported_version = NULL, reason = "missing_interface",
      missing_features = character())
  } else {
    outcome <- .reply(handshake(.interface_request))
  }
  if (!isTRUE(outcome$accepted)) stop(.interface_error(outcome))
  invisible(outcome)
}

.onLoad <- function(libname, pkgname) {
  namespace <- topenv()
  .interface_negotiate(function(name) {
    if (exists(paste0("wrap__", name), envir = namespace, inherits = FALSE)) {
      get(paste0(".native_", name), envir = namespace, inherits = FALSE)
    }
  })
}

Try the yamaa package in your browser

Any scripts or data that you put into this service are public.

yamaa documentation built on Nov. 17, 2026, 5:09 p.m.