Skip to main content

generate_r6_r_wrapper

Function generate_r6_r_wrapper 

Source
pub fn generate_r6_r_wrapper(parsed_impl: &ParsedImpl) -> String
Expand description

Generates the complete R wrapper string for an R6-style class.

Produces an R6::R6Class(...) core definition followed by per-method $set() blocks (see the module docs for the full $set-form shape, #369):

  • initialize method (inline in public): calls the Rust new constructor, or accepts a pre-made .ptr when static methods return Self (factory pattern)
  • Public methods: one ClassName$set("public", "name", function(...) {...}) block per &self/&mut self instance method, each with its own roxygen
  • Private methods (inline in private): methods marked with #[miniextendr(private)]
  • Active bindings: one ClassName$set("active", "name", function(...) {...}) block per getter/setter property (#[miniextendr(r6(prop = "..."))])
  • Private .ptr field: holds the ExternalPtr to the Rust struct
  • Finalizer (inline in private): optional destructor called when the R6 object is garbage-collected
  • Deep clone (inline in private): optional custom clone logic via #[miniextendr(r6(deep_clone))]
  • Static methods: emitted as ClassName$method_name <- function(...) outside the class
  • Class options: lock_objects, lock_class, cloneable, portable, inherit

Also generates roxygen2 documentation blocks for the class, its methods, and active bindings.