]>
git.saurik.com Git - apple/javascriptcore.git/blob - bindings/jni/jni_utility.h
2 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef _JNI_UTILITY_H_
27 #define _JNI_UTILITY_H_
29 #if ENABLE(JAVA_BINDINGS)
33 #include <JavaVM/jni.h>
35 // The order of these items can not be modified as they are tightly
36 // bound with the JVM on Mac OSX. If new types need to be added, they
37 // should be added to the end. It is used in jni_obc.mm when calling
38 // through to the JVM. Newly added items need to be made compatible
61 const char *getCharactersFromJString(jstring aJString
);
62 void releaseCharactersForJString(jstring aJString
, const char *s
);
64 const char *getCharactersFromJStringInEnv(JNIEnv
*env
, jstring aJString
);
65 void releaseCharactersForJStringInEnv(JNIEnv
*env
, jstring aJString
, const char *s
);
66 const jchar
*getUCharactersFromJStringInEnv(JNIEnv
*env
, jstring aJString
);
67 void releaseUCharactersForJStringInEnv(JNIEnv
*env
, jstring aJString
, const jchar
*s
);
69 JNIType
JNITypeFromClassName(const char *name
);
70 JNIType
JNITypeFromPrimitiveType(char type
);
71 const char *signatureFromPrimitiveType(JNIType type
);
73 jvalue
convertValueToJValue(ExecState
*exec
, JSValue
*value
, JNIType _JNIType
, const char *javaClassName
);
75 jvalue
getJNIField(jobject obj
, JNIType type
, const char *name
, const char *signature
);
77 jmethodID
getMethodID(jobject obj
, const char *name
, const char *sig
);
79 jobject
callJNIObjectMethod(jobject obj
, const char *name
, const char *sig
, ... );
80 void callJNIVoidMethod(jobject obj
, const char *name
, const char *sig
, ... );
81 jboolean
callJNIBooleanMethod(jobject obj
, const char *name
, const char *sig
, ... );
82 jboolean
callJNIStaticBooleanMethod(jclass cls
, const char *name
, const char *sig
, ... );
83 jbyte
callJNIByteMethod(jobject obj
, const char *name
, const char *sig
, ... );
84 jchar
callJNICharMethod(jobject obj
, const char *name
, const char *sig
, ... );
85 jshort
callJNIShortMethod(jobject obj
, const char *name
, const char *sig
, ... );
86 jint
callJNIIntMethod(jobject obj
, const char *name
, const char *sig
, ... );
87 jlong
callJNILongMethod(jobject obj
, const char *name
, const char *sig
, ... );
88 jfloat
callJNIFloatMethod(jobject obj
, const char *name
, const char *sig
, ... );
89 jdouble
callJNIDoubleMethod(jobject obj
, const char *name
, const char *sig
, ... );
91 jobject
callJNIObjectMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
92 void callJNIVoidMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
93 jboolean
callJNIBooleanMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
94 jbyte
callJNIByteMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
95 jchar
callJNICharMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
96 jshort
callJNIShortMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
97 jint
callJNIIntMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
98 jlong
callJNILongMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
99 jfloat
callJNIFloatMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
100 jdouble
callJNIDoubleMethodA(jobject obj
, const char *name
, const char *sig
, jvalue
*args
);
102 jobject
callJNIObjectMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
103 void callJNIVoidMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
104 jboolean
callJNIBooleanMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
105 jbyte
callJNIByteMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
106 jchar
callJNICharMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
107 jshort
callJNIShortMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
108 jint
callJNIIntMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
109 jlong
callJNILongMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
110 jfloat
callJNIFloatMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
111 jdouble
callJNIDoubleMethodIDA(jobject obj
, jmethodID methodID
, jvalue
*args
);
114 void setJavaVM(JavaVM
*javaVM
);
117 bool dispatchJNICall(const void *targetAppletView
, jobject obj
, bool isStatic
, JNIType returnType
, jmethodID methodID
, jvalue
*args
, jvalue
&result
, const char *callingURL
, JSValue
*&exceptionDescription
);
119 } // namespace Bindings
123 #endif // ENABLE(JAVA_BINDINGS)
125 #endif // _JNI_UTILITY_H_