summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-11 12:52:49 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-11 12:52:49 -0500
commitef7a60860d18e9be343b6fa5fe8d76fd080cead0 (patch)
tree640a3f17c9f0e1d133b05f1eb434d13057a78e8d /korundum/rubylib
parent46659f992d49f86347c43528a8705657b6896cb7 (diff)
downloadtdebindings-ef7a60860d18e9be343b6fa5fe8d76fd080cead0.tar.gz
tdebindings-ef7a60860d18e9be343b6fa5fe8d76fd080cead0.zip
Fix FTBS on ruby 1.9.x
Thanks to Darrell Anderson for the majority of the patch!
Diffstat (limited to 'korundum/rubylib')
-rw-r--r--korundum/rubylib/korundum/Korundum.cpp22
-rw-r--r--korundum/rubylib/korundum/kdehandlers.cpp34
2 files changed, 36 insertions, 20 deletions
diff --git a/korundum/rubylib/korundum/Korundum.cpp b/korundum/rubylib/korundum/Korundum.cpp
index cc3ce2ab..124e2a16 100644
--- a/korundum/rubylib/korundum/Korundum.cpp
+++ b/korundum/rubylib/korundum/Korundum.cpp
@@ -40,6 +40,14 @@
#include <smokeruby.h>
#include <smoke.h>
+#include "config.h"
+
+#ifndef HAVE_RUBY_1_9
+#define RARRAY_LEN(x) (RARRAY(x)->len)
+#define RSTRING_LEN(x) (RSTRING(x)->len)
+#define rb_str_catf_1 rb_str_catf
+#endif
+
extern "C" {
extern VALUE qt_internal_module;
extern VALUE kconfigskeleton_class;
@@ -805,7 +813,7 @@ public:
// isn't in the Smoke runtime
TQValueList<DCOPRef> windowList;
- for (long i = 0; i < RARRAY(result)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(result); i++) {
VALUE item = rb_ary_entry(result, i);
smokeruby_object *o = value_obj_info(item);
if( !o || !o->ptr)
@@ -822,7 +830,7 @@ public:
// And special case this type too
TQValueList<TQCString> propertyList;
- for (long i = 0; i < RARRAY(result)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(result); i++) {
VALUE item = rb_ary_entry(result, i);
propertyList.append(TQCString(StringValuePtr(item)));
}
@@ -836,7 +844,7 @@ public:
// Convert the ruby hash to an array of key/value arrays
VALUE temp = rb_funcall(result, rb_intern("to_a"), 0);
- for (long i = 0; i < RARRAY(temp)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(temp); i++) {
VALUE action = rb_ary_entry(rb_ary_entry(temp, i), 0);
VALUE item = rb_ary_entry(rb_ary_entry(temp, i), 1);
@@ -926,7 +934,7 @@ k_dcop_signal(int argc, VALUE * argv, VALUE self)
{
VALUE dcopObject = rb_funcall(kde_module, rb_intern("createDCOPObject"), 1, self);
- TQString signalname(rb_id2name(rb_frame_last_func()));
+ TQString signalname(rb_id2name(rb_frame_this_func()));
VALUE args = getdcopinfo(self, signalname);
if(args == Qnil) return Qfalse;
@@ -1020,7 +1028,7 @@ new_kde(int argc, VALUE * argv, VALUE klass)
if (rb_funcall(kde_module, rb_intern("hasDCOPSignals"), 1, klass) == Qtrue) {
VALUE signalNames = rb_funcall(kde_module, rb_intern("getDCOPSignalNames"), 1, klass);
- for (long index = 0; index < RARRAY(signalNames)->len; index++) {
+ for (long index = 0; index < RARRAY_LEN(signalNames); index++) {
VALUE signal = rb_ary_entry(signalNames, index);
rb_define_method(klass, StringValuePtr(signal), (VALUE (*) (...)) k_dcop_signal, -1);
}
@@ -1088,9 +1096,9 @@ konsole_part_startprogram(VALUE self, VALUE value_program, VALUE value_args)
TQStrList *args = new TQStrList;
if (value_args != Qnil) {
- for (long i = 0; i < RARRAY(value_args)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(value_args); i++) {
VALUE item = rb_ary_entry(value_args, i);
- args->append(TQString::fromLatin1(StringValuePtr(item), RSTRING(item)->len));
+ args->append(TQString::fromLatin1(StringValuePtr(item), RSTRING_LEN(item)));
}
}
diff --git a/korundum/rubylib/korundum/kdehandlers.cpp b/korundum/rubylib/korundum/kdehandlers.cpp
index 70932d5c..6961301f 100644
--- a/korundum/rubylib/korundum/kdehandlers.cpp
+++ b/korundum/rubylib/korundum/kdehandlers.cpp
@@ -52,6 +52,14 @@
#include <dom/dom_string.h>
#include <dom/html_element.h>
+#include "config.h"
+
+#ifndef HAVE_RUBY_1_9
+#define RARRAY_LEN(x) (RARRAY(x)->len)
+#define RSTRING_LEN(x) (RSTRING(x)->len)
+#define rb_str_catf_1 rb_str_catf
+#endif
+
extern "C" {
extern VALUE set_obj_info(const char * className, smokeruby_object * o);
};
@@ -122,7 +130,7 @@ void marshall_TQCStringList(Marshall *m) {
break;
}
- int count = RARRAY(list)->len;
+ int count = RARRAY_LEN(list);
QCStringList *stringlist = new QCStringList;
for(long i = 0; i < count; i++) {
@@ -131,7 +139,7 @@ void marshall_TQCStringList(Marshall *m) {
stringlist->append(TQCString());
continue;
}
- stringlist->append(TQCString(StringValuePtr(item), RSTRING(item)->len + 1));
+ stringlist->append(TQCString(StringValuePtr(item), RSTRING_LEN(item) + 1));
}
m->item().s_voidp = stringlist;
@@ -184,19 +192,19 @@ void marshall_KCmdLineOptions(Marshall *m) {
VALUE optionslist = *(m->var());
if (optionslist == Qnil
|| TYPE(optionslist) != T_ARRAY
- || RARRAY(optionslist)->len == 0 )
+ || RARRAY_LEN(optionslist) == 0 )
{
m->item().s_voidp = 0;
break;
}
// Allocate 'length + 1' entries, to include an all NULLs last entry
- KCmdLineOptions *cmdLineOptions = (KCmdLineOptions *) calloc( RARRAY(optionslist)->len + 1,
+ KCmdLineOptions *cmdLineOptions = (KCmdLineOptions *) calloc( RARRAY_LEN(optionslist) + 1,
sizeof(struct KCmdLineOptions) );
VALUE options;
long i;
- for(i = 0; i < RARRAY(optionslist)->len; i++) {
+ for(i = 0; i < RARRAY_LEN(optionslist); i++) {
options = rb_ary_entry(optionslist, i);
VALUE temp = rb_ary_entry(options, 0);
cmdLineOptions[i].name = StringValuePtr(temp);
@@ -244,7 +252,7 @@ void marshall_WIdList(Marshall *m) {
m->item().s_voidp = 0;
break;
}
- int count = RARRAY(list)->len;
+ int count = RARRAY_LEN(list);
TQValueList<WId> *valuelist = new TQValueList<WId>;
long i;
for(i = 0; i < count; i++) {
@@ -815,7 +823,7 @@ void marshall_KURLList(Marshall *m) {
m->item().s_voidp = 0;
break;
}
- int count = RARRAY(list)->len;
+ int count = RARRAY_LEN(list);
KURL::List *kurllist = new KURL::List;
long i;
for(i = 0; i < count; i++) {
@@ -916,11 +924,11 @@ void marshall_UDSEntryList(Marshall *m) {
KIO::UDSEntryList *cpplist = new KIO::UDSEntryList;
- for(long i = 0; i < RARRAY(list)->len; i++) {
+ for(long i = 0; i < RARRAY_LEN(list); i++) {
VALUE item = rb_ary_entry(list, i);
KIO::UDSEntry *cppsublist = new KIO::UDSEntry;
- for (int j = 0; j < RARRAY(item)->len; j++) {
+ for (int j = 0; j < RARRAY_LEN(item); j++) {
VALUE subitem = rb_ary_entry(item, j);
smokeruby_object *o = value_obj_info(subitem);
if(!o || !o->ptr)
@@ -998,7 +1006,7 @@ void marshall_ItemList(Marshall *m) {
m->item().s_voidp = 0;
break;
}
- int count = RARRAY(list)->len;
+ int count = RARRAY_LEN(list);
ItemList *cpplist = new ItemList;
long i;
for(i = 0; i < count; i++) {
@@ -1103,7 +1111,7 @@ void marshall_ValueItemList(Marshall *m) {
m->item().s_voidp = 0;
break;
}
- int count = RARRAY(list)->len;
+ int count = RARRAY_LEN(list);
ItemList *cpplist = new ItemList;
long i;
for(i = 0; i < count; i++) {
@@ -1211,7 +1219,7 @@ void marshall_Map(Marshall *m) {
// Convert the ruby hash to an array of key/value arrays
VALUE temp = rb_funcall(hash, rb_intern("to_a"), 0);
- for (long i = 0; i < RARRAY(temp)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(temp); i++) {
VALUE key = rb_ary_entry(rb_ary_entry(temp, i), 0);
VALUE value = rb_ary_entry(rb_ary_entry(temp, i), 1);
@@ -1316,7 +1324,7 @@ void marshall_TQMapTQCStringDCOPRef(Marshall *m) {
// Convert the ruby hash to an array of key/value arrays
VALUE temp = rb_funcall(hash, rb_intern("to_a"), 0);
- for (long i = 0; i < RARRAY(temp)->len; i++) {
+ for (long i = 0; i < RARRAY_LEN(temp); i++) {
VALUE key = rb_ary_entry(rb_ary_entry(temp, i), 0);
VALUE value = rb_ary_entry(rb_ary_entry(temp, i), 1);