rjb 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +725 -703
  3. data/README.md +65 -0
  4. data/ext/extconf.h +1 -1
  5. data/ext/extconf.rb +1 -0
  6. data/ext/jniwrap.h +34 -34
  7. data/ext/jp_co_infoseek_hp_arton_rjb_RBridge.h +21 -21
  8. data/ext/load.c +2 -0
  9. data/ext/rjb.c +2 -2
  10. data/lib/rjb.rb +3 -0
  11. data/lib/rjb/version.rb +27 -0
  12. data/lib/rjbextension.rb +1 -1
  13. data/readme.sj +27 -27
  14. data/test/exttest.rb +39 -39
  15. data/test/jartest.rb +24 -24
  16. data/test/jartest2.rb +23 -23
  17. data/test/jartest3.rb +28 -28
  18. data/test/jp/co/infoseek/hp/arton/rjb/CallbackTest$Callback.class +0 -0
  19. data/test/jp/co/infoseek/hp/arton/rjb/CallbackTest.class +0 -0
  20. data/test/jp/co/infoseek/hp/arton/rjb/IBase.class +0 -0
  21. data/test/jp/co/infoseek/hp/arton/rjb/JarTest.class +0 -0
  22. data/test/jp/co/infoseek/hp/arton/rjb/JarTest2.class +0 -0
  23. data/test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class +0 -0
  24. data/test/jp/co/infoseek/hp/arton/rjb/Test.class +0 -0
  25. data/test/jp/co/infoseek/hp/arton/rjb/Two.class +0 -0
  26. data/test/jp/co/infoseek/hp/arton/rjb/TwoCaller.class +0 -0
  27. data/test/test.rb +26 -26
  28. data/test/test_unload.rb +26 -26
  29. metadata +14 -26
  30. data/test/Base.class +0 -0
  31. data/test/CallbackTest$Callback.class +0 -0
  32. data/test/CallbackTest.class +0 -0
  33. data/test/ExtBase.class +0 -0
  34. data/test/IBase.class +0 -0
  35. data/test/JTest.class +0 -0
  36. data/test/Test$TestTypes.class +0 -0
  37. data/test/Test.class +0 -0
  38. data/test/Two.class +0 -0
  39. data/test/TwoCaller.class +0 -0
  40. data/test/jp/co/infoseek/hp/arton/rjb/JTest.class +0 -0
  41. data/test/js.rb +0 -54
  42. data/test/reader.rb +0 -11
  43. data/test/reader2.rb +0 -12
@@ -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
@@ -4,5 +4,5 @@
4
4
  #define HAVE_NL_LANGINFO 1
5
5
  #define HAVE_SETLOCALE 1
6
6
  #define HAVE_GETENV 1
7
- #define RJB_RUBY_VERSION_CODE 230
7
+ #define RJB_RUBY_VERSION_CODE 240
8
8
  #endif
@@ -53,6 +53,7 @@ else
53
53
  raise "JAVA_HOME is not set."
54
54
  end
55
55
 
56
+
56
57
  def create_rjb_makefile
57
58
  if have_header("jni.h")
58
59
  have_func("locale_charset", "iconv.h")
@@ -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
@@ -77,6 +77,8 @@
77
77
  #define JVM_TYPE "server"
78
78
  #elif defined(i586) || defined(__i386__)
79
79
  #define ARCH "i386"
80
+ #elif defined(__arm__)
81
+ #define ARCH "arm"
80
82
  #endif
81
83
  #ifndef ARCH
82
84
  #include <sys/systeminfo.h>
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.4"
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')
@@ -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
@@ -1 +1 @@
1
- require 'rjb/extension'
1
+ require 'rjb/extension'
data/readme.sj CHANGED
@@ -1,27 +1,27 @@
1
- ����
2
- �E���炩���ߊ‹��ϐ���JAVA_HOME��ݒ肵�Ă����Ă��������B
3
- �E���̏ꍇ�AJAVA_HOME�́AJ2SDK�̃C���X�g�[���f�B���N�g���̕K�v������܂��B
4
- �E���炩���ߊ‹��ϐ�PATH��$JAVA_HOME/bin��ݒ肵�Ă����Ă��������B
5
- �EWindows�̏ꍇ�APATH�ɂ�%PATH%;%JAVA_HOME%bin��ݒ肷�邱�ƂɂȂ�܂��B
6
- �Eruby1.8�ȍ~�����s�ł���悤��PATH��ݒ肵�Ă����Ă��������B
7
-
8
- �C���X�g�[�����@
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�ł́A�قƂ�ǂ̏ꍇ�ŏ���sudo�͕s�v�ł��B�u�قƂ�ǂ̏ꍇ�v�ɊY�����Ȃ��ꍇ�͉����K�v���͂킩���Ă���͂��ł��̂Ő����͏ȗ����܂��B
15
-
16
- ���s��
17
- �E���炩���ߊ‹��ϐ���JAVA_HOME��ݒ肵�Ă����Ă��������B
18
- �E���̏ꍇ�AJAVA_HOME�́AJ2SDK�̃C���X�g�[���f�B���N�g���̕K�v������܂��B
19
- �ELinux�Ɋւ��Ă�LD_LIBRARY_PATH�ɁAjava2�̋��L�I�u�W�F�N�g�f�B���N�g����ݒ肵�Ă����K�v������܂��B
20
-
21
- �e�X�g�����‹�
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
- �A����
25
- artonx@yahoo.co.jp
26
- http://arton.no-ip.info/collabo/backyard/?RjbQandA (�L�����ɂ�diary�փc�b�R�~�����Ă��������j
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
+
@@ -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
@@ -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