]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/library/swt.h
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / library / swt.h
1 /*******************************************************************************
2  * Copyright (c) 2000, 2010 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  * 
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14  
15 /**
16  * swt.h
17  *
18  * This file contains the global macro declarations for the
19  * SWT library.
20  *
21  */
22
23 #ifndef INC_swt_H
24 #define INC_swt_H
25
26 #include "jni.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 extern int IS_JNI_1_2;
33
34 /* #define DEBUG */
35
36 /* if DEBUG is defined print messages from dlerror */
37 #ifdef DEBUG
38 #define CHECK_DLERROR \
39     char* error = dlerror(); \
40     if (error != NULL) { \
41         fprintf(stderr, "dlerror: %s\n", error); \
42     }
43 #else
44 #define CHECK_DLERROR
45 #endif
46
47 #ifndef JNI64
48 #if __x86_64__
49 #define JNI64
50 #endif
51 #endif
52
53 /* 64 bit support */
54 #ifndef JNI64
55
56 /* int/long defines */
57 #define GetIntLongField GetIntField
58 #define SetIntLongField SetIntField
59 #define GetIntLongArrayElements GetIntArrayElements
60 #define ReleaseIntLongArrayElements ReleaseIntArrayElements
61 #define GetIntLongArrayRegion GetIntArrayRegion
62 #define SetIntLongArrayRegion SetIntArrayRegion
63 #define NewIntLongArray NewIntArray
64 #define CallStaticIntLongMethod CallStaticIntMethod
65 #define CallIntLongMethod CallIntMethod
66 #define CallStaticIntLongMethodV CallStaticIntMethodV
67 #define CallIntLongMethodV CallIntMethodV
68 #define jintLongArray jintArray
69 #define jintLong jint
70 #define I_J "I"
71 #define I_JArray "[I"
72
73 /* float/double defines */
74 #define GetFloatDoubleField GetFloatField
75 #define SetFloatDoubleField SetFloatField
76 #define GetFloatDoubleArrayElements GetFloatArrayElements
77 #define ReleaseFloatDoubleArrayElements ReleaseFloatArrayElements
78 #define GetFloatDoubleArrayRegion GetFloatArrayRegion
79 #define jfloatDoubleArray jfloatArray
80 #define jfloatDouble jfloat
81 #define F_D "F"
82 #define F_DArray "[F"
83
84 #else
85
86 /* int/long defines */
87 #define GetIntLongField GetLongField
88 #define SetIntLongField SetLongField
89 #define GetIntLongArrayElements GetLongArrayElements
90 #define ReleaseIntLongArrayElements ReleaseLongArrayElements
91 #define GetIntLongArrayRegion GetLongArrayRegion
92 #define SetIntLongArrayRegion SetLongArrayRegion
93 #define NewIntLongArray NewLongArray
94 #define CallStaticIntLongMethod CallStaticLongMethod
95 #define CallIntLongMethod CallLongMethod
96 #define CallStaticIntLongMethodV CallStaticLongMethodV
97 #define CallIntLongMethodV CallLongMethodV
98 #define jintLongArray jlongArray
99 #define jintLong jlong
100 #define I_J "J"
101 #define I_JArray "[J"
102
103 /* float/double defines */
104 #define GetFloatDoubleField GetDoubleField
105 #define SetFloatDoubleField SetDoubleField
106 #define GetFloatDoubleArrayElements GetDoubleArrayElements
107 #define ReleaseFloatDoubleArrayElements ReleaseDoubleArrayElements
108 #define GetFloatDoubleArrayRegion GetDoubleArrayRegion
109 #define jfloatDoubleArray jdoubleArray
110 #define jfloatDouble jdouble
111 #define F_D "D"
112 #define F_DArray "[D"
113
114 #endif
115
116 #ifdef __APPLE__
117 #define CALLING_CONVENTION
118 #define LOAD_FUNCTION(var, name) \
119                 static int initialized = 0; \
120                 static void *var = NULL; \
121                 if (!initialized) { \
122                         CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR(name##_LIB)); \
123                         if (bundle) var = CFBundleGetFunctionPointerForName(bundle, CFSTR(#name)); \
124                         initialized = 1; \
125                 } 
126 #elif defined (_WIN32) || defined (_WIN32_WCE)
127 #define CALLING_CONVENTION CALLBACK
128 #define LOAD_FUNCTION(var, name) \
129                 static int initialized = 0; \
130                 static FARPROC var = NULL; \
131                 if (!initialized) { \
132                         HMODULE hm = LoadLibraryA(name##_LIB); \
133                         if (hm) var = GetProcAddress(hm, #name); \
134                         initialized = 1; \
135                 }
136 #else
137 #define CALLING_CONVENTION
138 #define LOAD_FLAGS RTLD_LAZY
139 #define LOAD_FUNCTION(var, name) \
140                 static int initialized = 0; \
141                 static void *var = NULL; \
142                 if (!initialized) { \
143                         void* handle = dlopen(name##_LIB, LOAD_FLAGS); \
144                         if (handle) var = dlsym(handle, #name); \
145                         initialized = 1; \
146                         CHECK_DLERROR \
147                 }
148 #endif
149
150 void throwOutOfMemory(JNIEnv *env);
151
152 #define CHECK_NULL_VOID(ptr) \
153         if ((ptr) == NULL) { \
154                 throwOutOfMemory(env); \
155                 return; \
156         }
157
158 #define CHECK_NULL(ptr) \
159         if ((ptr) == NULL) { \
160                 throwOutOfMemory(env); \
161                 return 0; \
162         }
163
164 #ifdef __cplusplus
165 }
166 #endif 
167
168 #endif /* ifndef INC_swt_H */