25 #ifndef GLASS_GENERAL_H
26 #define GLASS_GENERAL_H
27
28 #include <jni.h>
29
30 #include <stdint.h>
31 #include <X11/Xlib.h>
32 #include <gdk/gdk.h>
33 #include <gtk/gtk.h>
34
35 #include "glass_wrapper.h"
36
37 #define JLONG_TO_PTR(value) ((void*)(intptr_t)(value))
38 #define PTR_TO_JLONG(value) ((jlong)(intptr_t)(value))
39
40 #define FILE_PREFIX "file://"
41 #define URI_LIST_COMMENT_PREFIX "#"
42 #define URI_LIST_LINE_BREAK "\r\n"
43
44 extern JNIEnv* mainEnv; // Use only with main loop thread!!!
45
46 #include <exception>
47
48 struct jni_exception: public std::exception {
49 jni_exception(jthrowable _th): throwable(_th), message() {
50 jclass jc = mainEnv->FindClass("java/lang/Throwable");
51 if (mainEnv->ExceptionOccurred()) {
52 mainEnv->ExceptionDescribe();
53 mainEnv->ExceptionClear();
54 }
55 jmethodID jmid = mainEnv->GetMethodID(jc, "getMessage", "()Ljava/lang/String;");
56 if (mainEnv->ExceptionOccurred()) {
57 mainEnv->ExceptionDescribe();
58 mainEnv->ExceptionClear();
59 }
60 jmessage = (jstring)mainEnv->CallObjectMethod(throwable, jmid);
61 message = jmessage == NULL ? "" : mainEnv->GetStringUTFChars(jmessage, NULL);
62 }
63 const char *what() const throw()
64 {
|
25 #ifndef GLASS_GENERAL_H
26 #define GLASS_GENERAL_H
27
28 #include <jni.h>
29
30 #include <stdint.h>
31 #include <X11/Xlib.h>
32 #include <gdk/gdk.h>
33 #include <gtk/gtk.h>
34
35 #include "glass_wrapper.h"
36
37 #define JLONG_TO_PTR(value) ((void*)(intptr_t)(value))
38 #define PTR_TO_JLONG(value) ((jlong)(intptr_t)(value))
39
40 #define FILE_PREFIX "file://"
41 #define URI_LIST_COMMENT_PREFIX "#"
42 #define URI_LIST_LINE_BREAK "\r\n"
43
44 extern JNIEnv* mainEnv; // Use only with main loop thread!!!
45 extern JavaVM* javaVM;
46
47 #include <exception>
48
49 struct jni_exception: public std::exception {
50 jni_exception(jthrowable _th): throwable(_th), message() {
51 jclass jc = mainEnv->FindClass("java/lang/Throwable");
52 if (mainEnv->ExceptionOccurred()) {
53 mainEnv->ExceptionDescribe();
54 mainEnv->ExceptionClear();
55 }
56 jmethodID jmid = mainEnv->GetMethodID(jc, "getMessage", "()Ljava/lang/String;");
57 if (mainEnv->ExceptionOccurred()) {
58 mainEnv->ExceptionDescribe();
59 mainEnv->ExceptionClear();
60 }
61 jmessage = (jstring)mainEnv->CallObjectMethod(throwable, jmid);
62 message = jmessage == NULL ? "" : mainEnv->GetStringUTFChars(jmessage, NULL);
63 }
64 const char *what() const throw()
65 {
|