1 %include <typemaps/valtypes.swg> 2 3 %fragment(SWIG_AsVal_frag(jstring),"header") { 4 SWIGINTERN int 5 SWIG_AsVal_dec(jstring)(Tcl_Obj * obj, jstring *val) 6 { 7 int len = 0; 8 const char *cstr = Tcl_GetStringFromObj(obj, &len); 9 if (!cstr || (strcmp(cstr,"NULL") == 0)) { 10 if (val) *val = 0; 11 return SWIG_OK; 12 } else { 13 int len = 0; 14 const Tcl_UniChar *ucstr = Tcl_GetUnicodeFromObj(obj,&len); 15 if (val) { 16 *val = JvNewString((const jchar*)ucstr, len); 17 } 18 } 19 20 return SWIG_NEWOBJ; 21 } 22 } 23 24 %fragment(SWIG_From_frag(jstring),"header") { 25 SWIGINTERNINLINE Tcl_Obj * 26 SWIG_From_dec(jstring)(jstring val) 27 { 28 if (!val) { 29 return Tcl_NewStringObj("NULL",-1); 30 } else { 31 return Tcl_NewUnicodeObj((Tcl_UniChar *)JvGetStringChars(val),JvGetStringUTFLength(val)); 32 } 33 } 34 } 35 36 %typemaps_asvalfrom(%checkcode(STRING), 37 %arg(SWIG_AsVal(jstring)), 38 %arg(SWIG_From(jstring)), 39 %arg(SWIG_AsVal_frag(jstring)), 40 %arg(SWIG_From_frag(jstring)), 41 java::lang::String *); 42 43