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
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 {
42 dynpmc_TclString = Parrot_PMC_typenum(interp,"TclString");
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
52 pmclass Match extends Hash dynpmc group match_group { ... }
54 and then in your .pir or .pasm file:
56 loadlib $P0, "match_group"
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:
69 If anything changes inside parrot, be sure to: