Created
August 21, 2010 07:12
-
-
Save jruby/541929 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cext/src/JUtil.cpp b/cext/src/JUtil.cpp | |
index 04d9905..573b706 100644 | |
--- a/cext/src/JUtil.cpp | |
+++ b/cext/src/JUtil.cpp | |
@@ -44,6 +44,22 @@ jruby::getCurrentEnv() | |
return env; | |
} | |
+extern "C" { | |
+JavaVM* jruby_jvm; | |
+ | |
+JNIEnv* | |
+jruby_getCurrentEnv() | |
+{ | |
+ JNIEnv* env; | |
+ jruby_jvm->GetEnv((void **) & env, JNI_VERSION_1_4); | |
+ if (env == NULL) { | |
+ jruby_jvm->AttachCurrentThread((void **) & env, NULL); | |
+ } | |
+ return env; | |
+} | |
+ | |
+} | |
+ | |
void | |
jruby::throwExceptionByName(JNIEnv* env, const char* exceptionName, const char* fmt, ...) | |
diff --git a/cext/src/JUtil.h b/cext/src/JUtil.h | |
index 314374f..39f78ca 100644 | |
--- a/cext/src/JUtil.h | |
+++ b/cext/src/JUtil.h | |
@@ -67,4 +67,9 @@ namespace jruby { | |
} //namespace jruby | |
+extern "C" { | |
+extern JavaVM* jruby_jvm; | |
+JNIEnv* jruby_getCurrentEnv(); | |
+} | |
+ | |
#endif // JRUBY_JUTIL_H | |
diff --git a/cext/src/include/ruby/ruby.h b/cext/src/include/ruby/ruby.h | |
index 7e97f11..9ccb267 100644 | |
--- a/cext/src/include/ruby/ruby.h | |
+++ b/cext/src/include/ruby/ruby.h | |
@@ -992,7 +992,7 @@ RUBY_DLLSPEC extern VALUE rb_eLoadError; | |
#define ruby_verbose (rb_gv_get("$VERBOSE")) | |
-// TODO: get rjb to use a different #ifdef than "RUBINIUS" | |
+/* TODO: get rjb to use a different #ifdef than "RUBINIUS" */ | |
#define RUBINIUS 1 | |
#define HAVE_RB_ERRINFO 1 | |
#define HAVE_RB_SET_ERRINFO 1 | |
@@ -1001,6 +1001,10 @@ RUBY_DLLSPEC extern VALUE rb_eLoadError; | |
#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n)) | |
+#include "jni.h" | |
+extern JavaVM* jruby_jvm; | |
+JNIEnv* jruby_getCurrentEnv(); | |
+ | |
#ifdef __cplusplus | |
} | |
#endif | |
diff --git a/cext/src/jruby-cext.cpp b/cext/src/jruby-cext.cpp | |
index 688def3..a69fe24 100644 | |
--- a/cext/src/jruby-cext.cpp | |
+++ b/cext/src/jruby-cext.cpp | |
@@ -419,5 +419,6 @@ JNI_OnLoad(JavaVM *vm, void *reserved) | |
} | |
jruby::jvm = vm; | |
+ jruby_jvm = vm; | |
return JNI_VERSION_1_4; | |
} | |
diff --git a/lib/ruby/1.8/dl.rb b/lib/ruby/1.8/dl.rb | |
index 91125cf..9e1e4e1 100644 | |
--- a/lib/ruby/1.8/dl.rb | |
+++ b/lib/ruby/1.8/dl.rb | |
@@ -201,6 +201,10 @@ module DL | |
def self.char2type(ch) | |
Char2TypeName[ch] | |
end | |
+ | |
+ def to_ptr | |
+ to_i | |
+ end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment