[Kde-bindings] playground/bindings/kimono

Richard Dale rdale at foton.es
Tue Feb 27 09:04:33 UTC 2007


On Tuesday 27 February 2007, Richard Dale wrote:
> Here is how I think parent_meta_object() and make_metaObject() should be:
>
> QMetaObject* parent_meta_object(void* obj) {
>     smokeqyoto_object* o = value_obj_info(obj);
>     Smoke::Index nameId = o->smoke->idMethodName("metaObject");
>     Smoke::Index parent_index = o->smoke->classes[o->classId].parents;
>     if (!parent_index)
>         return 0;
>
>     Smoke::Index parentId = o->smoke->inheritanceList[parent_index];
>     Smoke::Index meth = o->smoke->findMethod(parentId, nameId);
>     if (meth <= 0)
>         return 0;
>        
>     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);
>    
>     return (QMetaObject*) i[0].s_voidp;
> }
This code isn't the same a the QtRuby code, and I wonder if it's wrong. Why is 
it going to the parent class? I think it should be this:

QMetaObject* parent_meta_object(void* obj) {
    smokeqyoto_object* o = value_obj_info(obj);
	Smoke::Index nameId = o->smoke->idMethodName("metaObject");
	Smoke::Index meth = o->smoke->findMethod(o->classId, nameId);
	if (meth <= 0) {
		// Should never happen..
	}

	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);
    return (QMetaObject*) i[0].s_voidp;
}

-- Richard




More information about the Kde-bindings mailing list