@@ -10039,6 +10039,92 @@ void writeAllDCode(string outputPath, bool outputIsDir, DCodeOptions options, Se
10039
10039
}
10040
10040
}
10041
10041
10042
+ void findQtMetaTypeId (Tree t)
10043
+ {
10044
+ if (! t.isValid)
10045
+ return ;
10046
+ if (t.nodeType == NodeType.array)
10047
+ {
10048
+ foreach (c; t.childs)
10049
+ findQtMetaTypeId(c);
10050
+ }
10051
+ else if (t.nodeType == NodeType.merged)
10052
+ {
10053
+ auto mdata = &mergedSemantic.mergedTreeData(t);
10054
+ foreach (i, c; t.childs)
10055
+ if (! mdata.conditions[i].isFalse)
10056
+ findQtMetaTypeId(c);
10057
+ }
10058
+ else if (t.nodeType == NodeType.nonterminal
10059
+ && t.nonterminalID == CONDITION_TREE_NONTERMINAL_ID )
10060
+ {
10061
+ foreach (c; t.childs)
10062
+ findQtMetaTypeId(c);
10063
+ }
10064
+ else if (t.nonterminalID == nonterminalIDFor! " ClassSpecifier" )
10065
+ {
10066
+ findQtMetaTypeId(t.childs[0 ]);
10067
+ }
10068
+ else if (t.nonterminalID == nonterminalIDFor! " ClassHead" && t.hasChildWithName(" name" ))
10069
+ {
10070
+ findQtMetaTypeId(t.childByName(" name" ));
10071
+ }
10072
+ else if (t.nonterminalID == nonterminalIDFor! " ClassHeadName" )
10073
+ {
10074
+ findQtMetaTypeId(t.childs[$ - 1 ]);
10075
+ }
10076
+ else if (t.nonterminalID == nonterminalIDFor! " SimpleTemplateId" )
10077
+ {
10078
+ findQtMetaTypeId(t.childs[2 ]);
10079
+ }
10080
+ else if (t.nonterminalID == nonterminalIDFor! " TypeId" )
10081
+ {
10082
+ auto type = mergedSemantic.extraInfo(t).type;
10083
+
10084
+ if (type.kind == TypeKind.record)
10085
+ {
10086
+ auto recordType = cast (RecordType) type.type;
10087
+ foreach (e2; recordType.declarationSet.entries)
10088
+ {
10089
+ if (e2.data.type != DeclarationType.type)
10090
+ continue ;
10091
+ if (e2.data.flags & DeclarationFlags.forward)
10092
+ continue ;
10093
+ data.declarationData(e2.data)
10094
+ .extraAttributes.addOnce(" Q_DECLARE_METATYPE" );
10095
+
10096
+ auto f = getDeclarationFilename(e2.data, data);
10097
+
10098
+ if (f ! in data.importGraph)
10099
+ data.importGraph[f] = null ;
10100
+
10101
+ ImportInfo importInfo;
10102
+ if (" qt.core.metatype" in data.importGraph[f])
10103
+ {
10104
+ importInfo = data.importGraph[f][" qt.core.metatype" ];
10105
+ importInfo.condition = mergedSemantic.logicSystem.or(importInfo.condition,
10106
+ e2.condition);
10107
+ importInfo.outsideFunction |= true ;
10108
+ }
10109
+ else
10110
+ {
10111
+ importInfo = new ImportInfo;
10112
+ data.importGraph[f][" qt.core.metatype" ] = importInfo;
10113
+ importInfo.condition = e2.condition;
10114
+ importInfo.outsideFunction = true ;
10115
+ }
10116
+ }
10117
+ }
10118
+ }
10119
+ }
10120
+ if (" QMetaTypeId" in data.semantic.rootScope.symbols)
10121
+ foreach (e; data.semantic.rootScope.symbols[" QMetaTypeId" ].entries)
10122
+ {
10123
+ if (! (e.data.flags & DeclarationFlags.templateSpecialization))
10124
+ continue ;
10125
+ findQtMetaTypeId(e.data.tree);
10126
+ }
10127
+
10042
10128
foreach (filename, decls; data.declsByFile)
10043
10129
{
10044
10130
foreach (d; decls)
0 commit comments