Trying to understand moc
Andreas Pakulat
apaku at gmx.de
Thu Mar 29 20:09:12 BST 2007
On 29.03.07 20:26:53, Simon Hausmann wrote:
> On Thursday 29 March 2007 19:57:22 Andreas Pakulat wrote:
> > So basically I'm looking for a way to not have to use vthe
> > Q_DECLARE_INTERFACE macro when defining an interface (i.e. 2 macros,
> > the KDEV one because of the NS and the Q one for moc). The attached code
> > demonstrates the problem, just run it through moc and you see it
> > complains for the first macro but doesn't for the other 2.
> >
> > I'm happy to report this as a bug to TT if somebody says it looks like
> > one, it certainly doesn't look like a bug to me (yet).
>
> It's not really a bug, but I may be able to shed some light on this :)
>
> Originally moc only knew Q_DECLARE_INTERFACE but then Roberto started using
> Q_DECLARE_EXTENSION_INTERFACE in Designer. Sitting next to the source we
> added a hack to moc's tokenizer to map "Q_DECLARE_EXTENSION_INTERFACE" to the
> same token type as "Q_DECLARE_INTERFACE", namely Q_DECLARE_INTERAFCE_TOKEN.
> That is why you don't see anything about the extension macro in moc.cpp, it's
> all handled in ppkeywords.cpp.
Well, uhm you don't expect anybody to be able to understand that file,
do you ;)
> So unfortunately there's no way to make moc know about
> K_DECLARE_EXTENSION_INTERFACE from the outside until we get around
> implementing full macro substitution.
:(
> But I believe the solution to your original problem is much simpler:
>
> namespace Foo
> {
> struct MyInterface
> {
> ...
> };
> }
>
> Q_DECLARE_INTERFACE(Foo::MyInterface, "your.interface.name")
Uhm, no, we need the Extension Interfaces from Qt Designer, especially
the Q_DECLARE_EXTENSION_INTERFACE macro. Unfortunately that macro
doesn't work with namespaced interfaces (it declares a global static,
which needs to be inside the namespace, else the rest of the macro won't
work).
So for now, our only option is to tell users of the platform to use
KDEV_* macro + Q_DECLARE_INTERFACE.
Thx for the quick answer, btw.
Andreas
--
Stay the curse.
More information about the kde-core-devel
mailing list