{"id":7438,"date":"2022-12-20T19:38:06","date_gmt":"2022-12-20T22:38:06","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/classmopinstance-man3\/"},"modified":"2022-12-20T19:38:06","modified_gmt":"2022-12-20T22:38:06","slug":"classmopinstance-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/classmopinstance-man3\/","title":{"rendered":"Class::MOP::Instance (man3)"},"content":{"rendered":"<h1 align=\"center\">Class::MOP::Instance<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Class::MOP::Instance \u2212 Instance Meta Object<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">version 2.2014<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The Instance Protocol controls the creation of object instances, and the storage of attribute values in those instances.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Using this <small>API<\/small> directly in your own code violates encapsulation, and we recommend that you use the appropriate APIs in Class::MOP::Class and Class::MOP::Attribute instead. Those APIs in turn call the methods in this class as appropriate.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This class also participates in generating inlined code by providing snippets of code to access an object instance.<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Object construction <br \/> Class::MOP::Instance\u2212>new(%options)<\/b><\/p>\n<p style=\"margin-left:17%;\">This method creates a new meta-instance object.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">It accepts the following keys in %options:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p>associated_metaclass<\/p>\n<\/td>\n<td width=\"40%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:29%; margin-top: 1em\">The Class::MOP::Class object for which instances will be created.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"11%\"><\/td>\n<td width=\"16%\">\n<p style=\"margin-top: 1em\">attributes<\/p>\n<\/td>\n<td width=\"55%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:29%; margin-top: 1em\">An array reference of Class::MOP::Attribute objects. These are the attributes which can be stored in each instance.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Creating and altering instances <br \/> $metainstance\u2212>create_instance<\/b><\/p>\n<p style=\"margin-left:17%;\">This method returns a reference blessed into the associated metaclass\u2019s class.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The default is to use a hash reference. Subclasses can override this.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>clone_instance($instance)<\/b><\/p>\n<p style=\"margin-left:17%;\">Given an instance, this method creates a new object by making <i>shallow<\/i> clone of the original.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Introspection <br \/> $metainstance\u2212>associated_metaclass<\/b><\/p>\n<p style=\"margin-left:17%;\">This returns the Class::MOP::Class object associated with the meta-instance object.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>get_all_slots<\/b><\/p>\n<p style=\"margin-left:17%;\">This returns a list of slot names stored in object instances. In almost all cases, slot names correspond directly attribute names.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>is_valid_slot($slot_name)<\/b><\/p>\n<p style=\"margin-left:17%;\">This will return true if $slot_name is a valid slot name.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>get_all_attributes<\/b><\/p>\n<p style=\"margin-left:17%;\">This returns a list of attributes corresponding to the attributes passed to the constructor.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Operations on Instance Structures<\/b> <br \/> It\u2019s important to understand that the meta-instance object is a different entity from the actual instances it creates. For this reason, any operations on the $instance_structure always require that the object instance be passed to the method. <b><br \/> $metainstance\u2212>get_slot_value($instance_structure, $slot_name) <br \/> $metainstance\u2212>set_slot_value($instance_structure, $slot_name, $value) <br \/> $metainstance\u2212>initialize_slot($instance_structure, $slot_name) <br \/> $metainstance\u2212>deinitialize_slot($instance_structure, $slot_name) <br \/> $metainstance\u2212>initialize_all_slots($instance_structure) <br \/> $metainstance\u2212>deinitialize_all_slots($instance_structure) <br \/> $metainstance\u2212>is_slot_initialized($instance_structure, $slot_name) <br \/> $metainstance\u2212>weaken_slot_value($instance_structure, $slot_name) <br \/> $metainstance\u2212>slot_value_is_weak($instance_structure, $slot_name) <br \/> $metainstance\u2212>strengthen_slot_value($instance_structure, $slot_name) <br \/> $metainstance\u2212>rebless_instance_structure($instance_structure, <br \/> $new_metaclass)<\/b><\/p>\n<p style=\"margin-left:17%;\">The exact details of what each method does should be fairly obvious from the method name.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Inlinable Instance Operations <br \/> $metainstance\u2212>is_inlinable<\/b><\/p>\n<p style=\"margin-left:17%;\">This is a boolean that indicates whether or not slot access operations can be inlined. By default it is true, but subclasses can override this.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>inline_create_instance($class_variable)<\/b><\/p>\n<p style=\"margin-left:17%;\">This method expects a string that, <i>when inlined<\/i>, will become a class name. This would literally be something like &#8216;$class&#8217;, not an actual class name.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">It returns a snippet of code that creates a new object for the class. This is something like &#8221; bless {}, $class_name &#8220;.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>inline_get_is_lvalue<\/b><\/p>\n<p style=\"margin-left:17%;\">Returns whether or not &#8220;inline_get_slot_value&#8221; is a valid lvalue. This can be used to do extra optimizations when generating inlined methods.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>inline_slot_access($instance_variable, $slot_name) <br \/> $metainstance\u2212>inline_get_slot_value($instance_variable, $slot_name) <br \/> $metainstance\u2212>inline_set_slot_value($instance_variable, $slot_name, <br \/> $value) <br \/> $metainstance\u2212>inline_initialize_slot($instance_variable, $slot_name) <br \/> $metainstance\u2212>inline_deinitialize_slot($instance_variable, $slot_name) <br \/> $metainstance\u2212>inline_is_slot_initialized($instance_variable, <br \/> $slot_name) <br \/> $metainstance\u2212>inline_weaken_slot_value($instance_variable, $slot_name) <br \/> $metainstance\u2212>inline_strengthen_slot_value($instance_variable, <br \/> $slot_name)<\/b><\/p>\n<p style=\"margin-left:17%;\">These methods all expect two arguments. The first is the name of a variable, than when inlined, will represent the object instance. Typically this will be a literal string like &#8216;$_[0]&#8217;.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The second argument is a slot name.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The method returns a snippet of code that, when inlined, performs some operation on the instance.<\/p>\n<p style=\"margin-left:11%;\"><b>$metainstance\u2212>inline_rebless_instance_structure($instance_variable, <br \/> $class_variable)<\/b><\/p>\n<p style=\"margin-left:17%;\">This takes the name of a variable that will, when inlined, represent the object instance, and the name of a variable that will represent the class to rebless into, and returns code to rebless an instance into a class.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Introspection <br \/> Class::MOP::Instance\u2212>meta<\/b><\/p>\n<p style=\"margin-left:17%;\">This will return a Class::MOP::Class instance for this class.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">It should also be noted that Class::MOP will actually bootstrap this module by installing a number of attribute meta-objects into its metaclass.<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">Stevan Little <stevan@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Dave Rolsky <autarch@urth.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Jesse Luehrs <doy@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Shawn M Moore <sartak@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>\u00d7\u00d7\u00d7\u00d7 \u00d7\u00a7\u00d7\u00d7\u2019\u00d7\u00d7 (Yuval Kogman) <nothingmuch@woobling.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Karen Etheridge <ether@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Florian Ragwitz <rafl@debian.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Hans Dieter Pearcey <hdp@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Chris Prather <chris@prather.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Matt S Trout <mstrout@cpan.org><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This software is copyright (c) 2006 by Infinity Interactive, Inc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is free software; you can redistribute it and\/or modify it under the same terms as the Perl 5 programming language system itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Class::MOP::Instance \u2212 Instance Meta Object <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3750,3007],"class_list":["post-7438","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-classmopinstance","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7438"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7438\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}