Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0 KiB

5 years ago
%include <typemaps/valtypes.swg>
%fragment(SWIG_AsVal_frag(jstring),"header") {
SWIGINTERN int
SWIG_AsVal_dec(jstring)(SV *obj, jstring *val)
{
if (SvPOK(obj)) {
if (val) {
STRLEN len = 0;
char *cstr = SvPV(obj, len);
*val = JvNewStringLatin1(cstr, len);
}
return SWIG_OK;
}
return SWIG_ERROR;
}
}
%fragment(SWIG_From_frag(jstring),"header") {
SWIGINTERNINLINE SV *
SWIG_From_dec(jstring)(jstring val)
{
SV *obj = sv_newmortal();
if (!val) {
sv_setsv(obj, &PL_sv_undef);
} else {
jsize len = JvGetStringUTFLength(val);
if (!len) {
sv_setsv(obj, &PL_sv_undef);
} else {
char *tmp = %new_array(len, char);
JvGetStringUTFRegion(val, 0, len, tmp);
sv_setpvn(obj, tmp, len);
SvUTF8_on(obj);
%delete_array(tmp);
}
}
return obj;
}
}
%typemaps_asvalfrom(%checkcode(STRING),
%arg(SWIG_AsVal(jstring)),
%arg(SWIG_From(jstring)),
%arg(SWIG_AsVal_frag(jstring)),
%arg(SWIG_From_frag(jstring)),
java::lang::String *);