rjb 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/ChangeLog +4 -0
  2. data/ext/jniwrap.h +1 -1
  3. data/ext/load.c +13 -4
  4. data/ext/rjb.c +4 -4
  5. data/ext/rjb.h +2 -1
  6. metadata +2 -2
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Tue Aug 26 arton
2
+ *ext/load.c, rjb.c, rjb.h
3
+ export safe_funcall under the prefix 'rjb'.
4
+ calling DL with rb_protect for avoiding exception.
1
5
  Mon Aug 25 arton
2
6
  *ext/load.c
3
7
  Fix checking the result for loading alternate_jvm_type.
data/ext/jniwrap.h 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: jniwrap.h 80 2008-08-25 12:56:50Z arton $
15
+ * $Id: jniwrap.h 82 2008-08-26 12:51:51Z arton $
16
16
  */
17
17
  #ifndef _Included_jniwrap
18
18
  #define _Included_jniwrap
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 80 2008-08-25 12:56:50Z arton $
15
+ * $Id: load.c 82 2008-08-26 12:51:51Z arton $
16
16
  */
17
17
 
18
18
  #include <stdlib.h>
@@ -90,6 +90,8 @@ static int load_jvm(char* jvmtype)
90
90
  char* libpath;
91
91
  char* java_home;
92
92
  char* jh;
93
+ int sstat;
94
+ VALUE* argv;
93
95
 
94
96
  jh = getenv("JAVA_HOME");
95
97
  #if defined(__APPLE__) && defined(__MACH__)
@@ -150,9 +152,16 @@ static int load_jvm(char* jvmtype)
150
152
  rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
151
153
  return 0;
152
154
  }
153
-
154
- jvmdll = rb_funcall(rb_const_get(rb_cObject, rb_intern("DL")), rb_intern("dlopen"), 1, rb_str_new2(libpath));
155
-
155
+ argv = ALLOCA_N(VALUE, 4);
156
+ *argv = rb_const_get(rb_cObject, rb_intern("DL"));
157
+ *(argv + 1) = rb_intern("dlopen");
158
+ *(argv + 2) = 1;
159
+ *(argv + 3) = rb_str_new2(libpath);
160
+ jvmdll = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat);
161
+ if (sstat)
162
+ {
163
+ return 0;
164
+ }
156
165
  /* get function pointers of JNI */
157
166
  #if RJB_RUBY_VERSION_CODE < 190
158
167
  getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
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 80 2008-08-25 12:56:50Z arton $
15
+ * $Id: rjb.c 82 2008-08-26 12:51:51Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.1.5"
18
+ #define RJB_VERSION "1.1.6"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "extconf.h"
@@ -2779,7 +2779,7 @@ void Init_rjbcore()
2779
2779
  rb_gc_register_address(&rjbb);
2780
2780
  }
2781
2781
 
2782
- static VALUE safe_funcall(VALUE args)
2782
+ VALUE rjb_safe_funcall(VALUE args)
2783
2783
  {
2784
2784
  VALUE* argp = (VALUE*)args;
2785
2785
  return rb_funcall2(*argp, *(argp + 1), *(argp + 2), argp + 3);
@@ -2829,7 +2829,7 @@ JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
2829
2829
  *argv = ptr->wrapped;
2830
2830
  *(argv + 1) = id;
2831
2831
  *(argv + 2) = argc - 3;
2832
- result = rb_protect(safe_funcall, (VALUE)argv, &sstat);
2832
+ result = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat);
2833
2833
  rv2jobject(jenv, result, &j, NULL, 0);
2834
2834
  /* I can't delete this object... */
2835
2835
  break;
data/ext/rjb.h 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: rjb.h 64 2008-03-05 14:24:22Z kuwa1 $
15
+ * $Id: rjb.h 82 2008-08-26 12:51:51Z arton $
16
16
  * $Log: rjb.h,v $
17
17
  * Revision 1.1 2005/01/16 17:36:10 arton
18
18
  * Initial revision
@@ -69,6 +69,7 @@ extern JNIEnv* rjb_attach_current_thread(void);
69
69
  extern jclass rjb_find_class(JNIEnv* jenv, VALUE name);
70
70
  extern void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs);
71
71
  extern VALUE rjb_load_vm_default();
72
+ extern VALUE rjb_safe_funcall(VALUE args);
72
73
 
73
74
  /* in rjbexception.c */
74
75
  extern VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str);
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rjb
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.5
7
- date: 2008-08-25 00:00:00 +09:00
6
+ version: 1.1.6
7
+ date: 2008-08-26 00:00:00 +09:00
8
8
  summary: Ruby Java bridge
9
9
  require_paths:
10
10
  - lib