📄 kni.h
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* kni.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
*
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
/*
* Copyright (c) 1998-2002 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* Use is subject to license terms.
*/
/*=======================================================================
* SYSTEM: KVM
* SUBSYSTEM: K Native Interface (KNI)
* FILE: kni.h
* OVERVIEW: KNI definitions and declarations
* AUTHORS: Efren A. Serra, Antero Taivalsaari
*=======================================================================*/
/*=======================================================================
* KNI is an implementation-level native function interface
* for CLDC-category VMs. KNI is intended to be significantly
* more lightweight than JNI, so we have made some compromises:
*
* - Compile-time interface with static linking.
* - Source-level (no binary level) compatibility.
* - No argument marshalling. Arguments are read explicitly,
* and return values are set explicitly.
* - No invocation API (cannot call Java from native code).
* - No class definition support.
* - Limited object allocation support (strings only).
* - Limited array region access for arrays of a primitive type.
* - No monitorenter/monitorexit support.
* - Limited error handling and exception support.
* KNI functions do not throw exceptions, but return error
* values/null instead, or go fatal for severe errors.
* - Exceptions can be thrown explicitly, but no direct
* exception manipulation is supported.
*
* An important goal for the KNI implementation for the
* KVM is backwards compatibility. All the native functions
* written for the KVM using the earlier pre-KNI style should
* still work.
*=======================================================================*/
#ifndef _KNI_H_
#define _KNI_H_
/*=========================================================================
* Include files
*=======================================================================*/
#include "machine_md.h"
#ifndef __cplusplus
#include <global.h> /* C++ T_BOOLEAN already defined */
#endif /* !__cplusplus*/
#ifdef CLDCHI
#include "jvmconfig.h"
#endif /* CLDCHI */
#ifdef __cplusplus
extern "C" {
#endif
/*=========================================================================
* Definitions and declarations
*=======================================================================*/
/*
* KNI primitive data types
*
* Note: jlong is defined in machine_md.h, since its definition
* varies from one machine/compiler to another.
*/
typedef unsigned char jboolean;
typedef signed char jbyte;
typedef unsigned short jchar;
typedef short jshort;
typedef int jint;
typedef float jfloat;
typedef double jdouble;
typedef long jsize;
/*
* KNI reference data types
*
* Note: jfieldID and jobject are intended to be opaque
* types. The programmer should not make any assumptions
* about the actual type of these types, since the actual
* type may vary from one KNI implementation to another.
*
* In the KVM implementation of KNI, we use the corresponding
* KVM-specific types to make debugging easier.
*/
#ifdef CLDCHI
// struct _jobject;
// typedef struct _jobject *jobject;
typedef unsigned long** jobject;
struct _jfieldID;
typedef struct _jfieldID *jfieldID;
#else
typedef FIELD jfieldID;
typedef cell** jobject;
#endif /* CLDCHI */
typedef jobject jclass;
typedef jobject jthrowable;
typedef jobject jstring;
typedef jobject jarray;
typedef jarray jbooleanArray;
typedef jarray jbyteArray;
typedef jarray jcharArray;
typedef jarray jshortArray;
typedef jarray jintArray;
typedef jarray jlongArray;
typedef jarray jfloatArray;
typedef jarray jdoubleArray;
typedef jarray jobjectArray;
/*
* KNI return types
*
* The KNI implementation uses these type declarations
* to define the actual machine-specific return type of
* a KNI function.
*
* Note: KNI return types are intended to be opaque types.
* On the KVM, all these return types are defined as 'void',
* but their definition may vary from one VM to another.
*/
typedef void KNI_RETURNTYPE_VOID;
typedef void KNI_RETURNTYPE_BOOLEAN;
typedef void KNI_RETURNTYPE_BYTE;
typedef void KNI_RETURNTYPE_CHAR;
typedef void KNI_RETURNTYPE_SHORT;
typedef void KNI_RETURNTYPE_INT;
typedef void KNI_RETURNTYPE_LONG;
typedef void KNI_RETURNTYPE_FLOAT;
typedef void KNI_RETURNTYPE_DOUBLE;
typedef void KNI_RETURNTYPE_OBJECT;
/*
* jboolean constants
*/
#define KNI_TRUE 1
#define KNI_FALSE 0
/*
* Return values for KNI functions.
* Values correspond to JNI.
*/
#define KNI_OK 0 /* Success */
#define KNI_ERR (-1) /* Unknown error */
#define KNI_ENOMEM (-4) /* Not enough memory */
#define KNI_EINVAL (-6) /* Invalid arguments */
#ifdef __cplusplus
# define KNIEXPORT extern "C"
#else
# define KNIEXPORT extern
#endif /* __cplusplus */
/*
* Version information
*/
#define KNI_VERSION 0x00010000 /* KNI version 1.0 */
/*=========================================================================
* KNI functions (refer to KNI Specification for details)
*=======================================================================*/
/* Version information */
KNIEXPORT jint KNI_GetVersion(void);
/* Class and interface operations */
KNIEXPORT void KNI_FindClass(const char* name, jclass classHandle);
KNIEXPORT void KNI_GetSuperClass(jclass classHandle, jclass superclassHandle);
KNIEXPORT jboolean KNI_IsAssignableFrom(jclass classHandle1, jclass classHandle2);
/* Exceptions and errors */
KNIEXPORT jint KNI_ThrowNew(const char* name, const char* message);
KNIEXPORT void KNI_FatalError(const char* message);
/* Object operations */
KNIEXPORT void KNI_GetObjectClass(jobject objectHandle, jclass classHandle);
KNIEXPORT jboolean KNI_IsInstanceOf(jobject objectHandle, jclass classHandle);
/* Instance field access */
KNIEXPORT jfieldID KNI_GetFieldID(jclass classHandle, const char* name, const char* signature);
KNIEXPORT jboolean KNI_GetBooleanField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jbyte KNI_GetByteField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jchar KNI_GetCharField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jshort KNI_GetShortField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jint KNI_GetIntField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jfloat KNI_GetFloatField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jlong KNI_GetLongField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT jdouble KNI_GetDoubleField(jobject objectHandle, jfieldID fieldID);
KNIEXPORT void KNI_GetObjectField(jobject objectHandle, jfieldID fieldID, jobject toHandle);
KNIEXPORT void KNI_SetBooleanField(jobject objectHandle, jfieldID fieldID, jboolean value);
KNIEXPORT void KNI_SetByteField(jobject objectHandle, jfieldID fieldID, jbyte value);
KNIEXPORT void KNI_SetCharField(jobject objectHandle, jfieldID fieldID, jchar value);
KNIEXPORT void KNI_SetShortField(jobject objectHandle, jfieldID fieldID, jshort value);
KNIEXPORT void KNI_SetIntField(jobject objectHandle, jfieldID fieldID, jint value);
KNIEXPORT void KNI_SetFloatField(jobject objectHandle, jfieldID fieldID, jfloat value);
KNIEXPORT void KNI_SetLongField(jobject objectHandle, jfieldID fieldID, jlong value);
KNIEXPORT void KNI_SetDoubleField(jobject objectHandle, jfieldID fieldID, jdouble value);
KNIEXPORT void KNI_SetObjectField(jobject objectHandle, jfieldID fieldID, jobject fromHandle);
/* Add for FAST_KNI */
KNIEXPORT void KNI_SetFieldBarrier(void* addr, void* value);
/* Static field access */
KNIEXPORT jfieldID KNI_GetStaticFieldID(jclass classHandle, const char* name, const char* signature);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -