On 19/07/07, Stephen Hahn <sch at sun.com> wrote:
> * Roland Mainz <roland.mainz at nrubsig.org> [2007-07-19 17:01]:
> > Alexander Kolbasov wrote:
> > > > "Richard L. Hamilton" wrote:
> > > > >
> > > > > [...]
> > > > > > Hence, I totally agree with...
> > > > [snip]
> > > > > >From my point of view, function-call-like APIs that deal with binary
> > > > > data, preferably available in both C and perl (the latter for those 
> > > > > for
> > > > > whom everything has to be some sort of script), are preferable to
> > > > > new _text_ pseudo files that then need to be parsed from text back to
> > > > > something machine readable, which for particularly _human_ readable
> > > > > formats, may not be both efficient and unambiguous.
> > > > > (along those lines, it would be handy if there were a ksh93 extension
> > > > > that could map C data structures to ksh93 nested variables (using
> > > > > the API for the memory model of the ksh93 binary), not unlike what can
> > > > > be done for perl like that)
> > > >
> > > > Does "perl" have any special support for mapping C structures to
> > > > variables (e.g. some kind of compiler/script - "in" C structure type,
> > > > "out" perl code) ? ksh93 has an API which allows shell variables to use
> > > > native C variables&&datatypes as storage... but I am not sure whether
> > > > this is what you mean...
> > >
> > > Perl has a mechanism (called XSUB) to write glue code between C and Perl. 
> > > It
> > > is definitely not the nicest part of the language. Using this mechanism 
> > > you
> > > can export C data structures as Perl objects, but this is, by no means,
> > > automatic.
> >
> > Do you have any URLs which describe the XSUB stuff ?
>
>   There's probably a good online introduction, but the basics are
>   already on your system
>
>   $ which perldoc
>   /usr/perl5/bin/perldoc
>   $ perldoc perlxs
>   $ perldoc perlxstut
>   $ perldoc perlapi
>   $ perldoc perlguts

What Stephen says is true; it isn't pretty and you may lose your sanity.

You will also become quite familiar with the source code of perl
understanding their rather complex casting system for accessing data
types through perl / XS.

Finally, you will become quite familiar with rather aptly selected
passages from the "Lord of the Rings" that are littered throughout the
source code, usually in the header :)

-- 
Shawn Walker, Software and Systems Analyst
binarycrusader at gmail.com - http://binarycrusader.blogspot.com/

"Beware of bugs in the above code; I have only proved it correct, not
tried it. " --Donald Knuth

Reply via email to