PageRenderTime 27ms CodeModel.GetById 25ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/ruby/jstring.i

#
Swig | 44 lines | 40 code | 4 blank | 0 comment | 0 complexity | d11a6c628a414f385b72196c627c3a96 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1%include <typemaps/valtypes.swg>
 2
 3%fragment(SWIG_AsVal_frag(jstring),"header") {
 4SWIGINTERN int
 5SWIG_AsVal(jstring)(VALUE obj, jstring *val)
 6{
 7  if (NIL_P(obj)){
 8    if (val) *val = 0;
 9    return SWIG_OK;
10  } 
11  if (TYPE(obj) == T_STRING) {
12    if (val) {
13      char *cstr = rb_string_value_ptr(&(obj));
14      jsize len = RSTRING(obj)->len;
15      *val = JvNewStringLatin1(cstr, len);
16    }
17    return SWIG_NEWOBJ;
18  }
19  return SWIG_TypeError;
20}
21}
22
23%fragment(SWIG_From_frag(jstring),"header") {
24SWIGINTERNINLINE VALUE
25SWIG_From(jstring)(jstring val)
26{
27  if (!val) {
28    return Qnil;
29  } else {
30    jint len = JvGetStringUTFLength(val);
31    char buf[len];
32    JvGetStringUTFRegion(val, 0, len, buf);
33    return rb_str_new(buf,len);
34  }
35}
36}
37
38%typemaps_asvalfrom(%checkcode(STRING),
39		    %arg(SWIG_AsVal(jstring)), 
40		    %arg(SWIG_From(jstring)), 
41		    %arg(SWIG_AsVal_frag(jstring)), 
42		    %arg(SWIG_From_frag(jstring)), 
43		    java::lang::String *);
44