rjb 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ Fri Jun 4 arton
2
+ *ext/riconv.c
3
+ remove unused function if build with Ruby 1.9
4
+ *ext/rjb.c
5
+ RJB_VERSION -> 1.2.3
6
+ to accomodate with rubinius
7
+ *ext/load.c
8
+ to accomodate with rubinius
9
+ *ext/rjbexception.c
10
+ to accomodate with rubinius
1
11
  Sun May 30 arton
2
12
  *lib/rjbextension.rb
3
13
  Rjb extension from Andreas Ronge's neo4j
@@ -0,0 +1,9 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_JNI_H 1
4
+ #define HAVE_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 187
9
+ #endif
data/ext/load.c CHANGED
@@ -12,7 +12,7 @@
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: load.c 112 2010-05-29 03:09:11Z arton $
15
+ * $Id: load.c 119 2010-06-04 12:51:34Z arton $
16
16
  */
17
17
 
18
18
  #include <stdlib.h>
@@ -104,11 +104,13 @@ static int open_jvm(char* libpath)
104
104
  VALUE* argv;
105
105
 
106
106
  rb_require("dl");
107
+ #if !defined(RUBINIUS)
107
108
  if (!rb_const_defined_at(rb_cObject, rb_intern("DL")))
108
109
  {
109
110
  rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
110
111
  return 0;
111
112
  }
113
+ #endif
112
114
  argv = ALLOCA_N(VALUE, 4);
113
115
  *argv = rb_const_get(rb_cObject, rb_intern("DL"));
114
116
  *(argv + 1) = rb_intern("dlopen");
@@ -204,8 +206,13 @@ static int load_bridge(JNIEnv* jenv)
204
206
  jmethodID getSysLoader = (*jenv)->GetStaticMethodID(jenv, loader,
205
207
  "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
206
208
  jobject iloader = (*jenv)->CallStaticObjectMethod(jenv, loader, getSysLoader);
209
+ #if defined(RUBINIUS)
210
+ VALUE v = rb_const_get(rb_cObject, rb_intern("RjbConf"));
211
+ v = rb_const_get(v, rb_intern("BRIDGE_FILE"));
212
+ #else
207
213
  VALUE v = rb_const_get_at(rb_const_get(rb_cObject, rb_intern("RjbConf")),
208
214
  rb_intern("BRIDGE_FILE"));
215
+ #endif
209
216
  bridge = StringValuePtr(v);
210
217
  #if defined(DOSISH)
211
218
  bridge = ALLOCA_N(char, strlen(bridge) + 8);
@@ -12,7 +12,7 @@
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: riconv.c 104 2010-03-16 12:19:18Z arton $
15
+ * $Id: riconv.c 117 2010-06-04 12:16:25Z arton $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
@@ -43,6 +43,7 @@ static const char* const CS_SJIS = "SHIFT_JIS";
43
43
  static const char* const CS_UTF8 = "UTF-8";
44
44
 
45
45
 
46
+ #if RJB_RUBY_VERSION_CODE < 190
46
47
  static VALUE objIconvJ2R;
47
48
  static VALUE objIconvR2J;
48
49
  static const char* charcode; //is this necessary?
@@ -58,7 +59,9 @@ static int find_table(const char* const str, const char* const table[])
58
59
  }
59
60
  return 0;
60
61
  }
62
+ #endif
61
63
 
64
+ #if RJB_RUBY_VERSION_CODE < 190
62
65
  static const char* get_charcode_name_by_locale(const char* const name)
63
66
  {
64
67
  if (find_table(name, LOCALE_UTF8_TABLE))
@@ -119,8 +122,9 @@ static const char* get_charcode_name()
119
122
  }
120
123
  return result;
121
124
  }
125
+ #endif
122
126
 
123
-
127
+ #if RJB_RUBY_VERSION_CODE < 190
124
128
  static void reinit()
125
129
  {
126
130
  charcode = get_charcode_name();
@@ -142,7 +146,9 @@ static void reinit()
142
146
  objIconvR2J = objIconvJ2R = Qnil;
143
147
  }
144
148
  }
149
+ #endif
145
150
 
151
+ #if RJB_RUBY_VERSION_CODE < 190
146
152
  static void check_kcode()
147
153
  {
148
154
  VALUE rb_iconv_klass = rb_const_get(rb_cObject, rb_intern("Iconv"));
@@ -161,6 +167,7 @@ static void check_kcode()
161
167
  objIconvR2J = objIconvJ2R = Qnil;
162
168
  }
163
169
  }
170
+ #endif
164
171
 
165
172
  VALUE exticonv_local_to_utf8(VALUE local_string)
166
173
  {
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 112 2010-05-29 03:09:11Z arton $
15
+ * $Id: rjb.c 119 2010-06-04 12:51:34Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.2.2"
18
+ #define RJB_VERSION "1.2.3"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "extconf.h"
@@ -55,7 +55,14 @@
55
55
  #define RJB_LOAD_STATIC_METHOD(var, obj, name, sig) \
56
56
  var = (*jenv)->GetStaticMethodID(jenv, obj, name, sig); \
57
57
  rjb_check_exception(jenv, 1)
58
- #define IS_RJB_OBJECT(v) (rb_class_inherited(rjbi, rb_obj_class(v)) || rb_obj_class(v) == rjb)
58
+ #if defined(RUBINIUS)
59
+ #define CLASS_NEW(obj, name) rb_define_class(name, obj)
60
+ #define CLASS_INHERITED(spr, kls) rb_funcall(spr, rb_intern("inherited"), 1, kls)
61
+ #else
62
+ #define CLASS_NEW(obj, name) rb_class_new(obj)
63
+ #define CLASS_INHERITED(spr, kls) rb_class_inherited(spr, kls)
64
+ #endif
65
+ #define IS_RJB_OBJECT(v) (CLASS_INHERITED(rjbi, rb_obj_class(v)) || rb_obj_class(v) == rjb)
59
66
  #define USER_INITIALIZE "@user_initialize"
60
67
 
61
68
  static void register_class(VALUE, VALUE);
@@ -780,7 +787,7 @@ static void rv2jobject(JNIEnv* jenv, VALUE val, jvalue* jv, const char* psig, in
780
787
  Data_Get_Struct(val, struct rj_bridge, ptr);
781
788
  jv->l = ptr->proxy;
782
789
  }
783
- else if (rb_class_inherited(rjbc, rb_obj_class(val)))
790
+ else if (CLASS_INHERITED(rjbc, rb_obj_class(val)))
784
791
  {
785
792
  struct jv_data* ptr;
786
793
  Data_Get_Struct(val, struct jv_data, ptr);
@@ -1780,10 +1787,10 @@ static int clear_classes(VALUE key, VALUE val, VALUE dummy)
1780
1787
  static VALUE rjb_s_unload(int argc, VALUE* argv, VALUE self)
1781
1788
  {
1782
1789
  int result = 0;
1783
- #ifdef HAVE_RB_HASH_FOREACH
1790
+ #if defined(HAVE_RB_HASH_FOREACH) || defined(RUBINIUS)
1784
1791
  rb_hash_foreach(rjb_loaded_classes, clear_classes, 0);
1785
1792
  #else
1786
- #ifdef RHASH_TBL
1793
+ #if defined(RHASH_TBL)
1787
1794
  st_foreach(RHASH_TBL(rjb_loaded_classes), clear_classes, 0);
1788
1795
  #else
1789
1796
  st_foreach(RHASH(rjb_loaded_classes)->tbl, clear_classes, 0);
@@ -2264,7 +2271,11 @@ static VALUE rjb_class_eval(int argc, VALUE* argv, VALUE self)
2264
2271
  static VALUE rjb_s_unbind(VALUE self, VALUE rbobj)
2265
2272
  {
2266
2273
  JNIEnv* jenv = rjb_prelude();
2274
+ #if defined(RUBINIUS)
2275
+ return rb_funcall(proxies, rb_intern("delete"), 1, rbobj);
2276
+ #else
2267
2277
  return rb_ary_delete(proxies, rbobj);
2278
+ #endif
2268
2279
  }
2269
2280
 
2270
2281
  /*
@@ -2303,7 +2314,7 @@ static void register_class(VALUE self, VALUE clsname)
2303
2314
  * the hash was frozen, so it need to call st_ func directly.
2304
2315
  */
2305
2316
 
2306
- #ifdef HAVE_RB_HASH_ASET
2317
+ #if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
2307
2318
  rb_hash_aset(rjb_loaded_classes, clsname, self);
2308
2319
  #else
2309
2320
  #ifdef RHASH_TBL
@@ -2850,8 +2861,11 @@ static VALUE rjb_class_forname(int argc, VALUE* argv, VALUE self)
2850
2861
  */
2851
2862
  void Init_rjbcore()
2852
2863
  {
2864
+ #if defined(RUBINIUS)
2865
+ rb_require("iconv");
2866
+ #else
2853
2867
  rb_protect((VALUE(*)(VALUE))rb_require, (VALUE)"iconv", NULL);
2854
-
2868
+ #endif
2855
2869
  rjb_loaded_classes = rb_hash_new();
2856
2870
  #ifndef RUBINIUS
2857
2871
  OBJ_FREEZE(rjb_loaded_classes);
@@ -2860,7 +2874,7 @@ void Init_rjbcore()
2860
2874
  proxies = rb_ary_new();
2861
2875
  rb_global_variable(&proxies);
2862
2876
  user_initialize = rb_intern(USER_INITIALIZE);
2863
-
2877
+
2864
2878
  rjb = rb_define_module("Rjb");
2865
2879
  rb_define_module_function(rjb, "load", rjb_s_load, -1);
2866
2880
  rb_define_module_function(rjb, "unload", rjb_s_unload, -1);
@@ -2874,14 +2888,14 @@ void Init_rjbcore()
2874
2888
  rb_define_const(rjb, "VERSION", rb_str_new2(RJB_VERSION));
2875
2889
 
2876
2890
  /* Java class object */
2877
- rjbc = rb_class_new(rb_cObject);
2891
+ rjbc = CLASS_NEW(rb_cObject, "Rjb_JavaClass");
2878
2892
  rb_gc_register_address(&rjbc);
2879
2893
  rb_define_method(rjbc, "method_missing", rjb_missing, -1);
2880
2894
  rb_define_method(rjbc, "_invoke", rjb_invoke, -1);
2881
2895
  rb_define_method(rjbc, "_classname", rjb_i_class, 0);
2882
2896
 
2883
2897
  /* Java instance object */
2884
- rjbi = rb_class_new(rb_cObject);
2898
+ rjbi = CLASS_NEW(rb_cObject, "Rjb_JavaProxy");
2885
2899
  rb_gc_register_address(&rjbi);
2886
2900
  rb_define_method(rjbi, "method_missing", rjb_i_missing, -1);
2887
2901
  rb_define_method(rjbi, "_invoke", rjb_i_invoke, -1);
@@ -2890,7 +2904,7 @@ void Init_rjbcore()
2890
2904
  rb_define_alias(rjbi, "include", "extend");
2891
2905
 
2892
2906
  /* Ruby-Java Bridge object */
2893
- rjbb = rb_class_new(rb_cObject);
2907
+ rjbb = CLASS_NEW(rb_cObject, "Rjb_JavaBridge");
2894
2908
  rb_gc_register_address(&rjbb);
2895
2909
  }
2896
2910
 
@@ -12,7 +12,7 @@
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: rjbexception.c 112 2010-05-29 03:09:11Z arton $
15
+ * $Id: rjbexception.c 119 2010-06-04 12:51:34Z arton $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
@@ -54,7 +54,7 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
54
54
  if (rexp == Qnil)
55
55
  {
56
56
  rexp = rb_define_class(pcls, rb_eStandardError);
57
- #ifdef HAVE_RB_HASH_ASET
57
+ #if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
58
58
  rb_hash_aset(rjb_loaded_classes, cname, rexp);
59
59
  #else
60
60
  #ifdef RHASH_TBL
@@ -11,7 +11,7 @@ Copyright(c) 2010 arton
11
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
12
  Lesser General Public License for more details.
13
13
 
14
- $Id:$
14
+ $Id: rjbextension.rb 116 2010-05-30 14:23:07Z arton $
15
15
 
16
16
  This file is from Andreas Ronge project neo4j
17
17
  http://github.com/andreasronge/neo4j/blob/rjb/lib/rjb_ext.rb
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 3
10
+ version: 1.2.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - arton
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-05-30 00:00:00 +09:00
18
+ date: 2010-06-05 00:00:00 +09:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -26,31 +32,33 @@ extra_rdoc_files: []
26
32
  files:
27
33
  - ext/RBridge.java
28
34
  - ext/load.c
29
- - ext/rjbexception.c
30
35
  - ext/riconv.c
31
36
  - ext/rjb.c
37
+ - ext/rjbexception.c
38
+ - ext/extconf.h
39
+ - ext/jniwrap.h
32
40
  - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
33
41
  - ext/riconv.h
34
- - ext/jniwrap.h
35
42
  - ext/rjb.h
36
43
  - ext/depend
37
44
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
38
45
  - lib/rjb.rb
39
46
  - lib/rjbextension.rb
40
47
  - samples/filechooser.rb
41
- - test/test.rb
42
48
  - test/exttest.rb
43
49
  - test/gctest.rb
50
+ - test/test.rb
44
51
  - test/jp/co/infoseek/hp/arton/rjb/Base.class
52
+ - test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
45
53
  - test/jp/co/infoseek/hp/arton/rjb/IBase.class
46
- - test/jp/co/infoseek/hp/arton/rjb/Test.class
47
54
  - test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
48
- - test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
55
+ - test/jp/co/infoseek/hp/arton/rjb/Test.class
49
56
  - test/rjbtest.jar
50
57
  - COPYING
51
58
  - ChangeLog
52
59
  - readme.sj
53
60
  - readme.txt
61
+ - ext/extconf.rb
54
62
  has_rdoc: true
55
63
  homepage: http://rjb.rubyforge.org/
56
64
  licenses: []
@@ -61,22 +69,30 @@ rdoc_options: []
61
69
  require_paths:
62
70
  - lib
63
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
64
73
  requirements:
65
74
  - - ">="
66
75
  - !ruby/object:Gem::Version
76
+ hash: 51
77
+ segments:
78
+ - 1
79
+ - 8
80
+ - 2
67
81
  version: 1.8.2
68
- version:
69
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
70
84
  requirements:
71
85
  - - ">="
72
86
  - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
73
90
  version: "0"
74
- version:
75
91
  requirements:
76
92
  - none
77
93
  - JDK 5.0
78
94
  rubyforge_project:
79
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.7
80
96
  signing_key:
81
97
  specification_version: 3
82
98
  summary: Ruby Java bridge