rjb 1.5.4 → 1.5.5
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.
- checksums.yaml +4 -4
- data/ChangeLog +725 -703
- data/README.md +65 -0
- data/ext/extconf.h +1 -1
- data/ext/extconf.rb +1 -0
- data/ext/jniwrap.h +34 -34
- data/ext/jp_co_infoseek_hp_arton_rjb_RBridge.h +21 -21
- data/ext/load.c +2 -0
- data/ext/rjb.c +2 -2
- data/lib/rjb.rb +3 -0
- data/lib/rjb/version.rb +27 -0
- data/lib/rjbextension.rb +1 -1
- data/readme.sj +27 -27
- data/test/exttest.rb +39 -39
- data/test/jartest.rb +24 -24
- data/test/jartest2.rb +23 -23
- data/test/jartest3.rb +28 -28
- data/test/jp/co/infoseek/hp/arton/rjb/CallbackTest$Callback.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/CallbackTest.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/IBase.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/JarTest.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/JarTest2.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/jp/co/infoseek/hp/arton/rjb/Two.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/TwoCaller.class +0 -0
- data/test/test.rb +26 -26
- data/test/test_unload.rb +26 -26
- metadata +14 -26
- data/test/Base.class +0 -0
- data/test/CallbackTest$Callback.class +0 -0
- data/test/CallbackTest.class +0 -0
- data/test/ExtBase.class +0 -0
- data/test/IBase.class +0 -0
- data/test/JTest.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/jp/co/infoseek/hp/arton/rjb/JTest.class +0 -0
- data/test/js.rb +0 -54
- data/test/reader.rb +0 -11
- data/test/reader2.rb +0 -12
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 you sciprt.
|
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: http://bugs.sun.com/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/extconf.rb
CHANGED
data/ext/jniwrap.h
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
/*
|
2
|
-
* Rjb - Ruby <-> Java Bridge
|
3
|
-
* Copyright(c) 2006 Kuwashima
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* $Id: jniwrap.h 181 2012-01-28 05:28:41Z arton $
|
16
|
-
*/
|
17
|
-
#ifndef _Included_jniwrap
|
18
|
-
#define _Included_jniwrap
|
19
|
-
#ifdef __cplusplus
|
20
|
-
extern "C" {
|
21
|
-
#endif
|
22
|
-
|
23
|
-
#if defined(__GNUC__) && (defined(__CYGWIN32__) || defined(__MINGW32__))
|
24
|
-
#if !defined(__int64)
|
25
|
-
typedef long long __int64;
|
26
|
-
#endif
|
27
|
-
#endif
|
28
|
-
|
29
|
-
#include <jni.h>
|
30
|
-
|
31
|
-
#ifdef __cplusplus
|
32
|
-
}
|
33
|
-
#endif
|
34
|
-
#endif
|
1
|
+
/*
|
2
|
+
* Rjb - Ruby <-> Java Bridge
|
3
|
+
* Copyright(c) 2006 Kuwashima
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* $Id: jniwrap.h 181 2012-01-28 05:28:41Z arton $
|
16
|
+
*/
|
17
|
+
#ifndef _Included_jniwrap
|
18
|
+
#define _Included_jniwrap
|
19
|
+
#ifdef __cplusplus
|
20
|
+
extern "C" {
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#if defined(__GNUC__) && (defined(__CYGWIN32__) || defined(__MINGW32__))
|
24
|
+
#if !defined(__int64)
|
25
|
+
typedef long long __int64;
|
26
|
+
#endif
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include <jni.h>
|
30
|
+
|
31
|
+
#ifdef __cplusplus
|
32
|
+
}
|
33
|
+
#endif
|
34
|
+
#endif
|
@@ -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
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,2011,2012,2014 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010,2011,2012,2014-2016 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
|
@@ -14,7 +14,7 @@
|
|
14
14
|
*
|
15
15
|
*/
|
16
16
|
|
17
|
-
#define RJB_VERSION "1.5.
|
17
|
+
#define RJB_VERSION "1.5.5"
|
18
18
|
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "extconf.h"
|
data/lib/rjb.rb
CHANGED
@@ -45,6 +45,9 @@ module RjbConf
|
|
45
45
|
ENV['JVM_LIB'] = jvms[0]
|
46
46
|
end
|
47
47
|
end
|
48
|
+
elsif /win32|win64/ =~ RUBY_PLATFORM
|
49
|
+
# add JRE bin directory for further DLLs
|
50
|
+
ENV['PATH'] = "#{ENV['JAVA_HOME']}\\jre\\bin;#{ENV['PATH']}"
|
48
51
|
end
|
49
52
|
|
50
53
|
dir = File.join(File.dirname(File.dirname(__FILE__)), 'data')
|
data/lib/rjb/version.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rjb
|
2
|
+
class << self
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
# @return [String, nil] the valid version number. Can be nil.
|
7
|
+
def read_version
|
8
|
+
path = File.expand_path('../../../ext/rjb.c', __FILE__)
|
9
|
+
File.open(path) do |f|
|
10
|
+
f.each_line do |l|
|
11
|
+
m = /RJB_VERSION\s+"(.+?)"/.match(l)
|
12
|
+
|
13
|
+
# The file is closed even in this case.
|
14
|
+
return m[1] if m
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# The `Rjb` module defines `VERSION` in the C code.
|
21
|
+
# If Rjb is already required we have the constant.
|
22
|
+
unless defined?(::Rjb::VERSION)
|
23
|
+
unless (VERSION = read_version)
|
24
|
+
raise 'Cannot find a valid version number in `rjb.c`!'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rjbextension.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'rjb/extension'
|
1
|
+
require 'rjb/extension'
|
data/readme.sj
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
1. unzip rjb-*
|
10
|
-
2. cd rjb-*
|
11
|
-
3. ruby setup.rb config
|
12
|
-
4. ruby setup.rb setup
|
13
|
-
5. sudo ruby setup.rb install
|
14
|
-
Windows
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Windows2000 SP4-ruby1.8.2-j2se1.5.0, Solaris9-ruby1.8.0-j2se1.4.2, Linux 2.4.26-ruby-1.8.1-j2se1.4.2
|
23
|
-
|
24
|
-
|
25
|
-
artonx@yahoo.co.jp
|
26
|
-
|
27
|
-
|
1
|
+
準備
|
2
|
+
・あらかじめ環境変数にJAVA_HOMEを設定しておいてください。
|
3
|
+
・この場合、JAVA_HOMEは、J2SDKのインストールディレクトリの必要があります。
|
4
|
+
・あらかじめ環境変数PATHに$JAVA_HOME/binを設定しておいてください。
|
5
|
+
・Windowsの場合、PATHには%PATH%;%JAVA_HOME%binを設定することになります。
|
6
|
+
・ruby1.8以降が実行できるようにPATHを設定しておいてください。
|
7
|
+
|
8
|
+
インストール方法
|
9
|
+
1. unzip rjb-*
|
10
|
+
2. cd rjb-*
|
11
|
+
3. ruby setup.rb config
|
12
|
+
4. ruby setup.rb setup
|
13
|
+
5. sudo ruby setup.rb install
|
14
|
+
Windowsでは、ほとんどの場合最初のsudoは不要です。「ほとんどの場合」に該当しない場合は何が必要かはわかっているはずですので説明は省略します。
|
15
|
+
|
16
|
+
実行時
|
17
|
+
・あらかじめ環境変数にJAVA_HOMEを設定しておいてください。
|
18
|
+
・この場合、JAVA_HOMEは、J2SDKのインストールディレクトリの必要があります。
|
19
|
+
・Linuxに関してはLD_LIBRARY_PATHに、java2の共有オブジェクトディレクトリを設定しておく必要があります。
|
20
|
+
|
21
|
+
テストした環境
|
22
|
+
Windows2000 SP4-ruby1.8.2-j2se1.5.0, Solaris9-ruby1.8.0-j2se1.4.2, Linux 2.4.26-ruby-1.8.1-j2se1.4.2
|
23
|
+
|
24
|
+
連絡先
|
25
|
+
artonx@yahoo.co.jp
|
26
|
+
https://www.artonx.org/collabo/backyard/?RjbQandA (記入時にはdiaryへツッコミを入れてください)
|
27
|
+
|
data/test/exttest.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
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
|
-
|
12
|
-
if Rjb::VERSION < '1.2.2'
|
13
|
-
puts "Rjb #{Rjb::VERSION} does not support rjbextension. exit"
|
14
|
-
exit 0
|
15
|
-
end
|
16
|
-
|
17
|
-
require 'rjbextension'
|
18
|
-
require 'test/unit'
|
19
|
-
require 'fileutils'
|
20
|
-
|
21
|
-
FileUtils.rm_f 'jp/co/infoseek/hp/arton/rjb/Base.class'
|
22
|
-
|
23
|
-
puts "start RJB(#{Rjb::VERSION}) test"
|
24
|
-
class ExtTestRjb < Test::Unit::TestCase
|
25
|
-
|
26
|
-
def jp
|
27
|
-
JavaPackage.new('jp')
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_require_extension
|
31
|
-
assert !Rjb::loaded?
|
32
|
-
$LOAD_PATH << '.'
|
33
|
-
require 'rjbtest.jar'
|
34
|
-
Rjb::load
|
35
|
-
assert Rjb::loaded?
|
36
|
-
base = jp.co.infoseek.hp.arton.rjb.Base.new
|
37
|
-
assert_equal('hello', base.instance_var)
|
38
|
-
end
|
39
|
-
end
|
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
|
+
|
12
|
+
if Rjb::VERSION < '1.2.2'
|
13
|
+
puts "Rjb #{Rjb::VERSION} does not support rjbextension. exit"
|
14
|
+
exit 0
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rjbextension'
|
18
|
+
require 'test/unit'
|
19
|
+
require 'fileutils'
|
20
|
+
|
21
|
+
FileUtils.rm_f 'jp/co/infoseek/hp/arton/rjb/Base.class'
|
22
|
+
|
23
|
+
puts "start RJB(#{Rjb::VERSION}) test"
|
24
|
+
class ExtTestRjb < Test::Unit::TestCase
|
25
|
+
|
26
|
+
def jp
|
27
|
+
JavaPackage.new('jp')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_require_extension
|
31
|
+
assert !Rjb::loaded?
|
32
|
+
$LOAD_PATH << '.'
|
33
|
+
require 'rjbtest.jar'
|
34
|
+
Rjb::load
|
35
|
+
assert Rjb::loaded?
|
36
|
+
base = jp.co.infoseek.hp.arton.rjb.Base.new
|
37
|
+
assert_equal('hello', base.instance_var)
|
38
|
+
end
|
39
|
+
end
|
data/test/jartest.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
#!/usr/local/env ruby -Ku
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rjb'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rjb'
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
class JarTest < Test::Unit::TestCase
|
13
|
-
include Rjb
|
14
|
-
|
15
|
-
def setup
|
16
|
-
Rjb::load()
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_depends
|
20
|
-
add_jar(File.expand_path('./jartest2.jar'))
|
21
|
-
add_jar(File.expand_path('./jartest.jar'))
|
22
|
-
assert Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
23
|
-
end
|
24
|
-
end
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rjb'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rjb'
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class JarTest < Test::Unit::TestCase
|
13
|
+
include Rjb
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Rjb::load()
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_depends
|
20
|
+
add_jar(File.expand_path('./jartest2.jar'))
|
21
|
+
add_jar(File.expand_path('./jartest.jar'))
|
22
|
+
assert Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
23
|
+
end
|
24
|
+
end
|