PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Lib/tcl/jstring.i

#
Swig | 42 lines | 37 code | 5 blank | 0 comment | 0 complexity | 9c2757470f83a3cd19e57ec0472dc978 MD5 | raw file
 1%include <typemaps/valtypes.swg>
 2
 3%fragment(SWIG_AsVal_frag(jstring),"header") {
 4SWIGINTERN int
 5SWIG_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") {
25SWIGINTERNINLINE Tcl_Obj *
26SWIG_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