Home | History | Annotate | Download | only in perl5
      1 /* -----------------------------------------------------------------------------
      2  * std_common.i
      3  *
      4  * SWIG typemaps for STL - common utilities
      5  * ----------------------------------------------------------------------------- */
      6 
      7 %include <std/std_except.i>
      8 
      9 %apply size_t { std::size_t };
     10 
     11 %{
     12 #include <string>
     13 
     14 double SwigSvToNumber(SV* sv) {
     15     return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv);
     16 }
     17 std::string SwigSvToString(SV* sv) {
     18     STRLEN len;
     19     char *ptr = SvPV(sv, len);
     20     return std::string(ptr, len);
     21 }
     22 void SwigSvFromString(SV* sv, const std::string& s) {
     23     sv_setpvn(sv,s.data(),s.size());
     24 }
     25 %}
     26 
     27