[Kde-bindings] custom slots

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon May 15 10:17:33 UTC 2006


On Tuesday 09 May 2006 22:47, Thomas Moenicke wrote:
> Hi Richard,
>
> Richard Dale wrote:
> > First it calls the QObject::metaObject() method via the Smoke library on
> > the parent class to get the parent QMetaObject ('superdata'). Then it
> > unwraps the C data from the ruby arguments passed, and constructs the
> > QMetaObject with this call:
> >
> > 	QMetaObject ob = {
> > 		{ superdata, stringdata, data, 0 }
> > 	} ;
> >
> > 	QMetaObject * meta = new QMetaObject;
> > 	*meta = ob;
>
> It works fine. Nice to have tutorial 7 :-)
Congratulations! Once, you have tutorial 7 working you're nearly there..

> Is it possible to replace the staticMetaObject? I made a 'QMetaObject*
> dynamicMetaObject' member of the class and could access it, but it lost its
> values at runtime. It is wastage to rebuild the object in every call of
> metaObject(). Otherwise, I can add new slots at runtime.
QtRuby keeps the QMetaObject is creates in a Hash table with an entry for each 
class. It only rebuilds it if the slots/signals for the class change - if 
extra slots/signals are added, the entry is marked 'changed' and recreated 
when the next QObject.metaObject() call is made.

> > If the id passed to qt_metacall is less than the start offset for the
> > signals in the dynamically constructed QMetaObject for ruby slots, then
> > it must be a C++. Otherwise, it drops through the 'id < offset' test and
> > the code marshalls the C++ args in '_o' to ruby ones and calls the ruby
> > method.
>
> It is easy to implement it with the help of indexOfSlot(int),
> indexOfSignals(int) methods, the array members of _a[] can be invoked into
> zend types.
Yes, the only problem I had was that I found '&'s are dropped from the 
slot/signal types signatures, although '*'s are kept.

-- Richard



More information about the Kde-bindings mailing list