D
Dilbert
I have been using swig http://www.swig.org/ to incorporate simple C
subroutines into my Perl programs. That works fine, no complaint at
all.
However, I would now like to get my hands dirty and learn how to
communicate between Perl and C from the bottom up using XS-code.
I am thinking about reading "perldoc perlxs", but before I embark on
that adventure, I would ask for your oppinion:
- Would you recommed reading "perldoc perlxs" ?
- Are there any other tutorials ?
For example, if I wrote a C-function
first_test(int i, double d, char* s)
that returns a list -- three values:
* the first value is i - 1234
* the second value is d / 4.2
* the third value is a string "<".s.">".
My first beginner questions would be like:
- How do parameters get passed into the C-function ?
- What happens if Perl gives a string, but the C-function expects a
double ?
- What happens if Perl gives a double, but the C-function expects a
string ?
- How can a C-function return a list of values ?
- Do I need to allocate (malloc ?) memory to return values ?
- Who is reponsible for garbage collections of the allocated memory ?
- Can I pass / return more complicated data structures (hashes of
hashes, lists of lists, etc...) ?
Many questions, but I don't expect an immediate answer. What I really
want to know is: what would be the best tutorial for me ?
subroutines into my Perl programs. That works fine, no complaint at
all.
However, I would now like to get my hands dirty and learn how to
communicate between Perl and C from the bottom up using XS-code.
I am thinking about reading "perldoc perlxs", but before I embark on
that adventure, I would ask for your oppinion:
- Would you recommed reading "perldoc perlxs" ?
- Are there any other tutorials ?
For example, if I wrote a C-function
first_test(int i, double d, char* s)
that returns a list -- three values:
* the first value is i - 1234
* the second value is d / 4.2
* the third value is a string "<".s.">".
My first beginner questions would be like:
- How do parameters get passed into the C-function ?
- What happens if Perl gives a string, but the C-function expects a
double ?
- What happens if Perl gives a double, but the C-function expects a
string ?
- How can a C-function return a list of values ?
- Do I need to allocate (malloc ?) memory to return values ?
- Who is reponsible for garbage collections of the allocated memory ?
- Can I pass / return more complicated data structures (hashes of
hashes, lists of lists, etc...) ?
Many questions, but I don't expect an immediate answer. What I really
want to know is: what would be the best tutorial for me ?