diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-28 15:22:53 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-28 15:22:53 -0500 |
commit | cc2788364dd9c6a14d94646f09222f4721740a15 (patch) | |
tree | aa68add0c20846e1b30caf92b37c6b8f87bba35f /lib/kross/ruby/rubyextension.cpp | |
parent | 3c352d5eb2ea84b316075c11a301001fbba46528 (diff) | |
download | koffice-cc2788364dd9c6a14d94646f09222f4721740a15.tar.gz koffice-cc2788364dd9c6a14d94646f09222f4721740a15.zip |
Attempt to make kross compile with Ruby 1.9.x
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 98474bf65..89c73b1a1 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) ); |