pub fn generate_env_r_wrapper(parsed_impl: &ParsedImpl) -> StringExpand description
Generates the complete R wrapper string for an environment-based class.
Produces an R environment object (new.env(parent = emptyenv())) that serves as a
class namespace, with methods attached as ClassName$method_name. This pattern
supports both inherent methods and trait namespace dispatch via $/[[.
The generated code includes:
- Class environment:
ClassName <- new.env(parent = emptyenv()) - Constructor:
ClassName$new(...)that calls the Rustnewfunction, setsclass(self) <- "ClassName", and returns the ExternalPtr asself - Instance methods:
ClassName$method(x = self, ...)using default-arg binding so that$dispatch re-parents the environment to makeselfvisible - Static methods:
ClassName$method(...)that call Rust directly $.ClassNameS3 method: dispatchesobj$method(...)by looking up the method in the class environment, bindingselffor instance methods, and supporting trait namespace environments (nested envs with.__mx_instance__attributes)[[.ClassNamealias: delegates to$.ClassName
Roxygen2 documentation is generated for the class, each method, and the
dispatch methods, with appropriate @export/@keywords internal/@noRd tags.