moc and Q_DECLARE_INTERFACE

Andreas Pakulat apaku at gmx.de
Sat Mar 24 00:32:07 UTC 2007


Hi,

before I try to reach the moc developers @TT (btw, whats the best way to
contact TT for stuff like this - I doubt qt-interest readers will have a
good answer to this), I'd like to ask around here:

Anybody got an idea why the following macro is recognized by moc and the
proper interface-stuff added to the .moc file, while renaming the macro
into KDEV_DECLARE_EXTENSION_INTERFACE makes the whole thing break
because moc doesn't include the needed stuff in the .moc file:

#define Q_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
const char * const IFace##_iid = IId; \
Q_DECLARE_INTERFACE(IFace, IId) \
template <> inline IFace *qt_extension<IFace *>(QAbstractExtensionManager *manager, QObject *object) \
{ \
QObject *extension = manager->extension(object, Q_TYPEID(IFace)); \
return extension ? static_cast<IFace *>(extension->qt_metacast(IFace##_iid)) : static_cast<IFace *>(0);\
}

I tried to read through mocs parsing code, but thats really "strange"
stuff and I couldn't find out why it works for the Q_ version, but not
for the KDEV_ version. I don't see anything in moc's code that looks
like its recognizing Q_DECLARE_EXTENSION_INTERFACE. I tried to add some
-I switches to moc, but that doesn't help either.

Andreas

PS: KDEV_DECLARE_EXTENSION_INTERFACE looks like this (without the
Q_DECLARE_INTERFACE code):
#define KDEV_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
const char * const IFace##_iid = IId; \
template <> inline IFace *qt_extension<IFace *>( \
QAbstractExtensionManager *manager, QObject *object) \
{ QObject *extension = manager->extension(object, Q_TYPEID(IFace)); \
return extension ? static_cast<IFace *>(extension->qt_metacast( \
IFace##_iid)) : static_cast<IFace *>(0); }

-- 
Today is National Existential Ennui Awareness Day.




More information about the KDevelop-devel mailing list