[Kde-bindings] smoke function docs

Arno Rehn arno at arnorehn.de
Fri Aug 7 10:44:37 UTC 2009


On Friday 07 August 2009 12:05:18 Petr Vanek wrote:
> hi again,
>
> Can anybody supply missing info and/or correct me if I'm wrong with
> this exmplanation, please?
>
>     /*! Function to call given object's method with arguments.
>     \param method a method index. E.g. from findMethod etc.
>     \param obj an object (e.g. Qt object for Qt smoke) to call its
> method.
>     \param args Smoke::Stack with method's arguments.
>
>     Special case: method index 0 is used to setup binding object
>     inherited "SmokeBinding" instance.
>     */
>     typedef void (*ClassFn)(Index method, void* obj, Stack args);
You probably mean that, but there are two different 'types' of indices for 
methods. One that points to the Method struct in the methods table (i.e. 
qt_smoke->methods[index] ) and the other one that points to the index as used 
for calling the method with ClassFn (which is Smoke::Method::index). The one 
used here is Smoke::Method::index.

>     /*! Function to preform type cast.
>     \param obj ???
>     \param from ??? which index?
>     \param to ??? which index?
>     */
>     typedef void* (*CastFn)(void* obj, Index from, Index to);
'obj' is the object you want to cast to another type. 'from' is the current 
class index of 'obj' and 'to' the index of the class you want it to cast to.
This function is only useful in cases where the 'this' pointer changes 
depending on which type it is casted to. This is the case for multiple 
inheritance. If the method of an object which has more than one base is 
defined in a superclass, you have to use this function to upcast and get the 
correct 'this' pointer.

>     /*! Handling enum "methods".
>     \param EnumOperation EnumNew=?, EnumDelete=?,
>          EnumFromLong=smoked enum to long type,
>          EnumToLong=long type to smoked enum
>     \param Index ??? ondex of what? Enum "method"?
>     \param void* &  ??? reference to what?
>     \param long& long variable to handle with
>     */
>     typedef void (*EnumFn)(EnumOperation, Index, void*&, long&);
You can dynamically create instances of enums on the heap with smoke. 
EnumOperation is self-explaining, then :). 'Index' is the index of the enum 
(which should be in the 'classes' table as well, iirc), the void* is the 
pointer to the enum-instance and the 'long&' param is used to set or get a 
value from the enum-instance.

> thanks and cheers,
> Petr
No problem :)

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list