[Kde-bindings] KDE/kdebindings/ruby/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Dec 12 19:26:52 UTC 2008


SVN commit 896181 by rdale:

* When an overriden virtual method with a non-const QVector/QList argument
  was called, such as Generator.openDocument() in Okular, the Ruby values
  in the Ruby Array were not being converted back to the values in the
  C++ list after the method call. Thanks to David Palacio for the bug
  report.

CCMAIL: kde-bindings at kde.org



 M  +5 -0      ChangeLog  
 M  +32 -11    src/marshall_macros.h  


--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #896180:896181
@@ -11,6 +11,11 @@
 	  than needing to track down possible random buggy effects.
 	* Added Davor Ocelic's patch for Ruby 1.9 compatible RSTRING usage and
 	  improved instructions for building QtRuby without KDE.
+	* When an overriden virtual method with a non-const QVector/QList argument
+	  was called, such as Generator.openDocument() in Okular, the Ruby values
+	  in the Ruby Array were not being converted back to the values in the
+	  C++ list after the method call. Thanks to David Palacio for the bug
+	  report.
 
 2008-12-11  Richard Dale  <richard.j.dale at gmail.com>
 	* Make some changes from the patch at 
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_macros.h #896180:896181
@@ -56,7 +56,7 @@
 				break;
 			}
 
-			int count = RARRAY_LEN(list);
+			int count = RARRAY(list)->len;
 			ItemList *cpplist = new ItemList;
 			long i;
 			for(i = 0; i < count; i++) {
@@ -94,16 +94,16 @@
       
 		case Marshall::ToVALUE:
 		{
-			ItemList *valuelist = (ItemList*)m->item().s_voidp;
-			if(!valuelist) {
+			ItemList * cpplist = (ItemList *) m->item().s_voidp;
+			if (cpplist == 0) {
 				*(m->var()) = Qnil;
 				break;
 			}
 
 			VALUE av = rb_ary_new();
 
-			for (int i=0;i<valuelist->size();++i) {
-				void *p = (void *) valuelist->at(i);
+			for (int i=0; i < cpplist->size(); ++i) {
+				void *p = (void *) cpplist->at(i);
 
 				if (m->item().s_voidp == 0) {
 					*(m->var()) = Qnil;
@@ -126,8 +126,29 @@
 			*(m->var()) = av;
 			m->next();
 
+			if (!m->type().isConst()) {
+			  int count = RARRAY(av)->len;
+			  long i;
+			  cpplist->clear();
+			  for (i = 0; i < count; i++) {
+				  VALUE item = rb_ary_entry(av, i);
+				  // TODO do type checking!
+				  smokeruby_object *o = value_obj_info(item);
+				  if(!o || !o->ptr)
+					  continue;
+				  void *ptr = o->ptr;
+				  ptr = o->smoke->cast(
+					  ptr,				// pointer
+					  o->classId,				// from
+					  o->smoke->idClass(ItemSTR).index	// to
+				  );
+
+				  cpplist->append((Item*)ptr);
+			  }
+			}
+
 			if (m->cleanup()) {
-				delete valuelist;
+				delete cpplist;
 			}
 		}
 		break;
@@ -148,7 +169,7 @@
 				m->item().s_voidp = 0;
 				break;
 			}
-			int count = RARRAY_LEN(list);
+			int count = RARRAY(list)->len;
 			ItemList *cpplist = new ItemList;
 			long i;
 			for(i = 0; i < count; i++) {
@@ -264,7 +285,7 @@
 				break;
 			}
 
-			int count = RARRAY_LEN(list);
+			int count = RARRAY(list)->len;
 			ItemList *cpplist = new ItemList;
 			long i;
 			for (i = 0; i < count; i++) {
@@ -358,7 +379,7 @@
 				m->item().s_voidp = 0;
 				break;
 			}
-			int count = RARRAY_LEN(list);
+			int count = RARRAY(list)->len;
 			ItemList *cpplist = new ItemList;
 			long i;
 			for(i = 0; i < count; i++) {
@@ -476,7 +497,7 @@
 		// Convert the ruby hash to an array of key/value arrays
 		VALUE temp = rb_funcall(hv, rb_intern("to_a"), 0);
 
-		for (long i = 0; i < RARRAY_LEN(temp); i++) {
+		for (long i = 0; i < RARRAY(temp)->len; i++) {
 			VALUE key = rb_ary_entry(rb_ary_entry(temp, i), 0);
 			VALUE value = rb_ary_entry(rb_ary_entry(temp, i), 1);
 			
@@ -553,7 +574,7 @@
 		// Convert the ruby hash to an array of key/value arrays
 		VALUE temp = rb_funcall(hv, rb_intern("to_a"), 0);
 
-		for (long i = 0; i < RARRAY_LEN(temp); i++) {
+		for (long i = 0; i < RARRAY(temp)->len; i++) {
 			VALUE key = rb_ary_entry(rb_ary_entry(temp, i), 0);
 			VALUE value = rb_ary_entry(rb_ary_entry(temp, i), 1);
 			



More information about the Kde-bindings mailing list