SWIG C++ -> Java - mapeo de tipos propia clase de cadena como std::string

I'm struggling to adapt the SWIG built-in std_string.i to work for my own string class.

Lo que hizo:

  • Assuming my own string class is called my::space::String
  • Copy-pasted std_string.i en mi propio .i file and replaced
    • namespace std { by namespace my { namespace space {
    • minúsculas string by String
    • #include <string> by #include <myownheader.h>

The problem is that I'm getting a syntax error that I don't understand and which is not helpful:

wrapmystring.i:90: Error: Syntax error in input(1).

Es esta línea en el const String & typemap part:

%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const String &
%{ if(!$input) {
     SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
     return $null;
   }
   const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
   if (!$1_pstr) return $null;
   /* possible thread/reentrant code problem */
   static $*1_ltype $1_str;
   $1_str = $1_pstr; <=================== syntax error points here
   $result = &$1_str;
   jenv->ReleaseStringUTFChars($input, $1_pstr); %}

Any idea why it works in std_string.i and not with my own class?

preguntado el 23 de abril de 13 a las 13:04

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.