.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MakeMethods::Emulator::MethodMaker 3pm" .TH MakeMethods::Emulator::MethodMaker 3pm "2016-06-10" "perl v5.22.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::MakeMethods::Emulator::MethodMaker \- Emulate Class::MethodMaker .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& package MyObject; \& use Class::MakeMethods::Emulator::MethodMaker( \& new_with_init => \*(Aqnew\*(Aq, \& get_set => [ qw / foo bar baz / ]; \& ); \& \& ... OR ... \& \& package MyObject; \& use Class::MakeMethods::Emulator::MethodMaker \*(Aq\-take_namespace\*(Aq; \& use Class::MethodMaker ( \& new_with_init => \*(Aqnew\*(Aq, \& get_set => [ qw / foo bar baz / ]; \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides emulation of Class::MethodMaker, using the Class::MakeMethods framework. .PP Although originally based on Class::MethodMaker, the calling convention for Class::MakeMethods differs in a variety of ways; most notably, the names given to various types of methods have been changed, and the format for specifying method attributes has been standardized. This package uses the aliasing capability provided by Class::MakeMethods, defining methods that modify the declaration arguments as necessary and pass them off to various subclasses of Class::MakeMethods. .SH "COMPATIBILITY" .IX Header "COMPATIBILITY" Full compatibility is maintained with version 1.03; some of the changes in versions 1.04 through 1.10 are not yet included. .PP The test suite from Class::MethodMaker version 1.10 is included with this package, in the t/emulator_class_methodmaker/ directory. The unsupported tests have names ending in \*(L".todo\*(R". .PP The tests are unchanged from those in the Class::MethodMaker distribution, except for the substitution of \&\f(CW\*(C`Class::MakeMethods::Emulator::MethodMaker\*(C'\fR in the place of \&\f(CW\*(C`Class::MethodMaker\*(C'\fR. .PP In cases where earlier distributions of Class::MethodMaker contained a different version of a test, it is also included. (Note that version 0.92's get_concat returned '' for empty values, but in version 0.96 this was changed to undef; this emulator follows the later behavior. To avoid \*(L"use of undefined value\*(R" warnings from the 0.92 version of get_concat.t, that test has been modified by appending a new flag after the name, \f(CW\*(Aqget_concat \-\-noundef\*(Aq\fR, which restores the earlier behavior.) .SH "USAGE" .IX Header "USAGE" There are several ways to call this emulation module: .IP "\(bu" 4 Direct Access .Sp Replace occurrences in your code of \f(CW\*(C`Class::MethodMaker\*(C'\fR with \f(CW\*(C`Class::MakeMethods::Emulator::MethodMaker\*(C'\fR. .IP "\(bu" 4 Install Emulation .Sp If you \f(CW\*(C`use Class::MakeMethods::Emulator::MethodMaker \*(Aq\-take_namespace\*(Aq\*(C'\fR, the Class::MethodMaker namespace will be aliased to this package, and calls to the original package will be transparently handled by this emulator. .Sp To remove the emulation aliasing, call \f(CW\*(C`use Class::MakeMethods::Emulator::MethodMaker \*(Aq\-release_namespace\*(Aq\*(C'\fR. .Sp \&\fBNote:\fR This affects \fBall\fR subsequent uses of Class::MethodMaker in your program, including those in other modules, and might cause unexpected effects. .IP "\(bu" 4 The \-sugar Option .Sp Passing '\-sugar' as the first argument in a use or import call will cause the 'methods' package to be declared as an alias to this one. .Sp This allows you to write declarations in the following manner. .Sp .Vb 1 \& use Class::MakeMethods::Emulator::MethodMaker \*(Aq\-sugar\*(Aq; \& \& make methods \& get_set => [ qw / foo bar baz / ], \& list => [ qw / a b c / ]; .Ve .Sp \&\fBNote:\fR This feature is deprecated in Class::MethodMaker version 0.96 and later. .SH "METHOD CATALOG" .IX Header "METHOD CATALOG" \&\fB\s-1NOTE:\s0\fR The documentation below is derived from version 1.02 of Class::MethodMaker. Class::MakeMethods::Emulator::MethodMaker provides support for all of the features and examples shown below, with no changes required. .SH "CONSTRUCTOR METHODS" .IX Header "CONSTRUCTOR METHODS" .SS "new" .IX Subsection "new" Equivalent to Class::MakeMethods 'Template::Hash:new \-\-with_values'. .SS "new_with_init" .IX Subsection "new_with_init" Equivalent to Class::MakeMethods 'Template::Hash:new \-\-with_init'. .SS "new_hash_init" .IX Subsection "new_hash_init" Equivalent to Class::MakeMethods 'Template::Hash:new \-\-instance_with_methods'. .SS "new_with_args" .IX Subsection "new_with_args" Equivalent to Class::MakeMethods 'Template::Hash:new \-\-with_values'. .SS "copy" .IX Subsection "copy" Equivalent to Class::MakeMethods 'Template::Hash:new \-\-copy_with_values'. .SH "SCALAR ACCESSORS" .IX Header "SCALAR ACCESSORS" .SS "get_set" .IX Subsection "get_set" Basically equivalent to Class::MakeMethods 'Template::Hash:scalar', except that various arguments are intercepted and converted into the parallel Class::MakeMethods::Template interface declarations. .SS "get_concat" .IX Subsection "get_concat" Equivalent to Class::MakeMethods 'Template::Hash:string' with a special interface declaration that provides the get_concat and clear behaviors. .SS "counter" .IX Subsection "counter" Equivalent to Class::MakeMethods 'Template::Hash:number \-\-counter'. .SH "OBJECT ACCESSORS" .IX Header "OBJECT ACCESSORS" Basically equivalent to Class::MakeMethods 'Template::Hash:object' with an declaration that provides the \*(L"delete_x\*(R" interface. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object. .SS "object_list" .IX Subsection "object_list" Basically equivalent to Class::MakeMethods 'Template::Hash:object_list' with an declaration that provides the relevant helper methods. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object_list. .SS "forward" .IX Subsection "forward" Basically equivalent to Class::MakeMethods 'Template::Universal:forward_methods'. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Universal:forward_methods. .PP .Vb 1 \& forward => [ comp => \*(Aqmethod1\*(Aq, comp2 => \*(Aqmethod2\*(Aq ] .Ve .PP Define pass-through methods for certain fields. The above defines that method \f(CW\*(C`method1\*(C'\fR will be handled by component \f(CW\*(C`comp\*(C'\fR, whilst method \&\f(CW\*(C`method2\*(C'\fR will be handled by component \f(CW\*(C`comp2\*(C'\fR. .SH "REFERENCE ACCESSORS" .IX Header "REFERENCE ACCESSORS" .SS "list" .IX Subsection "list" Equivalent to Class::MakeMethods 'Template::Hash:array' with a custom method naming interface. .SS "hash" .IX Subsection "hash" Equivalent to Class::MakeMethods 'Template::Hash:hash' with a custom method naming interface. .SS "tie_hash" .IX Subsection "tie_hash" Equivalent to Class::MakeMethods 'Template::Hash:tiedhash' with a custom method naming interface. .SS "hash_of_lists" .IX Subsection "hash_of_lists" Equivalent to Class::MakeMethods 'Template::Hash:hash_of_arrays', or if the \-static flag is present, to 'Template::Static:hash_of_arrays'. .SH "STATIC ACCESSORS" .IX Header "STATIC ACCESSORS" .SS "static_get_set" .IX Subsection "static_get_set" Equivalent to Class::MakeMethods 'Template::Static:scalar' with a custom method naming interface. .SS "static_list" .IX Subsection "static_list" Equivalent to Class::MakeMethods 'Template::Static:array' with a custom method naming interface. .SS "static_hash" .IX Subsection "static_hash" Equivalent to Class::MakeMethods 'Template::Static:hash' with a custom method naming interface. .SH "GROUPED ACCESSORS" .IX Header "GROUPED ACCESSORS" .SS "boolean" .IX Subsection "boolean" Equivalent to Class::MakeMethods 'Template::Static:bits' with a custom method naming interface. .SS "grouped_fields" .IX Subsection "grouped_fields" Creates get/set methods like get_set but also defines a method which returns a list of the slots in the group. .PP .Vb 4 \& use Class::MakeMethods::Emulator::MethodMaker \& grouped_fields => [ \& some_group => [ qw / field1 field2 field3 / ], \& ]; .Ve .PP Its argument list is parsed as a hash of group-name => field-list pairs. Get-set methods are defined for all the fields and a method with the name of the group is defined which returns the list of fields in the group. .SS "struct" .IX Subsection "struct" Equivalent to Class::MakeMethods 'Template::Hash::struct'. .PP \&\fBNote:\fR This feature is included but not documented in Class::MethodMaker version 1. .SH "INDEXED ACCESSORS" .IX Header "INDEXED ACCESSORS" .SS "listed_attrib" .IX Subsection "listed_attrib" Equivalent to Class::MakeMethods 'Template::Flyweight:boolean_index' with a custom method naming interface. .SS "key_attrib" .IX Subsection "key_attrib" Equivalent to Class::MakeMethods 'Template::Hash:string_index'. .SS "key_with_create" .IX Subsection "key_with_create" Equivalent to Class::MakeMethods 'Template::Hash:string_index \-\-find_or_new'. .SH "CODE ACCESSORS" .IX Header "CODE ACCESSORS" .SS "code" .IX Subsection "code" Equivalent to Class::MakeMethods 'Template::Hash:code'. .SS "method" .IX Subsection "method" Equivalent to Class::MakeMethods 'Template::Hash:code \-\-method'. .SS "abstract" .IX Subsection "abstract" Equivalent to Class::MakeMethods 'Template::Universal:croak \-\-abstract'. .SH "ARRAY CONSTRUCTOR AND ACCESSORS" .IX Header "ARRAY CONSTRUCTOR AND ACCESSORS" .SS "builtin_class (\s-1EXPERIMENTAL\s0)" .IX Subsection "builtin_class (EXPERIMENTAL)" Equivalent to Class::MakeMethods 'Template::StructBuiltin:builtin_isa' with a modified argument order. .SH "CONVERSION" .IX Header "CONVERSION" If you wish to convert your code from use of the Class::MethodMaker emulator to direct use of Class::MakeMethods, you will need to adjust the arguments specified in your \f(CW\*(C`use\*(C'\fR or \f(CW\*(C`make\*(C'\fR calls. .PP Often this is simply a matter of replacing the names of aliased method-types listed below with the new equivalents. .PP For example, suppose that you code contained the following declaration: .PP .Vb 3 \& use Class::MethodMaker ( \& counter => [ \*(Aqfoo\*(Aq ] \& ); .Ve .PP Consulting the listings below you can find that \f(CW\*(C`counter\*(C'\fR is an alias for \f(CW\*(C`Hash:number \-\-counter\*(C'\fR and you could thus revise your declaration to read: .PP .Vb 3 \& use Class::MakeMethods ( \& \*(AqHash:number \-\-counter\*(Aq => [ \*(Aqfoo\*(Aq ] \& ); .Ve .PP However, note that those methods marked \*(L"(with custom interface)\*(R" below have a different default naming convention for helper methods in Class::MakeMethods, and you will need to either supply a similar interface or alter your module's calling interface. .PP Also note that the \f(CW\*(C`forward\*(C'\fR, \f(CW\*(C`object\*(C'\fR, and \f(CW\*(C`object_list\*(C'\fR method types, marked \*(L"(with modified arguments)\*(R" below, require their arguments to be specified differently. .PP See Class::MakeMethods::Template::Generic for more information about the default interfaces of these method types. .SS "Hash methods" .IX Subsection "Hash methods" The following equivalencies are declared for old meta-method names that are now handled by the Hash implementation: .PP .Vb 10 \& new \*(AqTemplate::Hash:new \-\-with_values\*(Aq \& new_with_init \*(AqTemplate::Hash:new \-\-with_init\*(Aq \& new_hash_init \*(AqTemplate::Hash:new \-\-instance_with_methods\*(Aq \& copy \*(AqTemplate::Hash:copy\*(Aq \& get_set \*(AqTemplate::Hash:scalar\*(Aq (with custom interfaces) \& counter \*(AqTemplate::Hash:number \-\-counter\*(Aq \& get_concat \*(AqTemplate::Hash:string \-\-get_concat\*(Aq (with custom interface) \& boolean \*(AqTemplate::Hash:bits\*(Aq (with custom interface) \& list \*(AqTemplate::Hash:array\*(Aq (with custom interface) \& struct \*(AqTemplate::Hash:struct\*(Aq \& hash \*(AqTemplate::Hash:hash\*(Aq (with custom interface) \& tie_hash \*(AqTemplate::Hash:tiedhash\*(Aq (with custom interface) \& hash_of_lists \*(AqTemplate::Hash:hash_of_arrays\*(Aq \& code \*(AqTemplate::Hash:code\*(Aq \& method \*(AqTemplate::Hash:code \-\-method\*(Aq \& object \*(AqTemplate::Hash:object\*(Aq (with custom interface and modified arguments) \& object_list \*(AqTemplate::Hash:array_of_objects\*(Aq (with custom interface and modified arguments) \& key_attrib \*(AqTemplate::Hash:string_index\*(Aq \& key_with_create \*(AqTemplate::Hash:string_index \-\-find_or_new\*(Aq .Ve .SS "Static methods" .IX Subsection "Static methods" The following equivalencies are declared for old meta-method names that are now handled by the Static implementation: .PP .Vb 2 \& static_get_set \*(AqTemplate::Static:scalar\*(Aq (with custom interface) \& static_hash \*(AqTemplate::Static:hash\*(Aq (with custom interface) .Ve .SS "Flyweight method" .IX Subsection "Flyweight method" The following equivalency is declared for the one old meta-method name that us now handled by the Flyweight implementation: .PP .Vb 1 \& listed_attrib \*(AqTemplate::Flyweight:boolean_index\*(Aq .Ve .SS "Struct methods" .IX Subsection "Struct methods" The following equivalencies are declared for old meta-method names that are now handled by the Struct implementation: .PP .Vb 1 \& builtin_class \*(AqTemplate::Struct:builtin_isa\*(Aq .Ve .SS "Universal methods" .IX Subsection "Universal methods" The following equivalencies are declared for old meta-method names that are now handled by the Universal implementation: .PP .Vb 2 \& abstract \*(AqTemplate::Universal:croak \-\-abstract\*(Aq \& forward \*(AqTemplate::Universal:forward_methods\*(Aq (with modified arguments) .Ve .SH "EXTENDING" .IX Header "EXTENDING" In order to enable third-party subclasses of MethodMaker to run under this emulator, several aliases or stub replacements are provided for internal Class::MethodMaker methods which have been eliminated or renamed. .IP "\(bu" 4 install_methods \- now simply return the desired methods .IP "\(bu" 4 find_target_class \- now passed in as the target_class attribute .IP "\(bu" 4 ima_method_maker \- no longer supported; use target_class instead .SH "BUGS" .IX Header "BUGS" This module aims to provide a 100% compatible drop-in replacement for Class::MethodMaker; if you detect a difference when using this emulation, please inform the author. .SH "SEE ALSO" .IX Header "SEE ALSO" See Class::MakeMethods for general information about this distribution. .PP See Class::MakeMethods::Emulator for more about this family of subclasses. .PP See Class::MethodMaker for more information about the original module. .PP A good introduction to Class::MethodMaker is provided by pages 222\-234 of \fIObject Oriented Perl\fR, by Damian Conway (Manning, 1999). .PP .Vb 1 \& http://www.browsebooks.com/Conway/ .Ve