™.. Class::MethodMaker::Engine - Online Linux Manual PageSection : 3
Updated : 2010-05-10
Source : perl v5.10.1
Note : User Contributed Perl Documentation
NAMEClass::MethodMaker::Engine − The parameter passing, method installation & non−data−structure methods of Class::MethodMaker.
SYNOPSISThis class is for internal implementation only. It is not a public API. The non-data-structure methods do form part of the public API, but not called directly: rather, called through the \*(C`use\*(C'\fR/\f(CW\*(C`import\*(C'\fR interface, as for data-structure methods.
The Class::MethodMaker Method Installation Engine
importThis performs argument parsing ready for calling create_methods. In particular, this is the point at which v1 & v2 calls are distinguished. This is implicitly called as part of a \*(C`use\*(C'\fR statement: use Class::MethodMaker
[ scalar => [qw/ foo bar baz /],
new => [qw/ new /] ,
];
is equivalent to Class::MethodMaker−>import([scalar => [qw/ foo bar baz /],
new => [qw/ new /] ,
]);
See perldoc −f use for details of this equivalence. The methods created are installed into the class calling the import − or more accurately, the first class up the calling stack that is not \*(C`Class::MethodMaker\*(C'\fR or a subclass thereof. SYNOPSIS Class::MethodMaker−>import([scalar => [+{ −type => 'File::Stat',
−forward => [qw/ mode size /],
'*_foo' => '*_fig',
'*_gop' => undef,
'*_bar' => '*_bar',
'*_hal' => '*_sal',
},
qw/ −static bob /,
]
]);
parse_optionsParse the arguments given to import and call create_methods appropriately. See main text for options syntax. SYNOPSIS Class::MethodMaker−>parse_options('TargetClass',
[scalar =>
[{ −type => 'File::stat',
−forward => [qw/ mode
size /],
'*_foo' => '*_fig',
'*_gop' => undef,
'*_bar' => '*_bar',
'*_hal' => '*_sal',
},
qw( −static bob ),
]])},
Class::MethodMaker−>parse_options('TargetClass2',
[scalar =>
['baz',
{ −type => 'File::stat',
−forward => [qw/ mode
size /],
'*_foo' => '*_fog',
'*_bar' => '*_bar',
'*_hal' => '*_sal',
},
qw( −static bob ),
]],
+{ −type => 'Math::BigInt', },
+{'*_foo' => '*_fig',
'*_gop' => undef,},
)},
ARGUMENTS target_class The class into which to install components args The arguments to parse, as a single arrayref. options A hashref of options to apply to all components created by this call (subject to overriding by explicit option calls). renames A hashref of renames to apply to all components created by this call (subject to overriding by explicit rename calls).
create_methodsAdd methods to a class. Methods for multiple components may be added this way, but create_methods handles only one set of options. parse_options is responsible for sorting which options to apply to which components, and calling create_methods appropriately. SYNOPSIS Class::MethodMaker−>create_methods($target_class,
scalar => bob,
+{ static => 1,
type => 'File::Stat',
forward => [qw/ mode size /], },
+{ '*_foo' => '*_fig',
'*_gop' => undef,
'*_bar' => '*_bar',
'*_hal' => '*_sal', }
);
ARGUMENTS targetclass The class to add methods to. type The basic data structure to use for the component, e.g., \*(C`scalar\*(C'\fR. compname Component name. The name must be a valid identifier, i.e., a continguous non-empty string of word (\*(C`\ew\*(C'\fR) characters, of which the first may not be a digit. options A hashref. Some options (\*(C`static\*(C'\fR, \f(CW\*(C`type\*(C'\fR, \f(CW\*(C`default\*(C'\fR, \f(CW\*(C`default_ctor\*(C'\fR) are handled by the auto-extender. These will be invoked if the name is present as a key and the value is true. Any other options are passed through to the method in question. The options should be named as-is; no leading hyphen should be applied (i.e., use \*(C`{static => 1}\*(C'\fR not \f(CW\*(C`{\-static => 1}\*(C'\fR). renames A list of customer renames. It is a hashref from method name to rename. The method name is the generic name (i.e., featuring a \*(C`*\*(C'\fR to replace with the component name). The rename is the value to rename with. It may itself contain a \*(C`*\*(C'\fR to replace with the component name. If rename is undef, the method is not installed. For methods that would not be installed by default, use a rename value that is the same as the method name. So, if a type would normally install methods '*_foo', '*_gop', '*_tom'
and optionally installs (but not by default) '*_bar', '*_wiz', '*_hal'
using a renames value of { '*_foo' => '*_fig',
'*_gop' => undef,
'*_bar' => '*_bar',
'*_hal' => '*_sal',
}
with a component name of \*(C`xx\*(C'\fR, then \f(CW*_foo\fR is installed as \f(CW\*(C`xx_fig\*(C'\fR, *_bar is installed as \*(C`xx_bar\*(C'\fR, \f(CW*_wiz\fR is not installed, \f(CW*_hal\fR is installed as \*(C`xx_sal\*(C'\fR, \f(CW*_gop\fR is not installed, and \f(CW*_tom\fR is installed as \*(C`xx_tom\*(C'\fR. The value may actually be an arrayref, in which case the function may be called by any of the multiple names specified.
install_methodsSYNOPSIS Class::MethodMaker−>install_methods
($classname, { incr => sub { $i++ },
decr => sub { $i−− },
}
);
ARGUMENTS target The class into which the methods are to be installed methods The methods to install, as a hashref. Keys are the method names; values are the methods themselves, as code refs.
Non-data-structure components
new use Class::MethodMaker
[ new => 'new' ];
Creates a basic constructor. Takes a single string or a reference to an array of strings as its argument. For each string creates a simple method that creates and returns an object of the appropriate class. The generated method may be called as a class method, as usual, or as in instance method, in which case a new object of the same class as the instance will be created. Options −hash The contructor will accept as arguments a list of pairs, from component name to initial value. For each pair, the named component is initialized by calling the method of the same name with the given value. E.g., package MyClass;
use Class::MethodMaker
[ new => [qw/ −hash new /],
scalar => [qw/ b c /],
];
sub d {
my $self = shift;
$self−>{d} = $_[0]
if @_;
return $self−>{d};
}
package main;
# The statement below implicitly calls
# $m−>b(1); $m−>c(2); $m−>d(3)
# on the newly constructed m.
my $m = MyClass−>new(b => 1, c => 2, d => 3);
Note that this can also call user-supplied methods that have the name of the component. Instead of a list of pairs, a single hashref may also be passed, which will be expanded appropriately. So the above is equivalent to: my $m = MyClass−>new({ b => 1, c => 2, d => 3 });
Advanced Users: Class::MethodMaker method renaming is taken into account, so even if the \*(C`*\*(C'\fR method is renamed or removed, this will still work. −init This option causes the new method to call an initializor method. The method is called \*(C`init\*(C'\fR (original, eh?) by default, but the option may be given an alternative value. The init method is passed any arguments that were passed to the constructor, but the method is invoked on the newly constructed instance. use Class::MethodMaker
[ new => [qw/ −init new1 /, { −init => 'bob' } => 'init2' ]];
Constructing with new1 involves an implicit call to \*(C`init\*(C'\fR, whilst constructing with new2 involves an implicit call to \*(C`bob\*(C'\fR (\fIinstead\fR of \*(C`init\*(C'\fR). It is the responsiblity of the user to ensure that an \*(C`init\*(C'\fR method (or whatever name) is defined. −singleton Creates a basic constructor which only ever returns a single instance of the class: i.e., after the first call, repeated calls to this constructor return the same instance. Note that the instance is instantiated at the time of the first call, not before.
abstract use Class::MethodMaker
[ abstract => [ qw / foo bar baz / ] ];
This creates a number of methods that will die if called. This is intended to support the use of abstract methods, that must be overidden in a useful subclass.
copy use Class::MethodMaker
[ copy => [qw/ shallow −deep deep /] ];
This creates method that produce a copy of self. The copy is a by default a shallow copy; any references will be shared by the instance upon which the method is called and the returned newborn. One option is taken, \*(C`\-deep\*(C'\fR, which causes the method to create deep copies instead (i.e., references are copied recursively). Implementation Note: Deep copies are performed using the \*(C`Storable\*(C'\fR module if available, else \*(C`Data::Dumper\*(C'\fR. The \f(CW\*(C`Storable\*(C'\fR module is liable to be much quicker. However, this implementation note is not an API specification: the implementation details are open to change in a future version as faster/better ways of performing a deep copy become available. Note that deep copying does not currently support the copying of coderefs, ties or XS-based objects.
AUTHORMartyn J. Pearce <fluffy@cpan.org> 0
Johanes Gumabo
Data Size : 35,979 byte
man-Class::MethodMaker::Engine.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 180,345
Visitor ID : :
Visitor IP : 3.145.64.210 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Class::MethodMaker::Engine.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Class::MethodMaker::Engine.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Class::MethodMaker::Engine.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|Class::MethodMaker::Engine.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|Class::MethodMaker::Engine.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|Class::MethodMaker::Engine.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|Class::MethodMaker::Engine.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|Class::MethodMaker::Engine.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|249|Class::MethodMaker::Engine.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|Class::MethodMaker::Engine.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|140|\*(C`use\*(C'\fR/\f(CW\*(C`import\*(C'\fR interface, as for |directly: rather, called through the \f(CW\*(C`use\*(C'\fR/\f(CW\*(C`import\*(C'\fR interface, as for
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|150|\*(C`use\*(C'\fR statement: |This is implicitly called as part of a \f(CW\*(C`use\*(C'\fR statement:
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|171|\*(C`Class::MethodMaker\*(C'\fR or a subclass thereof. |\&\f(CW\*(C`Class::MethodMaker\*(C'\fR or a subclass thereof.
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|275|\*(C`scalar\*(C'\fR. |The basic data structure to use for the component, e.g., \f(CW\*(C`scalar\*(C'\fR.
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|279|\*(C`\ew\*(C'\fR) characters, of which the first may not be a |non-empty string of word (\f(CW\*(C`\ew\*(C'\fR) characters, of which the first may not be a
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|283|\*(C`static\*(C'\fR, \f(CW\*(C`type\*(C'\fR, \f(CW\*(C`default\*(C'\fR, \f(CW\*(C`default_ctor\*(C'\fR) are |A hashref. Some options (\f(CW\*(C`static\*(C'\fR, \f(CW\*(C`type\*(C'\fR, \f(CW\*(C`default\*(C'\fR, \f(CW\*(C`default_ctor\*(C'\fR) are
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|287|\*(C`{static => 1}\*(C'\fR not \f(CW\*(C`{\-static => 1}\*(C'\fR). |should be applied (i.e., use \f(CW\*(C`{static => 1}\*(C'\fR not \f(CW\*(C`{\-static => 1}\*(C'\fR).
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|291|\*(C`*\*(C'\fR to replace with the |method name is the generic name (i.e., featuring a \f(CW\*(C`*\*(C'\fR to replace with the
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|293|\*(C`*\*(C'\fR to replace with the component name. If rename is undef, the |contain a \f(CW\*(C`*\*(C'\fR to replace with the component name. If rename is undef, the
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|318|\*(C`xx\*(C'\fR, then \f(CW*_foo\fR is installed as \f(CW\*(C`xx_fig\*(C'\fR, |with a component name of \f(CW\*(C`xx\*(C'\fR, then \f(CW*_foo\fR is installed as \f(CW\*(C`xx_fig\*(C'\fR,
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|319|\*(C`xx_bar\*(C'\fR, \f(CW*_wiz\fR is not installed, \f(CW*_hal\fR is |\&\f(CW*_bar\fR is installed as \f(CW\*(C`xx_bar\*(C'\fR, \f(CW*_wiz\fR is not installed, \f(CW*_hal\fR is
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|320|\*(C`xx_sal\*(C'\fR, \f(CW*_gop\fR is not installed, and \f(CW*_tom\fR is installed |installed as \f(CW\*(C`xx_sal\*(C'\fR, \f(CW*_gop\fR is not installed, and \f(CW*_tom\fR is installed
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|321|\*(C`xx_tom\*(C'\fR. |as \f(CW\*(C`xx_tom\*(C'\fR.
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|414|\*(C`*\*(C'\fR method is renamed or removed, this will still work. |so even if the \f(CW\*(C`*\*(C'\fR method is renamed or removed, this will still work.
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|418|\*(C`init\*(C'\fR (original, eh?) by default, but the option may be given an |is called \f(CW\*(C`init\*(C'\fR (original, eh?) by default, but the option may be given an
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|428|\*(C`init\*(C'\fR, whilst |Constructing with new1 involves an implicit call to \f(CW\*(C`init\*(C'\fR, whilst
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|429|\*(C`bob\*(C'\fR (\fIinstead\fR of |constructing with new2 involves an implicit call to \f(CW\*(C`bob\*(C'\fR (\fIinstead\fR of
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|430|\*(C`init\*(C'\fR). |\&\f(CW\*(C`init\*(C'\fR).
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|432|\*(C`init\*(C'\fR method (or |It is the responsiblity of the user to ensure that an \f(CW\*(C`init\*(C'\fR method (or
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|459|\*(C`\-deep\*(C'\fR, |method is called and the returned newborn. One option is taken, \f(CW\*(C`\-deep\*(C'\fR,
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|465|\*(C`Storable\*(C'\fR module if available, else |Deep copies are performed using the \f(CW\*(C`Storable\*(C'\fR module if available, else
) (rof_escape_sequence|91|Class::MethodMaker::Engine.3pm|466|\*(C`Data::Dumper\*(C'\fR. The \f(CW\*(C`Storable\*(C'\fR module is liable to be much quicker. |\&\f(CW\*(C`Data::Dumper\*(C'\fR. The \f(CW\*(C`Storable\*(C'\fR module is liable to be much quicker.
)