native modifier, but are
called the same way as any other method is called. Native methods can
either be implemented in C or assembler. Most of the runtime native
methods are implemented in C, but there are some implemented in
assembler for performance. public static native void cmain();
JAVA_NATIVE=1native subdirectory
that contain stub functions for all the native methods. These stub
functions are all in assembler as the Lightfoot Java and C calling conventions are different.native
subdirectory to prevent your modified version from getting overwritten
when you rebuild your application!Jcscall0JcscallnJcscalln also takes a parameter which is the number
of arguments for that function. These arguments should have been pushed
onto the stack. cnst
NoArgFunction ; Function address from the constant
pool
Jcscall0
; Call with no
arguments
Jxreturn
; No return value
cnst
NoArgFunctionRet ;
Function address from the
constant pool
Jcscall0
; Call with no
arguments
lp3
; return value
Jxreturn
; return
lp0
; this for a virtual method, arg0 for
; a static method
cnst
ArgFunctionRet ; Function address from the constant pool
Jcscalln 1
; Call with 1 argument
lp3
; return valuetypedef struct _JavaGPIO_t {
/** The device handle */
DCT_DEVHANDLE
hHandle;
/** The port */
int32
port;
/** The mask */
int32
mask;
} JavaGPIO_t;
/** The handle used in the native methods */
private int hHandle;
/** The GPIO port */
private int port;
/** The mask to use */
private int mask;
native.h
provides the following functionality.| Function |
Description |
GetStringCChars |
Given a Java string, allocate a
zero terminated C string on the heap. This must be freed when finished
with. |
ReleaseStringCChars |
Release the C string allocated
by GetStringCChars |
NewStringC |
Create a Java string from a zero
terminated C string. |
NewByteArray |
Create a new array of bytes |
NewObjectArray |
Create a new array of objects |
FindClass |
Find a class given the name |
ThrowNew |
Throw a new exception with a
message |
Throw |
Throw an exsting exception |
GetArrayLength |
Get the length of the specified
array |
IsJavaNull |
Return true if the Java object
is null |
GetMethodID |
Get the method id given a class
and method name |
AllocObject |
Allocate, but do not initialise
a new object |
NewObject |
Create a new object and call the
specified constructor |
CallVoidMethod |
Call a void method with no
arguments |
CallVoidMethodA |
Call a void method with
arguments specified in the argument array |