rjb 1.1.9 → 1.2.0
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.
- data/ChangeLog +11 -0
- data/ext/extconf.rb +5 -2
- data/ext/load.c +57 -40
- data/ext/rjb.c +2 -2
- metadata +15 -12
- data/ext/extconf.h +0 -9
data/ChangeLog
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
Sun Nov 1 arton
|
2
|
+
*ext/load.c
|
3
|
+
load jvm pointed by JVM_LIB environment variable first (suggested by Ittay Dror).
|
4
|
+
*ext/rjb.c
|
5
|
+
RJB_VERSION -> 1.2.0
|
6
|
+
Sun Oct 11 arton
|
7
|
+
*ext/extconf.rb
|
8
|
+
add double quotation around include path for mingw compiler, original patched by Roger Pack (thanks)
|
9
|
+
remove double quotaion around java_home variable for existing checking by File.directoy?
|
10
|
+
*rjb.rake
|
11
|
+
adding mingw support for the older version compatibility checking
|
1
12
|
Thu Sep 10 arton
|
2
13
|
*ext/load.c
|
3
14
|
Correct previous code (always reload jvm if OSX < Snow Leopard)
|
data/ext/extconf.rb
CHANGED
@@ -17,8 +17,8 @@ class Path
|
|
17
17
|
|
18
18
|
def include(parent, child)
|
19
19
|
inc = joint(parent, child)
|
20
|
-
$INCFLAGS += " -I#{inc}"
|
21
|
-
$CFLAGS += " -I#{inc}"
|
20
|
+
$INCFLAGS += " -I\"#{inc}\""
|
21
|
+
$CFLAGS += " -I\"#{inc}\""
|
22
22
|
inc
|
23
23
|
end
|
24
24
|
|
@@ -30,6 +30,9 @@ end
|
|
30
30
|
|
31
31
|
javahome = ENV['JAVA_HOME']
|
32
32
|
unless javahome.nil?
|
33
|
+
if javahome[0] == ?" && javahome[-1] == ?"
|
34
|
+
javahome = javahome[1..-2]
|
35
|
+
end
|
33
36
|
raise "JAVA_HOME is not directory." unless File.directory?(javahome)
|
34
37
|
p = Path.new
|
35
38
|
inc = p.include(javahome, 'include')
|
data/ext/load.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Rjb - Ruby <-> Java Bridge
|
3
|
-
* Copyright(c) 2004,2005,2006 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2009 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
|
@@ -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
|
15
|
+
* $Id: load.c 102 2009-11-01 14:01:41Z arton $
|
16
16
|
*/
|
17
17
|
|
18
18
|
#include <stdlib.h>
|
@@ -98,6 +98,37 @@ static VALUE jvmdll = Qnil;
|
|
98
98
|
static VALUE getdefaultjavavminitargsfunc;
|
99
99
|
static VALUE createjavavmfunc;
|
100
100
|
|
101
|
+
static int open_jvm(char* libpath)
|
102
|
+
{
|
103
|
+
int sstat;
|
104
|
+
VALUE* argv;
|
105
|
+
|
106
|
+
rb_require("dl");
|
107
|
+
if (!rb_const_defined_at(rb_cObject, rb_intern("DL")))
|
108
|
+
{
|
109
|
+
rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
argv = ALLOCA_N(VALUE, 4);
|
113
|
+
*argv = rb_const_get(rb_cObject, rb_intern("DL"));
|
114
|
+
*(argv + 1) = rb_intern("dlopen");
|
115
|
+
*(argv + 2) = 1;
|
116
|
+
*(argv + 3) = rb_str_new2(libpath);
|
117
|
+
jvmdll = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat);
|
118
|
+
if (sstat)
|
119
|
+
{
|
120
|
+
return 0;
|
121
|
+
}
|
122
|
+
/* get function pointers of JNI */
|
123
|
+
#if RJB_RUBY_VERSION_CODE < 190
|
124
|
+
getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(GETDEFAULTJVMINITARGS), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
|
125
|
+
createjavavmfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(CREATEJVM), rb_str_new2("IPPP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
|
126
|
+
#else
|
127
|
+
getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(GETDEFAULTJVMINITARGS));
|
128
|
+
createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(CREATEJVM));
|
129
|
+
#endif
|
130
|
+
return 1;
|
131
|
+
}
|
101
132
|
/*
|
102
133
|
* not completed, only valid under some circumstances.
|
103
134
|
*/
|
@@ -106,8 +137,6 @@ static int load_jvm(char* jvmtype)
|
|
106
137
|
char* libpath;
|
107
138
|
char* java_home;
|
108
139
|
char* jh;
|
109
|
-
int sstat;
|
110
|
-
VALUE* argv;
|
111
140
|
|
112
141
|
jh = getenv("JAVA_HOME");
|
113
142
|
#if defined(__APPLE__) && defined(__MACH__)
|
@@ -161,32 +190,7 @@ static int load_jvm(char* jvmtype)
|
|
161
190
|
+ strlen(ARCH) + strlen(jvmtype) + 1);
|
162
191
|
sprintf(libpath, JVMDLL, java_home, ARCH, jvmtype);
|
163
192
|
#endif
|
164
|
-
|
165
|
-
rb_require("dl");
|
166
|
-
if (!rb_const_defined_at(rb_cObject, rb_intern("DL")))
|
167
|
-
{
|
168
|
-
rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
|
169
|
-
return 0;
|
170
|
-
}
|
171
|
-
argv = ALLOCA_N(VALUE, 4);
|
172
|
-
*argv = rb_const_get(rb_cObject, rb_intern("DL"));
|
173
|
-
*(argv + 1) = rb_intern("dlopen");
|
174
|
-
*(argv + 2) = 1;
|
175
|
-
*(argv + 3) = rb_str_new2(libpath);
|
176
|
-
jvmdll = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat);
|
177
|
-
if (sstat)
|
178
|
-
{
|
179
|
-
return 0;
|
180
|
-
}
|
181
|
-
/* get function pointers of JNI */
|
182
|
-
#if RJB_RUBY_VERSION_CODE < 190
|
183
|
-
getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(GETDEFAULTJVMINITARGS), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
|
184
|
-
createjavavmfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(CREATEJVM), rb_str_new2("IPPP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
|
185
|
-
#else
|
186
|
-
getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(GETDEFAULTJVMINITARGS));
|
187
|
-
createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(CREATEJVM));
|
188
|
-
#endif
|
189
|
-
return 1;
|
193
|
+
return open_jvm(libpath);
|
190
194
|
}
|
191
195
|
|
192
196
|
static int load_bridge(JNIEnv* jenv)
|
@@ -264,20 +268,33 @@ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALU
|
|
264
268
|
|
265
269
|
if (!RTEST(jvmdll))
|
266
270
|
{
|
267
|
-
|
268
|
-
|
271
|
+
char* libjvm = getenv("JVM_LIB");
|
272
|
+
#if defined(_WIN32)
|
273
|
+
if (libjvm && *libjvm == '"' && *(libjvm + strlen(libjvm) - 1) == '"')
|
269
274
|
{
|
270
|
-
|
271
|
-
|
272
|
-
|
275
|
+
char* p = ALLOCA_N(char, strlen(libjvm) + 1);
|
276
|
+
strcpy(p, libjvm + 1);
|
277
|
+
*(p + strlen(p) - 1) = '\0';
|
278
|
+
libjvm = p;
|
279
|
+
}
|
280
|
+
#endif
|
281
|
+
if (libjvm == NULL || !open_jvm(libjvm))
|
282
|
+
{
|
283
|
+
#if defined(__APPLE__) && defined(__MACH__)
|
284
|
+
if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
|
285
|
+
{
|
286
|
+
JVMDLL = "%s/Libraries/libjvm.dylib";
|
287
|
+
CREATEJVM = "JNI_CreateJavaVM_Impl";
|
288
|
+
GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs_Impl";
|
273
289
|
#endif
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
290
|
+
if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
|
291
|
+
{
|
292
|
+
return -1;
|
293
|
+
}
|
278
294
|
#if defined(__APPLE__) && defined(__MACH__)
|
279
|
-
|
295
|
+
}
|
280
296
|
#endif
|
297
|
+
}
|
281
298
|
#if RJB_RUBY_VERSION_CODE < 190
|
282
299
|
ruby_errinfo = Qnil;
|
283
300
|
#else
|
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
|
15
|
+
* $Id: rjb.c 102 2009-11-01 14:01:41Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.
|
18
|
+
#define RJB_VERSION "1.2.0"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "extconf.h"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arton
|
@@ -9,11 +9,13 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-01 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: |
|
17
|
+
RJB is a bridge program that connect between Ruby and Java with Java Native Interface.
|
18
|
+
|
17
19
|
email: artonx@gmail.com
|
18
20
|
executables: []
|
19
21
|
|
@@ -24,31 +26,32 @@ extra_rdoc_files: []
|
|
24
26
|
files:
|
25
27
|
- ext/RBridge.java
|
26
28
|
- ext/load.c
|
29
|
+
- ext/rjbexception.c
|
27
30
|
- ext/riconv.c
|
28
31
|
- ext/rjb.c
|
29
|
-
- ext/rjbexception.c
|
30
|
-
- ext/extconf.h
|
31
|
-
- ext/jniwrap.h
|
32
32
|
- ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
|
33
33
|
- ext/riconv.h
|
34
|
+
- ext/jniwrap.h
|
34
35
|
- ext/rjb.h
|
35
36
|
- ext/depend
|
36
37
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
37
38
|
- lib/rjb.rb
|
38
39
|
- samples/filechooser.rb
|
39
|
-
- test/gctest.rb
|
40
40
|
- test/test.rb
|
41
|
+
- test/gctest.rb
|
41
42
|
- test/jp/co/infoseek/hp/arton/rjb/Base.class
|
42
|
-
- test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
|
43
43
|
- test/jp/co/infoseek/hp/arton/rjb/IBase.class
|
44
|
-
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
45
44
|
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
45
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
46
|
+
- test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
|
46
47
|
- COPYING
|
47
48
|
- ChangeLog
|
48
49
|
- readme.sj
|
49
50
|
- readme.txt
|
50
|
-
has_rdoc:
|
51
|
+
has_rdoc: true
|
51
52
|
homepage: http://rjb.rubyforge.org/
|
53
|
+
licenses: []
|
54
|
+
|
52
55
|
post_install_message:
|
53
56
|
rdoc_options: []
|
54
57
|
|
@@ -70,9 +73,9 @@ requirements:
|
|
70
73
|
- none
|
71
74
|
- JDK 5.0
|
72
75
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.5
|
74
77
|
signing_key:
|
75
|
-
specification_version:
|
78
|
+
specification_version: 3
|
76
79
|
summary: Ruby Java bridge
|
77
80
|
test_files:
|
78
81
|
- test/test.rb
|