Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Devel / SelfStubber.html
blobf580d5f0d0cbdbf1f766107bf2e981f198590d32
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>Devel::SelfStubber - generate stubs for a SelfLoading module</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;Devel::SelfStubber - generate stubs for a SelfLoading module</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 </ul>
26 <!-- INDEX END -->
28 <hr />
29 <p>
30 </p>
31 <h1><a name="name">NAME</a></h1>
32 <p>Devel::SelfStubber - generate stubs for a SelfLoading module</p>
33 <p>
34 </p>
35 <hr />
36 <h1><a name="synopsis">SYNOPSIS</a></h1>
37 <p>To generate just the stubs:</p>
38 <pre>
39 use Devel::SelfStubber;
40 Devel::SelfStubber-&gt;stub('MODULENAME','MY_LIB_DIR');</pre>
41 <p>or to generate the whole module with stubs inserted correctly</p>
42 <pre>
43 use Devel::SelfStubber;
44 $Devel::SelfStubber::JUST_STUBS=0;
45 Devel::SelfStubber-&gt;stub('MODULENAME','MY_LIB_DIR');</pre>
46 <p>MODULENAME is the Perl module name, e.g. Devel::SelfStubber,
47 NOT 'Devel/SelfStubber' or 'Devel/SelfStubber.pm'.</p>
48 <p>MY_LIB_DIR defaults to '.' if not present.</p>
49 <p>
50 </p>
51 <hr />
52 <h1><a name="description">DESCRIPTION</a></h1>
53 <p>Devel::SelfStubber prints the stubs you need to put in the module
54 before the __DATA__ token (or you can get it to print the entire
55 module with stubs correctly placed). The stubs ensure that if
56 a method is called, it will get loaded. They are needed specifically
57 for inherited autoloaded methods.</p>
58 <p>This is best explained using the following example:</p>
59 <p>Assume four classes, A,B,C &amp; D.</p>
60 <p>A is the root class, B is a subclass of A, C is a subclass of B,
61 and D is another subclass of A.</p>
62 <pre>
64 / \
65 B D
67 C</pre>
68 <p>If D calls an autoloaded method 'foo' which is defined in class A,
69 then the method is loaded into class A, then executed. If C then
70 calls method 'foo', and that method was reimplemented in class
71 B, but set to be autoloaded, then the lookup mechanism never gets to
72 the AUTOLOAD mechanism in B because it first finds the method
73 already loaded in A, and so erroneously uses that. If the method
74 foo had been stubbed in B, then the lookup mechanism would have
75 found the stub, and correctly loaded and used the sub from B.</p>
76 <p>So, for classes and subclasses to have inheritance correctly
77 work with autoloading, you need to ensure stubs are loaded.</p>
78 <p>The SelfLoader can load stubs automatically at module initialization
79 with the statement 'SelfLoader-&gt;load_stubs()';, but you may wish to
80 avoid having the stub loading overhead associated with your
81 initialization (though note that the SelfLoader::load_stubs method
82 will be called sooner or later - at latest when the first sub
83 is being autoloaded). In this case, you can put the sub stubs
84 before the __DATA__ token. This can be done manually, but this
85 module allows automatic generation of the stubs.</p>
86 <p>By default it just prints the stubs, but you can set the
87 global $Devel::SelfStubber::JUST_STUBS to 0 and it will
88 print out the entire module with the stubs positioned correctly.</p>
89 <p>At the very least, this is useful to see what the SelfLoader
90 thinks are stubs - in order to ensure future versions of the
91 SelfStubber remain in step with the SelfLoader, the
92 SelfStubber actually uses the SelfLoader to determine which
93 stubs are needed.</p>
94 <table border="0" width="100%" cellspacing="0" cellpadding="3">
95 <tr><td class="block" style="background-color: #cccccc" valign="middle">
96 <big><strong><span class="block">&nbsp;Devel::SelfStubber - generate stubs for a SelfLoading module</span></strong></big>
97 </td></tr>
98 </table>
100 </body>
102 </html>