103 |
jstring stdstr2jstr(JNIEnv *env, std::string stdstr) { |
jstring stdstr2jstr(JNIEnv *env, std::string stdstr) { |
104 |
return env->NewStringUTF(stdstr.c_str()); |
return env->NewStringUTF(stdstr.c_str()); |
105 |
} |
} |
106 |
|
/** Converts jstring to unistring _without_ asking |
107 |
|
* string length from JNIEnv. This could have been |
108 |
|
* the non-null-string bug, Benja founded. Although, |
109 |
|
* std::basic_string <unsigned short> doesn't seem |
110 |
|
* to be valid anymore: "undefined symbol: |
111 |
|
* std::char_traits<unsigned short>::length(unsigned short const*)" |
112 |
|
* |
113 |
|
* Anyway, these can be dropped, when cleaning Gzz-Gl-jni |
114 |
|
* and this is considered to be irrelevant. |
115 |
|
*/ |
116 |
|
/* |
117 |
|
typedef std::basic_string<unsigned short> unistring; |
118 |
|
unistring jstr2unistr_failing(JNIEnv *env, jstring jstr) { |
119 |
|
const jchar *strptr = env->GetStringChars(jstr, 0); |
120 |
|
unistring unistr(strptr); |
121 |
|
env->ReleaseStringChars(jstr, strptr); |
122 |
|
return unistr; |
123 |
|
} |
124 |
|
/* |
125 |
|
jstring unistr2jstr_failing(JNIEnv *env, unistring unistr) { |
126 |
|
return env->NewString(&(unistr[0]), unistr.size()); |
127 |
|
} |
128 |
|
*/ |
129 |
|
|
130 |
Os::Window *getWindowByWID(int wid) { |
Os::Window *getWindowByWID(int wid) { |
131 |
return (wid<0 ? defaultWindow : windows.get(wid)); |
return (wid<0 ? defaultWindow : windows.get(wid)); |
265 |
return (jdouble) atof(jstr2stdstr(env, jstr).c_str()); |
return (jdouble) atof(jstr2stdstr(env, jstr).c_str()); |
266 |
} |
} |
267 |
|
|
268 |
|
/* |
269 |
|
JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_GL_1Testing_loopUnistrConvFailing |
270 |
|
(JNIEnv *env, jobject obj, jstring jstr) { |
271 |
|
return unistr2jstr_failing(env, jstr2unistr_failing(env, jstr)); |
272 |
|
} |
273 |
|
*/ |
274 |
|
|
275 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_init |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_init |
276 |
(JNIEnv *env, jclass, jint) { |
(JNIEnv *env, jclass, jint) { |
277 |
if(inited++) { |
if(inited++) { |