Changeset 489:497c72c3ffbe in verona
- Timestamp:
- May 25, 2012 5:09:59 PM (13 months ago)
- Branch:
- default
- File:
-
- 1 edited
-
swig/verona.i (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
swig/verona.i
r488 r489 80 80 } 81 81 82 82 void make_cxxstr(JNIEnv* jenv, string& st, jstring jst) 83 { 84 jint len = env->GetStringUTFLength(jst); 85 jint jlen = env->GetStringLength(jst); 86 st.capacity(len); 87 env->GetStringUTFRegion(jenv, jst, 0, jlen, (char*) st.data()); 88 st.resize(len); 89 90 } 83 91 %} 84 92 … … 93 101 } 94 102 103 %typemap(in) std::string 104 %{ if(!$input) { 105 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); 106 return $null; 107 } 108 std::string $1_cxxstr; 109 make_cxxstr(jenv, $1_cxxstr, $input); 110 $1 = &$1_cxxstr; // in std::string 111 %} 112 113 %typemap(in) const std::string& 114 %{ if(!$input) { 115 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); 116 return $null; 117 } 118 std::string $1_cxxstr; 119 make_cxxstr(jenv, $1_cxxstr, $input); 120 $1 = &$1_cxxstr; // in const std::string& 121 %} 122 123 124 %typemap(directorout) std::string 125 %{ if(!$input) { 126 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); 127 return $null; 128 } 129 make_cxxstr(jenv, $result, $input); // dirout std::string 130 %} 131 132 %typemap(directorout) const std::string & 133 %{ if(!$input) { 134 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); 135 return $null; 136 } 137 std::string $1_cxxstr; 138 make_cxxstr(jenv, $1_cxxstr, $input); 139 $result = &$1_cxxstr; // dirout const std::string& 140 %} 141 142 143 144 %typemap(directorin,descriptor="Ljava/lang/String;") std::string 145 %{ $input = make_jstr(jenv, &$1); %} 95 146 96 147 %typemap(out) std::string 97 148 %{ $result = make_jstr(jenv, &$1); // out std::string %} 98 149 99 %typemap(directorin,descriptor="Ljava/lang/String;", noblock=1) const std::string { 100 101 $input = make_jstr(jenv, &$1); 102 TmpJOBJ $1_tmpobj(jenv, (jobject) $input); 103 } 150 %typemap(directorin,descriptor="Ljava/lang/String;") const std::string & 151 %{ $input = make_jstr(jenv, &$1); %} 104 152 105 153 %typemap(out) const std::string & … … 107 155 108 156 109 %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * { 110 $input = 0; 111 if ($1) { 112 $input = JCALL1(NewStringUTF, jenv, (const char *)::as_cstr($1)); 113 if (!$input) return $null; 114 } 115 116 TmpJOBJ $1_tmpobj(jenv, (jobject) $input); 117 } 118 119 %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) std::string&, std::string { 120 $input = 0; 121 if ($1) { 122 JavaStr js($1.begin(), $1.end()); 123 $input = JCALL2(NewString, jenv, js.data(), js.size()); 124 if (!$input) return $null; 125 } 126 127 TmpJOBJ $1_tmpobj(jenv, (jobject) $input); 128 } 129 130 157 %typemap(newfree) std::string * "delete $1;"; 131 158 132 159 #endif
Note: See TracChangeset
for help on using the changeset viewer.
