rjb 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ Tue Nov 21 arton
2
+ *load.c
3
+ *rjb.c
4
+ *rjbexception.c
5
+ *rjb.h
6
+ add prefix 'rjb' for externed symbol names to avoid confliction.
7
+
1
8
  Sun Oct 08 arton (on behalf of richard apodaca)
2
9
  *load.c
3
10
  support AMD64
@@ -1,21 +1,21 @@
1
1
  /* DO NOT EDIT THIS FILE - it is machine generated */
2
- #include <jni.h>
2
+ #include <jni.h>
3
3
  /* Header for class jp_co_infoseek_hp_arton_rjb_RBridge */
4
4
 
5
5
  #ifndef _Included_jp_co_infoseek_hp_arton_rjb_RBridge
6
- #define _Included_jp_co_infoseek_hp_arton_rjb_RBridge
6
+ #define _Included_jp_co_infoseek_hp_arton_rjb_RBridge
7
7
  #ifdef __cplusplus
8
8
  extern "C" {
9
- #endif
10
- /*
11
- * Class: jp_co_infoseek_hp_arton_rjb_RBridge
12
- * Method: call
13
- * Signature: (Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
14
- */
15
- JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
9
+ #endif
10
+ /*
11
+ * Class: jp_co_infoseek_hp_arton_rjb_RBridge
12
+ * Method: call
13
+ * Signature: (Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
14
+ */
15
+ JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
16
16
  (JNIEnv *, jobject, jstring, jobject, jobjectArray);
17
-
17
+
18
18
  #ifdef __cplusplus
19
19
  }
20
- #endif
21
- #endif
20
+ #endif
21
+ #endif
data/ext/load.c CHANGED
@@ -12,7 +12,7 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * $Id: load.c 5 2006-10-07 19:51:57Z arton $
15
+ * $Id: load.c 9 2006-11-20 19:26:14Z arton $
16
16
  */
17
17
 
18
18
  #include <stdlib.h>
@@ -63,9 +63,6 @@
63
63
  typedef void (*GETDEFAULTJAVAVMINITARGS)(void*);
64
64
  typedef int (*CREATEJAVAVM)(JavaVM**, void**, void*);
65
65
 
66
- extern JavaVM* jvm;
67
- extern jclass rbridge;
68
- extern jmethodID register_bridge;
69
66
  static VALUE jvmdll = Qnil;
70
67
  static VALUE GetDefaultJavaVMInitArgs;
71
68
  static VALUE CreateJavaVM;
@@ -119,7 +116,7 @@ static VALUE load_jvm(char* jvmtype)
119
116
  return Qtrue;
120
117
  }
121
118
 
122
- int load_bridge(JNIEnv* jenv)
119
+ static int load_bridge(JNIEnv* jenv)
123
120
  {
124
121
  JNINativeMethod nmethod[1];
125
122
  jbyte buff[8192];
@@ -151,23 +148,23 @@ int load_bridge(JNIEnv* jenv)
151
148
  }
152
149
  len = fread(buff, 1, sizeof(buff), f);
153
150
  fclose(f);
154
- rbridge = (*jenv)->DefineClass(jenv,
151
+ rjb_rbridge = (*jenv)->DefineClass(jenv,
155
152
  "jp/co/infoseek/hp/arton/rjb/RBridge", iloader, buff, len);
156
- if (rbridge == NULL)
153
+ if (rjb_rbridge == NULL)
157
154
  {
158
- check_exception(jenv, 1);
155
+ rjb_check_exception(jenv, 1);
159
156
  }
160
- register_bridge = (*jenv)->GetMethodID(jenv, rbridge, "register",
157
+ rjb_register_bridge = (*jenv)->GetMethodID(jenv, rjb_rbridge, "register",
161
158
  "(Ljava/lang/Class;)Ljava/lang/Object;");
162
159
  nmethod[0].name = "call";
163
160
  nmethod[0].signature = "(Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;";
164
161
  nmethod[0].fnPtr = Java_jp_co_infoseek_hp_arton_rjb_RBridge_call;
165
- (*jenv)->RegisterNatives(jenv, rbridge, nmethod, 1);
166
- rbridge = (*jenv)->NewGlobalRef(jenv, rbridge);
162
+ (*jenv)->RegisterNatives(jenv, rjb_rbridge, nmethod, 1);
163
+ rjb_rbridge = (*jenv)->NewGlobalRef(jenv, rjb_rbridge);
167
164
  return 0;
168
165
  }
169
166
 
170
- int create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALUE argv)
167
+ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALUE argv)
171
168
  {
172
169
  static JavaVMOption soptions[] = {
173
170
  #if defined(__sparc_v9__) || defined(__sparc__)
@@ -244,7 +241,7 @@ int create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALUE ar
244
241
  vm_args->ignoreUnrecognized = JNI_TRUE;
245
242
  ptr = rb_funcall(CreateJavaVM, rb_intern("to_i"), 0);
246
243
  createjavavm = *(CREATEJAVAVM*)FIX2INT(ptr);
247
- result = createjavavm(&jvm, (void**)pjenv, vm_args);
244
+ result = createjavavm(&rjb_jvm, (void**)pjenv, vm_args);
248
245
  if (!result)
249
246
  {
250
247
  result = load_bridge(*pjenv);
data/ext/rjb.c CHANGED
@@ -12,10 +12,10 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * $Id: rjb.c 4 2006-09-11 15:21:38Z arton $
15
+ * $Id: rjb.c 8 2006-11-20 19:17:22Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.0.2"
18
+ #define RJB_VERSION "1.0.3"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "st.h"
@@ -36,7 +36,6 @@
36
36
  #define ACC_VOLATILE 0x0040
37
37
  #define ACC_TRANSIENT 0x0080
38
38
 
39
- extern int create_jvm(JNIEnv** pjenv, JavaVMInitArgs*, char*, VALUE);
40
39
  static void register_class(VALUE, VALUE);
41
40
  static VALUE import_class(JNIEnv* jenv, jclass, VALUE);
42
41
  static VALUE register_instance(JNIEnv* jenv, struct jvi_data*, jobject);
@@ -48,16 +47,16 @@ static jarray r2objarray(JNIEnv* jenv, VALUE v, const char* cls);
48
47
 
49
48
  static VALUE rjb;
50
49
  static VALUE jklass;
51
- VALUE rjbc;
52
- VALUE rjbi;
53
- VALUE rjbb;
50
+ static VALUE rjbc;
51
+ static VALUE rjbi;
52
+ static VALUE rjbb;
54
53
 
55
- VALUE loaded_classes;
54
+ VALUE rjb_loaded_classes;
56
55
  static VALUE proxies;
57
- JavaVM* jvm;
58
- JNIEnv* main_jenv;
59
- jclass rbridge;
60
- jmethodID register_bridge;
56
+ JavaVM* rjb_jvm;
57
+ jclass rjb_rbridge;
58
+ jmethodID rjb_register_bridge;
59
+ static JNIEnv* main_jenv;
61
60
 
62
61
  /*
63
62
  * Object cache, never destroyed
@@ -74,11 +73,11 @@ static jmethodID field_getType;
74
73
  /* constructor */
75
74
  static jmethodID ctrGetParameterTypes;
76
75
  /* class */
77
- jclass j_class;
78
- jmethodID class_getName;
76
+ static jclass j_class;
77
+ jmethodID rjb_class_getName;
79
78
  /* throwable */
80
- jclass j_throwable;
81
- jmethodID throwable_getMessage;
79
+ jclass rjb_j_throwable;
80
+ jmethodID rjb_throwable_getMessage;
82
81
  /* String global reference */
83
82
  static jclass j_string;
84
83
  static jmethodID str_tostring;
@@ -112,15 +111,15 @@ typedef struct jobject_ruby_table {
112
111
  J2R func;
113
112
  } jprimitive_table;
114
113
 
115
- JNIEnv* attach_current_thread(void)
114
+ JNIEnv* rjb_attach_current_thread(void)
116
115
  {
117
116
  JNIEnv* env;
118
- (*jvm)->AttachCurrentThread(jvm, (void**)&env, '\0');
117
+ (*rjb_jvm)->AttachCurrentThread(rjb_jvm, (void**)&env, '\0');
119
118
  return env;
120
119
  }
121
120
 
122
121
 
123
- void release_string(JNIEnv *jenv, jstring str, const char* chrs)
122
+ void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs)
124
123
  {
125
124
  (*jenv)->ReleaseStringUTFChars(jenv, str, chrs);
126
125
  (*jenv)->DeleteLocalRef(jenv, str);
@@ -184,7 +183,7 @@ static VALUE jstring2val(JNIEnv* jenv, jstring s)
184
183
  p = (*jenv)->GetStringUTFChars(jenv, s, NULL);
185
184
  v = rb_str_new2(p);
186
185
  v = exticonv_utf8_to_local(v);
187
- release_string(jenv, s, p);
186
+ rjb_release_string(jenv, s, p);
188
187
  return v;
189
188
  }
190
189
 
@@ -211,12 +210,12 @@ static VALUE jv2rclass(JNIEnv* jenv, jclass jc)
211
210
  const char* cname;
212
211
  VALUE clsname;
213
212
  VALUE v;
214
- jstring nm = (*jenv)->CallObjectMethod(jenv, jc, class_getName);
215
- check_exception(jenv, 0);
213
+ jstring nm = (*jenv)->CallObjectMethod(jenv, jc, rjb_class_getName);
214
+ rjb_check_exception(jenv, 0);
216
215
  cname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
217
216
  clsname = rb_str_new2(cname);
218
- release_string(jenv, nm, cname);
219
- v = rb_hash_aref(loaded_classes, clsname);
217
+ rjb_release_string(jenv, nm, cname);
218
+ v = rb_hash_aref(rjb_loaded_classes, clsname);
220
219
  if (v == Qnil)
221
220
  {
222
221
  v = import_class(jenv, jc, clsname);
@@ -241,17 +240,17 @@ static VALUE jv2rv(JNIEnv* jenv, jvalue val)
241
240
  (*jenv)->DeleteLocalRef(jenv, klass);
242
241
  return jv2rclass(jenv, val.l);
243
242
  }
244
- nm = (*jenv)->CallObjectMethod(jenv, klass, class_getName);
245
- check_exception(jenv, 0);
243
+ nm = (*jenv)->CallObjectMethod(jenv, klass, rjb_class_getName);
244
+ rjb_check_exception(jenv, 0);
246
245
  cname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
247
246
  if (*cname == '[')
248
247
  {
249
- release_string(jenv, nm, cname);
248
+ rjb_release_string(jenv, nm, cname);
250
249
  return jarray2rv(jenv, val);
251
250
  }
252
251
  clsname = rb_str_new2(cname);
253
- release_string(jenv, nm, cname);
254
- v = rb_hash_aref(loaded_classes, clsname);
252
+ rjb_release_string(jenv, nm, cname);
253
+ v = rb_hash_aref(rjb_loaded_classes, clsname);
255
254
  if (v == Qnil)
256
255
  {
257
256
  v = import_class(jenv, klass, clsname);
@@ -639,9 +638,9 @@ static void rv2jstring(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
639
638
  jmethodID tostr;
640
639
  jstring js;
641
640
  tostr = (*jenv)->GetMethodID(jenv, ptr->klass, "toString", "()Ljava/lang/String;");
642
- check_exception(jenv, 0);
641
+ rjb_check_exception(jenv, 0);
643
642
  js = (*jenv)->CallObjectMethod(jenv, ptr->obj, tostr);
644
- check_exception(jenv, 0);
643
+ rjb_check_exception(jenv, 0);
645
644
  jv->l = js;
646
645
  }
647
646
  }
@@ -961,7 +960,7 @@ static jarray r2objarray(JNIEnv* jenv, VALUE v, const char* cls)
961
960
  {
962
961
  int i;
963
962
  ary = (*jenv)->NewObjectArray(jenv, RARRAY(v)->len, j_object, NULL);
964
- check_exception(jenv, 0);
963
+ rjb_check_exception(jenv, 0);
965
964
  for (i = 0; i < RARRAY(v)->len; i++)
966
965
  {
967
966
  jvalue jv;
@@ -1043,7 +1042,7 @@ static void rv2jarray(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
1043
1042
  rb_raise(rb_eRuntimeError, "array's rank unmatch");
1044
1043
  }
1045
1044
  ja = (*jenv)->NewObjectArray(jenv, RARRAY(val)->len, j_object, NULL);
1046
- check_exception(jenv, 0);
1045
+ rjb_check_exception(jenv, 0);
1047
1046
  for (i = 0; i < RARRAY(val)->len; i++)
1048
1047
  {
1049
1048
  jvalue jv;
@@ -1075,8 +1074,8 @@ static R2J get_r2j(JNIEnv* jenv, jobject o, int* siglen, char* sigp)
1075
1074
  int len, i;
1076
1075
  const char* cname;
1077
1076
  R2J result = NULL;
1078
- jstring nm = (*jenv)->CallObjectMethod(jenv, o, class_getName);
1079
- check_exception(jenv, 0);
1077
+ jstring nm = (*jenv)->CallObjectMethod(jenv, o, rjb_class_getName);
1078
+ rjb_check_exception(jenv, 0);
1080
1079
  cname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
1081
1080
  if (*cname == '[')
1082
1081
  {
@@ -1112,7 +1111,7 @@ static R2J get_r2j(JNIEnv* jenv, jobject o, int* siglen, char* sigp)
1112
1111
  result = rv2jobject;
1113
1112
  }
1114
1113
  }
1115
- release_string(jenv, nm, cname);
1114
+ rjb_release_string(jenv, nm, cname);
1116
1115
  return result;
1117
1116
  }
1118
1117
 
@@ -1122,8 +1121,8 @@ static J2R get_j2r(JNIEnv* jenv, jobject cls, char* psig, char* pdepth, char* pp
1122
1121
  J2R result = NULL;
1123
1122
  const char* cname;
1124
1123
  const char* jname = NULL;
1125
- jstring nm = (*jenv)->CallObjectMethod(jenv, cls, class_getName);
1126
- check_exception(jenv, 0);
1124
+ jstring nm = (*jenv)->CallObjectMethod(jenv, cls, rjb_class_getName);
1125
+ rjb_check_exception(jenv, 0);
1127
1126
  cname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
1128
1127
 
1129
1128
  if (*cname == '[')
@@ -1179,7 +1178,7 @@ static J2R get_j2r(JNIEnv* jenv, jobject cls, char* psig, char* pdepth, char* pp
1179
1178
  }
1180
1179
  java2jniname(ppsig);
1181
1180
  }
1182
- release_string(jenv, nm, cname);
1181
+ rjb_release_string(jenv, nm, cname);
1183
1182
  return result;
1184
1183
  }
1185
1184
 
@@ -1256,20 +1255,20 @@ static void create_methodinfo(JNIEnv* jenv, st_table* tbl, jobject m, int static
1256
1255
 
1257
1256
  result = ALLOC(struct cls_method);
1258
1257
  parama = (*jenv)->CallObjectMethod(jenv, m, getParameterTypes);
1259
- check_exception(jenv, 0);
1258
+ rjb_check_exception(jenv, 0);
1260
1259
  param_count = (*jenv)->GetArrayLength(jenv, parama);
1261
- check_exception(jenv, 0);
1260
+ rjb_check_exception(jenv, 0);
1262
1261
  setup_methodbase(jenv, &result->basic, parama, param_count);
1263
1262
 
1264
1263
  nm = (*jenv)->CallObjectMethod(jenv, m, method_getName);
1265
- check_exception(jenv, 0);
1264
+ rjb_check_exception(jenv, 0);
1266
1265
  jname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
1267
1266
  result->name = rb_intern(jname);
1268
- release_string(jenv, nm, jname);
1267
+ rjb_release_string(jenv, nm, jname);
1269
1268
  result->basic.id = (*jenv)->FromReflectedMethod(jenv, m);
1270
- check_exception(jenv, 0);
1269
+ rjb_check_exception(jenv, 0);
1271
1270
  cls = (*jenv)->CallObjectMethod(jenv, m, getReturnType);
1272
- check_exception(jenv, 0);
1271
+ rjb_check_exception(jenv, 0);
1273
1272
  setup_j2r(jenv, cls, result, static_method);
1274
1273
  (*jenv)->DeleteLocalRef(jenv, cls);
1275
1274
  result->static_method = static_method;
@@ -1298,14 +1297,14 @@ static void create_fieldinfo(JNIEnv* jenv, st_table* tbl, jobject f, int readonl
1298
1297
  result = ALLOC(struct cls_field);
1299
1298
  memset(result, 0, sizeof(struct cls_field));
1300
1299
  nm = (*jenv)->CallObjectMethod(jenv, f, field_getName);
1301
- check_exception(jenv, 0);
1300
+ rjb_check_exception(jenv, 0);
1302
1301
  jname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
1303
1302
  result->name = rb_intern(jname);
1304
- release_string(jenv, nm, jname);
1303
+ rjb_release_string(jenv, nm, jname);
1305
1304
  result->id = (*jenv)->FromReflectedField(jenv, f);
1306
- check_exception(jenv, 0);
1305
+ rjb_check_exception(jenv, 0);
1307
1306
  cls = (*jenv)->CallObjectMethod(jenv, f, field_getType);
1308
- check_exception(jenv, 0);
1307
+ rjb_check_exception(jenv, 0);
1309
1308
  result->value_convert = get_j2r(jenv, cls, &result->result_signature, &result->result_arraydepth, sigs, &iv, 0);
1310
1309
  result->arg_convert = get_r2j(jenv, cls, NULL, NULL);
1311
1310
  (*jenv)->DeleteLocalRef(jenv, cls);
@@ -1329,13 +1328,13 @@ static void setup_constructors(JNIEnv* jenv, struct cls_constructor*** pptr, job
1329
1328
  jobjectArray parama;
1330
1329
  jsize pcount;
1331
1330
  jobject c = (*jenv)->GetObjectArrayElement(jenv, methods, i);
1332
- check_exception(jenv, 0);
1331
+ rjb_check_exception(jenv, 0);
1333
1332
  pc = ALLOC(struct cls_constructor);
1334
1333
  tbl[i] = pc;
1335
1334
  parama = (*jenv)->CallObjectMethod(jenv, c, ctrGetParameterTypes);
1336
- check_exception(jenv, 0);
1335
+ rjb_check_exception(jenv, 0);
1337
1336
  pcount = (*jenv)->GetArrayLength(jenv, parama);
1338
- check_exception(jenv, 0);
1337
+ rjb_check_exception(jenv, 0);
1339
1338
  setup_methodbase(jenv, pc, parama, pcount);
1340
1339
  pc->id = (*jenv)->FromReflectedMethod(jenv, c);
1341
1340
  (*jenv)->DeleteLocalRef(jenv, c);
@@ -1354,7 +1353,7 @@ static void setup_methods(JNIEnv* jenv, st_table** tbl, st_table** static_tbl,
1354
1353
  for (i = 0; i < mcount; i++)
1355
1354
  {
1356
1355
  jobject m = (*jenv)->GetObjectArrayElement(jenv, methods, i);
1357
- check_exception(jenv, 0);
1356
+ rjb_check_exception(jenv, 0);
1358
1357
  modifier = (*jenv)->CallIntMethod(jenv, m, method_getModifiers);
1359
1358
  if (!(modifier & ACC_STATIC))
1360
1359
  {
@@ -1377,7 +1376,7 @@ static void setup_fields(JNIEnv* jenv, st_table** tbl, jobjectArray flds)
1377
1376
  for (i = 0; i < fcount; i++)
1378
1377
  {
1379
1378
  jobject f = (*jenv)->GetObjectArrayElement(jenv, flds, i);
1380
- check_exception(jenv, 0);
1379
+ rjb_check_exception(jenv, 0);
1381
1380
  modifier = (*jenv)->CallIntMethod(jenv, f, field_getModifiers);
1382
1381
  create_fieldinfo(jenv, *tbl, f, modifier & ACC_FINAL, modifier & ACC_STATIC);
1383
1382
  (*jenv)->DeleteLocalRef(jenv, f);
@@ -1392,9 +1391,9 @@ static void load_constants(JNIEnv* jenv, jclass klass, VALUE self, jobjectArray
1392
1391
  for (i = 0; i < fcount; i++)
1393
1392
  {
1394
1393
  jobject f = (*jenv)->GetObjectArrayElement(jenv, flds, i);
1395
- check_exception(jenv, 0);
1394
+ rjb_check_exception(jenv, 0);
1396
1395
  modifier = (*jenv)->CallIntMethod(jenv, f, field_getModifiers);
1397
- check_exception(jenv, 0);
1396
+ rjb_check_exception(jenv, 0);
1398
1397
  if ((modifier & (ACC_PUBLIC | ACC_STATIC | ACC_FINAL)) == (ACC_PUBLIC | ACC_STATIC | ACC_FINAL))
1399
1398
  {
1400
1399
  jstring nm;
@@ -1410,18 +1409,18 @@ static void load_constants(JNIEnv* jenv, jclass klass, VALUE self, jobjectArray
1410
1409
 
1411
1410
  // constants make define directly in the ruby object
1412
1411
  cls = (*jenv)->CallObjectMethod(jenv, f, field_getType);
1413
- check_exception(jenv, 0);
1412
+ rjb_check_exception(jenv, 0);
1414
1413
  iv = 0;
1415
1414
  sig = depth = 0;
1416
1415
  j2r = get_j2r(jenv, cls, &sig, &depth, sigs, &iv, 1);
1417
1416
  if (!j2r) j2r = jv2rv;
1418
1417
  (*jenv)->DeleteLocalRef(jenv, cls);
1419
1418
  nm = (*jenv)->CallObjectMethod(jenv, f, field_getName);
1420
- check_exception(jenv, 0);
1419
+ rjb_check_exception(jenv, 0);
1421
1420
  cname = (*jenv)->GetStringUTFChars(jenv, nm, NULL);
1422
- check_exception(jenv, 0);
1421
+ rjb_check_exception(jenv, 0);
1423
1422
  jfid = (*jenv)->GetStaticFieldID(jenv, klass, cname, sigs);
1424
- check_exception(jenv, 0);
1423
+ rjb_check_exception(jenv, 0);
1425
1424
  switch (sig)
1426
1425
  {
1427
1426
  case 'D':
@@ -1467,7 +1466,7 @@ static void load_constants(JNIEnv* jenv, jclass klass, VALUE self, jobjectArray
1467
1466
  rb_define_const(RBASIC(self)->klass, cname, j2r(jenv, jv));
1468
1467
  }
1469
1468
 
1470
- release_string(jenv, nm, cname);
1469
+ rjb_release_string(jenv, nm, cname);
1471
1470
  }
1472
1471
  (*jenv)->DeleteLocalRef(jenv, f);
1473
1472
  }
@@ -1481,21 +1480,21 @@ static void setup_metadata(JNIEnv* jenv, VALUE self, struct jv_data* ptr, VALUE
1481
1480
 
1482
1481
  jclass klass = (*jenv)->GetObjectClass(jenv, ptr->idata.obj);
1483
1482
  ptr->idata.klass = (*jenv)->NewGlobalRef(jenv, klass);
1484
- check_exception(jenv, 0);
1483
+ rjb_check_exception(jenv, 0);
1485
1484
  mid = (*jenv)->GetMethodID(jenv, klass, "getMethods", "()[Ljava/lang/reflect/Method;");
1486
- check_exception(jenv, 0);
1485
+ rjb_check_exception(jenv, 0);
1487
1486
  methods = (*jenv)->CallNonvirtualObjectMethod(jenv, ptr->idata.obj, klass, mid);
1488
- check_exception(jenv, 0);
1487
+ rjb_check_exception(jenv, 0);
1489
1488
  setup_methods(jenv, &ptr->idata.methods, &ptr->static_methods, methods);
1490
1489
  mid = (*jenv)->GetMethodID(jenv, klass, "getConstructors", "()[Ljava/lang/reflect/Constructor;");
1491
- check_exception(jenv, 0);
1490
+ rjb_check_exception(jenv, 0);
1492
1491
  methods = (*jenv)->CallNonvirtualObjectMethod(jenv, ptr->idata.obj, klass, mid);
1493
- check_exception(jenv, 0);
1492
+ rjb_check_exception(jenv, 0);
1494
1493
  setup_constructors(jenv, &ptr->constructors, methods);
1495
1494
  mid = (*jenv)->GetMethodID(jenv, klass, "getFields", "()[Ljava/lang/reflect/Field;");
1496
- check_exception(jenv, 0);
1495
+ rjb_check_exception(jenv, 0);
1497
1496
  flds = (*jenv)->CallNonvirtualObjectMethod(jenv, ptr->idata.obj, klass, mid);
1498
- check_exception(jenv, 0);
1497
+ rjb_check_exception(jenv, 0);
1499
1498
  setup_fields(jenv, &ptr->idata.fields, flds);
1500
1499
 
1501
1500
  register_class(self, classname);
@@ -1525,7 +1524,7 @@ static VALUE rjb_s_load(int argc, VALUE* argv, VALUE self)
1525
1524
  jclass jfield;
1526
1525
  jclass jconstructor;
1527
1526
 
1528
- if (jvm)
1527
+ if (rjb_jvm)
1529
1528
  {
1530
1529
  return Qnil;
1531
1530
  }
@@ -1547,56 +1546,56 @@ static VALUE rjb_s_load(int argc, VALUE* argv, VALUE self)
1547
1546
  Check_Type(vm_argv, T_ARRAY);
1548
1547
  }
1549
1548
  jenv = NULL;
1550
- res = create_jvm(&jenv, &vm_args, userpath, vm_argv);
1549
+ res = rjb_create_jvm(&jenv, &vm_args, userpath, vm_argv);
1551
1550
  if (res < 0)
1552
1551
  {
1553
- jvm = NULL;
1552
+ rjb_jvm = NULL;
1554
1553
  rb_raise(rb_eRuntimeError, "can't create Java VM");
1555
1554
  } else {
1556
1555
  main_jenv = jenv;
1557
1556
  }
1558
1557
 
1559
1558
  jconstructor = (*jenv)->FindClass(jenv, "java/lang/reflect/Constructor");
1560
- check_exception(jenv, 1);
1559
+ rjb_check_exception(jenv, 1);
1561
1560
  ctrGetParameterTypes = (*jenv)->GetMethodID(jenv, jconstructor, "getParameterTypes", "()[Ljava/lang/Class;");
1562
- check_exception(jenv, 1);
1561
+ rjb_check_exception(jenv, 1);
1563
1562
  jmethod = (*jenv)->FindClass(jenv, "java/lang/reflect/Method");
1564
1563
  method_getModifiers = (*jenv)->GetMethodID(jenv, jmethod, "getModifiers", "()I");
1565
- check_exception(jenv, 1);
1564
+ rjb_check_exception(jenv, 1);
1566
1565
  method_getName = (*jenv)->GetMethodID(jenv, jmethod, "getName", "()Ljava/lang/String;");
1567
- check_exception(jenv, 1);
1566
+ rjb_check_exception(jenv, 1);
1568
1567
  getParameterTypes = (*jenv)->GetMethodID(jenv, jmethod, "getParameterTypes", "()[Ljava/lang/Class;");
1569
- check_exception(jenv, 1);
1568
+ rjb_check_exception(jenv, 1);
1570
1569
  getReturnType = (*jenv)->GetMethodID(jenv, jmethod, "getReturnType", "()Ljava/lang/Class;");
1571
- check_exception(jenv, 1);
1570
+ rjb_check_exception(jenv, 1);
1572
1571
 
1573
1572
  jfield = (*jenv)->FindClass(jenv, "java/lang/reflect/Field");
1574
1573
  field_getModifiers = (*jenv)->GetMethodID(jenv, jfield, "getModifiers", "()I");
1575
- check_exception(jenv, 1);
1574
+ rjb_check_exception(jenv, 1);
1576
1575
  field_getName = (*jenv)->GetMethodID(jenv, jfield, "getName", "()Ljava/lang/String;");
1577
- check_exception(jenv, 1);
1576
+ rjb_check_exception(jenv, 1);
1578
1577
  field_getType = (*jenv)->GetMethodID(jenv, jfield, "getType", "()Ljava/lang/Class;");
1579
- check_exception(jenv, 1);
1578
+ rjb_check_exception(jenv, 1);
1580
1579
 
1581
1580
  j_class = (*jenv)->FindClass(jenv, "java/lang/Class");
1582
- check_exception(jenv, 1);
1583
- class_getName = (*jenv)->GetMethodID(jenv, j_class, "getName", "()Ljava/lang/String;");
1584
- check_exception(jenv, 1);
1581
+ rjb_check_exception(jenv, 1);
1582
+ rjb_class_getName = (*jenv)->GetMethodID(jenv, j_class, "getName", "()Ljava/lang/String;");
1583
+ rjb_check_exception(jenv, 1);
1585
1584
  j_class = (*jenv)->NewGlobalRef(jenv, j_class);
1586
1585
 
1587
- j_throwable = (*jenv)->FindClass(jenv, "java/lang/Throwable");
1588
- check_exception(jenv, 1);
1589
- throwable_getMessage = (*jenv)->GetMethodID(jenv, j_throwable, "getMessage", "()Ljava/lang/String;");
1590
- check_exception(jenv, 1);
1586
+ rjb_j_throwable = (*jenv)->FindClass(jenv, "java/lang/Throwable");
1587
+ rjb_check_exception(jenv, 1);
1588
+ rjb_throwable_getMessage = (*jenv)->GetMethodID(jenv, rjb_j_throwable, "getMessage", "()Ljava/lang/String;");
1589
+ rjb_check_exception(jenv, 1);
1591
1590
 
1592
1591
  j_string = (*jenv)->FindClass(jenv, "java/lang/String");
1593
- check_exception(jenv, 1);
1592
+ rjb_check_exception(jenv, 1);
1594
1593
  str_tostring = (*jenv)->GetMethodID(jenv, j_string, "toString", "()Ljava/lang/String;");
1595
- check_exception(jenv, 1);
1594
+ rjb_check_exception(jenv, 1);
1596
1595
  j_string = (*jenv)->NewGlobalRef(jenv, j_string);
1597
1596
 
1598
1597
  j_object = (*jenv)->FindClass(jenv, "java/lang/Object");
1599
- check_exception(jenv, 1);
1598
+ rjb_check_exception(jenv, 1);
1600
1599
  j_object = (*jenv)->NewGlobalRef(jenv, j_object);
1601
1600
 
1602
1601
  for (i = PRM_INT; i < PRM_LAST; i++)
@@ -1606,17 +1605,17 @@ static VALUE rjb_s_load(int argc, VALUE* argv, VALUE self)
1606
1605
  {
1607
1606
  jpcvt[i].ctr_id = (*jenv)->GetStaticMethodID(jenv,
1608
1607
  klass, "valueOf", jpcvt[i].ctrsig);
1609
- check_exception(jenv, 1);
1608
+ rjb_check_exception(jenv, 1);
1610
1609
  }
1611
1610
  else if (jpcvt[i].ctrsig)
1612
1611
  {
1613
1612
  jpcvt[i].ctr_id = (*jenv)->GetMethodID(jenv, klass,
1614
1613
  "<init>", jpcvt[i].ctrsig);
1615
- check_exception(jenv, 1);
1614
+ rjb_check_exception(jenv, 1);
1616
1615
  }
1617
1616
  jpcvt[i].to_prim_id = (*jenv)->GetMethodID(jenv, klass,
1618
1617
  jpcvt[i].to_prim_method, jpcvt[i].prmsig);
1619
- check_exception(jenv, 1);
1618
+ rjb_check_exception(jenv, 1);
1620
1619
  jpcvt[i].klass = (*jenv)->NewGlobalRef(jenv, klass);
1621
1620
  }
1622
1621
 
@@ -1641,11 +1640,11 @@ static int clear_classes(VALUE key, VALUE val, VALUE dummy)
1641
1640
  }
1642
1641
  static VALUE rjb_s_unload(int argc, VALUE* argv, VALUE self)
1643
1642
  {
1644
- st_foreach(RHASH(loaded_classes)->tbl, clear_classes, 0);
1645
- if (jvm)
1643
+ st_foreach(RHASH(rjb_loaded_classes)->tbl, clear_classes, 0);
1644
+ if (rjb_jvm)
1646
1645
  {
1647
- (*jvm)->DestroyJavaVM(jvm);
1648
- jvm = NULL;
1646
+ (*rjb_jvm)->DestroyJavaVM(rjb_jvm);
1647
+ rjb_jvm = NULL;
1649
1648
  }
1650
1649
  return Qnil;
1651
1650
  }
@@ -1657,7 +1656,7 @@ static VALUE rjb_s_unload(int argc, VALUE* argv, VALUE self)
1657
1656
  */
1658
1657
  static VALUE rjb_s_classes(VALUE self)
1659
1658
  {
1660
- return loaded_classes;
1659
+ return rjb_loaded_classes;
1661
1660
  }
1662
1661
 
1663
1662
  /*
@@ -1682,7 +1681,7 @@ static int free_method_item(ID key, struct cls_method* pm, int dummy)
1682
1681
  */
1683
1682
  static VALUE rjb_delete_ref(struct jvi_data* ptr)
1684
1683
  {
1685
- JNIEnv* jenv = attach_current_thread();
1684
+ JNIEnv* jenv = rjb_attach_current_thread();
1686
1685
  if (jenv)
1687
1686
  {
1688
1687
  (*jenv)->DeleteGlobalRef(jenv, ptr->obj);
@@ -1695,7 +1694,7 @@ static VALUE rjb_delete_ref(struct jvi_data* ptr)
1695
1694
  */
1696
1695
  static VALUE rj_bridge_free(struct rj_bridge* ptr)
1697
1696
  {
1698
- JNIEnv* jenv = attach_current_thread();
1697
+ JNIEnv* jenv = rjb_attach_current_thread();
1699
1698
  (*jenv)->DeleteLocalRef(jenv, ptr->proxy);
1700
1699
  (*jenv)->DeleteLocalRef(jenv, ptr->bridge);
1701
1700
  return Qnil;
@@ -1715,7 +1714,7 @@ static void rj_bridge_mark(struct rj_bridge* ptr)
1715
1714
  static VALUE rjb_s_free(struct jv_data* ptr)
1716
1715
  {
1717
1716
  /* class never delete
1718
- JNIEnv* jenv = attach_current_thread();
1717
+ JNIEnv* jenv = rjb_attach_current_thread();
1719
1718
  struct cls_constructor** c;
1720
1719
 
1721
1720
  rjb_delete_ref(&ptr->idata);
@@ -1733,7 +1732,7 @@ static VALUE rjb_s_free(struct jv_data* ptr)
1733
1732
  st_free_table(ptr->idata.methods);
1734
1733
  }
1735
1734
  (*jenv)->DeleteGlobalRef(jenv, ptr->idata.klass);
1736
- st_delete(RHASH(loaded_classes)->tbl, clsname, NULL);
1735
+ st_delete(RHASH(rjb_loaded_classes)->tbl, clsname, NULL);
1737
1736
  */
1738
1737
  return Qnil;
1739
1738
  }
@@ -1759,7 +1758,7 @@ static VALUE createinstance(JNIEnv* jenv, int argc, VALUE* argv,
1759
1758
  obj = (*jenv)->NewObjectA(jenv, org->obj, pc->id, args);
1760
1759
  if (!obj)
1761
1760
  {
1762
- check_exception(jenv, 1);
1761
+ rjb_check_exception(jenv, 1);
1763
1762
  }
1764
1763
  psig = pc->method_signature;
1765
1764
  for (i = 0; i < argc; i++)
@@ -1885,7 +1884,7 @@ static VALUE rjb_newinstance_s(int argc, VALUE* argv, VALUE self)
1885
1884
  char* sig;
1886
1885
  VALUE ret = Qnil;
1887
1886
  struct jv_data* ptr;
1888
- JNIEnv* jenv = attach_current_thread();
1887
+ JNIEnv* jenv = rjb_attach_current_thread();
1889
1888
 
1890
1889
  rb_scan_args(argc, argv, "1*", &vsig, &rest);
1891
1890
  sig = StringValueCStr(vsig);
@@ -1911,7 +1910,7 @@ static VALUE rjb_newinstance(int argc, VALUE* argv, VALUE self)
1911
1910
  VALUE ret = Qnil;
1912
1911
  struct jv_data* ptr;
1913
1912
  struct cls_constructor** pc;
1914
- JNIEnv* jenv = attach_current_thread();
1913
+ JNIEnv* jenv = rjb_attach_current_thread();
1915
1914
 
1916
1915
  Data_Get_Struct(self, struct jv_data, ptr);
1917
1916
 
@@ -1948,7 +1947,7 @@ static VALUE rjb_newinstance(int argc, VALUE* argv, VALUE self)
1948
1947
  /*
1949
1948
  * find java class from classname
1950
1949
  */
1951
- jclass find_class(JNIEnv* jenv, VALUE name)
1950
+ jclass rjb_find_class(JNIEnv* jenv, VALUE name)
1952
1951
  {
1953
1952
  char* cname;
1954
1953
  char* jnicls;
@@ -1965,24 +1964,24 @@ jclass find_class(JNIEnv* jenv, VALUE name)
1965
1964
  static VALUE rjb_s_bind(VALUE self, VALUE rbobj, VALUE itfname)
1966
1965
  {
1967
1966
  VALUE result = Qnil;
1968
- JNIEnv* jenv = attach_current_thread();
1967
+ JNIEnv* jenv = rjb_attach_current_thread();
1969
1968
 
1970
- jclass itf = find_class(jenv, itfname);
1971
- check_exception(jenv, 1);
1969
+ jclass itf = rjb_find_class(jenv, itfname);
1970
+ rjb_check_exception(jenv, 1);
1972
1971
  if (itf)
1973
1972
  {
1974
1973
  struct rj_bridge* ptr = ALLOC(struct rj_bridge);
1975
1974
  memset(ptr, 0, sizeof(struct rj_bridge));
1976
1975
  ptr->bridge = (*jenv)->NewGlobalRef(jenv,
1977
- (*jenv)->AllocObject(jenv, rbridge));
1976
+ (*jenv)->AllocObject(jenv, rjb_rbridge));
1978
1977
  if (!ptr->bridge)
1979
1978
  {
1980
1979
  free(ptr);
1981
- check_exception(jenv, 1);
1980
+ rjb_check_exception(jenv, 1);
1982
1981
  return Qnil;
1983
1982
  }
1984
1983
  ptr->proxy = (*jenv)->CallObjectMethod(jenv, ptr->bridge,
1985
- register_bridge, itf);
1984
+ rjb_register_bridge, itf);
1986
1985
  ptr->proxy = (*jenv)->NewGlobalRef(jenv, ptr->proxy);
1987
1986
  ptr->wrapped = rbobj;
1988
1987
  result = Data_Wrap_Struct(rjbb, rj_bridge_mark, rj_bridge_free, ptr);
@@ -1998,22 +1997,22 @@ static VALUE rjb_s_import(VALUE self, VALUE clsname)
1998
1997
  {
1999
1998
  JNIEnv* jenv;
2000
1999
  jclass jcls;
2001
- VALUE v = rb_hash_aref(loaded_classes, clsname);
2000
+ VALUE v = rb_hash_aref(rjb_loaded_classes, clsname);
2002
2001
  if (v != Qnil)
2003
2002
  {
2004
2003
  return v;
2005
2004
  }
2006
2005
 
2007
- if (!jvm)
2006
+ if (!rjb_jvm)
2008
2007
  {
2009
2008
  /* auto-load with default setting */
2010
2009
  rjb_s_load(0, NULL, 0);
2011
2010
  }
2012
- jenv = attach_current_thread();
2013
- jcls = find_class(jenv, clsname);
2011
+ jenv = rjb_attach_current_thread();
2012
+ jcls = rjb_find_class(jenv, clsname);
2014
2013
  if (!jcls)
2015
2014
  {
2016
- check_exception(jenv, 0);
2015
+ rjb_check_exception(jenv, 0);
2017
2016
  rb_raise(rb_eRuntimeError, "`%s' not found", StringValueCStr(clsname));
2018
2017
  }
2019
2018
  v = import_class(jenv, jcls, clsname);
@@ -2027,7 +2026,7 @@ static void register_class(VALUE self, VALUE clsname)
2027
2026
  /*
2028
2027
  * the hash was frozen, so it need to call st_ func directly.
2029
2028
  */
2030
- st_insert(RHASH(loaded_classes)->tbl, clsname, self);
2029
+ st_insert(RHASH(rjb_loaded_classes)->tbl, clsname, self);
2031
2030
  }
2032
2031
 
2033
2032
  /*
@@ -2035,12 +2034,12 @@ static void register_class(VALUE self, VALUE clsname)
2035
2034
  */
2036
2035
  static VALUE rjb_i_class(VALUE self)
2037
2036
  {
2038
- JNIEnv* jenv = attach_current_thread();
2037
+ JNIEnv* jenv = rjb_attach_current_thread();
2039
2038
  struct jvi_data* ptr;
2040
2039
  jstring nm;
2041
2040
  Data_Get_Struct(self, struct jvi_data, ptr);
2042
- nm = (*jenv)->CallObjectMethod(jenv, ptr->klass, class_getName);
2043
- check_exception(jenv, 0);
2041
+ nm = (*jenv)->CallObjectMethod(jenv, ptr->klass, rjb_class_getName);
2042
+ rjb_check_exception(jenv, 0);
2044
2043
  return jstring2val(jenv, nm);
2045
2044
  }
2046
2045
 
@@ -2354,7 +2353,7 @@ static VALUE invoke(JNIEnv* jenv, struct cls_method* pm, struct jvi_data* ptr,
2354
2353
  }
2355
2354
  break;
2356
2355
  }
2357
- check_exception(jenv, 1);
2356
+ rjb_check_exception(jenv, 1);
2358
2357
  psig = pm->basic.method_signature;
2359
2358
  for (i = 0; i < argc; i++)
2360
2359
  {
@@ -2379,7 +2378,7 @@ static VALUE invoke_by_instance(ID rmid, int argc, VALUE* argv,
2379
2378
  struct jvi_data* ptr, char* sig)
2380
2379
  {
2381
2380
  VALUE ret = Qnil;
2382
- JNIEnv* jenv = attach_current_thread();
2381
+ JNIEnv* jenv = rjb_attach_current_thread();
2383
2382
  struct cls_field* pf;
2384
2383
  struct cls_method* pm;
2385
2384
  char* tname = rb_id2name(rmid);
@@ -2448,7 +2447,7 @@ static VALUE invoke_by_class(ID rmid, int argc, VALUE* argv,
2448
2447
  struct cls_field* pf;
2449
2448
  struct cls_method* pm;
2450
2449
  char* tname = rb_id2name(rmid);
2451
- JNIEnv* jenv = attach_current_thread();
2450
+ JNIEnv* jenv = rjb_attach_current_thread();
2452
2451
 
2453
2452
  Data_Get_Struct(jklass, struct jv_data, clsptr);
2454
2453
  if (argc == 0 && st_lookup(ptr->idata.fields, rmid, (st_data_t*)&pf))
@@ -2567,9 +2566,9 @@ void Init_rjbcore()
2567
2566
  {
2568
2567
  rb_protect((VALUE(*)(VALUE))rb_require, (VALUE)"iconv", NULL);
2569
2568
 
2570
- loaded_classes = rb_hash_new();
2571
- OBJ_FREEZE(loaded_classes);
2572
- rb_global_variable(&loaded_classes);
2569
+ rjb_loaded_classes = rb_hash_new();
2570
+ OBJ_FREEZE(rjb_loaded_classes);
2571
+ rb_global_variable(&rjb_loaded_classes);
2573
2572
  proxies = rb_ary_new();
2574
2573
  rb_global_variable(&proxies);
2575
2574
 
data/ext/rjb.h CHANGED
@@ -12,7 +12,7 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * $Id: rjb.h 4 2006-09-11 15:21:38Z arton $
15
+ * $Id: rjb.h 8 2006-11-20 19:17:22Z arton $
16
16
  * $Log: rjb.h,v $
17
17
  * Revision 1.1 2005/01/16 17:36:10 arton
18
18
  * Initial revision
@@ -34,18 +34,24 @@
34
34
  #define _I64_MAX 9223372036854775807i64
35
35
  #endif
36
36
 
37
+ /* in load.c */
38
+ extern int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs*, char*, VALUE);
39
+
37
40
  /* in rjb.c */
38
- extern VALUE loaded_classes;
39
- extern jmethodID class_getName;
40
- extern jclass j_throwable;
41
- extern jmethodID throwable_getMessage;
42
- extern JNIEnv* attach_current_thread(void);
43
- extern jclass find_class(JNIEnv* jenv, VALUE name);
44
- extern void release_string(JNIEnv *jenv, jstring str, const char* chrs);
41
+ extern JavaVM* rjb_jvm;
42
+ extern jclass rjb_rbridge;
43
+ extern jmethodID rjb_register_bridge;
44
+ extern VALUE rjb_loaded_classes;
45
+ extern jmethodID rjb_class_getName;
46
+ extern jclass rjb_j_throwable;
47
+ extern jmethodID rjb_throwable_getMessage;
48
+ extern JNIEnv* rjb_attach_current_thread(void);
49
+ extern jclass rjb_find_class(JNIEnv* jenv, VALUE name);
50
+ extern void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs);
45
51
 
46
52
  /* in rjbexception.c */
47
- extern VALUE get_exception_class(JNIEnv* jenv, jstring str);
48
- extern void check_exception(JNIEnv* jenv, int t);
53
+ extern VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str);
54
+ extern void rjb_check_exception(JNIEnv* jenv, int t);
49
55
  extern VALUE rjb_s_throw(int, VALUE*, VALUE);
50
56
 
51
57
  /* conversion functions */
data/ext/rjbexception.c CHANGED
@@ -12,7 +12,7 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * $Id: rjbexception.c 4 2006-09-11 15:21:38Z arton $
15
+ * $Id: rjbexception.c 8 2006-11-20 19:17:22Z arton $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
@@ -26,7 +26,7 @@
26
26
  * At this time, the Java exception is defined without the package name.
27
27
  * This design may change in future release.
28
28
  */
29
- VALUE get_exception_class(JNIEnv* jenv, jstring str)
29
+ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
30
30
  {
31
31
  VALUE rexp;
32
32
  char* pcls;
@@ -34,7 +34,7 @@ VALUE get_exception_class(JNIEnv* jenv, jstring str)
34
34
  const char* p = (*jenv)->GetStringUTFChars(jenv, str, JNI_FALSE);
35
35
  char* clsname = ALLOCA_N(char, strlen(p) + 1);
36
36
  strcpy(clsname, p);
37
- release_string(jenv, str, p);
37
+ rjb_release_string(jenv, str, p);
38
38
  pcls = strrchr(clsname, '.');
39
39
  if (pcls)
40
40
  {
@@ -45,11 +45,11 @@ VALUE get_exception_class(JNIEnv* jenv, jstring str)
45
45
  pcls = clsname;
46
46
  }
47
47
  cname = rb_str_new2(pcls);
48
- rexp = rb_hash_aref(loaded_classes, cname);
48
+ rexp = rb_hash_aref(rjb_loaded_classes, cname);
49
49
  if (rexp == Qnil)
50
50
  {
51
51
  rexp = rb_define_class(pcls, rb_eStandardError);
52
- st_insert(RHASH(loaded_classes)->tbl, cname, rexp);
52
+ st_insert(RHASH(rjb_loaded_classes)->tbl, cname, rexp);
53
53
  }
54
54
  return rexp;
55
55
  }
@@ -61,10 +61,10 @@ VALUE rjb_s_throw(int argc, VALUE* argv, VALUE self)
61
61
  {
62
62
  VALUE klass;
63
63
  VALUE message;
64
- JNIEnv* jenv = attach_current_thread();
64
+ JNIEnv* jenv = rjb_attach_current_thread();
65
65
  if (rb_scan_args(argc, argv, "11", &klass, &message) == 2)
66
66
  {
67
- jclass excep = find_class(jenv, klass);
67
+ jclass excep = rjb_find_class(jenv, klass);
68
68
  if (excep == NULL)
69
69
  {
70
70
  rb_raise(rb_eRuntimeError, "`%s' not found", StringValueCStr(klass));
@@ -75,7 +75,7 @@ VALUE rjb_s_throw(int argc, VALUE* argv, VALUE self)
75
75
  {
76
76
  struct jvi_data* ptr;
77
77
  Data_Get_Struct(klass, struct jvi_data, ptr);
78
- if (!(*jenv)->IsInstanceOf(jenv, ptr->obj, j_throwable))
78
+ if (!(*jenv)->IsInstanceOf(jenv, ptr->obj, rjb_j_throwable))
79
79
  {
80
80
  rb_raise(rb_eRuntimeError, "arg1 must be a throwable");
81
81
  }
@@ -87,7 +87,7 @@ VALUE rjb_s_throw(int argc, VALUE* argv, VALUE self)
87
87
  return Qnil;
88
88
  }
89
89
 
90
- void check_exception(JNIEnv* jenv, int t)
90
+ void rjb_check_exception(JNIEnv* jenv, int t)
91
91
  {
92
92
  jthrowable exp = (*jenv)->ExceptionOccurred(jenv);
93
93
  if (exp)
@@ -103,18 +103,18 @@ void check_exception(JNIEnv* jenv, int t)
103
103
  {
104
104
  char* msg = "unknown exception";
105
105
  jclass cls = (*jenv)->GetObjectClass(jenv, exp);
106
- jstring str = (*jenv)->CallObjectMethod(jenv, exp, throwable_getMessage);
106
+ jstring str = (*jenv)->CallObjectMethod(jenv, exp, rjb_throwable_getMessage);
107
107
  if (str)
108
108
  {
109
109
  const char* p = (*jenv)->GetStringUTFChars(jenv, str, JNI_FALSE);
110
110
  msg = ALLOCA_N(char, strlen(p) + 1);
111
111
  strcpy(msg, p);
112
- release_string(jenv, str, p);
112
+ rjb_release_string(jenv, str, p);
113
113
  }
114
- str = (*jenv)->CallObjectMethod(jenv, cls, class_getName);
114
+ str = (*jenv)->CallObjectMethod(jenv, cls, rjb_class_getName);
115
115
  if (str)
116
116
  {
117
- rexp = get_exception_class(jenv, str);
117
+ rexp = rjb_get_exception_class(jenv, str);
118
118
  }
119
119
  if (rexp == Qnil)
120
120
  {
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rjb
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2006-10-08 00:00:00 +09:00
6
+ version: 1.0.3
7
+ date: 2006-11-21 00:00:00 +09:00
8
8
  summary: Ruby Java bridge
9
9
  require_paths:
10
10
  - lib
@@ -31,13 +31,13 @@ authors:
31
31
  files:
32
32
  - ext/RBridge.java
33
33
  - ext/riconv.c
34
- - ext/rjbexception.c
35
34
  - ext/rjb.c
35
+ - ext/rjbexception.c
36
36
  - ext/load.c
37
37
  - ext/jniwrap.h
38
- - ext/rjb.h
39
38
  - ext/riconv.h
40
39
  - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
40
+ - ext/rjb.h
41
41
  - ext/depend
42
42
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
43
43
  - lib/rjb.rb