📄 moc.h
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the tools applications of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef MOC_H#define MOC_H#include "parser.h"#include <QStringList>#include <QMap>#include <QPair>#include <stdio.h>#include <ctype.h>struct QMetaObject;struct Type{ enum ReferenceType { NoReference, Reference, Pointer }; inline Type() : isVolatile(false), isScoped(false), firstToken(NOTOKEN), referenceType(NoReference) {} inline explicit Type(const QByteArray &_name) : name(_name), isVolatile(false), firstToken(NOTOKEN), referenceType(NoReference) {} QByteArray name; uint isVolatile : 1; uint isScoped : 1; Token firstToken; ReferenceType referenceType;};struct EnumDef{ QByteArray name; QList<QByteArray> values;};struct ArgumentDef{ ArgumentDef() : isDefault(false) {} Type type; QByteArray rightType, normalizedType, name; QByteArray typeNameForCast; // type name to be used in cast from void * in metacall bool isDefault;};struct FunctionDef{ FunctionDef(): returnTypeIsVolatile(false), access(Private), isConst(false), isVirtual(false), inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false), isScriptable(false), isSlot(false), isSignal(false) {} Type type; QByteArray normalizedType; QByteArray tag; QByteArray name; bool returnTypeIsVolatile; QList<ArgumentDef> arguments; enum Access { Private, Protected, Public }; Access access; bool isConst; bool isVirtual; bool inlineCode; bool wasCloned; QByteArray inPrivateClass; bool isCompat; bool isInvokable; bool isScriptable; bool isSlot; bool isSignal;};struct PropertyDef{ PropertyDef():gspec(ValueSpec){} QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user; enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; Specification gspec; bool stdCppSet() const { QByteArray s("set"); s += toupper(name[0]); s += name.mid(1); return (s == write); }};struct ClassInfoDef{ QByteArray name; QByteArray value;};struct ClassDef { ClassDef(): hasQObject(false), hasQGadget(false){} QByteArray classname; QByteArray qualified; QList<QPair<QByteArray, FunctionDef::Access> > superclassList; struct Interface { inline explicit Interface(const QByteArray &_className) : className(_className) {} QByteArray className; QByteArray interfaceId; }; QList<QList<Interface> >interfaceList; bool hasQObject; bool hasQGadget; QList<FunctionDef> signalList, slotList, methodList, publicList; QList<PropertyDef> propertyList; QList<ClassInfoDef> classInfoList; QMap<QByteArray, bool> enumDeclarations; QList<EnumDef> enumList; QMap<QByteArray, QByteArray> flagAliases; int begin; int end;};struct NamespaceDef { QByteArray name; int begin; int end;};class Moc : public Parser{public: Moc() : noInclude(false), generatedCode(false) {} QByteArray filename; bool noInclude; bool generatedCode; QByteArray includePath; QList<QByteArray> includeFiles; QList<ClassDef> classList; QMap<QByteArray, QByteArray> interface2IdMap; QList<QByteArray> metaTypes; QSet<QByteArray> knownQObjectClasses; void parse(); void generate(FILE *out); QList<QMetaObject*> generate(bool ignoreProperties); bool parseClassHead(ClassDef *def); inline bool inClass(const ClassDef *def) const { return index > def->begin && index < def->end - 1; } inline bool inNamespace(const NamespaceDef *def) const { return index > def->begin && index < def->end - 1; } Type parseType(); bool parseEnum(EnumDef *def); bool parseFunction(FunctionDef *def, bool inMacro = false); bool parseMaybeFunction(FunctionDef *def); void parseSlots(ClassDef *def, FunctionDef::Access access); void parseSignals(ClassDef *def); void parseProperty(ClassDef *def); void parseEnumOrFlag(ClassDef *def, bool isFlag); void parseFlag(ClassDef *def); void parseClassInfo(ClassDef *def); void parseInterfaces(ClassDef *def); void parseDeclareInterface(); void parseDeclareMetatype(); void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access); void parseFunctionArguments(FunctionDef *def); QByteArray lexemUntil(Token); bool until(Token); // test for Q_INVOCABLE, Q_SCRIPTABLE, etc. and set the flags // in FunctionDef accordingly bool testFunctionAttribute(FunctionDef *def); bool testFunctionAttribute(Token tok, FunctionDef *def); void checkSuperClasses(ClassDef *def);};inline QByteArray noRef(const QByteArray &type){ if (type.endsWith('&')) return type.left(type.length()-1); return type;}#endif // MOC_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -