Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I found the problem by myself. If one uses XSPP, one must also use Module::Build::WithXSpp to generate XS tyepmap from XSPP typemaps. Otherwise the typemaps are actually not generated.

I'm trying to write a Perl wrapper for my C++ library using XSpp. The typemap looks like this:
%loadplugin{feature::default_xs_typemap}; %typemap{const std::string&}{parsed} { %precall_code {% std::string tmp(SvPV($PerlVar)); $Cvar = tmp; %}; }; %typemap{const std::string}{parsed} { %precall_code {% std::string $Cvar(SvPV($PerlVar)); %}; }; %typemap{GenoEye::PosType}{simple} { %xs_type{T_IV}; }; %typemap{GenoEye::Page*}{parsed} { %precall_code {% IV tmp = SvIV(SvRV($PerlVar)); $CVar = INT2PTR(GenoEye::Page, tmp); %}; %output_code {% $CVar->ref(); sv_setref_pv($PerlVar, "GenoEye::Page", $CVar) %}; };
When I do the compile, XS said the "const std::string" is not type mapped:
Could not find a typemap for C type 'const std::string'. The following C types are mapped by the current typemap: 'AV *', 'Boolean', 'CV *', 'FILE *', 'FileHandle', 'GenoEye::Page *', +'GenoEye::PosType', 'HV *', 'I16', 'I32', 'I8', 'IV', 'InOutStream', +'InputStream', 'NV', 'OutputStream', 'PerlIO *', 'Result', 'STRLEN', +'SV *', 'SVREF', 'SysRet', 'SysRetLong', 'Time_t *', 'U16', 'U32', 'U +8', 'UV', 'bool', 'bool_t', 'caddr_t', 'char', 'char *', 'char **', ' +const char *', 'double', 'float', 'int', 'long', 'short', 'size_t', ' +ssize_t', 'time_t', 'unsigned', 'unsigned char', 'unsigned char *', ' +unsigned int', 'unsigned long', 'unsigned long *', 'unsigned short', +'void *', 'wchar_t', 'wchar_t *' in /usr/bin/perl -MExtUtils::XSpp::Cmd -e xspp -- --typemap=typemap.x +sp GenoEye_Page.xsp, line 53
Then I tried to run xspp directly to see the generated XS code. In the TYPEMAP section, it seems most of the typemaps I written is not converted to XS. Why?
TYPEMAP: <<END TYPEMAP GenoEye::Page* O_OBJECT GenoEye::PosType T_IV INPUT O_OBJECT if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a blessed SV r +eference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT sv_setref_pv( $arg, xsp_constructor_class("${my $ntt = $type; $ntt + =~ s{^const\s+|[ \t*]+$}{}g; \$ntt}"), (void*)$var ); END

In reply to xspp did not handle "const string&" typemap by llancet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found