1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef GENERATOR_H
5#define GENERATOR_H
6
7#include "moc.h"
8
9QT_BEGIN_NAMESPACE
10
11class Generator
12{
13 FILE *out;
14 ClassDef *cdef;
15 QList<uint> meta_data;
16
17public:
18 Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes,
19 const QHash<QByteArray, QByteArray> &knownQObjectClasses,
20 const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile = nullptr,
21 bool requireCompleteTypes = false);
22 void generateCode();
23private:
24 bool registerableMetaType(const QByteArray &propertyType);
25 void registerClassInfoStrings();
26 void generateClassInfos();
27 void registerFunctionStrings(const QList<FunctionDef> &list);
28 void registerByteArrayVector(const QList<QByteArray> &list);
29 void generateFunctions(const QList<FunctionDef> &list, const char *functype, int type,
30 int &paramsIndex, int &initialMetatypeOffset);
31 void generateFunctionRevisions(const QList<FunctionDef> &list, const char *functype);
32 void generateFunctionParameters(const QList<FunctionDef> &list, const char *functype);
33 void generateTypeInfo(const QByteArray &typeName, bool allowEmptyName = false);
34 void registerEnumStrings();
35 void generateEnums(int index);
36 void registerPropertyStrings();
37 void generateProperties();
38 void generateMetacall();
39 void generateStaticMetacall();
40 void generateSignal(FunctionDef *def, int index);
41 void generatePluginMetaData();
42 QMultiMap<QByteArray, int> automaticPropertyMetaTypesHelper();
43 QMap<int, QMultiMap<QByteArray, int>>
44 methodsWithAutomaticTypesHelper(const QList<FunctionDef> &methodList);
45
46 void strreg(const QByteArray &); // registers a string
47 int stridx(const QByteArray &); // returns a string's id
48 QList<QByteArray> strings;
49 QByteArray purestSuperClass;
50 QList<QByteArray> metaTypes;
51 QHash<QByteArray, QByteArray> knownQObjectClasses;
52 QHash<QByteArray, QByteArray> knownGadgets;
53 bool requireCompleteTypes;
54};
55
56QT_END_NAMESPACE
57
58#endif // GENERATOR_H
59

source code of qtbase/src/tools/moc/generator.h