[Kde-bindings] smoke usage - how to create new bindings

Arno Rehn arno at arnorehn.de
Thu Aug 6 10:25:19 UTC 2009


On Thursday 06 August 2009 12:14:00 Petr Vanek wrote:
> On Aug 3, 2009, at 5:47 PM, Jonathan Yu wrote:
> > On Mon, Aug 3, 2009 at 11:38 AM, Arno Rehn<arno at arnorehn.de> wrote:
> >> On Monday 03 August 2009 17:33:44 Petr Vanek wrote:
> >>> Is there any "minimal" (pseudocode) code to show how Smoke works?
> >>> What
> >>> to implement to do basic marshalling etc.
> >>
> >> Hi Petr,
> >>
> >> take a look at http://techbase.kde.org/Development/Languages/
> >> Smoke . There's
> >> information about what smoke does and a minimal example in C++. It
> >> should give
> >> you an idea how to use SMOKE. If it's still not clear, feel free to
> >> ask :).
> >
> > I should note that when I first started working with it, that
> > description wasn't as thorough as I would have liked. Luckily Chris
> > Burel (of the perlqt4 project) wrote something nice which can be used
> > as supplemental information:
> >
> > http://code.google.com/p/perlqt4/wiki/Smoke_API_documentation
> >
> > (It's on the perlqt4 wiki but not specific to Perl)
>
> doh, this is *very* important document. Thanks for it.
>
> I'd like to examine one more thing. Let's say I have an (qt) object
> created in my lang. I can call its methods etc. as it's described in
> Smoke's methodMaps, flags etc.
> But how I should handle it "backwards"? E.g. how will be my language
> object notified about calls from Qt?
For virtual method calls that you override in your language, you have the 
SmokeBinding class. It has a method called 'callMethod' which is invoked every 
time a virtual method is called. You then have to check if the method is 
overriden in your language and possibly call that. Depending on whether you 
return true or false in 'callMethod' the original implementation of the 
virtual method will be called.

> How will be my language core
> infromed about new objects created by Qt?
What do you mean by that? Objects that are returned from a method call or 
given as parameters to virtual methods can simply be wrapped. If you really 
want to keep track of each and every (Q)Object that is created and destroyed, 
I believe you can use Qt's event filter stuff. Maybe take a look at Qyoto's or 
QtRuby's sources to see examples of that (though we only watch out for 
ChildAdd / ChildRemove events).

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list