1 |
14 |
jlechner |
GNU Classpath Native State API - Version 0.99.1
|
2 |
|
|
Written by Paul Fisher (rao@gnu.org)
|
3 |
|
|
|
4 |
|
|
For all function calls, if an error occurs, such that `NULL' or a
|
5 |
|
|
negative value is returned, it's very possible that an exception has
|
6 |
|
|
been thrown from within the function. The exception is not cleared,
|
7 |
|
|
and you are responsible for dealing with the thrown exception.
|
8 |
|
|
|
9 |
|
|
High level API:
|
10 |
|
|
|
11 |
|
|
For using the highlevel API, in all cases, OBJ must contain a `final
|
12 |
|
|
int' field called "native_state", which has been previously set to the
|
13 |
|
|
value of java.lang.System.identityHashCode(OBJ).
|
14 |
|
|
|
15 |
|
|
Function: struct state_table * init_state_table (JNIEnv *ENV,
|
16 |
|
|
jclass CLAZZ)
|
17 |
|
|
|
18 |
|
|
Creates a state table of default size. Returns `NULL' on error.
|
19 |
|
|
|
20 |
|
|
Function: struct state_table * init_state_table_with_size (JNIEnv *ENV,
|
21 |
|
|
jclass CLAZZ,
|
22 |
|
|
jint SIZE)
|
23 |
|
|
|
24 |
|
|
Creates a state table, with a tablesize of SIZE. SIZE should
|
25 |
|
|
always be prime. Returns `NULL' on error.
|
26 |
|
|
|
27 |
|
|
Function: jint set_state (JNIEnv *ENV, jobject OBJ,
|
28 |
|
|
struct state_table *TABLE, void *STATE)
|
29 |
|
|
|
30 |
|
|
Associates STATE with OBJ, in TABLE. Returns 0 on success, and a
|
31 |
|
|
negative value on failure. STATE must not be `NULL'. set_state is
|
32 |
|
|
reentrant, and calls to set_state/get_state/remove_state_slot may be
|
33 |
|
|
made at the same time.
|
34 |
|
|
|
35 |
|
|
Function: void * get_state (JNIEnv *ENV, jobject OBJ,
|
36 |
|
|
struct state_table *TABLE)
|
37 |
|
|
|
38 |
|
|
Retrieves the state associated with OBJ, in TABLE. Returns `NULL'
|
39 |
|
|
if no value is associated with OBJ, or if a failure occurs.
|
40 |
|
|
get_state is reentrant, and calls to
|
41 |
|
|
get_state/set_state/remove_state_slot may be made at the same time.
|
42 |
|
|
|
43 |
|
|
Function: void * remove_state_slot (JNIEnv *ENV, jobject OBJ,
|
44 |
|
|
struct state_table *TABLE)
|
45 |
|
|
|
46 |
|
|
Removes the internal slot associated with OBJ, in TABLE. Returns a
|
47 |
|
|
pointer to the C state if a state was associated with OBJ,
|
48 |
|
|
otherwise, `NULL' is returned. After `remove_state' is called,
|
49 |
|
|
`get_state' passing OBJ, will result in `NULL' being returned. This
|
50 |
|
|
function is generally called in the `finalize' method of a class.
|
51 |
|
|
remove_state_slot is reentrant, and calls to
|
52 |
|
|
get_state/set_state/remove_state_slot may be made at the same time.
|
53 |
|
|
|
54 |
|
|
Low level API:
|
55 |
|
|
|
56 |
|
|
Function: void set_state_oid (JNIEnv *ENV, jobject LOCK,
|
57 |
|
|
struct state_table *TABLE,
|
58 |
|
|
jint OBJECT_ID, void *STATE)
|
59 |
|
|
|
60 |
|
|
Associates STATE with OBJECT_ID, in TABLE. STATE must not be
|
61 |
|
|
`NULL'. On entering, a lock is obtained on LOCK. On exiting, the
|
62 |
|
|
lock is released.
|
63 |
|
|
|
64 |
|
|
Function: void * get_state_oid (JNIEnv *ENV, jobject LOCK,
|
65 |
|
|
struct state_table *TABLE,
|
66 |
|
|
jint OBJECT_ID)
|
67 |
|
|
|
68 |
|
|
Retrieves the state associated with OBJECT_ID, in TABLE. Returns
|
69 |
|
|
`NULL' if no value is associated with OBJECT_ID. On entering, a
|
70 |
|
|
lock is obtained on LOCK. On exiting, the lock is released.
|
71 |
|
|
|
72 |
|
|
Function: void * remove_state_oid (JNIEnv *ENV, jobject LOCK,
|
73 |
|
|
struct state_table *TABLE,
|
74 |
|
|
jint OBJECT_ID)
|
75 |
|
|
|
76 |
|
|
Removes the value associated with OBJECT_ID, in TABLE. Returns a
|
77 |
|
|
pointer to the C state if a state was associated with OBJECT_ID,
|
78 |
|
|
otherwise, `NULL' is returned. After `remove_state_oid' is called,
|
79 |
|
|
`get_state_oid' passing OBJECT_ID, will result in `NULL' being
|
80 |
|
|
returned. On entering, a lock is obtained on LOCK. On exiting, the
|
81 |
|
|
lock is released.
|