"toolkit"Object
The toolkit which made this code generator.
"target"ClassName|RoleName
The target package for generated methods.
"sandboxing_package"ClassName|RoleName|Undef
Package name to use as a sandbox; the default is usually fine.
"attribute"Str|ArrayRef
The attribute delegated to.
"attribute_spec"HashRef
Informational only.
"is_method"Bool
Indicates whether the generated code should be methods rather than functions. This defaults to true, and
false isn't really tested or well-defined.
"env"HashRef
Variables which need to be closed over when compiling coderefs.
"isa"Maybe[TypeTiny]
The type constraint for the attribute.
"coerce"Bool
Should the attribute coerce?
"method_installer"CodeRef
A coderef which can be called with $method_name and $coderef, will install the method. Note that it isn't
passed the package to install into (which can be found in "target"), so that would need to be closed
over.
"generator_for_self"CodeRef
A coderef which if called, generates a string like '$_[0]'.
Has a sensible default.
All the "generator_for_XXX" methods are called as methods, so have the code generator object as an
invocant.
"generator_for_slot"CodeRef
A coderef which if called, generates a string like '$_[0]{attrname}'.
"generator_for_get"CodeRef
A coderef which if called, generates a string like '$_[0]->attrname'.
"generator_for_set"CodeRef
A coderef which if called with a parameter, generates a string like "\$_[0]->_set_attrname( $parameter
)".
"generator_for_simple_default"CodeRef
A coderef which if called with a parameter, generates a string like 'undef' or 'q[]' or '{}'.
The parameter is a handler object, which offers a "default_for_reset" attribute which might be able to
provide a useful fallback.
"generator_for_args"CodeRef
A coderef which if called, generates a string like '@_[1..$#_]'.
Has a sensible default.
"generator_for_argc"CodeRef
A coderef which if called, generates a string like '$#_'.
Has a sensible default.
"generator_for_argc"CodeRef
A coderef which if called with a parameter, generates a string like "\$_[$parameter + 1]".
Has a sensible default.
"generator_for_currying"CodeRef
A coderef which if called with a parameter, generates a string like "splice(\@_,1,0,$parameter);".
Has a sensible default.
"generator_for_usage_string"CodeRef
The default is this coderef:
sub {
@_==3 or die;
shift;
my $method_name = shift;
my $guts = shift;
return "\$instance->$method_name($guts)";
}
"generator_for_type_assertion"CodeRef
Called as a method and passed a hashref compilation environment, a type constraint, and a variable name.
Generates code to assert that the variable value meets the type constraint, with coercion if appropriate.
"generator_for_error"CodeRef
Called as a method and passed a Perl string which is an expression evaluating to an error message.
Generates code to throw the error.
"generator_for_prelude"CodeRef
By default is a coderef returning the empty string. Can be used to generate some additional statements
which will be inserted near the top of the method being generated. (Typically after parameter checks but
before doing anything serious.) This can be used to unlock a read-only attribute, for example.
"get_is_lvalue"Bool
Indicates wheter the code generated by "generator_for_get" will be suitable for used as an lvalue.
"set_checks_isa"Bool
Indicates wheter the code generated by "generator_for_set" will do type checks.
"set_strictly"Bool
Indicates wheter we want to ensure that the setter is always called, and we should not try to bypass it,
even if we have an lvalue getter.