mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-22 22:20:08 +08:00
5aac1dac62
* java/awt/Window.java (Window(Window,GraphicsConfiguration)): Don't try to find graphics configuration. * java/awt/Toolkit.java (default_toolkit_name): Use new Configuration entry. * gnu/classpath/Configuration.java.in (default_awt_peer_toolkit): New global. * configure: Rebuilt. * configure.in (TOOLKIT): New subst. (--enable-java-awt) [xlib, gtk]: Set TOOLKIT if required. Do AWT tests much earlier. Run Gtk tests. Make jniinclude directory. Make output directories for .c files. * Makefile.in: Rebuilt. * Makefile.am (lib_gnu_java_awt_peer_gtk_la_SOURCES): New macro. (toolexeclib_LTLIBRARIES): Added cond_gtk_ltlibrary. (all_java_source_files): Added new sources. ($(lib_gnu_java_awt_peer_gtk_la_OBJECTS)): New target. (gtk_c_files): New macro. (gtk_c_source_files): New macro. (cond_gtk_ltlibrary): New macro. ($(gtk_c_files)): New target. (lib_gnu_java_awt_peer_gtk_la_LIBADD): New macro. (gtk_awt_peer_sources): New macro. (gtk_c_headers): New macro. ($(gtk_c_headers)): New target. (ACLOCAL_AMFLAGS): New macro. * gtk.m4, glib.m4, libart.m4: New files. * gnu/java/awt/peer/gtk/GdkFontMetrics.java, gnu/java/awt/peer/gtk/GdkGraphics.java, gnu/java/awt/peer/gtk/GtkArg.java, gnu/java/awt/peer/gtk/GtkArgList.java, gnu/java/awt/peer/gtk/GtkButtonPeer.java, gnu/java/awt/peer/gtk/GtkCanvasPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxPeer.java, gnu/java/awt/peer/gtk/GtkChoicePeer.java, gnu/java/awt/peer/gtk/GtkClipboard.java, gnu/java/awt/peer/gtk/GtkComponentPeer.java, gnu/java/awt/peer/gtk/GtkContainerPeer.java, gnu/java/awt/peer/gtk/GtkDialogPeer.java, gnu/java/awt/peer/gtk/GtkFileDialogPeer.java, gnu/java/awt/peer/gtk/GtkFontPeer.java, gnu/java/awt/peer/gtk/GtkFramePeer.java, gnu/java/awt/peer/gtk/GtkGenericPeer.java, gnu/java/awt/peer/gtk/GtkImage.java, gnu/java/awt/peer/gtk/GtkImagePainter.java, gnu/java/awt/peer/gtk/GtkLabelPeer.java, gnu/java/awt/peer/gtk/GtkListPeer.java, gnu/java/awt/peer/gtk/GtkMainThread.java, gnu/java/awt/peer/gtk/GtkMenuBarPeer.java, gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java, gnu/java/awt/peer/gtk/GtkMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkMenuPeer.java, gnu/java/awt/peer/gtk/GtkOffScreenImage.java, gnu/java/awt/peer/gtk/GtkPanelPeer.java, gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java, gnu/java/awt/peer/gtk/GtkScrollbarPeer.java, gnu/java/awt/peer/gtk/GtkScrollPanePeer.java, gnu/java/awt/peer/gtk/GtkTextAreaPeer.java, gnu/java/awt/peer/gtk/GtkTextComponentPeer.java, gnu/java/awt/peer/gtk/GtkTextFieldPeer.java, gnu/java/awt/peer/gtk/GtkToolkit.java, gnu/java/awt/peer/gtk/GtkWindowPeer.java, gnu/java/awt/peer/gtk/TestAWT.java, gnu/java/awt/peer/gtk/Test.java: New files from Classpath. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c, jni/gtk-peer/gthread-jni.c, jni/gtk-peer/gthread-jni.h, jni/gtk-peer/gtkpeer.h, jni/classpath/jcl.c, jni/classpath/jcl.h, jni/classpath/jnilink.c, jni/classpath/jnilink.h, jni/classpath/native_state.c, jni/classpath/native_state.h, jni/classpath/primlib.c, jni/classpath/primlib.h: Likewise. From-SVN: r62187
464 lines
18 KiB
C
464 lines
18 KiB
C
/* primlib.c
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Classpath.
|
|
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA.
|
|
|
|
Linking this library statically or dynamically with other modules is
|
|
making a combined work based on this library. Thus, the terms and
|
|
conditions of the GNU General Public License cover the whole
|
|
combination.
|
|
|
|
As a special exception, the copyright holders of this library give you
|
|
permission to link this library with independent modules to produce an
|
|
executable, regardless of the license terms of these independent
|
|
modules, and to copy and distribute the resulting executable under
|
|
terms of your choice, provided that you also meet, for each linked
|
|
independent module, the terms and conditions of the license of that
|
|
module. An independent module is a module which is not derived from
|
|
or based on this library. If you modify this library, you may extend
|
|
this exception to your version of the library, but you are not
|
|
obligated to do so. If you do not wish to do so, delete this
|
|
exception statement from your version. */
|
|
|
|
#include <jnilink.h>
|
|
#include <primlib.h>
|
|
#include <jcl.h>
|
|
|
|
static jclass nativeWrapClass[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL,
|
|
NULL,NULL,NULL, NULL,NULL,NULL};
|
|
|
|
static jclass nativeTypeClass[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL,
|
|
NULL,NULL,NULL, NULL,NULL,NULL};
|
|
|
|
static jmethodID nativeWrapClassConstructor[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL,
|
|
NULL,NULL,NULL, NULL,NULL,NULL};
|
|
|
|
static jmethodID nativeWrapClassAccessor[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL,
|
|
NULL,NULL,NULL, NULL,NULL,NULL};
|
|
|
|
static char * nativeWrapClassName[PRIMLIB_NUMTYPES] = {
|
|
NULL,
|
|
NULL,
|
|
"java/lang/Boolean",
|
|
"java/lang/Byte",
|
|
"java/lang/Character",
|
|
"java/lang/Short",
|
|
"java/lang/Integer",
|
|
"java/lang/Long",
|
|
"java/lang/Float",
|
|
"java/lang/Double",
|
|
"java/lang/Void",
|
|
NULL
|
|
};
|
|
|
|
static char * nativeWrapClassConstructorSig[PRIMLIB_NUMTYPES] = {
|
|
NULL,
|
|
NULL,
|
|
"(Z)V",
|
|
"(B)V",
|
|
"(C)V",
|
|
"(S)V",
|
|
"(I)V",
|
|
"(J)V",
|
|
"(F)V",
|
|
"(D)V",
|
|
"()V",
|
|
NULL
|
|
};
|
|
|
|
static char * nativeWrapClassAccessorName[PRIMLIB_NUMTYPES] = {
|
|
NULL,
|
|
NULL,
|
|
"booleanValue",
|
|
"byteValue",
|
|
"charValue",
|
|
"shortValue",
|
|
"intValue",
|
|
"longValue",
|
|
"floatValue",
|
|
"doubleValue",
|
|
NULL,
|
|
NULL
|
|
};
|
|
|
|
static char * nativeWrapClassAccessorSig[PRIMLIB_NUMTYPES] = {
|
|
NULL,
|
|
NULL,
|
|
"()Z",
|
|
"()B",
|
|
"()C",
|
|
"()S",
|
|
"()I",
|
|
"()J",
|
|
"()F",
|
|
"()D",
|
|
NULL,
|
|
NULL
|
|
};
|
|
|
|
|
|
JNIEXPORT jclass JNICALL PRIMLIB_GetNativeWrapClass(JNIEnv * env, int reflectType) {
|
|
return LINK_LinkClass(env,nativeWrapClass[reflectType],nativeWrapClassName[reflectType]);
|
|
}
|
|
|
|
static jclass ActuallyGetNativeTypeClass(JNIEnv * env, int reflectType) {
|
|
jclass wrapClass;
|
|
jfieldID typeField;
|
|
|
|
wrapClass = PRIMLIB_GetNativeWrapClass(env, reflectType);
|
|
if(wrapClass == NULL)
|
|
return NULL;
|
|
typeField = (*env)->GetStaticFieldID(env, wrapClass, "TYPE", "Ljava/lang/Class");
|
|
if(typeField == NULL)
|
|
return NULL;
|
|
return (*env)->GetStaticObjectField(env, wrapClass, typeField);
|
|
}
|
|
|
|
JNIEXPORT jclass JNICALL PRIMLIB_GetNativeTypeClass(JNIEnv * env, int reflectType) {
|
|
return LINK_LinkKnownClass(env, nativeTypeClass[reflectType], ActuallyGetNativeTypeClass(env,reflectType));
|
|
}
|
|
|
|
JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassConstructor(JNIEnv * env, int reflectType) {
|
|
PRIMLIB_GetNativeWrapClass(env,reflectType);
|
|
return LINK_LinkConstructor(env, nativeWrapClassConstructor[reflectType], nativeWrapClass[reflectType], nativeWrapClassConstructorSig[reflectType]);
|
|
}
|
|
|
|
JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassAccessor(JNIEnv * env, int reflectType) {
|
|
PRIMLIB_GetNativeWrapClass(env,reflectType);
|
|
return LINK_LinkMethod(env, nativeWrapClassAccessor[reflectType], nativeWrapClass[reflectType], nativeWrapClassAccessorName[reflectType], nativeWrapClassAccessorSig[reflectType]);
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapBoolean(JNIEnv * env, jboolean b) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_BOOLEAN);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN), construct, b);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapByte (JNIEnv * env, jbyte b) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_BYTE);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE), construct, b);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapChar (JNIEnv * env, jchar c) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_CHAR);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR), construct, c);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapShort (JNIEnv * env, jshort s) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_SHORT);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT), construct, s);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapInt (JNIEnv * env, jint i) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_INT);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT), construct, i);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapLong (JNIEnv * env, jlong l) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_LONG);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG), construct, l);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapFloat (JNIEnv * env, jfloat f) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_FLOAT);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT), construct, f);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL PRIMLIB_WrapDouble (JNIEnv * env, jdouble d) {
|
|
jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_DOUBLE);
|
|
JCL_RETHROW_EXCEPTION(env);
|
|
return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE), construct, d);
|
|
}
|
|
|
|
|
|
JNIEXPORT jboolean JNICALL PRIMLIB_UnwrapBoolean(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN))) {
|
|
return PRIMLIB_GetBooleanObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return JNI_FALSE;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jbyte JNICALL PRIMLIB_UnwrapByte(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jshort JNICALL PRIMLIB_UnwrapShort(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) {
|
|
return PRIMLIB_GetShortObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return (jshort)PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jchar JNICALL PRIMLIB_UnwrapChar(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) {
|
|
return PRIMLIB_GetCharObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL PRIMLIB_UnwrapInt(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) {
|
|
return PRIMLIB_GetIntObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) {
|
|
return (jint)PRIMLIB_GetShortObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) {
|
|
return (jint)PRIMLIB_GetCharObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return (jint)PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jlong JNICALL PRIMLIB_UnwrapLong(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) {
|
|
return PRIMLIB_GetLongObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) {
|
|
return (jlong)PRIMLIB_GetIntObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) {
|
|
return (jlong)PRIMLIB_GetShortObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) {
|
|
return (jlong)PRIMLIB_GetCharObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return (jlong)PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jfloat JNICALL PRIMLIB_UnwrapFloat(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT))) {
|
|
return PRIMLIB_GetFloatObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) {
|
|
return (jfloat)PRIMLIB_GetLongObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) {
|
|
return (jfloat)PRIMLIB_GetIntObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) {
|
|
return (jfloat)PRIMLIB_GetShortObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) {
|
|
return (jfloat)PRIMLIB_GetCharObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return (jfloat)PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jdouble JNICALL PRIMLIB_UnwrapDouble(JNIEnv * env, jobject obj) {
|
|
if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE))) {
|
|
return PRIMLIB_GetDoubleObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT))) {
|
|
return (jdouble)PRIMLIB_GetFloatObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) {
|
|
return (jdouble)PRIMLIB_GetLongObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) {
|
|
return (jdouble)PRIMLIB_GetIntObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) {
|
|
return (jdouble)PRIMLIB_GetShortObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) {
|
|
return (jdouble)PRIMLIB_GetCharObjectValue(env, obj);
|
|
} else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) {
|
|
return (jdouble)PRIMLIB_GetByteObjectValue(env, obj);
|
|
} else {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveWrapperType(JNIEnv * env, jobject obj) {
|
|
jclass typeClass;
|
|
if(obj == NULL) {
|
|
return PRIMLIB_NULL;
|
|
}
|
|
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_DOUBLE;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_FLOAT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_LONG;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_INT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_CHAR;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_SHORT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_BYTE;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_BOOLEAN;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_VOID);
|
|
if((*env)->IsInstanceOf(env, obj, typeClass)) {
|
|
return PRIMLIB_VOID;
|
|
}
|
|
return PRIMLIB_OBJECT;
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveType(JNIEnv * env, jclass returnType) {
|
|
jclass typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_DOUBLE);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_DOUBLE;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_FLOAT);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_FLOAT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_LONG);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_LONG;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_INT);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_INT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_CHAR);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_CHAR;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_SHORT);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_SHORT;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_BYTE);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_BYTE;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_BOOLEAN);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_BOOLEAN;
|
|
}
|
|
typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_VOID);
|
|
if((*env)->IsAssignableFrom(env, returnType, typeClass)) {
|
|
return PRIMLIB_VOID;
|
|
}
|
|
return PRIMLIB_OBJECT;
|
|
}
|
|
|
|
|
|
JNIEXPORT jboolean JNICALL PRIMLIB_GetBooleanObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_BOOLEAN);
|
|
return (*env)->CallBooleanMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jbyte JNICALL PRIMLIB_GetByteObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_BYTE);
|
|
return (*env)->CallByteMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jshort JNICALL PRIMLIB_GetShortObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_SHORT);
|
|
return (*env)->CallShortMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jchar JNICALL PRIMLIB_GetCharObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_CHAR);
|
|
return (*env)->CallCharMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL PRIMLIB_GetIntObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_INT);
|
|
return (*env)->CallIntMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jlong JNICALL PRIMLIB_GetLongObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_LONG);
|
|
return (*env)->CallLongMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jfloat JNICALL PRIMLIB_GetFloatObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_FLOAT);
|
|
return (*env)->CallFloatMethod(env, obj, acc);
|
|
}
|
|
|
|
JNIEXPORT jdouble JNICALL PRIMLIB_GetDoubleObjectValue(JNIEnv * env, jobject obj) {
|
|
jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_DOUBLE);
|
|
return (*env)->CallDoubleMethod(env, obj, acc);
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jvalue JNICALL PRIMLIB_UnwrapJValue(JNIEnv* env, jobject obj, jclass classType) {
|
|
jvalue retval;
|
|
jint objType = PRIMLIB_GetReflectiveType(env, classType);
|
|
if(objType == PRIMLIB_BOOLEAN) {
|
|
retval.z = PRIMLIB_UnwrapBoolean(env,obj);
|
|
} else if(objType == PRIMLIB_BYTE) {
|
|
retval.b = PRIMLIB_UnwrapByte(env,obj);
|
|
} else if(objType == PRIMLIB_CHAR) {
|
|
retval.c = PRIMLIB_UnwrapChar(env,obj);
|
|
} else if(objType == PRIMLIB_SHORT) {
|
|
retval.s = PRIMLIB_UnwrapShort(env,obj);
|
|
} else if(objType == PRIMLIB_INT) {
|
|
retval.i = PRIMLIB_UnwrapInt(env,obj);
|
|
} else if(objType == PRIMLIB_LONG) {
|
|
retval.j = PRIMLIB_UnwrapLong(env,obj);
|
|
} else if(objType == PRIMLIB_FLOAT) {
|
|
retval.f = PRIMLIB_UnwrapFloat(env,obj);
|
|
} else if(objType == PRIMLIB_DOUBLE) {
|
|
retval.d = PRIMLIB_UnwrapDouble(env,obj);
|
|
} else {
|
|
if(obj != NULL && !(*env)->IsInstanceOf(env, obj, classType)) {
|
|
JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct object type.");
|
|
return retval;
|
|
}
|
|
retval.l = obj;
|
|
}
|
|
return retval;
|
|
}
|
|
|