rjb 1.3.2-x86-mswin32-60 → 1.3.4-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +528 -512
- data/ext/load.c +23 -8
- data/ext/rjb.c +31 -8
- data/lib/rjbcore.so +0 -0
- data/test/test.rb +11 -1
- data/test/test_osxjvm.rb +23 -0
- metadata +11 -19
- 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/jar/jp/co/infoseek/hp/arton/rjb/JarTest.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/Base.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/ExtBase.class +0 -0
- data/test/m.rb +0 -20
- data/test/tx.rb +0 -52
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
|
15
|
+
* $Id: load.c 159 2010-11-16 16:35:49Z arton $
|
16
16
|
*/
|
17
17
|
|
18
18
|
#include <stdlib.h>
|
@@ -131,10 +131,21 @@ static int open_jvm(char* libpath)
|
|
131
131
|
#endif
|
132
132
|
return 1;
|
133
133
|
}
|
134
|
+
|
135
|
+
#if defined(__APPLE__) && defined(__MACH__)
|
136
|
+
static int file_exist(const char* dir, const char* file)
|
137
|
+
{
|
138
|
+
VALUE path = rb_funcall(rb_cFile, rb_intern("join"), 2,
|
139
|
+
rb_str_new2(dir), rb_str_new2(file));
|
140
|
+
VALUE ret = rb_funcall(rb_cFile, rb_intern("exist?"), 1, path);
|
141
|
+
return RTEST(ret);
|
142
|
+
}
|
143
|
+
#endif
|
144
|
+
|
134
145
|
/*
|
135
146
|
* not completed, only valid under some circumstances.
|
136
147
|
*/
|
137
|
-
static int load_jvm(char* jvmtype)
|
148
|
+
static int load_jvm(const char* jvmtype)
|
138
149
|
{
|
139
150
|
char* libpath;
|
140
151
|
char* java_home;
|
@@ -150,7 +161,7 @@ static int load_jvm(char* jvmtype)
|
|
150
161
|
{
|
151
162
|
if (strlen(jh) > HOME_NAME_LEN)
|
152
163
|
{
|
153
|
-
|
164
|
+
size_t len = strlen(jh);
|
154
165
|
char* p = ALLOCA_N(char, len + 8);
|
155
166
|
jh = strcpy(p, jh);
|
156
167
|
if (*(jh + len - 1) == '/')
|
@@ -163,6 +174,10 @@ static int load_jvm(char* jvmtype)
|
|
163
174
|
strcpy(p + len, "/..");
|
164
175
|
}
|
165
176
|
}
|
177
|
+
if (!jvmtype && !file_exist(jh, "JavaVM"))
|
178
|
+
{
|
179
|
+
jh = DEFAULT_HOME;
|
180
|
+
}
|
166
181
|
}
|
167
182
|
#endif
|
168
183
|
if (!jh)
|
@@ -208,7 +223,7 @@ static int load_bridge(JNIEnv* jenv)
|
|
208
223
|
JNINativeMethod nmethod[1];
|
209
224
|
jbyte buff[8192];
|
210
225
|
char* bridge;
|
211
|
-
|
226
|
+
size_t len;
|
212
227
|
FILE* f;
|
213
228
|
#if defined(RUBINIUS)
|
214
229
|
VALUE v = rb_const_get(rb_cObject, rb_intern("RjbConf"));
|
@@ -268,12 +283,12 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
|
|
268
283
|
{ "DUMMY", NULL }, /* for classpath count */
|
269
284
|
};
|
270
285
|
char* newpath;
|
271
|
-
|
286
|
+
size_t len;
|
272
287
|
int result;
|
273
288
|
GETDEFAULTJAVAVMINITARGS initargs;
|
274
289
|
CREATEJAVAVM createjavavm;
|
275
290
|
JavaVMOption* options;
|
276
|
-
|
291
|
+
size_t optlen;
|
277
292
|
int i;
|
278
293
|
VALUE optval;
|
279
294
|
|
@@ -292,7 +307,7 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
|
|
292
307
|
if (libjvm == NULL || !open_jvm(libjvm))
|
293
308
|
{
|
294
309
|
#if defined(__APPLE__) && defined(__MACH__)
|
295
|
-
if (!(load_jvm(
|
310
|
+
if (!(load_jvm(NULL)))
|
296
311
|
{
|
297
312
|
JVMDLL = "%s/Libraries/libjvm.dylib";
|
298
313
|
CREATEJVM = "JNI_CreateJavaVM_Impl";
|
@@ -359,7 +374,7 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
|
|
359
374
|
(options + i)->optionString = StringValueCStr(optval);
|
360
375
|
(options + i)->extraInfo = NULL;
|
361
376
|
}
|
362
|
-
vm_args->nOptions = optlen;
|
377
|
+
vm_args->nOptions = (int)optlen;
|
363
378
|
vm_args->options = options;
|
364
379
|
vm_args->ignoreUnrecognized = JNI_TRUE;
|
365
380
|
if (NIL_P(createjavavmfunc))
|
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
|
15
|
+
* $Id: rjb.c 163 2010-11-22 07:31:27Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.3.
|
18
|
+
#define RJB_VERSION "1.3.4"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "extconf.h"
|
@@ -75,6 +75,7 @@ static VALUE jarray2rv(JNIEnv* jenv, jvalue val);
|
|
75
75
|
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
|
+
static jarray r2barray(JNIEnv* jenv, VALUE v, const char* cls);
|
78
79
|
|
79
80
|
static VALUE rjb;
|
80
81
|
static VALUE jklass;
|
@@ -748,7 +749,7 @@ static void rv2jstring(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
|
|
748
749
|
return; /* never delete at this time */
|
749
750
|
}
|
750
751
|
}
|
751
|
-
|
752
|
+
}
|
752
753
|
(*jenv)->DeleteLocalRef(jenv, jv->l);
|
753
754
|
}
|
754
755
|
}
|
@@ -814,7 +815,11 @@ static void rv2jobject(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
|
|
814
815
|
}
|
815
816
|
break;
|
816
817
|
case T_STRING:
|
817
|
-
|
818
|
+
if (psig && *psig == '[' && *(psig + 1) == 'B') {
|
819
|
+
jv->l = r2barray(jenv, val, NULL);
|
820
|
+
} else {
|
821
|
+
rv2jstring(jenv, val, jv, NULL, 0);
|
822
|
+
}
|
818
823
|
break;
|
819
824
|
case T_FLOAT:
|
820
825
|
arg.d = NUM2DBL(val);
|
@@ -1115,6 +1120,22 @@ static void rv2jarray(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, int
|
|
1115
1120
|
}
|
1116
1121
|
if (release)
|
1117
1122
|
{
|
1123
|
+
if (TYPE(val) == T_STRING && *(psig + 1) == 'B')
|
1124
|
+
{
|
1125
|
+
// copy array's contents into arg string
|
1126
|
+
jsize len = (*jenv)->GetArrayLength(jenv, jv->l);
|
1127
|
+
jbyte* p = (*jenv)->GetByteArrayElements(jenv, jv->l, NULL);
|
1128
|
+
if (len <= RSTRING_LEN(val))
|
1129
|
+
{
|
1130
|
+
memcpy(StringValuePtr(val), p, len);
|
1131
|
+
}
|
1132
|
+
else
|
1133
|
+
{
|
1134
|
+
VALUE src = rb_str_new(p, len);
|
1135
|
+
rb_str_set_len(val, 0);
|
1136
|
+
rb_str_append(val, src);
|
1137
|
+
}
|
1138
|
+
}
|
1118
1139
|
(*jenv)->DeleteLocalRef(jenv, jv->l);
|
1119
1140
|
}
|
1120
1141
|
else
|
@@ -2099,7 +2120,7 @@ static int check_rtype(JNIEnv* jenv, VALUE v, char* p)
|
|
2099
2120
|
case T_FLOAT:
|
2100
2121
|
return strchr("DF", *p) != NULL;
|
2101
2122
|
case T_STRING:
|
2102
|
-
|
2123
|
+
return pcls && !strcmp("java.lang.String", pcls) || *p == '[' && *(p + 1) == 'B';
|
2103
2124
|
case T_TRUE:
|
2104
2125
|
case T_FALSE:
|
2105
2126
|
return *p == 'Z';
|
@@ -3057,11 +3078,13 @@ static VALUE rjb_class_forname(int argc, VALUE* argv, VALUE self)
|
|
3057
3078
|
*/
|
3058
3079
|
void Init_rjbcore()
|
3059
3080
|
{
|
3060
|
-
#if
|
3081
|
+
#if RJB_RUBY_VERSION_CODE < 190
|
3082
|
+
#if defined(RUBINIUS)
|
3061
3083
|
rb_require("iconv");
|
3062
|
-
#else
|
3084
|
+
#else
|
3063
3085
|
rb_protect((VALUE(*)(VALUE))rb_require, (VALUE)"iconv", NULL);
|
3064
|
-
#endif
|
3086
|
+
#endif
|
3087
|
+
#endif
|
3065
3088
|
rjb_loaded_classes = rb_hash_new();
|
3066
3089
|
#ifndef RUBINIUS
|
3067
3090
|
OBJ_FREEZE(rjb_loaded_classes);
|
data/lib/rjbcore.so
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 161 2010-11-22 07:18:00Z arton $
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'rjb'
|
@@ -750,5 +750,15 @@ class TestRjb < Test::Unit::TestCase
|
|
750
750
|
jt = import('jp.co.infoseek.hp.arton.rjb.JarTest')
|
751
751
|
assert_equal 'abcd', jt.new.add('ab', 'cd')
|
752
752
|
end
|
753
|
+
def test_bothdirection_buffer
|
754
|
+
org = "abcdefghijklmn"
|
755
|
+
baip = import('java.io.ByteArrayInputStream')
|
756
|
+
ba = baip.new(org)
|
757
|
+
buff = "\0" * org.size
|
758
|
+
assert_equal org.size, ba.read(buff)
|
759
|
+
assert_equal -1, ba.read(buff)
|
760
|
+
ba.close
|
761
|
+
assert_equal org, buff
|
762
|
+
end
|
753
763
|
end
|
754
764
|
|
data/test/test_osxjvm.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
# $Id:$
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'rjb'
|
7
|
+
rescue LoadError
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rjb'
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
if RUBY_PLATFORM =~ /darwin/
|
14
|
+
class TestOsxJvm < Test::Unit::TestCase
|
15
|
+
def test_with_javahome
|
16
|
+
ENV['JAVA_HOME'] = `/usr/libexec/java_home`
|
17
|
+
assert_nothing_raised do
|
18
|
+
Rjb::load
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 4
|
10
|
+
version: 1.3.4
|
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: 2010-
|
18
|
+
date: 2010-11-22 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -32,36 +32,28 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- ext/RBridge.java
|
34
34
|
- ext/load.c
|
35
|
+
- ext/rjbexception.c
|
35
36
|
- ext/riconv.c
|
36
37
|
- ext/rjb.c
|
37
|
-
- ext/rjbexception.c
|
38
|
-
- ext/extconf.h
|
39
|
-
- ext/jniwrap.h
|
40
38
|
- ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
|
41
39
|
- ext/riconv.h
|
40
|
+
- ext/extconf.h
|
41
|
+
- ext/jniwrap.h
|
42
42
|
- ext/rjb.h
|
43
43
|
- ext/depend
|
44
44
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
45
45
|
- lib/rjb.rb
|
46
46
|
- lib/rjbextension.rb
|
47
47
|
- samples/filechooser.rb
|
48
|
+
- test/test.rb
|
48
49
|
- test/exttest.rb
|
50
|
+
- test/test_osxjvm.rb
|
49
51
|
- test/gctest.rb
|
50
|
-
- test/m.rb
|
51
|
-
- test/test.rb
|
52
|
-
- test/tx.rb
|
53
|
-
- test/Base.class
|
54
|
-
- test/ExtBase.class
|
55
|
-
- test/IBase.class
|
56
|
-
- test/jar/jp/co/infoseek/hp/arton/rjb/JarTest.class
|
57
|
-
- test/jp/co/infoseek/hp/arton/rjb/Base.class
|
58
|
-
- test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
|
59
52
|
- test/jp/co/infoseek/hp/arton/rjb/IBase.class
|
60
|
-
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
61
53
|
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
62
|
-
- test/
|
63
|
-
- test/jartest.jar
|
54
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
64
55
|
- test/rjbtest.jar
|
56
|
+
- test/jartest.jar
|
65
57
|
- COPYING
|
66
58
|
- ChangeLog
|
67
59
|
- readme.sj
|
data/test/Base.class
DELETED
Binary file
|
data/test/ExtBase.class
DELETED
Binary file
|
data/test/IBase.class
DELETED
Binary file
|
data/test/JTest.class
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/m.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
puts RUBY_VERSION
|
2
|
-
class X
|
3
|
-
module Y
|
4
|
-
def hello
|
5
|
-
puts 'hello'
|
6
|
-
end
|
7
|
-
end
|
8
|
-
def make_proc(&block)
|
9
|
-
block
|
10
|
-
end
|
11
|
-
def test
|
12
|
-
Proc.new do
|
13
|
-
extend Y
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
x = X.new
|
18
|
-
a = Object.new
|
19
|
-
a.instance_eval &x.test
|
20
|
-
a.hello
|
data/test/tx.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#!/usr/local/env ruby -Ku
|
2
|
-
# encoding: utf-8
|
3
|
-
# $Id: test.rb 87 2009-02-15 12:25:36Z arton $
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'rjb'
|
7
|
-
rescue LoadError
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rjb'
|
10
|
-
end
|
11
|
-
require 'test/unit'
|
12
|
-
|
13
|
-
puts "start RJB(#{Rjb::VERSION}) test"
|
14
|
-
class TestRjb < Test::Unit::TestCase
|
15
|
-
include Rjb
|
16
|
-
def setup
|
17
|
-
Rjb::load('.')
|
18
|
-
@jString = import('java.lang.String')
|
19
|
-
@jInteger = Rjb::import('java.lang.Integer')
|
20
|
-
@jShort = Rjb::import('java.lang.Short')
|
21
|
-
@jDouble = Rjb::import('java.lang.Double')
|
22
|
-
@jFloat = Rjb::import('java.lang.Float')
|
23
|
-
@jBoolean = Rjb::import('java.lang.Boolean')
|
24
|
-
@jByte = Rjb::import('java.lang.Byte')
|
25
|
-
@jLong = Rjb::import('java.lang.Long')
|
26
|
-
@jChar = Rjb::import('java.lang.Character')
|
27
|
-
end
|
28
|
-
|
29
|
-
def teardown
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_scalar
|
33
|
-
str = @jString.new_with_sig('Ljava.lang.String;', "abcde")
|
34
|
-
p str
|
35
|
-
p str.class
|
36
|
-
# rjb object (String)
|
37
|
-
str2 = @jString.new_with_sig('Ljava.lang.String;', 'fghijk')
|
38
|
-
p str2
|
39
|
-
p str2.class
|
40
|
-
a = str.concat(str2)
|
41
|
-
p a
|
42
|
-
p a.class
|
43
|
-
p str2
|
44
|
-
p str2.class
|
45
|
-
a = str.concat(str2)
|
46
|
-
p a
|
47
|
-
p a.class
|
48
|
-
assert_equal('abcdefghijk', str.concat(str2))
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|