[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebindings/qtruby/rubylib/qtruby
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2006-09-25 21:21:38
Message-ID: 1159219298.307991.14229.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 588405 by rdale:

* Oops, checked in wrong version of Qt.cpp, revert most of the last change


 M  +28 -103   Qt.cpp  


--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #588404:588405
@@ -1396,17 +1396,10 @@
 static VALUE
 metaObject(VALUE self)
 {
-    VALUE metaObject = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 1, \
CLASS_OF(self)); +    VALUE metaObject = rb_funcall(qt_internal_module, \
rb_intern("getMetaObject"), 1, self);  return metaObject;
 }
 
-static VALUE
-staticMetaObject(VALUE klass)
-{
-    VALUE metaObject = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 1, \
                klass);
-    return metaObject;
-}
-
 /* This shouldn't be needed, but kalyptus doesn't generate a staticMetaObject
 	method for QObject::staticMetaObject, although it does for all the other
 	classes, and it isn't obvious what the problem with it is. 
@@ -1704,7 +1697,7 @@
 	if (TYPE(self) == T_DATA) {
 		// If a ruby block was passed then run that now
 		if (rb_block_given_p()) {
-			rb_funcall(qt_internal_module, rb_intern("run_initializer_block"), 2, self, \
rb_block_proc()); +		rb_funcall(qt_internal_module, \
rb_intern("run_initializer_block"), 2, self, rb_block_proc());  }
 
 		return self;
@@ -1826,12 +1819,12 @@
 getmetainfo(VALUE self, int &offset, int &index)
 {
     char * signalname = rb_id2name(rb_frame_last_func());
-	VALUE metaObject_value = rb_funcall(CLASS_OF(self), rb_intern("staticMetaObject"), \
0); +    VALUE metaObject_value = rb_funcall(qt_internal_module, \
rb_intern("getMetaObject"), 1, self);  
     smokeruby_object *ometa = value_obj_info(metaObject_value);
     if(!ometa) return 0;
     QMetaObject *metaobject = (QMetaObject*)ometa->ptr;
-printf("getmetainfo className: %s\n", metaobject->className());
+
     offset = metaobject->methodOffset();
 
     VALUE signalInfo = rb_funcall(qt_internal_module, rb_intern("signalInfo"), 2, \
self, rb_str_new2(signalname)); @@ -1867,9 +1860,8 @@
     return result;
 }
 
-
 static VALUE
-qt_metacall(int argc, VALUE * argv, VALUE self)
+qt_metacall(int /*argc*/, VALUE * argv, VALUE self)
 {
 	// Arguments: QMetaObject::Call _c, int id, void ** _o
 	QMetaObject::Call _c = (QMetaObject::Call) NUM2INT(	rb_funcall(	qt_internal_module,
@@ -1883,19 +1875,15 @@
 	// it isn't an error to get a NULL value of _o here.
 	Data_Get_Struct(argv[2], void*, _o);
 	
-	VALUE metaObject_value = rb_funcall(CLASS_OF(self), rb_intern("staticMetaObject"), \
0); +	VALUE metaObject_value = rb_funcall(qt_internal_module, \
rb_intern("getMetaObject"), 1, self);  smokeruby_object *ometa = \
value_obj_info(metaObject_value);  if (!ometa) return argv[1];
 	
 	QMetaObject *metaobject = (QMetaObject*)ometa->ptr;
-
-printf("qt_metacall id: %d\n", id);	
 	
 	int count = metaobject->methodCount();
 	int offset = metaobject->methodOffset();
 
-printf("qt_metacall id: %d count: %d offset: %d\n", id, count, offset);	
-
 	if (id < offset) {
 		// Assume the target slot is a C++ one
 		smokeruby_object *o = value_obj_info(self);
@@ -1942,84 +1930,7 @@
 	return INT2NUM(id - count);
 }
 
-
-/*
 static VALUE
-qt_metacall(int argc, VALUE * argv, VALUE self)
-{
-	int _id = 0;
-	// Arguments: QMetaObject::Call _c, int _id, void ** _a
-	QMetaObject::Call _c = (QMetaObject::Call) NUM2INT(	rb_funcall(	qt_internal_module,
-																	rb_intern("get_qinteger"), 
-																	1, 
-																	argv[0] ) );
-
-	int id = NUM2INT(argv[1]);
-	void ** _a = 0;
-
-	// Note that for a slot with no args and no return type,
-	// it isn't an error to get a NULL value of _o here.
-	Data_Get_Struct(argv[2], void*, _a);
-
-	smokeruby_object *o = value_obj_info(self);
-	Smoke::Index nameId = o->smoke->idMethodName("qt_metacall$$?");
-	Smoke::Index meth = o->smoke->findMethod(o->classId, nameId);
-	if(meth > 0) {
-		Smoke::Method &m = o->smoke->methods[o->smoke->methodMaps[meth].method];
-		Smoke::ClassFn fn = o->smoke->classes[m.classId].classFn;
-		Smoke::StackItem i[4];
-		i[1].s_enum = _c;
-		i[2].s_int = id;
-		i[3].s_voidp = _a;
-		(*fn)(m.method, o->ptr, i);
-		_id = i[0].s_int;
-	} else {
-		// Should never happen..
-		rb_raise(rb_eRuntimeError, "Cannot find %s::qt_metacall() method\n", 
-			o->smoke->classes[o->classId].className );
-	}
-
-printf("qt_metacall _id: %d\n", _id);	
-	if (_id < 0) {
-		return _id;
-	}
-	
-	VALUE metaObject_value = rb_funcall(CLASS_OF(self), rb_intern("staticMetaObject"), \
                0);
-	smokeruby_object *ometa = value_obj_info(metaObject_value);
-	if (!ometa) return argv[1];
-	
-	QMetaObject *metaobject = (QMetaObject*) ometa->ptr;
-
-    if (_c == QMetaObject::InvokeMetaMethod) {
-		int count = metaobject->methodCount();
-		int offset = metaobject->methodOffset();
-printf("qt_metacall count: %d offset: %d _id: %d\n", count, offset, _id);	
-		
-		QMetaMethod method = metaobject->method(offset + _id);
-		
-		VALUE mocArgs = rb_funcall(	qt_internal_module, 
-									rb_intern("getMocArguments"), 
-									2, 
-									rb_str_new2(method.typeName()),
-									rb_str_new2(method.signature()) );
-		
-		QString name(method.signature());
-static QRegExp * rx = 0;
-		if (rx == 0) {
-			rx = new QRegExp("\\(.*");
-		}
-		name.replace(*rx, "");
-
-		InvokeSlot slot(self, rb_intern(name.toLatin1()), mocArgs, _a);
-		slot.next();
-		_id -= count;
-	}
-	
-	return INT2NUM(_id);
-}
-*/
-
-static VALUE
 qobject_connect(int argc, VALUE * argv, VALUE self)
 {
 	if (rb_block_given_p()) {
@@ -2341,13 +2252,28 @@
 }
 
 static VALUE
-make_metaObject(VALUE /*self*/, VALUE superklass, VALUE stringdata_value, VALUE \
data_value) +make_metaObject(VALUE /*self*/, VALUE obj, VALUE stringdata_value, VALUE \
data_value)  {
-	VALUE metaObject = rb_funcall(superklass, rb_intern("staticMetaObject"), 0);
-	smokeruby_object *o = value_obj_info(metaObject);
-	QMetaObject * superdata = (QMetaObject*) o->ptr;
-printf("superdata className: %s\n", superdata->className());
+    smokeruby_object *o = value_obj_info(obj);
+    if (!o || !o->ptr) {
+    	rb_raise(rb_eRuntimeError, "Cannot create metaObject\n");
+    }
 
+	Smoke::Index nameId = o->smoke->idMethodName("metaObject");
+	Smoke::Index meth = o->smoke->findMethod(o->classId, nameId);
+	if (meth <= 0) {
+		// Should never happen..
+    	rb_raise(	rb_eRuntimeError, 
+					"Cannot find %s::metaObject() method\n", 
+					o->smoke->classes[o->classId].className );
+	}
+
+	Smoke::Method &methodId = o->smoke->methods[o->smoke->methodMaps[meth].method];
+	Smoke::ClassFn fn = o->smoke->classes[methodId.classId].classFn;
+	Smoke::StackItem i[1];
+	(*fn)(methodId.method, o->ptr, i);
+
+	QMetaObject *superdata = (QMetaObject *) i[0].s_voidp;
 	char *stringdata = new char[RSTRING(stringdata_value)->len];
 
 	int count = RARRAY(data_value)->len;
@@ -2367,7 +2293,7 @@
 	QMetaObject * meta = new QMetaObject;
 	*meta = ob;
 
-//#ifdef DEBUG
+#ifdef DEBUG
 	printf("make_metaObject() superdata: %p\n", meta->d.superdata);
 	printf("stringdata: ");
 	for (int j = 0; j < RSTRING(stringdata_value)->len; j++) {
@@ -2384,7 +2310,7 @@
 		printf("%d, ", data[i]);
 	}
 	printf("\n");
-//#endif
+#endif
 
     smokeruby_object * m = (smokeruby_object *) malloc(sizeof(smokeruby_object));
     m->smoke = qt_Smoke;
@@ -2400,7 +2326,6 @@
 {
 	rb_define_method(klass, "qt_metacall", (VALUE (*) (...)) qt_metacall, -1);
 	rb_define_method(klass, "metaObject", (VALUE (*) (...)) metaObject, 0);
-    rb_define_singleton_method(klass, "staticMetaObject", (VALUE (*) (...)) \
staticMetaObject, 0);  return self;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic