I can't immediately see how:
MODULE = Test PACKAGE = main transforms into
MODULE = XS::Wrap PACKAGE = XS::Wrap.
Is that done by hand ?
I'd attack the problem using
InlineX::C2XS, but few others seem to share my enthusiasm for that (with good reasons, no doubt).
That is, for me, one way is to cd to some directory and create ./src/Wrap.c, where that file contains your C code:
#include <stdio.h>
#include <xswrap.h>
void _arr (){
unsigned char* c_array = arr();
inline_stack_vars;
inline_stack_reset;
int i;
for (i=0; i<3; i++){
inline_stack_push(sv_2mortal(newSViv(c_array[i])));
}
inline_stack_done;
}
Then create a ./XS-Wrap-0.42 source distro directory.
Then create a ./build_src.pl that contains:
use warnings;
use strict;
use InlineX::C2XS qw(c2xs);
my $options =
{WRITE_PM => 1,
WRITE_MAKEFILE_PL => 1,
VERSION => '0.42',
MANIF => 1,
T => 1,
EXPORT_OK_ALL => 1,
EXPORT_TAGS_ALL => 'all',
};
c2xs('XS::Wrap', 'XS::Wrap', './XS-Wrap-0.42', $options);
Then run
perl build_src.pl
Then modify the files generated in ./XS-Wrap-0.42 as needed.
This could all be further customised and further automated, as could your approach.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.