Thank you for fast reply.
result = Parrot_call_sub_ret_int(interp, sub, "II", 5);
"II" this magic string I was missing. The first one "I" for return value
and the second one "I" for parameter. I tried it only with a space
between them so that is the reason why I got error.
Now I have another question. Is there any way to pass argument only as a
pointer because I don`t want to pass argument by value. To be more
concrete I want to pass a pointer on packet data received from pcap and
further process this data in Parrot. Thanks.
Radovan
Jeff Horwitz napsal(a):
On Wed, 29 Jul 2009, Radovan Baranec wrote:
Hi,
I am very interesting in Parrot embedding system it is part of my
diploma project "The assessment of appropriateness of using virtual
machines to decode packets". I`d like to ask how to pass arguments
from C to Parrot subroutines? What is the best a most comfortable
way? I will appreciate some examples.
take a look at docs/embed.pod -- it has documentation on the functions
you'd be using, in particular the Parrot_call_sub family of functions.
you pass the subroutine name, a type signature for the arguments, and
the arguments themselves.
you can find examples in t/src/extend.t and t/src/embed.t, as well as
real-world usage in the mod_parrot source in src/parrot_util.c (svn
repo at https://svn.perl.org/parrot-modules/mod_parrot/trunk/)
I am also thinking about which data structure should I use to
store/represent packet in PIR. If you have had ever meet this problem
or solution pls let me know. Thanks.
you can store the raw data in a PMC (very simple if you pass it as an
argument from C), and/or your could break it out into an object (also
a PMC). you can do this from C or PIR. it all depends on how and
where you plan on using the data.
btw: this is my first mailing list ever so pls have a patience with me
welcome!
With best regards,
Radovan
-jeff
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev