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":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.