📄 kni.h
字号:
/* Static field access */KNIEXPORT jfieldID KNI_GetStaticFieldID(jclass classHandle, const char* name, const char* signature);KNIEXPORT jboolean KNI_GetStaticBooleanField(jclass classHandle, jfieldID fieldID);KNIEXPORT jbyte KNI_GetStaticByteField(jclass classHandle, jfieldID fieldID);KNIEXPORT jchar KNI_GetStaticCharField(jclass classHandle, jfieldID fieldID);KNIEXPORT jshort KNI_GetStaticShortField(jclass classHandle, jfieldID fieldID);KNIEXPORT jint KNI_GetStaticIntField(jclass classHandle, jfieldID fieldID);KNIEXPORT jlong KNI_GetStaticLongField(jclass classHandle, jfieldID fieldID);KNIEXPORT jfloat KNI_GetStaticFloatField(jclass classHandle, jfieldID fieldID);KNIEXPORT jdouble KNI_GetStaticDoubleField(jclass classHandle, jfieldID fieldID);KNIEXPORT void KNI_GetStaticObjectField(jclass classHandle, jfieldID fieldID, jobject toHandle);KNIEXPORT void KNI_SetStaticBooleanField(jclass classHandle, jfieldID fieldID, jboolean value);KNIEXPORT void KNI_SetStaticByteField(jclass classHandle, jfieldID fieldID, jbyte value);KNIEXPORT void KNI_SetStaticCharField(jclass classHandle, jfieldID fieldID, jchar value);KNIEXPORT void KNI_SetStaticShortField(jclass classHandle, jfieldID fieldID, jshort value);KNIEXPORT void KNI_SetStaticIntField(jclass classHandle, jfieldID fieldID, jint value);KNIEXPORT void KNI_SetStaticLongField(jclass classHandle, jfieldID fieldID, jlong value);KNIEXPORT void KNI_SetStaticFloatField(jclass classHandle, jfieldID fieldID, jfloat value);KNIEXPORT void KNI_SetStaticDoubleField(jclass classHandle, jfieldID fieldID, jdouble value);KNIEXPORT void KNI_SetStaticObjectField(jclass classHandle, jfieldID fieldID, jobject fromHandle);/* String operations */KNIEXPORT jsize KNI_GetStringLength(jstring stringHandle);KNIEXPORT void KNI_GetStringRegion(jstring stringHandle, jsize offset, jsize n, jchar* jcharbuf);KNIEXPORT void KNI_NewString(const jchar* uchars, jsize length, jstring stringHandle);KNIEXPORT void KNI_NewStringUTF(const char* utf8chars, jstring stringHandle);/* Array operations */KNIEXPORT jsize KNI_GetArrayLength(jarray arrayHandle);KNIEXPORT jboolean KNI_GetBooleanArrayElement(jbooleanArray arrayHandle, jint index);KNIEXPORT jbyte KNI_GetByteArrayElement(jbyteArray arrayHandle, jint index);KNIEXPORT jchar KNI_GetCharArrayElement(jcharArray arrayHandle, jint index);KNIEXPORT jshort KNI_GetShortArrayElement(jshortArray arrayHandle, jint index);KNIEXPORT jint KNI_GetIntArrayElement(jintArray arrayHandle, jint index);KNIEXPORT jfloat KNI_GetFloatArrayElement(jfloatArray arrayHandle, jint index);KNIEXPORT jlong KNI_GetLongArrayElement(jlongArray arrayHandle, jint index);KNIEXPORT jdouble KNI_GetDoubleArrayElement(jdoubleArray arrayHandle, jint index);KNIEXPORT void KNI_GetObjectArrayElement(jobjectArray arrayHandle, jint index, jobject toHandle);KNIEXPORT void KNI_SetBooleanArrayElement(jbooleanArray arrayHandle, jint index, jboolean value);KNIEXPORT void KNI_SetByteArrayElement(jbyteArray arrayHandle, jint index, jbyte value);KNIEXPORT void KNI_SetCharArrayElement(jcharArray arrayHandle, jint index, jchar value);KNIEXPORT void KNI_SetShortArrayElement(jshortArray arrayHandle, jint index, jshort value);KNIEXPORT void KNI_SetIntArrayElement(jintArray arrayHandle, jint index, jint value);KNIEXPORT void KNI_SetFloatArrayElement(jfloatArray arrayHandle, jint index, jfloat value);KNIEXPORT void KNI_SetLongArrayElement(jlongArray arrayHandle, jint index, jlong value);KNIEXPORT void KNI_SetDoubleArrayElement(jdoubleArray arrayHandle, jint index, jdouble value);KNIEXPORT void KNI_SetObjectArrayElement(jobjectArray arrayHandle, jint index, jobject fromHandle);KNIEXPORT void KNI_GetRawArrayRegion(jarray arrayHandle, jsize offset, jsize n, jbyte* dstBuffer);KNIEXPORT void KNI_SetRawArrayRegion(jarray arrayHandle, jsize offset, jsize n, const jbyte* srcBuffer);/* Parameter access */KNIEXPORT jboolean KNI_GetParameterAsBoolean(jint index);KNIEXPORT jbyte KNI_GetParameterAsByte(jint index);KNIEXPORT jchar KNI_GetParameterAsChar(jint index);KNIEXPORT jshort KNI_GetParameterAsShort(jint index);KNIEXPORT jint KNI_GetParameterAsInt(jint index);KNIEXPORT jfloat KNI_GetParameterAsFloat(jint index);KNIEXPORT jlong KNI_GetParameterAsLong(jint index);KNIEXPORT jdouble KNI_GetParameterAsDouble(jint index);KNIEXPORT void KNI_GetParameterAsObject(jint index, jobject toHandle);KNIEXPORT void KNI_GetThisPointer(jobject toHandle);KNIEXPORT void KNI_GetClassPointer(jclass toHandle);/* Return operations (implemented as macros on the KVM) */#define KNI_ReturnVoid() \{ \ if (CurrentNativeMethod != NULL) { \ kvm_resetOperandStack(); \ } \ return; \}#define KNI_ReturnBoolean(value) \{ \ kvm_resetOperandStack(); \ pushStack((value)); \ return; \}#define KNI_ReturnByte(value) \{ \ kvm_resetOperandStack(); \ pushStack((value)); \ return; \}#define KNI_ReturnChar(value) \{ \ kvm_resetOperandStack(); \ pushStack((value)); \ return; \}#define KNI_ReturnShort(value) \{ \ kvm_resetOperandStack(); \ pushStack((value)); \ return; \}#define KNI_ReturnInt(value) \{ \ kvm_resetOperandStack(); \ pushStack((value)); \ return; \}#define KNI_ReturnLong(value) \{ \ kvm_resetOperandStack(); \ pushLong((value)); \ return; \}#define KNI_ReturnFloat(value) \{ \ kvm_resetOperandStack(); \ pushStackAsType(float, (value)); \ return; \}#define KNI_ReturnDouble(value) \{ \ kvm_resetOperandStack(); \ pushDouble(value); \ return; \}/* Handle operations (implemented as macros on the KVM) */#define KNI_StartHandles(n) \ { int _tmp_roots_ = TemporaryRootsLength#define KNI_DeclareHandle(handle) \ DECLARE_TEMPORARY_ROOT(jobject, handle ## _0, NULL); \ jobject handle = (jobject)&(handle ## _0)#define KNI_IsNullHandle(handle) \ ((*(handle)) ? KNI_FALSE : KNI_TRUE)#define KNI_IsSameObject(handle1, handle2) \ ((*(handle1) == *(handle2)) ? KNI_TRUE : KNI_FALSE)#define KNI_ReleaseHandle(handle) \ *(handle) = 0;#define KNI_EndHandles() \ END_TEMPORARY_ROOTS#define KNI_EndHandlesAndReturnObject(handle) \ kvm_resetOperandStack(); \ pushStack(*(cell*)(handle)); \ END_TEMPORARY_ROOTS \ return;/* Private operations */void kvm_resetOperandStack();/*========================================================================= * COMMENT: * Since version 1.0.3, KVM garbage collector includes a special * callback mechanism that allows each KVM port to register * implementation-specific cleanup routines that get called * automatically upon system exit. This mechanism can be used, * e.g., for adding network or UI-widget cleanup routines to * the system. These cleanup routines will be called automatically * when the corresponding Java object gets garbage collected. * * In KVM 1.0.4, we have made this mechanism capable of * being used from KNI functions. A separate cleanup * registration function, KNI_registerCleanup, has been * defined for this purpose. Unlike the regular register- * Cleanup routine defined in file 'garbage.h', this function * accepts parameters as 'jobject' handles instead of * INSTANCE_HANDLEs. * * NOTE: These routines are not part of the KNI API!! * They have been provided as a convenience for * people who need to port existing class libraries * onto KNI. *=======================================================================*//* The function type of a cleanup callback function */typedef void (*KNICleanupCallback)(jobject);/* * Register a cleanup function for the instance. * When the gc finds the object unreachable it will see if there is * an associated cleanup function and if so will call it with the instance. */extern void KNI_registerCleanup(jobject, KNICleanupCallback);#endif /* _KNI_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -