pub struct ParsedImpl {Show 25 fields
pub type_ident: Ident,
pub class_system: ClassSystem,
pub class_name: Option<String>,
pub doc_tags: Vec<String>,
pub methods: Vec<ParsedMethod>,
pub original_impl: ItemImpl,
pub cfg_attrs: Vec<Attribute>,
pub vctrs_attrs: VctrsAttrs,
pub r6_inherit: Option<String>,
pub r6_portable: Option<bool>,
pub r6_cloneable: Option<bool>,
pub r6_lock_objects: Option<bool>,
pub r6_lock_class: Option<bool>,
pub s7_parent: Option<String>,
pub s7_abstract: bool,
pub r_data_accessors: RDataAccessors,
pub field_lookup: FieldLookup,
pub field_fallback: Option<FieldFallback>,
pub strict: bool,
pub preconditions: Option<bool>,
pub internal: bool,
pub noexport: bool,
pub constructor_demoted: bool,
pub param_warnings: TokenStream,
pub class_param_names: HashSet<String>,
}Expand description
Fully parsed #[miniextendr] impl block, ready for code generation.
Contains the type identity, chosen class system, all parsed methods, the original
impl block (with miniextendr attrs stripped for re-emission), and all class-system-specific
configuration options. Created by ParsedImpl::parse and consumed by the per-class-system
R wrapper generators and generate_method_c_wrapper.
Fields§
§type_ident: IdentThe Rust type name being implemented (e.g., Counter).
class_system: ClassSystemWhich R class system to generate wrappers for.
class_name: Option<String>Optional override for the R class name. When None, uses type_ident as the class name.
Roxygen tag lines extracted from /// doc comments on the impl block.
Used for class-level documentation (e.g., the R6 class docstring or S3 type description).
methods: Vec<ParsedMethod>All parsed methods in this impl block, in source order.
original_impl: ItemImplThe original impl block with #[miniextendr] and roxygen attrs stripped.
Re-emitted as-is so the Rust compiler sees the actual method implementations.
cfg_attrs: Vec<Attribute>#[cfg(...)] attributes from the impl block, propagated to all generated items
(C wrappers, R wrapper constants, call def arrays) for conditional compilation.
vctrs_attrs: VctrsAttrsvctrs-specific attributes (only used when class_system is Vctrs)
r6_inherit: Option<String>R6 parent class name for inheritance (e.g., "ParentClass").
Propagated from ImplAttrs::r6_inherit.
r6_portable: Option<bool>R6 portable flag. When Some(true), generates a portable R6 class.
Propagated from ImplAttrs::r6_portable.
r6_cloneable: Option<bool>R6 cloneable flag. Controls whether $clone() is available on instances.
Propagated from ImplAttrs::r6_cloneable.
r6_lock_objects: Option<bool>R6 lock_objects flag. When Some(true), prevents adding new fields after creation.
Propagated from ImplAttrs::r6_lock_objects.
r6_lock_class: Option<bool>R6 lock_class flag. When Some(true), prevents modifying the class definition.
Propagated from ImplAttrs::r6_lock_class.
s7_parent: Option<String>S7 parent class name for inheritance (e.g., "ParentClass").
Propagated from ImplAttrs::s7_parent.
s7_abstract: boolWhen true, marks this as an abstract S7 class that cannot be instantiated.
Propagated from ImplAttrs::s7_abstract.
r_data_accessors: RDataAccessorsThe class-level form of the sidecar #[r_data] fields
(r_data_accessors, see RDataAccessors).
For R6: active bindings are added via $set("active", ...) after class creation.
For S7: properties are spliced from .rdata_properties_{Type} into new_class().
For S3, S4 and env: $ / [[ field methods (field_syntax.rs, #1848).
field_lookup: FieldLookups3(r_data_accessors, lookup = "list"): how the S3 readers look a
field up (see FieldLookup).
field_fallback: Option<FieldFallback>fallback = "Self::f" (and fallback_names) on an S3, S4 or env
class with r_data_accessors: what the readers call for a name no
field has (see FieldFallback, #2150).
strict: boolStrict conversion mode: methods returning lossy types use checked conversions.
preconditions: Option<bool>The impl block’s preconditions / no_preconditions, inherited by
every method wrapper. See ImplAttrs::preconditions.
internal: boolMark class as internal: adds @keywords internal, suppresses @export.
noexport: boolSuppress @export without adding @keywords internal.
constructor_demoted: boolGenerate the block as it reads when another impl block of the type
has the constructor: the constructor this block would infer stays a
static method. expand_impl sets it for the second rendering of a
block that infers one (ParsedImpl::inferred_constructor).
param_warnings: TokenStreamDeprecation warnings for @param tags found on the impl block.
Appended to the final TokenStream output.
class_param_names: HashSet<String>Parameter names declared via @param in the impl-block doc comments.
For R6 classes, roxygen2 8.0.0 inherits class-level @param tags into
all methods. These are the names that appeared in impl-block-level @param
tags (extracted before stripping). The R6 generator uses this set to suppress
(no documentation available) placeholders for covered params and to emit
class-level @param lines in the class header.
Implementations§
Source§impl ParsedImpl
impl ParsedImpl
Sourcepub fn parse(attrs: ImplAttrs, item_impl: ItemImpl) -> Result<Self>
pub fn parse(attrs: ImplAttrs, item_impl: ItemImpl) -> Result<Self>
Parse an impl block with class system attribute.
Note: Trait impls (impl Trait for Type) are handled by expand_impl
before this function is called, so we only handle inherent impls here.
Sourcefn reject_unsupported_describe_in(&self) -> Result<()>
fn reject_unsupported_describe_in(&self) -> Result<()>
Reject a method-level @describeIn that roxygen2 cannot honour (#1590).
roxygen2 lists a @describeIn block in its destination’s “Functions”
section through the R object the block documents, and rejects the tag
next to @name / @rdname, so MethodDocBuilder drops both for it.
That only works where the method’s block sits on a plain R function or
S3 method: S3 instance methods (generic.Class), the static methods of
S3 / S4 / S7 / vctrs (class_method()), and the S4 constructor
(Class()). Everywhere else the block has no object to list:
- S4 / S7 instance methods are registered by
setMethod()/S7::method<-after theif (!exists(...))generic guard the block is attached to; - Env and R6 methods are
Class$method <-assignments or live insideR6Class(); - the S3 / vctrs / S7 constructor is documented by the class block.
There the tag would only earn a roxygen2 warning and a dropped block,
so it is a compile error pointing at @rdname instead.
Sourcepub fn class_name(&self) -> String
pub fn class_name(&self) -> String
Get the class name (override or type name).
Sourcepub fn class_settings(&self) -> String
pub fn class_settings(&self) -> String
The class-level settings, written like the attribute, which every impl
block of a type must spell the same (#1776): the class system with its
options, class = "...", internal / noexport, and the @noRd /
@keywords internal tags. They shape the members each block
generates, so the wrapper writer refuses blocks that differ. The
per-method defaults (strict, preconditions) may differ. A field
fallback (fallback = "...", #2150) is no setting: one block has it,
as one has the constructor (class_definitions).
Sourcepub fn class_definitions(&self) -> Vec<String>
pub fn class_definitions(&self) -> Vec<String>
What this impl block has that only one block of a type may: the
constructor, S7 properties and the field fallback (#2150). The
wrapper writer defines the class from the block that has them (#1776),
so the field methods that call the fallback are that block’s; the
impl docs of every block merge into the class’s roxygen block
(ClassWrapper::class_docs).
Sourcepub fn included_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn included_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get methods that should be included.
Sourcepub fn constructor(&self) -> Option<&ParsedMethod>
pub fn constructor(&self) -> Option<&ParsedMethod>
Sourcepub fn declared_constructor(&self) -> Option<&ParsedMethod>
pub fn declared_constructor(&self) -> Option<&ParsedMethod>
The constructor the block declares: the method marked
#[miniextendr(<system>(constructor))] (at most one,
check_constructor_markers), else
a receiver-less new returning Self. For vctrs, new may return
anything: the canonical vctrs constructor returns the vector payload
(e.g. Vec<f64>), which vctrs::new_vctr() then wraps; returning
Self would produce an ExternalPtr that new_vctr can’t accept as
.data.
Sourcepub fn constructor_candidates(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn constructor_candidates(&self) -> impl Iterator<Item = &ParsedMethod>
The methods that could be the class constructor: the receiver-less
methods returning Self (bare Self, as ParsedMethod::returns_self
reads it, so not Result<Self, E> or Option<Self>), other than the
declared constructor and an S7 convert_from method, in source order.
Without a declared constructor, the one candidate of a type is its
constructor; with several, the type needs a declared one. None for
vctrs, whose constructor returns the vector payload rather than Self.
Sourcepub fn inferred_constructor(&self) -> Option<&ParsedMethod>
pub fn inferred_constructor(&self) -> Option<&ParsedMethod>
The constructor this block infers: its one
candidate, whatever its name, when it
declares no constructor. None in the rendering for a type whose
constructor another impl block declares
(constructor_demoted). The wrapper
writer decides per type which rendering it writes.
Sourcefn is_method_constructor(&self, m: &ParsedMethod) -> bool
fn is_method_constructor(&self, m: &ParsedMethod) -> bool
Whether m is the class constructor.
The roxygen tags of the static method m, called as call (e.g.
Counter$from_value()). The constructor under its own name
(constructor_keeps_own_name)
points at the class constructor constructor (e.g. Counter$new())
instead of repeating its docs, keeping the method’s @noRd /
@keywords, and its @param tags when params (roxygen2 merges them
with the class constructor’s).
Sourcefn check_constructor_markers(&self) -> Result<()>
fn check_constructor_markers(&self) -> Result<()>
Refuse two methods marked #[miniextendr(<system>(constructor))]: a
class has one constructor.
Sourcepub fn public_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn public_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get public instance methods (have env, not private, not active, not an
R6 finalizer or deep_clone handler).
Sourcepub fn private_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn private_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get private instance methods (have env, private visibility, not active).
Sourcepub fn active_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn active_instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get active binding getter methods for R6 (have env, marked active, not setter). Active bindings provide property-like access (obj$name instead of obj$name()).
Sourcepub fn active_setter_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn active_setter_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get active binding setter methods for R6 (have env, marked as r6_setter).
Sourcepub fn find_setter_for_prop(&self, prop_name: &str) -> Option<&ParsedMethod>
pub fn find_setter_for_prop(&self, prop_name: &str) -> Option<&ParsedMethod>
Find the setter method for a given property name.
Sourcepub fn instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn instance_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get instance methods (have env) - includes both public and private.
Sourcepub fn static_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn static_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get static methods (no env, not finalizer): the receiver-less methods
other than the constructor, and the constructor too when its R name
isn’t new (constructor_keeps_own_name).
Sourcefn constructor_keeps_own_name(&self, m: &ParsedMethod) -> bool
fn constructor_keeps_own_name(&self, m: &ParsedMethod) -> bool
Whether the constructor m is also a static method under its own
name: Type$from_value() next to Type$new(), Type_from_value()
next to Type(), type_from_value() next to new_type(). A
constructor named new has no second name, and a vctrs constructor
returns the vector payload, which only new_<class>() classes.
Sourcepub fn as_coercion_methods(&self) -> impl Iterator<Item = &ParsedMethod>
pub fn as_coercion_methods(&self) -> impl Iterator<Item = &ParsedMethod>
Get methods with #[miniextendr(as = "...")] attribute.
These generate S3 methods for R’s as.<class>() generics like
as.data.frame.MyType, as.list.MyType, etc.
Sourcepub fn finalizer(&self) -> Option<&ParsedMethod>
pub fn finalizer(&self) -> Option<&ParsedMethod>
Get the finalizer method, if any.
Trait Implementations§
Source§impl Debug for ParsedImpl
impl Debug for ParsedImpl
Source§impl ParsedImplExt for ParsedImpl
impl ParsedImplExt for ParsedImpl
Source§fn constructor_context(&self) -> Option<MethodContext<'_>>
fn constructor_context(&self) -> Option<MethodContext<'_>>
MethodContext for the constructor method, if one exists.Source§fn instance_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>
fn instance_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>
MethodContext.Source§fn static_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>
fn static_method_contexts(&self) -> impl Iterator<Item = MethodContext<'_>>
MethodContext.Source§fn public_instance_method_contexts(
&self,
) -> impl Iterator<Item = MethodContext<'_>>
fn public_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>
MethodContext (for R6 public list).Source§fn private_instance_method_contexts(
&self,
) -> impl Iterator<Item = MethodContext<'_>>
fn private_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>
MethodContext (for R6 private list).Source§fn active_instance_method_contexts(
&self,
) -> impl Iterator<Item = MethodContext<'_>>
fn active_instance_method_contexts( &self, ) -> impl Iterator<Item = MethodContext<'_>>
MethodContext (for R6 active list).Auto Trait Implementations§
impl !Send for ParsedImpl
impl !Sync for ParsedImpl
impl Freeze for ParsedImpl
impl RefUnwindSafe for ParsedImpl
impl Unpin for ParsedImpl
impl UnsafeUnpin for ParsedImpl
impl UnwindSafe for ParsedImpl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 656 bytes