Howdy fellow monks!
I've been fighting with perlxs and a C++ class for a bit now.
I've managed to get the whole thing to compile, but I'm
having a bit of trouble understanding how to use it now
that I've got it. The perldoc for perlxs seems to say how
to set up the .xs file, but not how to call the functions.
For instance, I've added the following to the basic .xs file:
float
Point_2D::x()
CODE:
RETVAL=THIS->x();
OUTPUT:
RETVAL
void
Point_2D::set_x(arg)
float arg
CODE:
THIS->x(arg);
void
Point_2D::DESTROY()
CODE:
delete THIS;
Point_2D *
Point_2D::new()
CODE:
RETVAL = new Point_2D();
OUTPUT:
RETVAL
And I've made a test script that looks like this:
#!/usr/sbin/perl -w
use ExtUtils::testlib;
use Point_2D;
my $pt;
my $output;
print "making object\n";
$pt = Point_2D::new(Point_2D);
print "setting value\n";
Point_2D::set_x($pt,1.2);
print "retrieving value\n";
$output = Point_2D::x($pt);
print "output = ",$output;
The output of which is:
making object
12823:/usr/sbin/perl: rld: Fatal Error: attempted access to unresolvable symbol in bli
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.