fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / dynpmc / README.pod
blob1c04887e583b80e649d4f956522012d3cea2f00a
1 =pod
3 =head1 OVERVIEW
5 This is a build directory for custom PMCs with a sample foo.pmc
6 providing the Foo PMC class.
8 =head1 CREATING A DYNAMIC PMC
10 =over 4
12 =item 1
14 Edit/create your foo.pmc source - For details on creating PMCs, see
15 F<tools/dev/gen_class.pl>
17 There are some differences you have to be aware of when creating dynamic PMCs.
19 When declaring the dynamic PMC, you must specify  the C<dynpmc> flag, as in:
21         pmclass TclString extends TclObject dynpmc ... { ... }
23 Note that regular (non-dynamic) PMCs have a type id
24 C<enum_class_PMCNAME>, but dynamic PMCs obviously cannot use the same
25 thing. Instead, a dynamically-chosen value is assigned at runtime -
26 so, when you refer to the type of the class , you must dynamically
27 determine the PMC type. So, while C<scalar> (a builtin) has the
28 luxury of knowing at compile time what the class number of its child
29 C<String> is -- for example:
31         if (type == enum_class_String) { ...
33 a dynamic PMC such as C<TclInt> must instead perform a runtime lookup
34 of its corresponding C<TclString> PMC, resulting in the more complicated:
36   static INTVAL dynpmc_TclString;
38   pmclass TclInt extends TclObject extends Integer dynpmc group tcl_group {
40     void class_init() {
41       if (pass) {
42         dynpmc_TclString = Parrot_PMC_typenum(interp,"TclString");
43       }
44     }
45   }
47 Finally, if you have a group of PMCs that are interdependent, use the
48 C<group GROUPNAME> syntax to trigger a group library to be built. You
49 will use the group name as the name of the library to load using the
50 PASM op C<loadlib>.
52         pmclass Match extends Hash dynpmc group match_group { ... }
54 and then in your .pir or .pasm file:
56         loadlib $P0, "match_group"
58 =item 2
60 Edit C<../../config/gen/makefiles/dynpmc.in> and append your PMC(s) to
61 the build target. The dynpmc.in file is processed by Configure.pl to 
62 create the real makefiles. So, invoke the configure script, then make:
63                 
64         $ perl Configure.pl
65         $ make
67 =item 3
69 If anything changes inside parrot, be sure to:
71         $ make dynpmc-clean
73 =back