rjb 1.3.4-x86-mswin32-60 → 1.3.5-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +19 -0
- data/ext/load.c +6 -2
- data/ext/rjb.c +83 -28
- data/lib/rjbcore.so +0 -0
- data/samples/unzip.rb +66 -0
- data/test/Base.class +0 -0
- data/test/ExtBase.class +0 -0
- data/test/IBase.class +0 -0
- data/test/JTest.class +0 -0
- data/test/JarTest.class +0 -0
- data/test/Test$TestTypes.class +0 -0
- data/test/Test.class +0 -0
- data/test/Two.class +0 -0
- data/test/TwoCaller.class +0 -0
- data/test/jartest.jar +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/IBase.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/JTest.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/Test.class +0 -0
- data/test/rjbtest.jar +0 -0
- data/test/test.rb +34 -2
- metadata +17 -6
data/ChangeLog
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
Mon Jul 18 arton
|
2
|
+
*ext/rjb.c
|
3
|
+
fix inhiritance test.
|
4
|
+
add anonymous inner class feature (as JRuby)
|
5
|
+
*test/test.rb
|
6
|
+
add anonymous inner class test
|
7
|
+
*test/Two.java
|
8
|
+
for anonymous inner class test
|
9
|
+
*test/TwoCaller.java
|
10
|
+
for anonymous inner class test
|
11
|
+
Sat Jul 16 arton
|
12
|
+
*ext/laod.c
|
13
|
+
load server JVM if _WIN64
|
14
|
+
*ext/rjb.c
|
15
|
+
RJB_VERSION -> 1.3.5
|
16
|
+
*test/test.rb
|
17
|
+
add primitive_conversion and generic test.
|
18
|
+
*test/Test.java
|
19
|
+
add method that takes generic map and returns it
|
1
20
|
Mon Nov 22 arton
|
2
21
|
*ext/rjb.c
|
3
22
|
RJB_VERSION -> 1.3.4
|
data/ext/load.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Rjb - Ruby <-> Java Bridge
|
3
|
-
* Copyright(c) 2004,2005,2006,2009,2010 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2009,2010,2011 arton
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -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
|
15
|
+
* $Id: load.c 167 2011-07-15 17:40:25Z arton $
|
16
16
|
*/
|
17
17
|
|
18
18
|
#include <stdlib.h>
|
@@ -42,6 +42,10 @@
|
|
42
42
|
#else
|
43
43
|
#define JVMDLL "%s\\jre\\bin\\%s\\jvm.dll"
|
44
44
|
#define DIRSEPARATOR '\\'
|
45
|
+
#if defined(_WIN64)
|
46
|
+
#undef JVM_TYPE
|
47
|
+
#define JVM_TYPE "server"
|
48
|
+
#endif
|
45
49
|
#endif
|
46
50
|
#define CLASSPATH_SEP ';'
|
47
51
|
#elif defined(__APPLE__) && defined(__MACH__)
|
data/ext/rjb.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Rjb - Ruby <-> Java Bridge
|
3
|
-
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010,2011 arton
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -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
|
15
|
+
* $Id: rjb.c 170 2011-07-18 12:45:13Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.3.
|
18
|
+
#define RJB_VERSION "1.3.5"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "extconf.h"
|
@@ -57,12 +57,12 @@
|
|
57
57
|
rjb_check_exception(jenv, 1)
|
58
58
|
#if defined(RUBINIUS)
|
59
59
|
#define CLASS_NEW(obj, name) rb_define_class_under(rjb, name, obj)
|
60
|
-
#define CLASS_INHERITED(spr, kls) rb_funcall(spr, rb_intern("
|
60
|
+
#define CLASS_INHERITED(spr, kls) RTEST(rb_funcall(spr, rb_intern(">="), 1, kls))
|
61
61
|
#else
|
62
62
|
#define CLASS_NEW(obj, name) rb_define_class_under(rjb, name, obj)
|
63
|
-
#define CLASS_INHERITED(spr, kls)
|
63
|
+
#define CLASS_INHERITED(spr, kls) RTEST(rb_funcall(spr, rb_intern(">="), 1, kls))
|
64
64
|
#endif
|
65
|
-
#define IS_RJB_OBJECT(v) (CLASS_INHERITED(rjbi, rb_obj_class(v)) || rb_obj_class(v) == rjb)
|
65
|
+
#define IS_RJB_OBJECT(v) (CLASS_INHERITED(rjbi, rb_obj_class(v)) || rb_obj_class(v) == rjb || CLASS_INHERITED(rjbb, rb_obj_class(v)))
|
66
66
|
#define USER_INITIALIZE "@user_initialize"
|
67
67
|
|
68
68
|
static void register_class(VALUE, VALUE);
|
@@ -76,15 +76,19 @@ static jarray r2objarray(JNIEnv* jenv, VALUE v, const char* cls);
|
|
76
76
|
static VALUE jv2rv_withprim(JNIEnv* jenv, jobject o);
|
77
77
|
static J2R get_arrayconv(const char* cname, char* depth);
|
78
78
|
static jarray r2barray(JNIEnv* jenv, VALUE v, const char* cls);
|
79
|
+
static VALUE rjb_s_bind(VALUE self, VALUE rbobj, VALUE itfname);
|
79
80
|
|
80
81
|
static VALUE rjb;
|
81
82
|
static VALUE jklass;
|
82
83
|
static VALUE rjbc;
|
83
84
|
static VALUE rjbi;
|
84
85
|
static VALUE rjbb;
|
86
|
+
static VALUE rjba;
|
85
87
|
|
86
88
|
static ID user_initialize;
|
87
89
|
static ID cvar_classpath;
|
90
|
+
static ID anonymousblock;
|
91
|
+
static ID id_call;
|
88
92
|
|
89
93
|
VALUE rjb_loaded_classes;
|
90
94
|
static VALUE proxies;
|
@@ -836,7 +840,12 @@ static void rv2jobject(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
|
|
836
840
|
jpcvt[PRM_LONG].ctr_id, arg);
|
837
841
|
break;
|
838
842
|
#endif
|
843
|
+
case T_OBJECT:
|
839
844
|
default:
|
845
|
+
#if DEBUG
|
846
|
+
fprintf(stderr, "rtype:%d, sig=%s\n", TYPE(val), psig);
|
847
|
+
fflush(stderr);
|
848
|
+
#endif
|
840
849
|
rb_raise(rb_eRuntimeError, "can't convert to java type");
|
841
850
|
break;
|
842
851
|
}
|
@@ -858,8 +867,8 @@ static void rv2jobject(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
|
|
858
867
|
|
859
868
|
static void check_fixnumarray(VALUE v)
|
860
869
|
{
|
861
|
-
|
862
|
-
|
870
|
+
size_t i;
|
871
|
+
size_t len = RARRAY_LEN(v);
|
863
872
|
VALUE* p = RARRAY_PTR(v);
|
864
873
|
/* check all fixnum (overflow is permit) */
|
865
874
|
for (i = 0; i < len; i++)
|
@@ -1140,7 +1149,7 @@ static void rv2jarray(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
|
|
1140
1149
|
}
|
1141
1150
|
else
|
1142
1151
|
{
|
1143
|
-
|
1152
|
+
size_t i;
|
1144
1153
|
jarray ja = NULL;
|
1145
1154
|
if (NIL_P(val))
|
1146
1155
|
{
|
@@ -1181,7 +1190,7 @@ static void rv2jarray(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
|
|
1181
1190
|
*/
|
1182
1191
|
static R2J get_r2j(JNIEnv* jenv, jobject o, int* siglen, char* sigp)
|
1183
1192
|
{
|
1184
|
-
|
1193
|
+
size_t len, i;
|
1185
1194
|
const char* cname;
|
1186
1195
|
R2J result = NULL;
|
1187
1196
|
jstring nm = (*jenv)->CallObjectMethod(jenv, o, rjb_class_getName);
|
@@ -1227,8 +1236,8 @@ static R2J get_r2j(JNIEnv* jenv, jobject o, int* siglen, char* sigp)
|
|
1227
1236
|
|
1228
1237
|
static J2R get_arrayconv(const char* cname, char* pdepth)
|
1229
1238
|
{
|
1230
|
-
|
1231
|
-
|
1239
|
+
size_t i;
|
1240
|
+
size_t start;
|
1232
1241
|
for (start = 1; *(cname + start) == '['; start++);
|
1233
1242
|
*pdepth = (char)start;
|
1234
1243
|
for (i = 0; i < COUNTOF(jcvt); i++)
|
@@ -1248,7 +1257,7 @@ static J2R get_arrayconv(const char* cname, char* pdepth)
|
|
1248
1257
|
|
1249
1258
|
static J2R get_j2r(JNIEnv* jenv, jobject cls, char* psig, char* pdepth, char* ppsig, off_t* piv, int static_method)
|
1250
1259
|
{
|
1251
|
-
|
1260
|
+
size_t i;
|
1252
1261
|
J2R result = NULL;
|
1253
1262
|
const char* cname;
|
1254
1263
|
const char* jname = NULL;
|
@@ -2065,6 +2074,17 @@ static VALUE import_class(JNIEnv* jenv, jclass jcls, VALUE clsname)
|
|
2065
2074
|
return v;
|
2066
2075
|
}
|
2067
2076
|
|
2077
|
+
static VALUE rjb_a_initialize(VALUE self, VALUE proc)
|
2078
|
+
{
|
2079
|
+
rb_ivar_set(self, anonymousblock, proc);
|
2080
|
+
}
|
2081
|
+
|
2082
|
+
static VALUE rjb_a_missing(int argc, VALUE* argv, VALUE self)
|
2083
|
+
{
|
2084
|
+
VALUE proc = rb_ivar_get(self, anonymousblock);
|
2085
|
+
return rb_funcall2(proc, id_call, argc, argv);
|
2086
|
+
}
|
2087
|
+
|
2068
2088
|
static VALUE rjb_i_prepare_proxy(VALUE self)
|
2069
2089
|
{
|
2070
2090
|
return rb_funcall(self, rb_intern("instance_eval"), 1,
|
@@ -2095,15 +2115,14 @@ static VALUE register_instance(JNIEnv* jenv, VALUE klass, struct jv_data* org, j
|
|
2095
2115
|
* temporary signature check
|
2096
2116
|
* return !0 if found
|
2097
2117
|
*/
|
2098
|
-
static int check_rtype(JNIEnv* jenv, VALUE
|
2118
|
+
static int check_rtype(JNIEnv* jenv, VALUE* pv, char* p)
|
2099
2119
|
{
|
2100
2120
|
char* pcls = NULL;
|
2101
2121
|
if (*p == 'L')
|
2102
2122
|
{
|
2103
2123
|
char* pt = strchr(p, ';');
|
2104
|
-
if (pt)
|
2105
|
-
|
2106
|
-
int len = pt - p - 1;
|
2124
|
+
if (pt) {
|
2125
|
+
size_t len = pt - p - 1;
|
2107
2126
|
pcls = ALLOCA_N(char, len + 1);
|
2108
2127
|
strncpy(pcls, p + 1, len);
|
2109
2128
|
*(pcls + len) = '\0';
|
@@ -2113,7 +2132,7 @@ static int check_rtype(JNIEnv* jenv, VALUE v, char* p)
|
|
2113
2132
|
{
|
2114
2133
|
return 1;
|
2115
2134
|
}
|
2116
|
-
switch (TYPE(
|
2135
|
+
switch (TYPE(*pv))
|
2117
2136
|
{
|
2118
2137
|
case T_FIXNUM:
|
2119
2138
|
return strchr("BCDFIJS", *p) != NULL;
|
@@ -2127,22 +2146,25 @@ static int check_rtype(JNIEnv* jenv, VALUE v, char* p)
|
|
2127
2146
|
case T_ARRAY:
|
2128
2147
|
return *p == '[';
|
2129
2148
|
case T_DATA:
|
2130
|
-
if (IS_RJB_OBJECT(
|
2149
|
+
if (IS_RJB_OBJECT(*pv) && pcls)
|
2131
2150
|
{
|
2132
2151
|
/* imported object */
|
2133
2152
|
jclass cls;
|
2134
2153
|
struct jvi_data* ptr;
|
2135
2154
|
int result = 0;
|
2136
2155
|
if (!strcmp("java.lang.String", pcls)) return 1;
|
2137
|
-
Data_Get_Struct(
|
2156
|
+
Data_Get_Struct(*pv, struct jvi_data, ptr);
|
2138
2157
|
RJB_FIND_CLASS(cls, java2jniname(pcls));
|
2139
2158
|
if (cls)
|
2140
|
-
|
2159
|
+
{
|
2141
2160
|
result = (cls && (*jenv)->IsInstanceOf(jenv, ptr->obj, cls));
|
2142
2161
|
(*jenv)->DeleteLocalRef(jenv, cls);
|
2143
2162
|
}
|
2144
2163
|
return result;
|
2145
|
-
}
|
2164
|
+
} else if (pcls) {
|
2165
|
+
VALUE blockobj = rb_class_new_instance(1, pv, rjba);
|
2166
|
+
*pv = rjb_s_bind(rjbb, blockobj, rb_str_new2(pcls));
|
2167
|
+
}
|
2146
2168
|
/* fall down to the next case */
|
2147
2169
|
case T_OBJECT:
|
2148
2170
|
/* fall down to the next case */
|
@@ -2212,7 +2234,7 @@ static VALUE rjb_newinstance(int argc, VALUE* argv, VALUE self)
|
|
2212
2234
|
psig = (*pc)->method_signature;
|
2213
2235
|
for (i = 0; i < argc; i++)
|
2214
2236
|
{
|
2215
|
-
if (!check_rtype(jenv,
|
2237
|
+
if (!check_rtype(jenv, argv + i, psig))
|
2216
2238
|
{
|
2217
2239
|
found = 0;
|
2218
2240
|
break;
|
@@ -2375,6 +2397,17 @@ static VALUE rjb_class_eval(int argc, VALUE* argv, VALUE self)
|
|
2375
2397
|
return self;
|
2376
2398
|
}
|
2377
2399
|
|
2400
|
+
static VALUE rjb_s_impl(VALUE self)
|
2401
|
+
{
|
2402
|
+
VALUE obj;
|
2403
|
+
VALUE proc;
|
2404
|
+
rb_need_block();
|
2405
|
+
proc = rb_block_proc();
|
2406
|
+
obj = rb_class_new_instance(1, &proc, rjba);
|
2407
|
+
return rjb_s_bind(rjbb, obj, rb_funcall(self, rb_intern("name"), 0));
|
2408
|
+
}
|
2409
|
+
|
2410
|
+
|
2378
2411
|
/*
|
2379
2412
|
* jclass Rjb::bind(rbobj, interface_name)
|
2380
2413
|
*/
|
@@ -2774,6 +2807,15 @@ static VALUE invoke(JNIEnv* jenv, struct cls_method* pm, struct jvi_data* ptr,
|
|
2774
2807
|
char* psig;
|
2775
2808
|
struct cls_method* orgpm = pm;
|
2776
2809
|
|
2810
|
+
if (rb_block_given_p())
|
2811
|
+
{
|
2812
|
+
VALUE* pargs = ALLOCA_N(VALUE, argc + 1);
|
2813
|
+
memcpy(pargs, argv, argc * sizeof(VALUE));
|
2814
|
+
*(pargs + argc) = rb_block_proc();
|
2815
|
+
++argc;
|
2816
|
+
argv = pargs;
|
2817
|
+
}
|
2818
|
+
|
2777
2819
|
for (found = 0; pm; pm = pm->next)
|
2778
2820
|
{
|
2779
2821
|
if (argc == pm->basic.arg_count)
|
@@ -2792,7 +2834,7 @@ static VALUE invoke(JNIEnv* jenv, struct cls_method* pm, struct jvi_data* ptr,
|
|
2792
2834
|
found = 1;
|
2793
2835
|
for (i = 0; i < argc; i++)
|
2794
2836
|
{
|
2795
|
-
if (!check_rtype(jenv,
|
2837
|
+
if (!check_rtype(jenv, argv + i, psig))
|
2796
2838
|
{
|
2797
2839
|
found = 0;
|
2798
2840
|
break;
|
@@ -2895,7 +2937,6 @@ static VALUE invoke_by_instance(ID rmid, int argc, VALUE* argv,
|
|
2895
2937
|
struct cls_field* pf;
|
2896
2938
|
struct cls_method* pm;
|
2897
2939
|
const char* tname = rb_id2name(rmid);
|
2898
|
-
|
2899
2940
|
if (argc == 0 && st_lookup(ptr->fields, rmid, (st_data_t*)&pf))
|
2900
2941
|
{
|
2901
2942
|
ret = getter(jenv, pf, ptr);
|
@@ -2944,7 +2985,7 @@ static VALUE rjb_i_missing(int argc, VALUE* argv, VALUE self)
|
|
2944
2985
|
{
|
2945
2986
|
struct jvi_data* ptr;
|
2946
2987
|
ID rmid = rb_to_id(argv[0]);
|
2947
|
-
|
2988
|
+
|
2948
2989
|
Data_Get_Struct(self, struct jvi_data, ptr);
|
2949
2990
|
|
2950
2991
|
return invoke_by_instance(rmid, argc -1, argv + 1, ptr, NULL);
|
@@ -3033,11 +3074,17 @@ static VALUE find_const(VALUE pv)
|
|
3033
3074
|
return rb_const_get(*p, (ID)*(p + 1));
|
3034
3075
|
}
|
3035
3076
|
|
3077
|
+
static VALUE call_blcock(int argc, VALUE* argv)
|
3078
|
+
{
|
3079
|
+
return rb_yield_values2(argc, argv);
|
3080
|
+
}
|
3081
|
+
|
3036
3082
|
static VALUE rjb_missing(int argc, VALUE* argv, VALUE self)
|
3037
3083
|
{
|
3038
3084
|
struct jv_data* ptr;
|
3039
3085
|
ID rmid = rb_to_id(argv[0]);
|
3040
3086
|
const char* rmname = rb_id2name(rmid);
|
3087
|
+
|
3041
3088
|
if (isupper(*rmname))
|
3042
3089
|
{
|
3043
3090
|
VALUE r, args[2];
|
@@ -3116,6 +3163,7 @@ void Init_rjbcore()
|
|
3116
3163
|
rjbc = CLASS_NEW(rb_cObject, "Rjb_JavaClass");
|
3117
3164
|
rb_gc_register_address(&rjbc);
|
3118
3165
|
rb_define_method(rjbc, "method_missing", rjb_missing, -1);
|
3166
|
+
rb_define_method(rjbc, "impl", rjb_s_impl, 0);
|
3119
3167
|
rb_define_method(rjbc, "_invoke", rjb_invoke, -1);
|
3120
3168
|
rb_define_method(rjbc, "_classname", rjb_i_class, 0);
|
3121
3169
|
|
@@ -3131,12 +3179,20 @@ void Init_rjbcore()
|
|
3131
3179
|
/* Ruby-Java Bridge object */
|
3132
3180
|
rjbb = CLASS_NEW(rb_cObject, "Rjb_JavaBridge");
|
3133
3181
|
rb_gc_register_address(&rjbb);
|
3182
|
+
|
3183
|
+
/* anonymous interface object */
|
3184
|
+
rjba = CLASS_NEW(rb_cObject, "Rjb_AnonymousClass");
|
3185
|
+
rb_gc_register_address(&rjba);
|
3186
|
+
rb_define_method(rjba, "initialize", rjb_a_initialize, 1);
|
3187
|
+
rb_define_method(rjba, "method_missing", rjb_a_missing, -1);
|
3188
|
+
anonymousblock = rb_intern("@anon_block");
|
3189
|
+
id_call = rb_intern("call");
|
3134
3190
|
}
|
3135
3191
|
|
3136
3192
|
VALUE rjb_safe_funcall(VALUE args)
|
3137
3193
|
{
|
3138
3194
|
VALUE* argp = (VALUE*)args;
|
3139
|
-
return rb_funcall2(*argp, *(argp + 1), *(argp + 2), argp + 3);
|
3195
|
+
return rb_funcall2(*argp, *(argp + 1), (int)*(argp + 2), argp + 3);
|
3140
3196
|
}
|
3141
3197
|
|
3142
3198
|
/**
|
@@ -3148,7 +3204,6 @@ JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
|
|
3148
3204
|
int i;
|
3149
3205
|
jvalue j;
|
3150
3206
|
memset(&j, 0, sizeof(j));
|
3151
|
-
|
3152
3207
|
for (i = 0; i < RARRAY_LEN(proxies); i++)
|
3153
3208
|
{
|
3154
3209
|
struct rj_bridge* ptr;
|
data/lib/rjbcore.so
CHANGED
Binary file
|
data/samples/unzip.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rjb'
|
2
|
+
|
3
|
+
if Rjb::VERSION < '1.3.4'
|
4
|
+
$stderr.puts "require rjb-1.3.4 or later, bye."
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
|
8
|
+
class ZipFile
|
9
|
+
include Enumerable
|
10
|
+
Zip = Rjb::import('java.util.zip.ZipFile')
|
11
|
+
def initialize(file, &block)
|
12
|
+
@zipfile = Zip.new(file)
|
13
|
+
if block
|
14
|
+
yield self
|
15
|
+
@zipfile.close
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def close
|
19
|
+
@zipfile.close
|
20
|
+
end
|
21
|
+
def each(&block)
|
22
|
+
unless block
|
23
|
+
Enumerator.new(self)
|
24
|
+
else
|
25
|
+
e = @zipfile.entries
|
26
|
+
while e.has_more_elements
|
27
|
+
yield e.next_element
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def size
|
32
|
+
@zipfile.size
|
33
|
+
end
|
34
|
+
def unzip(ent)
|
35
|
+
if String === ent
|
36
|
+
ent = @zipfile.entry(ent)
|
37
|
+
end
|
38
|
+
is = @zipfile.input_stream(ent)
|
39
|
+
buff = "\0" * 4096
|
40
|
+
File.open(ent.name, 'wb') do |fout|
|
41
|
+
loop do
|
42
|
+
len = is.read(buff, 0, buff.size)
|
43
|
+
break if len < 0
|
44
|
+
fout.write(buff[0, len])
|
45
|
+
end
|
46
|
+
is.close
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if __FILE__ == $0
|
52
|
+
if ARGV.size == 0
|
53
|
+
puts 'usage: ruby unzip.rb filename'
|
54
|
+
else
|
55
|
+
ARGV.each do |file|
|
56
|
+
ZipFile.new(file) do |zip|
|
57
|
+
zip.each do |f|
|
58
|
+
puts "#{f.name}, #{f.size}"
|
59
|
+
unless f.directory?
|
60
|
+
zip.unzip(f)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/test/Base.class
ADDED
Binary file
|
data/test/ExtBase.class
ADDED
Binary file
|
data/test/IBase.class
ADDED
Binary file
|
data/test/JTest.class
ADDED
Binary file
|
data/test/JarTest.class
ADDED
Binary file
|
Binary file
|
data/test/Test.class
ADDED
Binary file
|
data/test/Two.class
ADDED
Binary file
|
Binary file
|
data/test/jartest.jar
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/rjbtest.jar
CHANGED
Binary file
|
data/test/test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/local/env ruby -Ku
|
2
2
|
# encoding: utf-8
|
3
|
-
# $Id: test.rb
|
3
|
+
# $Id: test.rb 170 2011-07-18 12:45:13Z arton $
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'rjb'
|
@@ -638,10 +638,22 @@ class TestRjb < Test::Unit::TestCase
|
|
638
638
|
|
639
639
|
#rjb-bugs-15430 rebported by Bryan Duxbury
|
640
640
|
def test_generics_map
|
641
|
-
|
641
|
+
|
642
|
+
ctest = import('jp.co.infoseek.hp.arton.rjb.Test')
|
643
|
+
test = ctest.new
|
642
644
|
map = test.sorted_map
|
643
645
|
assert_equal "\0\x1\x2\x3\x4", map.get('abc')
|
644
646
|
assert_equal "\x5\x6\x7\x8\x9", map.get('def')
|
647
|
+
|
648
|
+
cmap = import('java.util.TreeMap')
|
649
|
+
map = cmap.new
|
650
|
+
map.put('abc', @jString.new('abc').bytes)
|
651
|
+
map.put('012', @jString.new('012').bytes)
|
652
|
+
|
653
|
+
Rjb::primitive_conversion = true
|
654
|
+
map2 = test.throughSortedMap(map)
|
655
|
+
assert_equal '012', map2.get('012')
|
656
|
+
assert_equal 'abc', map2.get('abc')
|
645
657
|
end
|
646
658
|
|
647
659
|
def x_test_zzunload
|
@@ -760,5 +772,25 @@ class TestRjb < Test::Unit::TestCase
|
|
760
772
|
ba.close
|
761
773
|
assert_equal org, buff
|
762
774
|
end
|
775
|
+
def test_anoninterface
|
776
|
+
arrays = import('java.util.Arrays')
|
777
|
+
a = [3, -4, 5, -6, 8, -10, -14]
|
778
|
+
index = arrays.binary_search(a, 6) do |m, o1, o2|
|
779
|
+
o1.abs - o2.abs
|
780
|
+
end
|
781
|
+
assert_equal 3, index
|
782
|
+
index = arrays.binary_search(a, 7) do |m, o1, o2|
|
783
|
+
o1.abs - o2.abs
|
784
|
+
end
|
785
|
+
assert_equal -5, index
|
786
|
+
end
|
787
|
+
def test_impl
|
788
|
+
two = import('Two')
|
789
|
+
t = two.impl { |m| m.to_s }
|
790
|
+
a = import('TwoCaller').new
|
791
|
+
ret = a.foo(t)
|
792
|
+
assert_equal 'method1', ret[0]
|
793
|
+
assert_equal 'method2', ret[1]
|
794
|
+
end
|
763
795
|
end
|
764
796
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 5
|
10
|
+
version: 1.3.5
|
11
11
|
platform: x86-mswin32-60
|
12
12
|
authors:
|
13
13
|
- arton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-18 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -45,13 +45,24 @@ files:
|
|
45
45
|
- lib/rjb.rb
|
46
46
|
- lib/rjbextension.rb
|
47
47
|
- samples/filechooser.rb
|
48
|
+
- samples/unzip.rb
|
48
49
|
- test/test.rb
|
49
50
|
- test/exttest.rb
|
50
51
|
- test/test_osxjvm.rb
|
51
52
|
- test/gctest.rb
|
53
|
+
- test/jp/co/infoseek/hp/arton/rjb/JTest.class
|
52
54
|
- test/jp/co/infoseek/hp/arton/rjb/IBase.class
|
53
55
|
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
54
56
|
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
57
|
+
- test/Base.class
|
58
|
+
- test/JTest.class
|
59
|
+
- test/IBase.class
|
60
|
+
- test/Test.class
|
61
|
+
- test/Test$TestTypes.class
|
62
|
+
- test/TwoCaller.class
|
63
|
+
- test/Two.class
|
64
|
+
- test/JarTest.class
|
65
|
+
- test/ExtBase.class
|
55
66
|
- test/rjbtest.jar
|
56
67
|
- test/jartest.jar
|
57
68
|
- COPYING
|
@@ -93,7 +104,7 @@ requirements:
|
|
93
104
|
- JDK 5.0
|
94
105
|
- " VC6 version of Ruby"
|
95
106
|
rubyforge_project: rjb
|
96
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.5.2
|
97
108
|
signing_key:
|
98
109
|
specification_version: 3
|
99
110
|
summary: Ruby Java bridge
|