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 +18 -0
- data/data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class +0 -0
- data/ext/depend +4 -4
- data/ext/extconf.h +2 -0
- data/ext/extconf.rb +2 -1
- data/ext/jp_co_infoseek_hp_arton_rjb_RBridge.h +21 -21
- data/ext/load.c +60 -24
- data/ext/riconv.c +36 -1
- data/ext/riconv.h +4 -3
- data/ext/rjb.c +62 -53
- data/ext/rjb.h +8 -1
- data/ext/rjbexception.c +7 -2
- data/test/test.rb +68 -44
- metadata +5 -5
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
|
Binary file
|
data/ext/depend
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
riconv.o : riconv.c
|
2
|
-
rjb.o : rjb.c
|
3
|
-
rjbexception.o : rjbexception.c
|
4
|
-
load.o : load.c
|
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
|
data/ext/extconf.h
CHANGED
data/ext/extconf.rb
CHANGED
@@ -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
|
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
|
64
|
-
typedef int (*CREATEJAVAVM)(JavaVM**,
|
70
|
+
typedef int (*GETDEFAULTJAVAVMINITARGS)(void*);
|
71
|
+
typedef int (*CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
|
72
|
+
|
65
73
|
|
66
74
|
static VALUE jvmdll = Qnil;
|
67
|
-
static VALUE
|
68
|
-
static VALUE
|
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
|
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
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
219
|
+
if (!RTEST(jvmdll))
|
194
220
|
{
|
195
|
-
if (load_jvm(JVM_TYPE)
|
221
|
+
if (!load_jvm(JVM_TYPE))
|
196
222
|
{
|
197
223
|
return -1;
|
198
224
|
}
|
199
225
|
}
|
200
226
|
|
201
|
-
|
202
|
-
|
203
|
-
|
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
|
-
|
243
|
-
|
244
|
-
|
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);
|
data/ext/riconv.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: riconv.c
|
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
|
}
|
data/ext/riconv.h
CHANGED
@@ -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
|
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
|
-
|
21
|
-
|
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
|
15
|
+
* $Id: rjb.c 50 2007-12-28 07:31:33Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.0
|
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
|
281
|
+
if (RTEST(primitive_conversion))
|
277
282
|
{
|
278
|
-
return
|
283
|
+
return jv2rv_withprim(jenv, val.l);
|
279
284
|
}
|
280
|
-
return
|
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 =
|
430
|
-
|
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
|
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
|
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 =
|
807
|
-
VALUE* p =
|
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,
|
824
|
-
(*jenv)->SetByteArrayRegion(jenv, ary, 0,
|
825
|
-
|
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,
|
840
|
+
ary = (*jenv)->NewByteArray(jenv, RARRAY_LEN(v));
|
833
841
|
pb = (*jenv)->GetByteArrayElements(jenv, ary, NULL);
|
834
|
-
for (i = 0; i <
|
842
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
835
843
|
{
|
836
|
-
*(pb + i) = (jbyte)FIX2ULONG(
|
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,
|
863
|
+
ary = (*jenv)->NewCharArray(jenv, RARRAY_LEN(v));
|
856
864
|
pb = (*jenv)->GetCharArrayElements(jenv, ary, NULL);
|
857
|
-
for (i = 0; i <
|
865
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
858
866
|
{
|
859
|
-
*(pb + i) = (jchar)FIX2ULONG(
|
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,
|
882
|
+
ary = (*jenv)->NewDoubleArray(jenv, RARRAY_LEN(v));
|
875
883
|
pb = (*jenv)->GetDoubleArrayElements(jenv, ary, NULL);
|
876
|
-
for (i = 0; i <
|
884
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
877
885
|
{
|
878
|
-
*(pb + i) = (jdouble)rb_num2dbl(
|
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,
|
901
|
+
ary = (*jenv)->NewFloatArray(jenv, RARRAY_LEN(v));
|
894
902
|
pb = (*jenv)->GetFloatArrayElements(jenv, ary, NULL);
|
895
|
-
for (i = 0; i <
|
903
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
896
904
|
{
|
897
|
-
*(pb + i) = (jfloat)rb_num2dbl(
|
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,
|
921
|
+
ary = (*jenv)->NewIntArray(jenv, RARRAY_LEN(v));
|
914
922
|
pb = (*jenv)->GetIntArrayElements(jenv, ary, NULL);
|
915
|
-
for (i = 0; i <
|
923
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
916
924
|
{
|
917
|
-
*(pb + i) = (jint)FIX2LONG(
|
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,
|
940
|
+
ary = (*jenv)->NewLongArray(jenv, RARRAY_LEN(v));
|
933
941
|
pb = (*jenv)->GetLongArrayElements(jenv, ary, NULL);
|
934
|
-
for (i = 0; i <
|
942
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
935
943
|
{
|
936
944
|
#if HAVE_LONG_LONG
|
937
|
-
*(pb + i) = (jlong)rb_num2ll(
|
945
|
+
*(pb + i) = (jlong)rb_num2ll(RARRAY_PTR(v)[i]);
|
938
946
|
#else
|
939
|
-
*(pb + i) = (jlong)FIX2LONG(
|
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,
|
964
|
+
ary = (*jenv)->NewShortArray(jenv, RARRAY_LEN(v));
|
957
965
|
pb = (*jenv)->GetShortArrayElements(jenv, ary, NULL);
|
958
|
-
for (i = 0; i <
|
966
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
959
967
|
{
|
960
|
-
*(pb + i) = (jshort)FIX2LONG(
|
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,
|
983
|
+
ary = (*jenv)->NewBooleanArray(jenv, RARRAY_LEN(v));
|
976
984
|
pb = (*jenv)->GetBooleanArrayElements(jenv, ary, NULL);
|
977
|
-
for (i = 0; i <
|
985
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
978
986
|
{
|
979
987
|
*(pb + i)
|
980
|
-
= (
|
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,
|
1008
|
+
ary = (*jenv)->NewObjectArray(jenv, RARRAY_LEN(v), j_object, NULL);
|
1001
1009
|
rjb_check_exception(jenv, 0);
|
1002
|
-
for (i = 0; i <
|
1010
|
+
for (i = 0; i < RARRAY_LEN(v); i++)
|
1003
1011
|
{
|
1004
1012
|
jvalue jv;
|
1005
|
-
rv2jobject(jenv,
|
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,
|
1090
|
+
ja = (*jenv)->NewObjectArray(jenv, RARRAY_LEN(val), j_object, NULL);
|
1083
1091
|
rjb_check_exception(jenv, 0);
|
1084
|
-
for (i = 0; i <
|
1092
|
+
for (i = 0; i < RARRAY_LEN(val); i++)
|
1085
1093
|
{
|
1086
1094
|
jvalue jv;
|
1087
|
-
rv2jarray(jenv,
|
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
|
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(
|
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
|
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
|
1977
|
+
return strchr("BCDFIJS", *p) != NULL;
|
1969
1978
|
case T_FLOAT:
|
1970
|
-
return
|
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(
|
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 <
|
2766
|
+
for (i = 0; i < RARRAY_LEN(proxies); i++)
|
2758
2767
|
{
|
2759
2768
|
struct rj_bridge* ptr;
|
2760
|
-
VALUE val =
|
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
|
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
|
|
data/ext/rjbexception.c
CHANGED
@@ -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
|
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(
|
57
|
+
st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);
|
53
58
|
}
|
54
59
|
return rexp;
|
55
60
|
}
|
data/test/test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/local/env ruby
|
2
|
-
# $Id: test.rb
|
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(
|
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',
|
88
|
-
assert_equal(
|
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', [
|
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([
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
155
|
-
|
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,
|
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(
|
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(
|
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
|
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(
|
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
|
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
|
7
|
-
date: 2007-
|
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
|