rjb 1.6.8 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +13 -0
- data/README.md +65 -0
- data/ext/extconf.h +1 -1
- data/ext/riconv.c +6 -4
- data/ext/rjb.c +7 -2
- data/test/l.rb +11 -0
- data/test/listtest.rb +5 -1
- data/test/test.rb +22 -1
- metadata +9 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb30d6521841ff5187f03891746f241d1484f6acec69219124321a77d0f9e183
|
4
|
+
data.tar.gz: fcbcc52de14fd2103fdb2e3ffad9644cbf74587c621c5362c02a4fa46c6a40b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f20a728bad840480a3851c78a60970cd6e773d3b4261c8d738099177af9f69d04010d7ba3c4ee914dcbed0c5608976689ba4a7cd7d94797d523709ab1b81ad
|
7
|
+
data.tar.gz: 499ca077eb5cedae7eef353d2964a7e6be942bcbddcf14939d141913856ede4a2d5f09cbf76a0edebb4cb00c021ba64859dc1517dc9769a85ea609b46ec9b249
|
data/ChangeLog
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
Sun Apr 14 2024 arton
|
2
|
+
* ext/rjb.c
|
3
|
+
RJB_VERSION -> 1.7.0
|
4
|
+
java2jniname replaces second '.' to '$' for nested/inner classes
|
5
|
+
* test/test.rb
|
6
|
+
add test_load_nested/inner_class_as_java_naming_convention
|
7
|
+
Thu Nov 9 2023 arton
|
8
|
+
* ext/rjb.c
|
9
|
+
RJB_VERSION -> 1.6.9
|
10
|
+
* ext/riconv.c
|
11
|
+
fix CESU-8 check
|
12
|
+
* test/test.rb
|
13
|
+
add test_jav_hangul_syllable for checking CESU-8 bug (char start with 0xed)
|
1
14
|
Thu Sep 28 2023 chaddow
|
2
15
|
#93 fake allocation framework to remove T_DATA warning
|
3
16
|
* ext/rjb.c
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Rjb is Ruby-Java bridge using Java Native Interface.
|
2
|
+
|
3
|
+
The [Ruby Kaigi 2010](http://www.slideshare.net/artonx/j-ruby-kaigi-2010)
|
4
|
+
Presentation on `Rjb`.
|
5
|
+
|
6
|
+
A short [introduction](https://www.artonx.org/collabo/backyard/?RubyJavaBridge)
|
7
|
+
in English.
|
8
|
+
|
9
|
+
Some [examples](https://www.artonx.org/collabo/backyard/?RjbQandA) in
|
10
|
+
Japanese, but the source code is clear for everybody.
|
11
|
+
|
12
|
+
# How to install
|
13
|
+
|
14
|
+
You need to install Java2 sdk, and setup `JAVA_HOME` enviromental
|
15
|
+
varible except for OS X. I assume that OS X's `JAVA_HOME` is reported
|
16
|
+
by calling `/usr/libexec/java_home`.
|
17
|
+
|
18
|
+
This done please proceed with:
|
19
|
+
|
20
|
+
``` bash
|
21
|
+
ruby setup.rb config
|
22
|
+
ruby setup.rb setup
|
23
|
+
```
|
24
|
+
|
25
|
+
``` bash
|
26
|
+
# (in Unix)
|
27
|
+
sudo ruby setup.rb install
|
28
|
+
```
|
29
|
+
|
30
|
+
or
|
31
|
+
|
32
|
+
``` bash
|
33
|
+
# (in win32)
|
34
|
+
ruby setup.rb install
|
35
|
+
```
|
36
|
+
|
37
|
+
# How to test
|
38
|
+
|
39
|
+
On Windows based machines:
|
40
|
+
|
41
|
+
``` bash
|
42
|
+
cd test
|
43
|
+
ruby test.rb
|
44
|
+
```
|
45
|
+
|
46
|
+
On Unix based machines plese see `test/readme.unix`. You need to set
|
47
|
+
`LD_LIBRARY_PATH` environmental variable to run `rjb`.
|
48
|
+
|
49
|
+
# Notice for opening non-ASCII 7bit filename
|
50
|
+
|
51
|
+
If you'll plan to open the non-ascii character named file by Java
|
52
|
+
class through Rjb, it may require to set LC_ALL environment variable
|
53
|
+
in your script.
|
54
|
+
|
55
|
+
For example in Rails, set above line in `production.rb` as your environment:
|
56
|
+
|
57
|
+
``` bash
|
58
|
+
ENV['LC_ALL'] = 'en_us.utf8' # or ja_JP.utf8 etc.
|
59
|
+
```
|
60
|
+
|
61
|
+
cf: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4733494
|
62
|
+
(Thanks Paul for this information).
|
63
|
+
|
64
|
+
# Contact
|
65
|
+
artonx@yahoo.co.jp
|
data/ext/extconf.h
CHANGED
data/ext/riconv.c
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
*
|
15
15
|
* $Id: riconv.c 117 2010-06-04 12:16:25Z arton $
|
16
16
|
*/
|
17
|
-
|
18
17
|
#include "ruby.h"
|
19
18
|
#include "extconf.h"
|
20
19
|
|
@@ -196,12 +195,15 @@ static int contains_auxchar(const unsigned char* p)
|
|
196
195
|
{
|
197
196
|
while (*p)
|
198
197
|
{
|
199
|
-
|
198
|
+
if (*p == 0xed && *(p + 1) && *(p + 2))
|
200
199
|
{
|
201
200
|
#if defined(DEBUG)
|
202
|
-
|
201
|
+
printf("find %02x %02x %02x %02x %02x %02x\n", *p, *(p + 1), *(p + 2), *(p + 3), *(p + 4), *(p + 5));
|
203
202
|
#endif
|
204
|
-
|
203
|
+
if ((*(p + 1) & 0xa0) == 0xa0 && (*(p + 2) & 0xb0) == 0xb0)
|
204
|
+
{
|
205
|
+
return 1;
|
206
|
+
}
|
205
207
|
}
|
206
208
|
switch (*p & 0xe0)
|
207
209
|
{
|
data/ext/rjb.c
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
*
|
15
15
|
*/
|
16
16
|
|
17
|
-
#define RJB_VERSION "1.
|
17
|
+
#define RJB_VERSION "1.7.0"
|
18
18
|
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "extconf.h"
|
@@ -185,11 +185,16 @@ void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs)
|
|
185
185
|
static char* java2jniname(char* jnicls)
|
186
186
|
{
|
187
187
|
char* p;
|
188
|
+
int found_class_separator = isupper(*jnicls) ? 1 : 0;
|
188
189
|
for (p = jnicls; *p; p++)
|
189
190
|
{
|
190
191
|
if (*p == '.')
|
191
192
|
{
|
192
|
-
*p
|
193
|
+
if (isupper(*(p + 1)))
|
194
|
+
{
|
195
|
+
found_class_separator++;
|
196
|
+
}
|
197
|
+
*p = (found_class_separator <= 1) ? '/' : '$';
|
193
198
|
}
|
194
199
|
}
|
195
200
|
return jnicls;
|
data/test/l.rb
ADDED
data/test/listtest.rb
CHANGED
@@ -4,20 +4,22 @@
|
|
4
4
|
Copyright(c) 2012 arton
|
5
5
|
=end
|
6
6
|
|
7
|
+
require 'test/unit'
|
7
8
|
begin
|
8
9
|
require 'rjb/list'
|
9
10
|
rescue LoadError
|
10
11
|
require 'rubygems'
|
11
12
|
require 'rjb/list'
|
12
13
|
end
|
13
|
-
require 'test/unit'
|
14
14
|
require 'fileutils'
|
15
15
|
|
16
16
|
class ListTest < Test::Unit::TestCase
|
17
17
|
include Rjb
|
18
18
|
def test_create
|
19
19
|
ja = import('java.util.ArrayList')
|
20
|
+
p 'imported'
|
20
21
|
a = ja.new
|
22
|
+
p 'new'
|
21
23
|
a.add(1)
|
22
24
|
a.add(2)
|
23
25
|
a.add(3)
|
@@ -28,6 +30,7 @@ class ListTest < Test::Unit::TestCase
|
|
28
30
|
end
|
29
31
|
assert_equal 4, n
|
30
32
|
end
|
33
|
+
=begin
|
31
34
|
def test_returned_proxy
|
32
35
|
ja = import('java.util.Arrays')
|
33
36
|
a = ja.as_list([1, 2, 3])
|
@@ -52,5 +55,6 @@ class ListTest < Test::Unit::TestCase
|
|
52
55
|
ja = import('java.util.Arrays')
|
53
56
|
assert_equal 55, ja.as_list((1..10).to_a).inject(0) {|r, e| r + e.intValue}
|
54
57
|
end
|
58
|
+
=end
|
55
59
|
end
|
56
60
|
|
data/test/test.rb
CHANGED
@@ -960,10 +960,20 @@ class TestRjb < Test::Unit::TestCase
|
|
960
960
|
end
|
961
961
|
|
962
962
|
def test_java_utf8
|
963
|
-
y = @jString.new('𠮷野家')
|
963
|
+
y = @jString.new('𠮷野家') # with surrogate pair
|
964
964
|
assert_equal '𠮷野家', y.toString
|
965
965
|
end
|
966
966
|
|
967
|
+
def test_java_hangul_syllable
|
968
|
+
# 토 \uD1A => ED 86 A0 (utf-8)
|
969
|
+
test_string = "토" # simple unicode char (not surrogate pair)
|
970
|
+
y = @jString.new_with_sig('Ljava.lang.String;', test_string)
|
971
|
+
assert_equal(test_string, y.toString)
|
972
|
+
test_string = "토토" # simple unicode char (not surrogate pair)
|
973
|
+
y = @jString.new_with_sig('Ljava.lang.String;', test_string)
|
974
|
+
assert_equal(test_string, y.toString)
|
975
|
+
end
|
976
|
+
|
967
977
|
def test_respond_to
|
968
978
|
str = @jString.new('blabla')
|
969
979
|
assert str.respond_to? :substring
|
@@ -976,4 +986,15 @@ class TestRjb < Test::Unit::TestCase
|
|
976
986
|
assert_false e.respond_to? :unknown_method
|
977
987
|
end
|
978
988
|
end
|
989
|
+
|
990
|
+
def test_load_nested_class_as_java_convention
|
991
|
+
tstate = import('java.lang.Thread.State')
|
992
|
+
assert_equal(tstate.BLOCKED.ordinal, 2)
|
993
|
+
assert_equal(tstate.BLOCKED.name, 'BLOCKED')
|
994
|
+
end
|
995
|
+
|
996
|
+
def test_load_inner_class_as_java_convention
|
997
|
+
tes = import('java.util.HashMap.EntrySet')
|
998
|
+
assert_equal(tes._classname, 'java.lang.Class')
|
999
|
+
end
|
979
1000
|
end
|
metadata
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: RJB is a Bridge library which connects Ruby and Java code using the Java
|
14
14
|
Native Interface.
|
15
|
-
|
16
|
-
'
|
17
15
|
email: artonx@gmail.com
|
18
16
|
executables: []
|
19
17
|
extensions:
|
@@ -22,6 +20,7 @@ extra_rdoc_files: []
|
|
22
20
|
files:
|
23
21
|
- COPYING
|
24
22
|
- ChangeLog
|
23
|
+
- README.md
|
25
24
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
26
25
|
- ext/RBridge.java
|
27
26
|
- ext/depend.erb
|
@@ -61,6 +60,7 @@ files:
|
|
61
60
|
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
62
61
|
- test/jp/co/infoseek/hp/arton/rjb/Two.class
|
63
62
|
- test/jp/co/infoseek/hp/arton/rjb/TwoCaller.class
|
63
|
+
- test/l.rb
|
64
64
|
- test/listtest.rb
|
65
65
|
- test/osx_jvmcheck.rb
|
66
66
|
- test/rjbtest.jar
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- test/test_osxjvm.rb
|
69
69
|
- test/test_osxload.rb
|
70
70
|
- test/test_unload.rb
|
71
|
-
homepage:
|
71
|
+
homepage: http://www.artonx.org/collabo/backyard/?RubyJavaBridge
|
72
72
|
licenses:
|
73
73
|
- LGPL-2.1-or-later
|
74
74
|
metadata: {}
|
@@ -87,11 +87,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements:
|
90
|
-
- none
|
91
90
|
- JDK 5.0
|
92
|
-
rubygems_version: 3.
|
91
|
+
rubygems_version: 3.5.3
|
93
92
|
signing_key:
|
94
93
|
specification_version: 4
|
95
|
-
summary: Ruby Java
|
96
|
-
test_files:
|
97
|
-
- test/test.rb
|
94
|
+
summary: Ruby Java Bridge
|
95
|
+
test_files: []
|