Skip to main content

Module r_class_formatter

Module r_class_formatter 

Source
Expand description

Shared utilities for R class wrapper generation.

This module provides abstractions to reduce duplication across the 5 class system generators (Env, R6, S3, S4, S7). Each class system has different R idioms but shares common patterns:

  • Class-level roxygen documentation
  • Constructor generation
  • Instance method iteration with .Call() building
  • Static method handling
  • Return strategy application

§Architecture

ParsedImpl
    │
    ├─▶ ClassDocBuilder  → roxygen header lines (#' @title, @name, etc.)
    │
    └─▶ MethodContext[]  → pre-computed method data for each method
            │
            └─▶ ClassFormatter::format_constructor()
            └─▶ ClassFormatter::format_instance_method()
            └─▶ ClassFormatter::format_static_method()

Structs§

ClassDocBuilder
Builder for class-level roxygen documentation header.
MethodContext
Pre-computed context for a method, holding all data needed for R wrapper generation.
MethodDocBuilder
Builder for method-level roxygen documentation.

Traits§

ParsedImplExt
Extension trait for ParsedImpl to iterate over methods as MethodContext.

Functions§

class_ref_or_verbatim 🔒
Return a .__MX_CLASS_REF_<name>__ placeholder (for bare identifiers) so the resolver can look up the actual R class name at cdylib write time, or name verbatim (for namespaced / non-identifier strings).
effective_r_defaults 🔒
Effective R-formal defaults for a method.
emit_s3_generic_guard 🔒
Emit the conditional S3 generic guard for a given generic name.
is_bare_identifier 🔒
Check whether s is a bare R identifier (only [A-Za-z_][A-Za-z0-9_]*).
match_arg_doc_placeholder_map 🔒
Build the R-param-name → @param placeholder map for a method’s match_arg and choices params. Pass to MethodDocBuilder::with_match_arg_doc_placeholders in each class generator.
should_export_from_tags 🔒
Determine whether a class or method should be @export-ed.