rjb 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,11 @@
1
+ Sun Aug 19 arton
2
+ *ext/rjb.c
3
+ export bound object's original ruby object as @wrapped
4
+ RJB_VERSION -> 1.4.1
5
+ *lib/rjb.rb
6
+ define Rjb_JavaBridge class for support @wrapped delegation
7
+ *test/test.rb
8
+ add @wrapped object invoking test
1
9
  Sun Apr 22 arton
2
10
  *ext/rjb.c
3
11
  add Rjb_JavaProxy#initialize_proxy method for preparing proxy instance.
@@ -1,9 +1,8 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #define HAVE_JNI_H 1
4
- #define HAVE_RUBY_DL_H 1
5
- #define HAVE_NL_LANGINFO 1
6
- #define HAVE_SETLOCALE 1
7
- #define HAVE_GETENV 1
8
- #define RJB_RUBY_VERSION_CODE 193
9
- #endif
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_JNI_H 1
4
+ #define HAVE_DL_H 1
5
+ #define HAVE_SETLOCALE 1
6
+ #define HAVE_GETENV 1
7
+ #define RJB_RUBY_VERSION_CODE 187
8
+ #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/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 187 2012-04-22 12:35:49Z arton $
15
+ * $Id: rjb.c 191 2012-08-18 15:04:18Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.4.0"
18
+ #define RJB_VERSION "1.4.1"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "extconf.h"
@@ -2390,6 +2390,7 @@ static VALUE rjb_s_bind(VALUE self, VALUE rbobj, VALUE itfname)
2390
2390
  ptr->wrapped = rbobj;
2391
2391
  result = Data_Wrap_Struct(rjbb, rj_bridge_mark, rj_bridge_free, ptr);
2392
2392
  rb_ary_push(proxies, result);
2393
+ rb_ivar_set(result, rb_intern("@wrapped"), rbobj);
2393
2394
  }
2394
2395
  return result;
2395
2396
  }
data/lib/rjb.rb CHANGED
@@ -97,4 +97,13 @@ module Rjb
97
97
  end
98
98
  end
99
99
  end
100
+ class Rjb_JavaBridge
101
+ def method_missing(name, *args)
102
+ @wrapped.__send__(name, *args)
103
+ end
104
+ def respond_to?(name, inc_private = false)
105
+ @wrapped.respond_to?(name, inc_private)
106
+ end
107
+ attr_reader :wrapped
108
+ end
100
109
  end
data/readme.txt CHANGED
@@ -1,28 +1,35 @@
1
- Rjb is Ruby-Java bridge using Java Native Interface.
2
-
3
- How to install
4
-
5
- you need to install Java2 sdk, and setup JAVA_HOME enviromental varible except for OS X.
6
- I assume that OS X's JAVA_HOME is fixed as '/System/Library/Frameworks/JavaVM.framework'.
7
-
8
- then,
9
-
10
- ruby setup.rb config
11
- ruby setup.rb setup
12
-
13
- (in Unix)
14
- sudo ruby setup.rb install
15
- or
16
- (in win32)
17
- ruby setup.rb install
18
-
19
- How to test
20
- in Win32
21
- cd test
22
- ruby test.rb
23
-
24
- in Unix
25
- see test/readme.unix
26
- you must set LD_LIBRARY_PATH environmental variable to run rjb.
27
-
28
- artonx@yahoo.co.jp
1
+ Rjb is Ruby-Java bridge using Java Native Interface.
2
+
3
+ How to install
4
+
5
+ you need to install Java2 sdk, and setup JAVA_HOME enviromental varible except for OS X.
6
+ I assume that OS X's JAVA_HOME is fixed as '/System/Library/Frameworks/JavaVM.framework'.
7
+
8
+ then,
9
+
10
+ ruby setup.rb config
11
+ ruby setup.rb setup
12
+
13
+ (in Unix)
14
+ sudo ruby setup.rb install
15
+ or
16
+ (in win32)
17
+ ruby setup.rb install
18
+
19
+ How to test
20
+ in Win32
21
+ cd test
22
+ ruby test.rb
23
+
24
+ in Unix
25
+ see test/readme.unix
26
+ you must set LD_LIBRARY_PATH environmental variable to run rjb.
27
+
28
+ -- Notice for opening non-ASCII 7bit filename
29
+ If you'll plan to open the non-ascii character named file by Java class through Rjb, it may require to set LC_ALL environment variable in you sciprt.
30
+ For example in Rails, set above line in production.rb as your environment.
31
+ ENV['LC_ALL'] = 'en_us.utf8' # or ja_JP.utf8 etc.
32
+ cf: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4733494
33
+ (Thanks Paul for this information).
34
+
35
+ artonx@yahoo.co.jp
File without changes
@@ -1,6 +1,6 @@
1
1
  #!/usr/local/env ruby -Ku
2
2
  # encoding: utf-8
3
- # $Id: test.rb 176 2011-11-09 14:27:28Z arton $
3
+ # $Id: test.rb 191 2012-08-18 15:04:18Z arton $
4
4
 
5
5
  begin
6
6
  require 'rjb'
@@ -256,7 +256,7 @@ class TestRjb < Test::Unit::TestCase
256
256
  it = bind(it, 'java.util.Iterator')
257
257
  test = import('jp.co.infoseek.hp.arton.rjb.Test')
258
258
  a = test.new
259
- assert("43210", a.concat(it))
259
+ assert_equal("43210", a.concat(it))
260
260
  end
261
261
 
262
262
  def test_unbind()
@@ -811,5 +811,42 @@ class TestRjb < Test::Unit::TestCase
811
811
  end
812
812
  end
813
813
 
814
+ class CbTest
815
+ def method(l, s, i, d, str)
816
+ "test_ok:#{l}-#{s}-#{i}-#{d}-#{str}"
817
+ end
818
+ end
819
+ def test_longcallback()
820
+ cb = bind(CbTest.new, 'jp.co.infoseek.hp.arton.rjb.CallbackTest$Callback')
821
+ test = import('jp.co.infoseek.hp.arton.rjb.CallbackTest')
822
+ assert_equal 'test_ok:1234-1234-1234-1234.5-1234', test.callCallback(cb)
823
+ end
824
+
825
+ class TestIterEx < TestIter
826
+ def initialize()
827
+ super
828
+ @strattr = 'strattr'
829
+ @numattr = 32
830
+ end
831
+ attr_accessor :strattr, :numattr
832
+ def multargs(a, b)
833
+ a + b
834
+ end
835
+ end
836
+ def test_method_otherthan_bound()
837
+ it = TestIterEx.new
838
+ it = bind(it, 'java.util.Iterator')
839
+ test = import('jp.co.infoseek.hp.arton.rjb.Test')
840
+ a = test.new
841
+ assert_equal("43210", a.concat(it))
842
+ assert(it.respond_to?(:numattr))
843
+ assert(it.respond_to?(:multargs))
844
+ assert_equal(32, it.numattr)
845
+ assert_equal('strattr', it.strattr)
846
+ it.numattr += 1
847
+ assert_equal(33, it.numattr)
848
+ assert_equal(5, it.multargs(3, 2))
849
+ end
850
+
814
851
  end
815
852
 
File without changes
metadata CHANGED
@@ -1,83 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rjb
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.0
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 1.4.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - arton
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-22 00:00:00.000000000 Z
12
+
13
+ date: 2012-08-18 00:00:00 Z
13
14
  dependencies: []
14
- description: ! 'RJB is a bridge program that connect between Ruby and Java with Java
15
- Native Interface.
16
15
 
17
- '
16
+ description: |
17
+ RJB is a bridge program that connect between Ruby and Java with Java Native Interface.
18
+
18
19
  email: artonx@gmail.com
19
20
  executables: []
20
- extensions:
21
+
22
+ extensions:
21
23
  - ext/extconf.rb
22
24
  extra_rdoc_files: []
23
- files:
25
+
26
+ files:
24
27
  - ext/RBridge.java
25
28
  - ext/rjbexception.c
26
29
  - ext/rjb.c
27
- - ext/riconv.c
28
30
  - ext/load.c
29
- - ext/rjb.h
31
+ - ext/riconv.c
30
32
  - ext/extconf.h
31
- - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
32
33
  - ext/jniwrap.h
34
+ - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
35
+ - ext/rjb.h
33
36
  - ext/riconv.h
34
37
  - ext/depend
35
38
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
36
- - lib/rjb.rb
37
39
  - lib/rjbextension.rb
40
+ - lib/rjb.rb
38
41
  - samples/filechooser.rb
39
42
  - samples/unzip.rb
40
- - test/test.rb
43
+ - test/jartest.rb
44
+ - test/gctest.rb
41
45
  - test/test_osxjvm.rb
46
+ - test/test.rb
42
47
  - test/exttest.rb
43
- - test/jartest3.rb
44
48
  - test/jartest2.rb
45
- - test/gctest.rb
46
- - test/listtest.rb
49
+ - test/jartest3.rb
47
50
  - test/test_unload.rb
48
- - test/jartest.rb
49
- - test/TwoCaller.class
50
- - test/Two.class
51
- - test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
51
+ - test/listtest.rb
52
52
  - test/jp/co/infoseek/hp/arton/rjb/Test.class
53
+ - test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
54
+ - test/jp/co/infoseek/hp/arton/rjb/CallbackTest$Callback.class
55
+ - test/jp/co/infoseek/hp/arton/rjb/CallbackTest.class
53
56
  - test/jp/co/infoseek/hp/arton/rjb/IBase.class
57
+ - test/Two.class
58
+ - test/TwoCaller.class
59
+ - test/jartest.jar
54
60
  - test/jartest2.jar
55
61
  - test/rjbtest.jar
56
- - test/jartest.jar
57
62
  - COPYING
58
63
  - ChangeLog
59
- - readme.txt
60
64
  - readme.sj
65
+ - readme.txt
61
66
  - ext/extconf.rb
62
67
  homepage: http://rjb.rubyforge.org/
63
68
  licenses: []
69
+
64
70
  post_install_message:
65
71
  rdoc_options: []
66
- require_paths:
72
+
73
+ require_paths:
67
74
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
69
76
  none: false
70
- requirements:
71
- - - ! '>='
72
- - !ruby/object:Gem::Version
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
73
80
  version: 1.8.2
74
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
82
  none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- requirements:
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ requirements:
81
88
  - none
82
89
  - JDK 5.0
83
90
  rubyforge_project: rjb
@@ -85,5 +92,5 @@ rubygems_version: 1.8.23
85
92
  signing_key:
86
93
  specification_version: 3
87
94
  summary: Ruby Java bridge
88
- test_files:
95
+ test_files:
89
96
  - test/test.rb