3 May 2002 00:07
Namespace fun
David Beazley <beazley <at> cs.uchicago.edu>
2002-05-02 22:07:17 GMT
2002-05-02 22:07:17 GMT
William S Fulton writes:
>
>
> Dave
>
> Some more namespace problems/queries 'cause I know you love them :).
>
> What am I doing wrong here?
>
> namespace std {
> %typemap(jni) string "jstring"
> %typemap(jtype) string "String"
> %typemap(jstype) string "String"
>
> %typemap(in) string
> %{ if($input) {
> char *p = (char *)jenv->GetStringUTFChars($input, 0);
> $1 = std::string(p);
> jenv->ReleaseStringUTFChars($input, p);
> } %}
>
> %typemap(out) string
> %{ $result = jenv->NewStringUTF($1.c_str()); %}
> }
>
I'm a little jet-lagged (just got back), but in order for this to work
as intended, you need to tell SWIG that "string" is a typename defined
in the namespace. Just use a forward class definition.
namespace std {
class string;
%typemap() ....
}
Cheers,
Dave
RSS Feed