rjb 1.0.11 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,21 @@
1
+ Tue Dec 27 Kuwashima
2
+ *test/Test.java
3
+ *test/test.rb
4
+ *ext/depend
5
+ *ext/load.c
6
+ *ext/extconf.rb
7
+ *ext/rjbexception.c
8
+ *ext/rjb.c
9
+ *ext/riconv.c
10
+ change for compatibility with Ruby-1.9.0
11
+ Tue Nov 20 arton
12
+ *rjb.c
13
+ mark version 1.10.12 for next relase.
14
+ *load.c
15
+ omit useless double-quotations from JAVA_HOME, maybe specifies a longpathname (but useless).
16
+ Wed Nov 14 Kuwashima
17
+ *rjb.c
18
+ add error check to constructor.
1
19
  Fri Nov 9 arton
2
20
  *test.rb
3
21
  *Test.java
data/ext/depend CHANGED
@@ -1,7 +1,7 @@
1
- riconv.o : riconv.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h jp_co_infoseek_hp_arton_rjb_RBridge.h
2
- rjb.o : rjb.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
3
- rjbexception.o : rjbexception.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
4
- load.o : load.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h jp_co_infoseek_hp_arton_rjb_RBridge.h
1
+ riconv.o : riconv.c jp_co_infoseek_hp_arton_rjb_RBridge.h
2
+ rjb.o : rjb.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
3
+ rjbexception.o : rjbexception.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
4
+ load.o : load.c jp_co_infoseek_hp_arton_rjb_RBridge.h
5
5
  jp_co_infoseek_hp_arton_rjb_RBridge.h : jniwrap.h ../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
6
6
  javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge
7
7
  ../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class : RBridge.java
@@ -1,7 +1,9 @@
1
1
  #ifndef EXTCONF_H
2
2
  #define EXTCONF_H
3
3
  #define HAVE_JNI_H 1
4
+ #define HAVE_DL_H 1
4
5
  #define HAVE_NL_LANGINFO 1
5
6
  #define HAVE_SETLOCALE 1
6
7
  #define HAVE_GETENV 1
8
+ #define RJB_RUBY_VERSION_CODE 186
7
9
  #endif
@@ -42,11 +42,12 @@ if !javahome.nil?
42
42
  end
43
43
 
44
44
  def create_rjb_makefile
45
- if have_header("jni.h")
45
+ if have_header("jni.h") && have_header("dl.h") || have_header("ruby/dl.h")
46
46
  have_func("locale_charset", "iconv.h")
47
47
  have_func("nl_langinfo", "langinfo.h")
48
48
  have_func("setlocale", "locale.h")
49
49
  have_func("getenv")
50
+ $defs << "-DRJB_RUBY_VERSION_CODE="+RUBY_VERSION.gsub(/\./, '')
50
51
  create_header
51
52
  create_makefile("rjbcore")
52
53
  end
@@ -1,21 +1,21 @@
1
- /* DO NOT EDIT THIS FILE - it is machine generated */
2
- #include <jni.h>
3
- /* Header for class jp_co_infoseek_hp_arton_rjb_RBridge */
4
-
5
- #ifndef _Included_jp_co_infoseek_hp_arton_rjb_RBridge
6
- #define _Included_jp_co_infoseek_hp_arton_rjb_RBridge
7
- #ifdef __cplusplus
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
16
- (JNIEnv *, jobject, jstring, jobject, jobjectArray);
17
-
18
- #ifdef __cplusplus
19
- }
20
- #endif
21
- #endif
1
+ /* DO NOT EDIT THIS FILE - it is machine generated */
2
+ #include <jni.h>
3
+ /* Header for class jp_co_infoseek_hp_arton_rjb_RBridge */
4
+
5
+ #ifndef _Included_jp_co_infoseek_hp_arton_rjb_RBridge
6
+ #define _Included_jp_co_infoseek_hp_arton_rjb_RBridge
7
+ #ifdef __cplusplus
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
16
+ (JNIEnv *, jobject, jstring, jobject, jobjectArray);
17
+
18
+ #ifdef __cplusplus
19
+ }
20
+ #endif
21
+ #endif
data/ext/load.c CHANGED
@@ -12,15 +12,22 @@
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 9 2006-11-20 19:26:14Z arton $
15
+ * $Id: load.c 43 2007-12-26 18:55:04Z kuwa1 $
16
16
  */
17
17
 
18
18
  #include <stdlib.h>
19
19
  #include <stdio.h>
20
20
  #include "ruby.h"
21
+ #include "extconf.h"
22
+ #if RJB_RUBY_VERSION_CODE < 190
21
23
  #include "intern.h"
22
24
  #include "st.h"
23
25
  #include "util.h"
26
+ #else
27
+ #include "ruby/intern.h"
28
+ #include "ruby/st.h"
29
+ #include "ruby/util.h"
30
+ #endif
24
31
  #include "jniwrap.h"
25
32
  #include "jp_co_infoseek_hp_arton_rjb_RBridge.h"
26
33
  #include "rjb.h"
@@ -60,22 +67,24 @@
60
67
  #define CLASSPATH_SEP ':'
61
68
  #endif
62
69
 
63
- typedef void (*GETDEFAULTJAVAVMINITARGS)(void*);
64
- typedef int (*CREATEJAVAVM)(JavaVM**, void**, void*);
70
+ typedef int (*GETDEFAULTJAVAVMINITARGS)(void*);
71
+ typedef int (*CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
72
+
65
73
 
66
74
  static VALUE jvmdll = Qnil;
67
- static VALUE GetDefaultJavaVMInitArgs;
68
- static VALUE CreateJavaVM;
75
+ static VALUE getdefaultjavavminitargsfunc;
76
+ static VALUE createjavavmfunc;
69
77
 
70
78
  /*
71
79
  * not completed, only valid under some circumstances.
72
80
  */
73
- static VALUE load_jvm(char* jvmtype)
81
+ static int load_jvm(char* jvmtype)
74
82
  {
75
83
  char* libpath;
76
84
  char* java_home;
77
85
  char* jh;
78
86
  VALUE dl;
87
+ VALUE importer;
79
88
 
80
89
  #if defined(__APPLE__) && defined(__MACH__)
81
90
  jh = "/System/Library/Frameworks/JavaVM.framework";
@@ -84,8 +93,17 @@ static VALUE load_jvm(char* jvmtype)
84
93
  #endif
85
94
  if (!jh)
86
95
  {
87
- return Qnil;
96
+ return 0;
97
+ }
98
+ #if defined(_WIN32)
99
+ if (*jh == '"' && *(jh + strlen(jh) - 1) == '"')
100
+ {
101
+ char* p = ALLOCA_N(char, strlen(jh) + 1);
102
+ strcpy(p, jh + 1);
103
+ *(p + strlen(p) - 1) = '\0';
104
+ jh = p;
88
105
  }
106
+ #endif
89
107
  java_home = ALLOCA_N(char, strlen(jh) + 1);
90
108
  strcpy(java_home, jh);
91
109
  if (*(java_home + strlen(jh) - 1) == DIRSEPARATOR)
@@ -104,16 +122,24 @@ static VALUE load_jvm(char* jvmtype)
104
122
  + strlen(ARCH) + strlen(jvmtype) + 1);
105
123
  sprintf(libpath, JVMDLL, java_home, ARCH, jvmtype);
106
124
  #endif
125
+
107
126
  rb_require("dl");
108
- dl = rb_eval_string("DL");
109
- jvmdll = rb_funcall(dl, rb_intern("dlopen"), 1, rb_str_new2(libpath));
110
- GetDefaultJavaVMInitArgs = rb_funcall(jvmdll, rb_intern("sym"),
111
- 2, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"),
112
- rb_str_new2("0p"));
113
- CreateJavaVM = rb_funcall(jvmdll, rb_intern("sym"),
114
- 2, rb_str_new2("JNI_CreateJavaVM"),
115
- rb_str_new2("pppp"));
116
- return Qtrue;
127
+ if (!rb_const_defined_at(rb_cObject, rb_intern("DL")))
128
+ {
129
+ rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
130
+ return 0;
131
+ }
132
+
133
+ jvmdll = rb_funcall(rb_const_get(rb_cObject, rb_intern("DL")), rb_intern("dlopen"), 1, rb_str_new2(libpath));
134
+
135
+ #if RJB_RUBY_VERSION_CODE < 190
136
+ getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
137
+ createjavavmfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2("JNI_CreateJavaVM"), rb_str_new2("IPPP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
138
+ #else
139
+ getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"));
140
+ createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_CreateJavaVM"));
141
+ #endif
142
+ return 1;
117
143
  }
118
144
 
119
145
  static int load_bridge(JNIEnv* jenv)
@@ -190,17 +216,24 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
190
216
  int i;
191
217
  VALUE optval;
192
218
 
193
- if (jvmdll == Qnil)
219
+ if (!RTEST(jvmdll))
194
220
  {
195
- if (load_jvm(JVM_TYPE) == Qnil)
221
+ if (!load_jvm(JVM_TYPE))
196
222
  {
197
223
  return -1;
198
224
  }
199
225
  }
200
226
 
201
- ptr = rb_funcall(GetDefaultJavaVMInitArgs, rb_intern("to_i"), 0);
202
- initargs = *(GETDEFAULTJAVAVMINITARGS*)FIX2INT(ptr);
203
- initargs(vm_args);
227
+ if (NIL_P(getdefaultjavavminitargsfunc))
228
+ {
229
+ return -1;
230
+ }
231
+ initargs = (GETDEFAULTJAVAVMINITARGS)NUM2ULONG(getdefaultjavavminitargsfunc);
232
+ result = initargs(vm_args);
233
+ if (0 > result)
234
+ {
235
+ return result;
236
+ }
204
237
  len = strlen(userpath);
205
238
  if (getenv("CLASSPATH"))
206
239
  {
@@ -239,9 +272,12 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
239
272
  vm_args->nOptions = optlen;
240
273
  vm_args->options = options;
241
274
  vm_args->ignoreUnrecognized = JNI_TRUE;
242
- ptr = rb_funcall(CreateJavaVM, rb_intern("to_i"), 0);
243
- createjavavm = *(CREATEJAVAVM*)FIX2INT(ptr);
244
- result = createjavavm(&rjb_jvm, (void**)pjenv, vm_args);
275
+ if (NIL_P(createjavavmfunc))
276
+ {
277
+ return -1;
278
+ }
279
+ createjavavm = (CREATEJAVAVM)NUM2ULONG(createjavavmfunc);
280
+ result = createjavavm(&rjb_jvm, pjenv, vm_args);
245
281
  if (!result)
246
282
  {
247
283
  result = load_bridge(*pjenv);
@@ -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: riconv.c 37 2007-11-08 17:25:36Z arton $
15
+ * $Id: riconv.c 45 2007-12-26 20:03:21Z kuwa1 $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
@@ -165,6 +165,7 @@ static void check_kcode()
165
165
 
166
166
  VALUE exticonv_local_to_utf8(VALUE local_string)
167
167
  {
168
+ #if RJB_RUBY_VERSION_CODE < 190
168
169
  check_kcode();
169
170
  if(RTEST(objIconvR2J))
170
171
  {
@@ -174,10 +175,28 @@ VALUE exticonv_local_to_utf8(VALUE local_string)
174
175
  {
175
176
  return local_string;
176
177
  }
178
+ #else
179
+ VALUE rb_cEncoding, default_external, encoding, ascii8bit;
180
+ rb_cEncoding = rb_const_get(rb_cObject, rb_intern("Encoding"));
181
+ default_external = rb_funcall(rb_cEncoding, rb_intern("default_external"), 0);
182
+ ascii8bit = rb_const_get(rb_cEncoding, rb_intern("ASCII_8BIT"));
183
+ encoding = rb_funcall(local_string, rb_intern("encoding"), 0);
184
+
185
+ if (ascii8bit == encoding && ascii8bit == default_external)
186
+ {
187
+ return local_string; //don't know default encoding
188
+ }
189
+ else if (encoding == ascii8bit)
190
+ {
191
+ local_string = rb_funcall(local_string, rb_intern("force_encoding"), 1, default_external);
192
+ }
193
+ return rb_funcall(local_string, rb_intern("encode"), 1, rb_str_new2("utf-8"));
194
+ #endif
177
195
  }
178
196
 
179
197
  VALUE exticonv_utf8_to_local(VALUE utf8_string)
180
198
  {
199
+ #if RJB_RUBY_VERSION_CODE < 190
181
200
  check_kcode();
182
201
  if(RTEST(objIconvR2J))
183
202
  {
@@ -187,4 +206,20 @@ VALUE exticonv_utf8_to_local(VALUE utf8_string)
187
206
  {
188
207
  return utf8_string;
189
208
  }
209
+ #else
210
+ VALUE rb_cEncoding, encoding, ascii8bit;
211
+ rb_cEncoding = rb_const_get(rb_cObject, rb_intern("Encoding"));
212
+ encoding = rb_funcall(rb_cEncoding, rb_intern("default_external"), 0);
213
+ ascii8bit = rb_const_get(rb_cEncoding, rb_intern("ASCII_8BIT"));
214
+
215
+ utf8_string = rb_funcall(utf8_string, rb_intern("force_encoding"), 1, rb_str_new2("utf-8"));
216
+ if (ascii8bit == encoding)
217
+ {
218
+ return utf8_string; //don't know default encoding
219
+ }
220
+ else
221
+ {
222
+ return rb_funcall(utf8_string, rb_intern("encode"), 1, encoding);
223
+ }
224
+ #endif
190
225
  }
@@ -12,12 +12,13 @@
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: riconv.h 29 2007-10-22 08:29:05Z kuwa1 $
15
+ * $Id: riconv.h 43 2007-12-26 18:55:04Z kuwa1 $
16
16
  */
17
17
  #ifndef _RICONV_H
18
18
  #define _RICONV_H
19
19
 
20
- extern VALUE exticonv_local_to_utf8(VALUE);
21
- extern VALUE exticonv_utf8_to_local(VALUE);
20
+
21
+ VALUE exticonv_local_to_utf8(VALUE);
22
+ VALUE exticonv_utf8_to_local(VALUE);
22
23
 
23
24
  #endif /* _RICONV_H */
data/ext/rjb.c CHANGED
@@ -12,13 +12,18 @@
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 39 2007-11-08 17:33:57Z arton $
15
+ * $Id: rjb.c 50 2007-12-28 07:31:33Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.0.11"
18
+ #define RJB_VERSION "1.1.0"
19
19
 
20
20
  #include "ruby.h"
21
+ #include "extconf.h"
22
+ #if RJB_RUBY_VERSION_CODE < 190
21
23
  #include "st.h"
24
+ #else
25
+ #include "ruby/st.h"
26
+ #endif
22
27
  #include "jniwrap.h"
23
28
  #include "jp_co_infoseek_hp_arton_rjb_RBridge.h"
24
29
  #include "riconv.h"
@@ -273,11 +278,11 @@ static VALUE jv2rv_r(JNIEnv* jenv, jvalue val)
273
278
 
274
279
  static VALUE jv2rv(JNIEnv* jenv, jvalue val)
275
280
  {
276
- if (primitive_conversion == Qfalse)
281
+ if (RTEST(primitive_conversion))
277
282
  {
278
- return jv2rv_r(jenv, val);
283
+ return jv2rv_withprim(jenv, val.l);
279
284
  }
280
- return jv2rv_withprim(jenv, val.l);
285
+ return jv2rv_r(jenv, val);
281
286
  }
282
287
 
283
288
  static VALUE jvoid2rv(JNIEnv* jenv, jvalue val)
@@ -426,8 +431,8 @@ static VALUE call_conv(JNIEnv* jenv, jvalue val, size_t sz, void* p, CONV conv,
426
431
  char* cp = (char*)p;
427
432
  jsize len = (*jenv)->GetArrayLength(jenv, val.l);
428
433
  VALUE v = rb_ary_new2(len);
429
- VALUE* pv = RARRAY(v)->ptr;
430
- RARRAY(v)->len = len;
434
+ VALUE* pv = RARRAY_PTR(v);
435
+ RARRAY_LEN(v) = len;
431
436
  for (i = 0; i < len; i++)
432
437
  {
433
438
  *pv++ =conv(jenv, cp);
@@ -526,8 +531,11 @@ static VALUE jv2rv_withprim(JNIEnv* jenv, jobject o)
526
531
  {
527
532
  jvalue jv;
528
533
  int i;
529
- jclass klass = (*jenv)->GetObjectClass(jenv, o);
534
+ jclass klass;
530
535
  jv.j = 0;
536
+ if (!o)
537
+ rb_raise(rb_eRuntimeError, "Object is NULL");
538
+ klass = (*jenv)->GetObjectClass(jenv, o);
531
539
  for (i = PRM_INT; i < PRM_LAST; i++)
532
540
  {
533
541
  if ((*jenv)->IsSameObject(jenv, jpcvt[i].klass, klass))
@@ -645,7 +653,7 @@ static void rv2jshort(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
645
653
  static void rv2jboolean(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int release)
646
654
  {
647
655
  if (!release)
648
- jv->z = (val == Qnil || val == Qfalse) ? JNI_FALSE : JNI_TRUE;
656
+ jv->z = (RTEST(val)) ? JNI_TRUE : JNI_FALSE;
649
657
  }
650
658
  static void rv2jstring(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int release)
651
659
  {
@@ -803,8 +811,8 @@ static void rv2jobject(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
803
811
  static void check_fixnumarray(VALUE v)
804
812
  {
805
813
  int i;
806
- int len = RARRAY(v)->len;
807
- VALUE* p = RARRAY(v)->ptr;
814
+ int len = RARRAY_LEN(v);
815
+ VALUE* p = RARRAY_PTR(v);
808
816
  // check all fixnum (overflow is permit)
809
817
  for (i = 0; i < len; i++)
810
818
  {
@@ -820,20 +828,20 @@ static jarray r2barray(JNIEnv* jenv, VALUE v, const char* cls)
820
828
  jarray ary = NULL;
821
829
  if (TYPE(v) == T_STRING)
822
830
  {
823
- ary = (*jenv)->NewByteArray(jenv, RSTRING(v)->len);
824
- (*jenv)->SetByteArrayRegion(jenv, ary, 0, RSTRING(v)->len,
825
- RSTRING(v)->ptr);
831
+ ary = (*jenv)->NewByteArray(jenv, RSTRING_LEN(v));
832
+ (*jenv)->SetByteArrayRegion(jenv, ary, 0, RSTRING_LEN(v),
833
+ RSTRING_PTR(v));
826
834
  }
827
835
  else if (TYPE(v) == T_ARRAY)
828
836
  {
829
837
  int i;
830
838
  jbyte* pb;
831
839
  check_fixnumarray(v);
832
- ary = (*jenv)->NewByteArray(jenv, RARRAY(v)->len);
840
+ ary = (*jenv)->NewByteArray(jenv, RARRAY_LEN(v));
833
841
  pb = (*jenv)->GetByteArrayElements(jenv, ary, NULL);
834
- for (i = 0; i < RARRAY(v)->len; i++)
842
+ for (i = 0; i < RARRAY_LEN(v); i++)
835
843
  {
836
- *(pb + i) = (jbyte)FIX2ULONG(RARRAY(v)->ptr[i]);
844
+ *(pb + i) = (jbyte)FIX2ULONG(RARRAY_PTR(v)[i]);
837
845
  }
838
846
  (*jenv)->ReleaseByteArrayElements(jenv, ary, pb, 0);
839
847
  }
@@ -852,11 +860,11 @@ static jarray r2carray(JNIEnv* jenv, VALUE v, const char* cls)
852
860
  int i;
853
861
  jchar* pb;
854
862
  check_fixnumarray(v);
855
- ary = (*jenv)->NewCharArray(jenv, RARRAY(v)->len);
863
+ ary = (*jenv)->NewCharArray(jenv, RARRAY_LEN(v));
856
864
  pb = (*jenv)->GetCharArrayElements(jenv, ary, NULL);
857
- for (i = 0; i < RARRAY(v)->len; i++)
865
+ for (i = 0; i < RARRAY_LEN(v); i++)
858
866
  {
859
- *(pb + i) = (jchar)FIX2ULONG(RARRAY(v)->ptr[i]);
867
+ *(pb + i) = (jchar)FIX2ULONG(RARRAY_PTR(v)[i]);
860
868
  }
861
869
  (*jenv)->ReleaseCharArrayElements(jenv, ary, pb, 0);
862
870
  return ary;
@@ -871,11 +879,11 @@ static jarray r2darray(JNIEnv* jenv, VALUE v, const char* cls)
871
879
  {
872
880
  int i;
873
881
  jdouble* pb;
874
- ary = (*jenv)->NewDoubleArray(jenv, RARRAY(v)->len);
882
+ ary = (*jenv)->NewDoubleArray(jenv, RARRAY_LEN(v));
875
883
  pb = (*jenv)->GetDoubleArrayElements(jenv, ary, NULL);
876
- for (i = 0; i < RARRAY(v)->len; i++)
884
+ for (i = 0; i < RARRAY_LEN(v); i++)
877
885
  {
878
- *(pb + i) = (jdouble)rb_num2dbl(RARRAY(v)->ptr[i]);
886
+ *(pb + i) = (jdouble)rb_num2dbl(RARRAY_PTR(v)[i]);
879
887
  }
880
888
  (*jenv)->ReleaseDoubleArrayElements(jenv, ary, pb, 0);
881
889
  return ary;
@@ -890,11 +898,11 @@ static jarray r2farray(JNIEnv* jenv, VALUE v, const char* cls)
890
898
  {
891
899
  int i;
892
900
  jfloat* pb;
893
- ary = (*jenv)->NewFloatArray(jenv, RARRAY(v)->len);
901
+ ary = (*jenv)->NewFloatArray(jenv, RARRAY_LEN(v));
894
902
  pb = (*jenv)->GetFloatArrayElements(jenv, ary, NULL);
895
- for (i = 0; i < RARRAY(v)->len; i++)
903
+ for (i = 0; i < RARRAY_LEN(v); i++)
896
904
  {
897
- *(pb + i) = (jfloat)rb_num2dbl(RARRAY(v)->ptr[i]);
905
+ *(pb + i) = (jfloat)rb_num2dbl(RARRAY_PTR(v)[i]);
898
906
  }
899
907
  (*jenv)->ReleaseFloatArrayElements(jenv, ary, pb, 0);
900
908
  return ary;
@@ -910,11 +918,11 @@ static jarray r2iarray(JNIEnv* jenv, VALUE v, const char* cls)
910
918
  int i;
911
919
  jint* pb;
912
920
  check_fixnumarray(v);
913
- ary = (*jenv)->NewIntArray(jenv, RARRAY(v)->len);
921
+ ary = (*jenv)->NewIntArray(jenv, RARRAY_LEN(v));
914
922
  pb = (*jenv)->GetIntArrayElements(jenv, ary, NULL);
915
- for (i = 0; i < RARRAY(v)->len; i++)
923
+ for (i = 0; i < RARRAY_LEN(v); i++)
916
924
  {
917
- *(pb + i) = (jint)FIX2LONG(RARRAY(v)->ptr[i]);
925
+ *(pb + i) = (jint)FIX2LONG(RARRAY_PTR(v)[i]);
918
926
  }
919
927
  (*jenv)->ReleaseIntArrayElements(jenv, ary, pb, 0);
920
928
  return ary;
@@ -929,14 +937,14 @@ static jarray r2larray(JNIEnv* jenv, VALUE v, const char* cls)
929
937
  {
930
938
  int i;
931
939
  jlong* pb;
932
- ary = (*jenv)->NewLongArray(jenv, RARRAY(v)->len);
940
+ ary = (*jenv)->NewLongArray(jenv, RARRAY_LEN(v));
933
941
  pb = (*jenv)->GetLongArrayElements(jenv, ary, NULL);
934
- for (i = 0; i < RARRAY(v)->len; i++)
942
+ for (i = 0; i < RARRAY_LEN(v); i++)
935
943
  {
936
944
  #if HAVE_LONG_LONG
937
- *(pb + i) = (jlong)rb_num2ll(RARRAY(v)->ptr[i]);
945
+ *(pb + i) = (jlong)rb_num2ll(RARRAY_PTR(v)[i]);
938
946
  #else
939
- *(pb + i) = (jlong)FIX2LONG(RARRAY(v)->ptr[i]);
947
+ *(pb + i) = (jlong)FIX2LONG(RARRAY_PTR(v)[i]);
940
948
  #endif
941
949
  }
942
950
  (*jenv)->ReleaseLongArrayElements(jenv, ary, pb, 0);
@@ -953,11 +961,11 @@ static jarray r2sarray(JNIEnv* jenv, VALUE v, const char* cls)
953
961
  int i;
954
962
  jshort* pb;
955
963
  check_fixnumarray(v);
956
- ary = (*jenv)->NewShortArray(jenv, RARRAY(v)->len);
964
+ ary = (*jenv)->NewShortArray(jenv, RARRAY_LEN(v));
957
965
  pb = (*jenv)->GetShortArrayElements(jenv, ary, NULL);
958
- for (i = 0; i < RARRAY(v)->len; i++)
966
+ for (i = 0; i < RARRAY_LEN(v); i++)
959
967
  {
960
- *(pb + i) = (jshort)FIX2LONG(RARRAY(v)->ptr[i]);
968
+ *(pb + i) = (jshort)FIX2LONG(RARRAY_PTR(v)[i]);
961
969
  }
962
970
  (*jenv)->ReleaseShortArrayElements(jenv, ary, pb, 0);
963
971
  return ary;
@@ -972,12 +980,12 @@ static jarray r2boolarray(JNIEnv* jenv, VALUE v, const char* cls)
972
980
  {
973
981
  int i;
974
982
  jboolean* pb;
975
- ary = (*jenv)->NewBooleanArray(jenv, RARRAY(v)->len);
983
+ ary = (*jenv)->NewBooleanArray(jenv, RARRAY_LEN(v));
976
984
  pb = (*jenv)->GetBooleanArrayElements(jenv, ary, NULL);
977
- for (i = 0; i < RARRAY(v)->len; i++)
985
+ for (i = 0; i < RARRAY_LEN(v); i++)
978
986
  {
979
987
  *(pb + i)
980
- = (NIL_P(RARRAY(v)->ptr[i]) || RARRAY(v)->ptr[i] == Qfalse)
988
+ = (!RTEST(RARRAY_PTR(v)[i]))
981
989
  ? JNI_FALSE : JNI_TRUE;
982
990
  }
983
991
  (*jenv)->ReleaseBooleanArrayElements(jenv, ary, pb, 0);
@@ -997,12 +1005,12 @@ static jarray r2objarray(JNIEnv* jenv, VALUE v, const char* cls)
997
1005
  if (TYPE(v) == T_ARRAY)
998
1006
  {
999
1007
  int i;
1000
- ary = (*jenv)->NewObjectArray(jenv, RARRAY(v)->len, j_object, NULL);
1008
+ ary = (*jenv)->NewObjectArray(jenv, RARRAY_LEN(v), j_object, NULL);
1001
1009
  rjb_check_exception(jenv, 0);
1002
- for (i = 0; i < RARRAY(v)->len; i++)
1010
+ for (i = 0; i < RARRAY_LEN(v); i++)
1003
1011
  {
1004
1012
  jvalue jv;
1005
- rv2jobject(jenv, RARRAY(v)->ptr[i], &jv, NULL, 0);
1013
+ rv2jobject(jenv, RARRAY_PTR(v)[i], &jv, NULL, 0);
1006
1014
  (*jenv)->SetObjectArrayElement(jenv, ary, i, jv.l);
1007
1015
  }
1008
1016
  return ary;
@@ -1079,12 +1087,12 @@ static void rv2jarray(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
1079
1087
  if (TYPE(val) != T_ARRAY) {
1080
1088
  rb_raise(rb_eRuntimeError, "array's rank unmatch");
1081
1089
  }
1082
- ja = (*jenv)->NewObjectArray(jenv, RARRAY(val)->len, j_object, NULL);
1090
+ ja = (*jenv)->NewObjectArray(jenv, RARRAY_LEN(val), j_object, NULL);
1083
1091
  rjb_check_exception(jenv, 0);
1084
- for (i = 0; i < RARRAY(val)->len; i++)
1092
+ for (i = 0; i < RARRAY_LEN(val); i++)
1085
1093
  {
1086
1094
  jvalue jv;
1087
- rv2jarray(jenv, RARRAY(val)->ptr[i], &jv, psig + 1, 0);
1095
+ rv2jarray(jenv, RARRAY_PTR(val)[i], &jv, psig + 1, 0);
1088
1096
  (*jenv)->SetObjectArrayElement(jenv, ja, i, jv.l);
1089
1097
  }
1090
1098
  }
@@ -1171,7 +1179,7 @@ static J2R get_arrayconv(const char* cname, char* pdepth)
1171
1179
  return jcvt[i].ja2r;
1172
1180
  }
1173
1181
  }
1174
- return &jarray2rv;
1182
+ return jarray2rv;
1175
1183
  }
1176
1184
 
1177
1185
  static J2R get_j2r(JNIEnv* jenv, jobject cls, char* psig, char* pdepth, char* ppsig, off_t* piv, int static_method)
@@ -1751,7 +1759,7 @@ static int clear_classes(VALUE key, VALUE val, VALUE dummy)
1751
1759
  }
1752
1760
  static VALUE rjb_s_unload(int argc, VALUE* argv, VALUE self)
1753
1761
  {
1754
- st_foreach(RHASH(rjb_loaded_classes)->tbl, clear_classes, 0);
1762
+ st_foreach(RHASH_TBL(rjb_loaded_classes), clear_classes, 0);
1755
1763
  if (rjb_jvm)
1756
1764
  {
1757
1765
  (*rjb_jvm)->DestroyJavaVM(rjb_jvm);
@@ -1775,7 +1783,7 @@ static VALUE rjb_s_classes(VALUE self)
1775
1783
  */
1776
1784
  static VALUE rjb_s_set_pconversion(VALUE self, VALUE val)
1777
1785
  {
1778
- primitive_conversion = (val == Qnil || val == Qfalse) ? Qfalse : Qtrue;
1786
+ primitive_conversion = (RTEST(val)) ? Qtrue : Qfalse;
1779
1787
  return val;
1780
1788
  }
1781
1789
 
@@ -1883,6 +1891,7 @@ static VALUE createinstance(JNIEnv* jenv, int argc, VALUE* argv,
1883
1891
  R2J pr2j = *(pc->arg_convert + i);
1884
1892
  pr2j(jenv, argv[i], args + i, psig, 0);
1885
1893
  psig = next_sig(psig);
1894
+ rjb_check_exception(jenv, 1);
1886
1895
  }
1887
1896
  obj = (*jenv)->NewObjectA(jenv, org->obj, pc->id, args);
1888
1897
  if (!obj)
@@ -1965,9 +1974,9 @@ static int check_rtype(JNIEnv* jenv, VALUE v, char* p)
1965
1974
  switch (TYPE(v))
1966
1975
  {
1967
1976
  case T_FIXNUM:
1968
- return (int)strchr("BCDFIJS", *p);
1977
+ return strchr("BCDFIJS", *p) != NULL;
1969
1978
  case T_FLOAT:
1970
- return (int)strchr("DF", *p);
1979
+ return strchr("DF", *p) != NULL;
1971
1980
  case T_STRING:
1972
1981
  return pcls && !strcmp("java.lang.String", pcls);
1973
1982
  case T_TRUE:
@@ -2164,7 +2173,7 @@ static void register_class(VALUE self, VALUE clsname)
2164
2173
  /*
2165
2174
  * the hash was frozen, so it need to call st_ func directly.
2166
2175
  */
2167
- st_insert(RHASH(rjb_loaded_classes)->tbl, clsname, self);
2176
+ st_insert(RHASH_TBL(rjb_loaded_classes), clsname, self);
2168
2177
  }
2169
2178
 
2170
2179
  /*
@@ -2754,10 +2763,10 @@ JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
2754
2763
  jvalue j;
2755
2764
  memset(&j, 0, sizeof(j));
2756
2765
 
2757
- for (i = 0; i < RARRAY(proxies)->len; i++)
2766
+ for (i = 0; i < RARRAY_LEN(proxies); i++)
2758
2767
  {
2759
2768
  struct rj_bridge* ptr;
2760
- VALUE val = RARRAY(proxies)->ptr[i];
2769
+ VALUE val = RARRAY_PTR(proxies)[i];
2761
2770
  Data_Get_Struct(val, struct rj_bridge, ptr);
2762
2771
  if ((*jenv)->IsSameObject(jenv, proxy, ptr->proxy))
2763
2772
  {
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 8 2006-11-20 19:17:22Z arton $
15
+ * $Id: rjb.h 47 2007-12-28 06:39:43Z arton $
16
16
  * $Log: rjb.h,v $
17
17
  * Revision 1.1 2005/01/16 17:36:10 arton
18
18
  * Initial revision
@@ -23,6 +23,12 @@
23
23
  #ifndef RJB_H
24
24
  #define RJB_H
25
25
 
26
+ #if RJB_RUBY_VERSION_CODE < 190
27
+ #if !defined(RHASH_TBL)
28
+ #define RHASH_TBL(x) RHASH((x))->tbl
29
+ #endif
30
+ #endif
31
+
26
32
  #if !defined(COUNTOF)
27
33
  #define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
28
34
  #endif
@@ -34,6 +40,7 @@
34
40
  #define _I64_MAX 9223372036854775807i64
35
41
  #endif
36
42
 
43
+
37
44
  /* in load.c */
38
45
  extern int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs*, char*, VALUE);
39
46
 
@@ -12,11 +12,16 @@
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 8 2006-11-20 19:17:22Z arton $
15
+ * $Id: rjbexception.c 47 2007-12-28 06:39:43Z arton $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
19
+ #include "extconf.h"
20
+ #if RJB_RUBY_VERSION_CODE < 190
19
21
  #include "st.h"
22
+ #else
23
+ #include "ruby/st.h"
24
+ #endif
20
25
  #include "jniwrap.h"
21
26
  #include "riconv.h"
22
27
  #include "rjb.h"
@@ -49,7 +54,7 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
49
54
  if (rexp == Qnil)
50
55
  {
51
56
  rexp = rb_define_class(pcls, rb_eStandardError);
52
- st_insert(RHASH(rjb_loaded_classes)->tbl, cname, rexp);
57
+ st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);
53
58
  }
54
59
  return rexp;
55
60
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/local/env ruby
2
- # $Id: test.rb 34 2007-11-08 16:52:07Z arton $
2
+ # $Id: test.rb 45 2007-12-26 20:03:21Z kuwa1 $
3
3
 
4
4
  require 'test/unit'
5
5
  require 'rjb'
@@ -47,7 +47,7 @@ class TestRjb < Test::Unit::TestCase
47
47
  assert_equal('abcde', str.toString)
48
48
  # argument test
49
49
  # char
50
- assert_equal('abxde', str.replace(?c, ?x))
50
+ assert_equal('abxde', str.replace("c".sum, "x".sum))
51
51
  # string
52
52
  assert_equal('abdxe', str.replaceAll('cd', 'dx'))
53
53
  # int
@@ -84,12 +84,12 @@ class TestRjb < Test::Unit::TestCase
84
84
  # short
85
85
  s = @jShort.new_with_sig('S', 1532)
86
86
  assert_equal(1532, s.shortValue)
87
- c = @jChar.new_with_sig('C', ?A)
88
- assert_equal(?A, c.charValue)
87
+ c = @jChar.new_with_sig('C', "A".sum)
88
+ assert_equal("A".sum, c.charValue)
89
89
  end
90
90
 
91
91
  def test_array
92
- str = @jString.new_with_sig('[C', [?a, ?b, ?c, ?d, ?e, ?c, ?f, ?c, ?g])
92
+ str = @jString.new_with_sig('[C', ["a".sum, "b".sum, "c".sum, "d".sum, "e".sum, "c".sum, "f".sum, "c".sum, "g".sum])
93
93
  assert_equal('abcdecfcg', str.toString)
94
94
  # conv string array
95
95
  splt = str.split('c')
@@ -102,7 +102,7 @@ class TestRjb < Test::Unit::TestCase
102
102
  assert_equal('abcdecfcg', ba)
103
103
  # conv char array to array(int)
104
104
  ca = str.toCharArray
105
- assert_equal([?a, ?b, ?c, ?d, ?e, ?c, ?f, ?c, ?g], ca)
105
+ assert_equal(["a".sum, "b".sum, "c".sum, "d".sum, "e".sum, "c".sum, "f".sum, "c".sum, "g".sum], ca)
106
106
  end
107
107
 
108
108
  def test_importobj()
@@ -134,40 +134,64 @@ class TestRjb < Test::Unit::TestCase
134
134
  end
135
135
 
136
136
  def test_kjconv()
137
- $KCODE = 'euc'
138
- euc_kj = "\xb4\xc1\xbb\xfa\xa5\xc6\xa5\xad\xa5\xb9\xa5\xc8"
139
- s = @jString.new(euc_kj)
140
- assert_equal(s.toString(), euc_kj)
141
- $KCODE = 'sjis'
142
- sjis_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
143
- s = @jString.new(sjis_kj)
144
- assert_equal(s.toString(), sjis_kj)
145
- $KCODE = 'utf8'
146
- utf8_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
147
- s = @jString.new(utf8_kj)
148
- assert_equal(s.toString(), utf8_kj)
149
- $KCODE = 'none'
150
- if /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
151
- #expecting shift_jis on windows
152
- none_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
137
+ if Object::const_defined?(:Encoding)
138
+ euc_kj = "\xb4\xc1\xbb\xfa\xa5\xc6\xa5\xad\xa5\xb9\xa5\xc8".force_encoding "euc-jp"
139
+ s = @jString.new(euc_kj)
140
+ assert_equal(s.toString().encoding, Encoding::UTF_8)
141
+ assert_equal(s.toString().encode("euc-jp"), euc_kj)
142
+ sjis_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67".force_encoding "shift_jis"
143
+ s = @jString.new(sjis_kj)
144
+ assert_equal(s.toString().encode("shift_jis"), sjis_kj)
145
+ utf8_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88".force_encoding "utf-8"
146
+ s = @jString.new(utf8_kj.encode("utf-8"))
147
+ assert_equal(s.toString(), utf8_kj)
148
+ if /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
149
+ #expecting shift_jis on windows
150
+ none_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67" #.force_encoding "shift_jis"
151
+ s = @jString.new(none_kj)
152
+ assert_equal(s.toString().encode("shift_jis"), none_kj)
153
+ else
154
+ #expecting utf-8 unless windows
155
+ none_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88".force_encoding "utf-8"
156
+ s = @jString.new(none_kj)
157
+ assert_equal(s.toString(), none_kj)
158
+ end
153
159
  else
154
- #expecting utf-8 unless windows
155
- none_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
160
+ $KCODE = 'euc'
161
+ euc_kj = "\xb4\xc1\xbb\xfa\xa5\xc6\xa5\xad\xa5\xb9\xa5\xc8"
162
+ s = @jString.new(euc_kj)
163
+ assert_equal(s.toString(), euc_kj)
164
+ $KCODE = 'sjis'
165
+ sjis_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
166
+ s = @jString.new(sjis_kj)
167
+ assert_equal(s.toString(), sjis_kj)
168
+ $KCODE = 'utf8'
169
+ utf8_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
170
+ s = @jString.new(utf8_kj)
171
+ assert_equal(s.toString(), utf8_kj)
172
+ $KCODE = 'none'
173
+ if /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
174
+ #expecting shift_jis on windows
175
+ none_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
176
+ else
177
+ #expecting utf-8 unless windows
178
+ none_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
179
+ end
180
+ s = @jString.new(none_kj)
181
+ assert_equal(s.toString(), none_kj)
182
+ $KCODE = 'utf8'
183
+ utf8_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
184
+ s = @jString.new(utf8_kj)
185
+ assert_equal(s.toString(), utf8_kj)
186
+ $KCODE = 'sjis'
187
+ sjis_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
188
+ s = @jString.new(sjis_kj)
189
+ assert_equal(s.toString(), sjis_kj)
190
+ $KCODE = 'euc'
191
+ euc_kj = "\xb4\xc1\xbb\xfa\xa5\xc6\xa5\xad\xa5\xb9\xa5\xc8"
192
+ s = @jString.new(euc_kj)
193
+ assert_equal(s.toString(), euc_kj)
156
194
  end
157
- s = @jString.new(none_kj)
158
- assert_equal(s.toString(), none_kj)
159
- $KCODE = 'utf8'
160
- utf8_kj = "\xE6\xBC\xA2\xE5\xAD\x97\xE3\x83\x86\xE3\x82\xAD\xE3\x82\xB9\xE3\x83\x88"
161
- s = @jString.new(utf8_kj)
162
- assert_equal(s.toString(), utf8_kj)
163
- $KCODE = 'sjis'
164
- sjis_kj = "\x8a\xbf\x8e\x9a\x83\x65\x83\x4c\x83\x58\x83\x67"
165
- s = @jString.new(sjis_kj)
166
- assert_equal(s.toString(), sjis_kj)
167
- $KCODE = 'euc'
168
- euc_kj = "\xb4\xc1\xbb\xfa\xa5\xc6\xa5\xad\xa5\xb9\xa5\xc8"
169
- s = @jString.new(euc_kj)
170
- assert_equal(s.toString(), euc_kj)
171
195
  end
172
196
 
173
197
  def test_constants()
@@ -451,7 +475,7 @@ class TestRjb < Test::Unit::TestCase
451
475
  stringbuffer = Rjb::import('java.lang.StringBuffer')
452
476
  sb = stringbuffer.new('abc')
453
477
  assert_equal(1, sb.index_of('bc'))
454
- sb.set_char_at(1, ?B)
478
+ sb.set_char_at(1, "B".sum)
455
479
  assert_equal('aBc', sb.to_string)
456
480
  sb.length = 2
457
481
  assert_equal('aB', sb.to_string)
@@ -472,7 +496,7 @@ class TestRjb < Test::Unit::TestCase
472
496
  assert_equal(-6, @jByte.valueOf('-6'))
473
497
  assert_equal(0x7000000000000000, @jLong.valueOf('8070450532247928832'))
474
498
  assert_equal(-9223372036854775807, @jLong.valueOf('-9223372036854775807'))
475
- assert_equal(?A, @jChar.valueOf(?A))
499
+ assert_equal("A".sum, @jChar.valueOf("A".sum))
476
500
  end
477
501
 
478
502
  def test_obj_to_primitive
@@ -486,7 +510,7 @@ class TestRjb < Test::Unit::TestCase
486
510
  a.add @jBoolean.TRUE
487
511
  a.add @jByte.valueOf('5')
488
512
  a.add @jLong.valueOf('8070450532247928832')
489
- a.add @jChar.valueOf(?A)
513
+ a.add @jChar.valueOf("A".sum)
490
514
 
491
515
  Rjb::primitive_conversion = true
492
516
 
@@ -498,7 +522,7 @@ class TestRjb < Test::Unit::TestCase
498
522
  assert a.get(5)
499
523
  assert_equal 5, a.get(6)
500
524
  assert_equal 8070450532247928832, a.get(7)
501
- assert_equal ?A, a.get(8)
525
+ assert_equal "A".sum, a.get(8)
502
526
  end
503
527
 
504
528
  def test_primitive_to_obj
@@ -514,7 +538,7 @@ class TestRjb < Test::Unit::TestCase
514
538
  a.add @jBoolean.TRUE
515
539
  a.add @jByte.valueOf('5')
516
540
  a.add @jLong.valueOf('8070450532247928832')
517
- a.add @jChar.valueOf(?A)
541
+ a.add @jChar.valueOf("A".sum)
518
542
  assert_equal 'abcdef', a.get(0)
519
543
  assert_equal 1, a.get(1)
520
544
  assert_equal 2, a.get(2)
@@ -523,7 +547,7 @@ class TestRjb < Test::Unit::TestCase
523
547
  assert a.get(5)
524
548
  assert_equal 5, a.get(6)
525
549
  assert_equal 8070450532247928832, a.get(7)
526
- assert_equal ?A, a.get(8)
550
+ assert_equal "A".sum, a.get(8)
527
551
  end
528
552
 
529
553
  def test_enum
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.11
7
- date: 2007-11-09 00:00:00 +09:00
6
+ version: 1.1.0
7
+ date: 2007-12-28 00:00:00 +09:00
8
8
  summary: Ruby Java bridge
9
9
  require_paths:
10
10
  - lib
@@ -31,8 +31,8 @@ authors:
31
31
  files:
32
32
  - ext/RBridge.java
33
33
  - ext/load.c
34
- - ext/riconv.c
35
34
  - ext/rjbexception.c
35
+ - ext/riconv.c
36
36
  - ext/rjb.c
37
37
  - ext/jniwrap.h
38
38
  - ext/rjb.h
@@ -43,13 +43,13 @@ files:
43
43
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
44
44
  - lib/rjb.rb
45
45
  - samples/filechooser.rb
46
- - test/test.rb
47
46
  - test/gctest.rb
47
+ - test/test.rb
48
48
  - test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
49
49
  - test/jp/co/infoseek/hp/arton/rjb/Test.class
50
50
  - test/jp/co/infoseek/hp/arton/rjb/IBase.class
51
- - test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
52
51
  - test/jp/co/infoseek/hp/arton/rjb/Base.class
52
+ - test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
53
53
  - COPYING
54
54
  - ChangeLog
55
55
  - readme.sj