The "most obvious" way to pass complex C++ data to perl is to use objects with accessors with a complementary perl XS mapping (so you're using a pointer to a C++ object like a perl object). You want the accessors because although perl can in theory access the data in a foreign object directly, it gets messy very quickly. IIRC in C++ structs are more or less the same as classes so you should be able to transform your structs into classes reasonably easily.
In C++
class SomeObject {
public:
int get_valueA();
void set_valueA(int value);
// etc...
}
XS code (you need these to use the methods from SomeObject in perl:
int
SomeObject::get_valueA()
void
SomeObject::set_valueA(int value)
You'll also want to set up a typemap for each class.
See also the standard typemap file in your perl distribution for T_PTROBJ_SPECIAL.
See also perlxstut and perlxs and the book "Extending and Embedding Perl".
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.