Thank you very much for your answers. Finally I was able to add my own PMC to Parrot to represent packet from pcap. Now I am writing packet decoder in PIR and I run across this problem: I need to convert big endian to little endian in PIR. In doc I found this: http://docs.parrot.org/parrot/latest/html/docs/dev/byteorder.pod.html but I want to avoid to call C function from PIR.

Rado

Allison Randal napsal(a):
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_...@mycpointer$(O) $(INCLUDES) $(CFLAGS)
        $(LD) @ld_...@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
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to