diff options
Diffstat (limited to 'lib/kross/ruby/rubyextension.cpp')
-rw-r--r-- | lib/kross/ruby/rubyextension.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/kross/ruby/rubyextension.cpp b/lib/kross/ruby/rubyextension.cpp index 98474bf6..89c73b1a 100644 --- a/lib/kross/ruby/rubyextension.cpp +++ b/lib/kross/ruby/rubyextension.cpp @@ -17,8 +17,18 @@ * Boston, MA 02110-1301, USA. ***************************************************************************/ #include "rubyextension.h" +#include "rubyinterpreter.h" +#define HAVE_STRLCAT_PROTO 1 +#define HAVE_STRLCPY_PROTO 1 +#include "config.h" + +#ifndef HAVE_RUBY_1_9 #include <st.h> +#else // HAVE_RUBY_1_9 +#include <ruby/st.h> +#define STR2CSTR(x) StringValuePtr(x) +#endif // HAVE_RUBY_1_9 #include <tqmap.h> #include <tqstring.h> @@ -174,7 +184,7 @@ VALUE RubyExtension::convertFromException(Kross::Api::Exception::Ptr exc) { if(RubyExtensionPrivate::s_krossException == 0) { - RubyExtensionPrivate::s_krossException = rb_define_class("KrossException", rb_eRuntimeError); + RubyExtensionPrivate::s_krossException = rb_define_class_under(RubyInterpreter::krossModule(), "KrossException", rb_eRuntimeError); } exc->_KShared_ref(); return Data_Wrap_Struct(RubyExtensionPrivate::s_krossException, 0, RubyExtension::delete_exception, exc.data() ); @@ -211,7 +221,11 @@ Kross::Api::Object::Ptr RubyExtension::toObject(VALUE value) case T_ARRAY: { TQValueList<Kross::Api::Object::Ptr> l; +#ifdef HAVE_RUBY_1_9 + for(int i = 0; i < RARRAY_LEN(value); i++) +#else // HAVE_RUBY_1_9 for(int i = 0; i < RARRAY(value)->len; i++) +#endif // HAVE_RUBY_1_9 { Kross::Api::Object::Ptr o = toObject( rb_ary_entry( value , i ) ); if(o) l.append(o); @@ -357,7 +371,7 @@ VALUE RubyExtension::toVALUE(Kross::Api::Object::Ptr object) if(RubyExtensionPrivate::s_krossObject == 0) { - RubyExtensionPrivate::s_krossObject = rb_define_class("KrossObject", rb_cObject); + RubyExtensionPrivate::s_krossObject = rb_define_class_under(RubyInterpreter::krossModule(), "Object", rb_cObject ); rb_define_method(RubyExtensionPrivate::s_krossObject, "method_missing", (VALUE (*)(...))RubyExtension::method_missing, -1); } return Data_Wrap_Struct(RubyExtensionPrivate::s_krossObject, 0, RubyExtension::delete_object, new RubyExtension(object) ); |