rjb 1.0.6-mswin32 → 1.0.7-mswin32
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 +15 -0
- data/ext/rjb.c +35 -4
- data/lib/rjbcore.so +0 -0
- data/test/test.rb +23 -1
- metadata +8 -8
data/ChangeLog
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
Fri Sep 14 arton
|
2
|
+
*rjb.c
|
3
|
+
version 1.0.7
|
4
|
+
add auto primitive conversion toggled by Rjb::primitive_conversion
|
5
|
+
*test.rb
|
6
|
+
add test_auto_conv
|
7
|
+
Sun Jun 17 arton
|
8
|
+
*rjb.c
|
9
|
+
add method aliases.
|
10
|
+
setXxYy -> xx_yy=
|
11
|
+
getXxYy -> xx_yy
|
12
|
+
isXxYy -> xx_yy?
|
13
|
+
xxYyZz -> xx_yy_zz
|
14
|
+
*test.rb
|
15
|
+
add a test for the method alias feature.
|
1
16
|
Tue Nov 21 arton
|
2
17
|
*rjb.c
|
3
18
|
Skip the constant registering process, if the constant was already defined.
|
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 19 2007-09-14 14:59:29Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.0.
|
18
|
+
#define RJB_VERSION "1.0.7"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "st.h"
|
@@ -44,6 +44,7 @@ static VALUE rjb_class_forname(int argc, VALUE* argv, VALUE self);
|
|
44
44
|
static void setup_metadata(JNIEnv* jenv, VALUE self, struct jv_data*, VALUE classname);
|
45
45
|
static VALUE jarray2rv(JNIEnv* jenv, jvalue val);
|
46
46
|
static jarray r2objarray(JNIEnv* jenv, VALUE v, const char* cls);
|
47
|
+
static VALUE jv2rv_withprim(JNIEnv* jenv, jobject o);
|
47
48
|
|
48
49
|
static VALUE rjb;
|
49
50
|
static VALUE jklass;
|
@@ -57,6 +58,7 @@ JavaVM* rjb_jvm;
|
|
57
58
|
jclass rjb_rbridge;
|
58
59
|
jmethodID rjb_register_bridge;
|
59
60
|
static JNIEnv* main_jenv;
|
61
|
+
static VALUE primitive_conversion = Qfalse;
|
60
62
|
|
61
63
|
/*
|
62
64
|
* Object cache, never destroyed
|
@@ -224,7 +226,7 @@ static VALUE jv2rclass(JNIEnv* jenv, jclass jc)
|
|
224
226
|
return v;
|
225
227
|
}
|
226
228
|
|
227
|
-
static VALUE
|
229
|
+
static VALUE jv2rv_r(JNIEnv* jenv, jvalue val)
|
228
230
|
{
|
229
231
|
const char* cname;
|
230
232
|
jstring nm;
|
@@ -262,6 +264,15 @@ static VALUE jv2rv(JNIEnv* jenv, jvalue val)
|
|
262
264
|
return v;
|
263
265
|
}
|
264
266
|
|
267
|
+
static VALUE jv2rv(JNIEnv* jenv, jvalue val)
|
268
|
+
{
|
269
|
+
if (primitive_conversion == Qfalse)
|
270
|
+
{
|
271
|
+
return jv2rv_r(jenv, val);
|
272
|
+
}
|
273
|
+
return jv2rv_withprim(jenv, val.l);
|
274
|
+
}
|
275
|
+
|
265
276
|
static VALUE jvoid2rv(JNIEnv* jenv, jvalue val)
|
266
277
|
{
|
267
278
|
return Qnil;
|
@@ -535,7 +546,7 @@ static VALUE jv2rv_withprim(JNIEnv* jenv, jobject o)
|
|
535
546
|
}
|
536
547
|
}
|
537
548
|
jv.l = o;
|
538
|
-
return
|
549
|
+
return jv2rv_r(jenv, jv);
|
539
550
|
}
|
540
551
|
|
541
552
|
/*
|
@@ -1730,6 +1741,24 @@ static VALUE rjb_s_classes(VALUE self)
|
|
1730
1741
|
return rjb_loaded_classes;
|
1731
1742
|
}
|
1732
1743
|
|
1744
|
+
/**
|
1745
|
+
* For JRuby conpatible optsion
|
1746
|
+
*/
|
1747
|
+
static VALUE rjb_s_set_pconversion(VALUE self, VALUE val)
|
1748
|
+
{
|
1749
|
+
primitive_conversion = (val == Qnil || val == Qfalse) ? Qfalse : Qtrue;
|
1750
|
+
return val;
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
/**
|
1754
|
+
* For JRuby conpatible optsion
|
1755
|
+
*/
|
1756
|
+
static VALUE rjb_s_get_pconversion(VALUE self)
|
1757
|
+
{
|
1758
|
+
return primitive_conversion;
|
1759
|
+
}
|
1760
|
+
|
1761
|
+
|
1733
1762
|
/*
|
1734
1763
|
* free java class
|
1735
1764
|
*/
|
@@ -2657,6 +2686,8 @@ void Init_rjbcore()
|
|
2657
2686
|
rb_define_module_function(rjb, "bind", rjb_s_bind, 2);
|
2658
2687
|
rb_define_module_function(rjb, "classes", rjb_s_classes, 0);
|
2659
2688
|
rb_define_module_function(rjb, "throw", rjb_s_throw, -1);
|
2689
|
+
rb_define_module_function(rjb, "primitive_conversion=", rjb_s_set_pconversion, 1);
|
2690
|
+
rb_define_module_function(rjb, "primitive_conversion", rjb_s_get_pconversion, 0);
|
2660
2691
|
rb_define_const(rjb, "VERSION", rb_str_new2(RJB_VERSION));
|
2661
2692
|
|
2662
2693
|
/* Java class object */
|
data/lib/rjbcore.so
CHANGED
Binary file
|
data/test/test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/local/env ruby
|
2
|
-
# $Id: test.rb
|
2
|
+
# $Id: test.rb 19 2007-09-14 14:59:29Z arton $
|
3
3
|
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rjb'
|
@@ -9,6 +9,7 @@ class TestRjb < Test::Unit::TestCase
|
|
9
9
|
include Rjb
|
10
10
|
def setup
|
11
11
|
load('.')
|
12
|
+
Rjb::primitive_conversion = false
|
12
13
|
end
|
13
14
|
|
14
15
|
def tearDown
|
@@ -435,5 +436,26 @@ class TestRjb < Test::Unit::TestCase
|
|
435
436
|
sb.length = 2
|
436
437
|
assert_equal('aB', sb.to_string)
|
437
438
|
end
|
439
|
+
|
440
|
+
def test_auto_conv
|
441
|
+
assert_equal(false, Rjb::primitive_conversion)
|
442
|
+
Rjb::primitive_conversion = true
|
443
|
+
assert_equal(true, Rjb::primitive_conversion)
|
444
|
+
jInteger = Rjb::import('java.lang.Integer')
|
445
|
+
assert_equal(1, jInteger.valueOf('1'))
|
446
|
+
assert_equal(-1, jInteger.valueOf('-1'))
|
447
|
+
jShort = Rjb::import('java.lang.Short')
|
448
|
+
assert_equal(2, jShort.valueOf('2'))
|
449
|
+
assert_equal(-2, jShort.valueOf('-2'))
|
450
|
+
jDouble = Rjb::import('java.lang.Double')
|
451
|
+
assert_equal(3.1, jDouble.valueOf('3.1'))
|
452
|
+
jFloat = Rjb::import('java.lang.Float')
|
453
|
+
assert_equal(4.5, jFloat.valueOf('4.5'))
|
454
|
+
jBoolean = Rjb::import('java.lang.Boolean')
|
455
|
+
assert(jBoolean.TRUE)
|
456
|
+
jByte = Rjb::import('java.lang.Byte')
|
457
|
+
assert_equal(5, jByte.valueOf('5'))
|
458
|
+
assert_equal(-6, jByte.valueOf('-6'))
|
459
|
+
end
|
438
460
|
end
|
439
461
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
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.0.7
|
7
|
+
date: 2007-09-14 00:00:00 +09:00
|
8
8
|
summary: Ruby Java bridge
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,22 +32,22 @@ files:
|
|
32
32
|
- ext/RBridge.java
|
33
33
|
- ext/load.c
|
34
34
|
- ext/riconv.c
|
35
|
-
- ext/rjbexception.c
|
36
35
|
- ext/rjb.c
|
36
|
+
- ext/rjbexception.c
|
37
37
|
- ext/jniwrap.h
|
38
|
-
- ext/rjb.h
|
39
|
-
- ext/riconv.h
|
40
38
|
- ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
|
39
|
+
- ext/riconv.h
|
40
|
+
- ext/rjb.h
|
41
41
|
- ext/depend
|
42
42
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
43
43
|
- lib/rjb.rb
|
44
44
|
- samples/filechooser.rb
|
45
|
-
- test/test.rb
|
46
45
|
- test/gctest.rb
|
46
|
+
- test/test.rb
|
47
|
+
- test/jp/co/infoseek/hp/arton/rjb/Base.class
|
47
48
|
- test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
|
48
|
-
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
49
49
|
- test/jp/co/infoseek/hp/arton/rjb/IBase.class
|
50
|
-
- test/jp/co/infoseek/hp/arton/rjb/
|
50
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
51
51
|
- COPYING
|
52
52
|
- ChangeLog
|
53
53
|
- readme.sj
|