How to add own PMC to Parrot
Allison Randal
allison at parrot.org
Fri Aug 7 01:36:51 UTC 2009
Radovan Baranec wrote:
> Hi,
>
> I am fighting with this problem few hours. I`ve changed cpointer.pmc and
> tried to test these changes. In doc stands that I should run realclean
> and then Configure.pl to add new PMC to the set of built-in PMCs. But
> these scripts are only in downloaded files they are not in installed
> files. So what should I do? Should I change cpointer.pmc in downloaded
> files or in installed files, then run realclean and then Configure.pl
> from downloaded files or what? I`ve already tried both of it with no
> success.
Those instructions are for adding a new PMC to the Parrot core. When
you're creating PMCs outside the core, you should create your own new
PMC instead of editing an installed PMC directly. Copy the cpointer.pmc
source file and change the name to something like mycpointer.pmc. Edit
the file to change the name in the pmclass line and add 'dynpmc':
pmclass MyCPointer dynpmc need_ext {
/* Copy of all ATTRs and VTABLE functions. */
}
Also change every instance of the old name ("CPointer" or "CPOINTER") to
the new name (also in CamelCase or ALLCAPS).
Then you'll need a few command-line calls to build and install the PMC,
easiest in a makefile. I've attached a Makefile.in template which you
can turn into a makefile with the command (all one line):
perl /usr/local/lib/parrot/1.4.0/tools/dev/gen_makefile.pl Makefile.in
Makefile
Most of the file is just getting configuration values from Parrot. The
actual work is the final 5 lines.
Create a dump format of the PMC:
$(PMC2CD) mycpointer.pmc
Generate the C file for the PMC:
$(PMC2CC) mycpointer.pmc
Compile the C file to a dynamic object:
$(CC) -c @cc_o_out at mycpointer$(O) $(INCLUDES) $(CFLAGS)
$(LD) @ld_out at mycpointer$(LOAD_EXT) mycpointer$(O) $(LINKARGS)
Install the shared library in the dynamic extension directory:
$(CP) "mycpointer$(LOAD_EXT)" $(INSTALL_DIR)
Run 'sudo make install' (or your platform equivalent), then you can use
your new PMC. Here's a small PIR file that uses it:
.loadlib 'mycpointer'
.sub main :main
$P0 = new 'MyCPointer'
#...
.end
Allison
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile.in
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20090806/521576ab/attachment.diff>
More information about the parrot-dev
mailing list