[Kde-bindings] KDE/kdebindings

Richard Dale rdale at foton.es
Thu Nov 26 11:47:24 UTC 2009


On Wednesday 25 November 2009 09:24:14 pm Arno Rehn wrote:
> On Wednesday 25 November 2009 20:15:12 Richard Dale wrote:
> > On Wednesday 25 November 2009 07:10:32 pm Arno Rehn wrote:
> > > SVN commit 1054240 by arnorehn:
> > >
> > > Add mf_virtual and mf_purevirtual method flags to SMOKE and make
> > > generator flag the methods accordingly.
> > >
> > > CCMAIL: kde-bindings at kde.org
> > >
> > >
> > >
> > >  M  +10 -0     generator/generators/smoke/writeSmokeDataFile.cpp
> > >  M  +3 -1      smoke/smoke.h
> > >
> > >
> > > ---
> > > trunk/KDE/kdebindings/generator/generators/smoke/writeSmokeDataFile.cpp
> > > #1054239:1054240 @@ -451,6 +451,8 @@
> > >          if (isExternal && !declaredVirtualMethods.contains(klass))
> > >              continue;
> > >
> > > +        QList<const Method*> virtualMethods =
> > >  Util::virtualMethodsForClass(klass); +
> > >          int xcall_index = 1;
> > >          foreach (const Method& meth, klass->methods()) {
> > >              if (isExternal &&
> > >  !declaredVirtualMethods[klass].contains(&meth)) @@ -486,6 +488,14 @@
> > >                  flags += "|Smoke::mf_attribute";
> > >              if (meth.isQPropertyAccessor())
> > >                  flags += "|Smoke::mf_property";
> > > +
> > > +            // Simply checking for flags() & Method::Virtual won't be
> > >  enough, because methods can override virtuals without being +
> > >  // declared 'virtual' themselves (and they're still virtual, then). +
> > >        if (virtualMethods.contains(&meth))
> > > +                flags += "|Smoke::mf_virtual";
> > > +            if (meth.flags() & Method::PureVirtual)
> > > +                flags += "|Smoke::mf_purevirtual";
> > > +
> > >              flags.replace("0|", "");
> > >              out << flags;
> > >              if (meth.type() == Type::Void) {
> > > --- trunk/KDE/kdebindings/smoke/smoke.h #1054239:1054240
> > > @@ -131,7 +131,9 @@
> > >          mf_dtor = 0x40,
> > >          mf_protected = 0x80,
> > >          mf_attribute = 0x100,
> > > -        mf_property = 0x200
> > > +        mf_property = 0x200,
> > > +        mf_virtual = 0x400,
> > > +        mf_purevirtual = 0x800
> > >      };
> > >      /**
> > >       * Describe one method of one class.
> >
> > Looks good. Would it be possible to have an mf_signal attribute too? That
> > would be useful for the QtScript bindings which need to do something
> > different for calls on signal methods.
> 
> Yes, but you can obtain information about signals and slots from the meta
> object anyway. That's how I want to do it in the C# assembly generator,
>  too. Just call staticMetaObject() via smoke and you have all the
>  information available in the QMetaObject.
That is ok to do once at code generation time, but it is too slow to do at 
runtime with the QtScript bindings. For every method call (even for non-
signals) I would need to search through all the signal entries in the 
QMetaObject and its parents. If there is a mf_signal flag I can look up the 
method as usual in the smoke lib, and then special case any signals I find.

Similary it is possible to determine whether or not a method is overloaded in 
the smoke lib as all the info is there, it just isn't easy to do it efficiently 
at runtime and a mf_overloaded flag would be a really useful for optimization 
IMHO.

-- Richard



More information about the Kde-bindings mailing list