📄 jni.bor
字号:
{******************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ Java Native Interface Unit }
{ }
{ Portions created by Sun are }
{ Copyright (C) 1996-1999 Sun Microsystems, Inc., }
{ 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. }
{ All Rights Reserved. }
{ }
{ The original file is: jni.h, released 22 Apr 1999. }
{ The original Pascal code is: jni.pas, released 01 Sep 2000. }
{ }
{ Portions created by Matthew Mead are }
{ Copyright (C) 2001 MMG and Associates }
{ }
{ Obtained through: }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/NPL/NPL-1_1Final.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{ History: }
{ 03 Dec 2000 - Fixed parameters for DestroyJavaVM, GetEnv, }
{ AttachCurrentThread, and DetachCurrentThread }
{ 02 Jan 2001 - Fix in TJNIEnv.ArgsToJValues. Cast AnsiString }
{ to JString. }
{ }
{******************************************************************}
unit JNI;
interface
uses
Types, Libc,
SysUtils;
{ Note:
It is possible to include the defintions from JNI_MD.INC directly
in this file. However, the idea behind separating platform-specific
definitions is to keep this file as generic as possible. Some time
ago, this would not have been important, since Delphi *was* a
Windows-only tool. Now, with Kylix approaching, it will be important
to keep the platform-specific types separate.
}
// JNI_MD.INC contains the machine-dependent typedefs for JByte, JInt and JLong
{$INCLUDE JNI_MD.INC}
type
va_list = PChar;
const
JNI_VERSION_1_1 = JInt($00010001);
{$EXTERNALSYM JNI_VERSION_1_1}
JNI_VERSION_1_2 = JInt($00010002);
{$EXTERNALSYM JNI_VERSION_1_2}
// JBoolean constants
JNI_TRUE = True;
{$EXTERNALSYM JNI_TRUE}
JNI_FALSE = False;
{$EXTERNALSYM JNI_FALSE}
// possible return values for JNI functions.
JNI_OK = 0; // success
{$EXTERNALSYM JNI_OK}
JNI_ERR = -1; // unknown error
{$EXTERNALSYM JNI_ERR}
JNI_EDETACHED = -2; // thread detached from the VM
{$EXTERNALSYM JNI_EDETACHED}
JNI_EVERSION = -3; // JNI version error
{$EXTERNALSYM JNI_EVERSION}
JNI_ENOMEM = -4; // not enough memory
{$EXTERNALSYM JNI_ENOMEM}
JNI_EEXIST = -5; // VM already created
{$EXTERNALSYM JNI_EEXIST}
JNI_EINVAL = -6; // invalid arguments
{$EXTERNALSYM JNI_EINVAL}
JNI_ENOJAVA = -101; // local error for not finding the DLL
// used in ReleaseScalarArrayElements
JNI_COMMIT = 1;
{$EXTERNALSYM JNI_COMMIT}
JNI_ABORT = 2;
{$EXTERNALSYM JNI_ABORT}
type
// JNI Types
JBoolean = Boolean;
JChar = WideChar;
JShort = Smallint;
JFloat = Single;
JDouble = Double;
JSize = JInt;
_JObject = record
end;
JObject = ^_JObject;
JClass = JObject;
JThrowable = JObject;
JString = JObject;
JArray = JObject;
JBooleanArray = JArray;
JByteArray = JArray;
JCharArray = JArray;
JShortArray = JArray;
JIntArray = JArray;
JLongArray = JArray;
JFloatArray = JArray;
JDoubleArray = JArray;
JObjectArray = JArray;
JWeak = JObject;
JRef = JObject;
JValue = packed record
case Integer of
0: (z: JBoolean);
1: (b: JByte );
2: (c: JChar );
3: (s: JShort );
4: (i: JInt );
5: (j: JLong );
6: (f: JFloat );
7: (d: JDouble );
8: (l: JObject );
end;
JFieldID = ^_JFieldID;
_JFieldID = record
end;
JMethodID = ^_JMethodID;
_JMethodID = record
end;
PPointer = ^Pointer;
PJByte = ^JByte;
PJBoolean = ^JBoolean;
PJChar = ^JChar;
PJShort = ^JShort;
PJInt = ^JInt;
PJLong = ^JLong;
PJFloat = ^JFloat;
PJDouble = ^JDouble;
PJString = ^JString;
PJSize = ^JSize;
PJClass = ^JClass;
PJObject = ^JObject;
PJThrowable = ^JThrowable;
PJArray = ^JArray;
PJByteArray = ^JByteArray;
PJBooleanArray = ^JBooleanArray;
PJCharArray = ^JCharArray;
PJShortArray = ^JShortArray;
PJIntArray = ^JIntArray;
PJLongArray = ^JLongArray;
PJFloatArray = ^JFloatArray;
PJDoubleArray = ^JDoubleArray;
PJObjectArray = ^JObjectArray;
PJFieldID = ^JFieldID;
PJMethodID = ^JMethodID;
PJValue = ^JValue;
PJWeak = ^JWeak;
PJRef = ^JRef;
// used in RegisterNatives to describe native method name, signature,
// and function pointer.
PJNINativeMethod = ^JNINativeMethod;
JNINativeMethod = packed record
name: PAnsiChar;
signature: PAnsiChar;
fnPtr: Pointer;
end;
{$EXTERNALSYM JNINativeMethod}
// JNI Native Method Interface.
JNIEnv = ^JNINativeInterface_;
{$EXTERNALSYM JNIEnv}
PJNIEnv = ^JNIEnv;
PPJNIEnv = ^PJNIEnv;
PJNINativeInterface = ^JNINativeInterface_;
// JNI Invocation Interface.
JavaVM = ^JNIInvokeInterface_;
{$EXTERNALSYM JavaVM}
PJNIInvokeInterface = ^JNIInvokeInterface_;
PJavaVM = ^JavaVM;
JNINativeInterface_ = packed record
reserved0: Pointer;
reserved1: Pointer;
reserved2: Pointer;
reserved3: Pointer;
GetVersion: function(Env: PJNIEnv): JInt; cdecl;
DefineClass: function(Env: PJNIEnv; const Name: PAnsiChar; Loader: JObject; const Buf: PJByte; Len: JSize): JClass; cdecl;
FindClass: function(Env: PJNIEnv; const Name: PAnsiChar): JClass; cdecl;
// Reflection Support
FromReflectedMethod: function(Env: PJNIEnv; Method: JObject): JMethodID; cdecl;
FromReflectedField: function(Env: PJNIEnv; Field: JObject): JFieldID; cdecl;
ToReflectedMethod: function(Env: PJNIEnv; AClass: JClass; MethodID: JMethodID; IsStatic: JBoolean): JObject; cdecl;
GetSuperclass: function(Env: PJNIEnv; Sub: JClass): JClass; cdecl;
IsAssignableFrom: function(Env: PJNIEnv; Sub: JClass; Sup: JClass): JBoolean; cdecl;
// Reflection Support
ToReflectedField: function(Env: PJNIEnv; AClass: JClass; FieldID: JFieldID; IsStatic: JBoolean): JObject; cdecl;
Throw: function(Env: PJNIEnv; Obj: JThrowable): JInt; cdecl;
ThrowNew: function(Env: PJNIEnv; AClass: JClass; const Msg: PAnsiChar): JInt; cdecl;
ExceptionOccurred: function(Env: PJNIEnv): JThrowable; cdecl;
ExceptionDescribe: procedure(Env: PJNIEnv); cdecl;
ExceptionClear: procedure(Env: PJNIEnv); cdecl;
FatalError: procedure(Env: PJNIEnv; const Msg: PAnsiChar); cdecl;
// Local Reference Management
PushLocalFrame: function(Env: PJNIEnv; Capacity: JInt): JInt; cdecl;
PopLocalFrame: function(Env: PJNIEnv; Result: JObject): JObject; cdecl;
NewGlobalRef: function(Env: PJNIEnv; LObj: JObject): JObject; cdecl;
DeleteGlobalRef: procedure(Env: PJNIEnv; GRef: JObject); cdecl;
DeleteLocalRef: procedure(Env: PJNIEnv; Obj: JObject); cdecl;
IsSameObject: function(Env: PJNIEnv; Obj1: JObject; Obj2: JObject): JBoolean; cdecl;
// Local Reference Management
NewLocalRef: function(Env: PJNIEnv; Ref: JObject): JObject; cdecl;
EnsureLocalCapacity: function(Env: PJNIEnv; Capacity: JInt): JObject; cdecl;
AllocObject: function(Env: PJNIEnv; AClass: JClass): JObject; cdecl;
NewObject: function(Env: PJNIEnv; AClass: JClass; MethodID: JMethodID): JObject; cdecl;
NewObjectV: function(Env: PJNIEnv; AClass: JClass; MethodID: JMethodID; Args: va_list): JObject; cdecl;
NewObjectA: function(Env: PJNIEnv; AClass: JClass; MethodID: JMethodID; Args: PJValue): JObject; cdecl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -