@@ -33,13 +33,19 @@ public ICollection<KeyValuePair<string, string>> GetVerifiedWrappedModules()
33
33
34
34
public void Preprocess ( Driver driver , ASTContext lib )
35
35
{
36
- foreach ( var unit in lib . TranslationUnits . Where ( u => u . FilePath != "<invalid>" ) )
36
+ foreach ( var unit in lib . TranslationUnits . Where ( u => u . IsValid ) )
37
37
{
38
- IgnorePrivateDeclarations ( unit ) ;
38
+ // HACK: work around https://github.com/mono/CppSharp/issues/677
39
+ if ( unit . FileName == "locale_classes.tcc" )
40
+ {
41
+ unit . ExplicitlyIgnore ( ) ;
42
+ }
43
+ else
44
+ {
45
+ IgnorePrivateDeclarations ( unit ) ;
46
+ }
39
47
}
40
48
lib . SetClassAsValueType ( "QByteArray" ) ;
41
- lib . SetClassAsValueType ( "QListData" ) ;
42
- lib . SetClassAsValueType ( "QListData::Data" ) ;
43
49
lib . SetClassAsValueType ( "QLocale" ) ;
44
50
lib . SetClassAsValueType ( "QModelIndex" ) ;
45
51
lib . SetClassAsValueType ( "QPoint" ) ;
@@ -51,8 +57,6 @@ public void Preprocess(Driver driver, ASTContext lib)
51
57
lib . SetClassAsValueType ( "QGenericArgument" ) ;
52
58
lib . SetClassAsValueType ( "QGenericReturnArgument" ) ;
53
59
lib . SetClassAsValueType ( "QVariant" ) ;
54
- lib . IgnoreClassMethodWithName ( "QString" , "fromStdWString" ) ;
55
- lib . IgnoreClassMethodWithName ( "QString" , "toStdWString" ) ;
56
60
57
61
// QString is type-mapped to string so we only need two methods for the conversion
58
62
var qString = lib . FindCompleteClass ( "QString" ) ;
@@ -133,6 +137,34 @@ where string.IsNullOrEmpty(@enum.Name)
133
137
{
134
138
enumeration . Name = "TypeEnum" ;
135
139
}
140
+
141
+ // HACK: work around https://github.com/mono/CppSharp/issues/692
142
+ foreach ( var name in new [ ] { "QImage" , "QPixmap" } )
143
+ {
144
+ var @class = lib . FindCompleteClass ( name ) ;
145
+ var ctorWithArray = @class . Constructors . FirstOrDefault (
146
+ c => c . Parameters . Count == 1 && c . Parameters [ 0 ] . Type . Desugar ( ) is ArrayType ) ;
147
+ if ( ctorWithArray != null )
148
+ {
149
+ ctorWithArray . ExplicitlyIgnore ( ) ;
150
+ }
151
+ }
152
+ foreach ( var name in new [ ] { "QGraphicsScene" , "QGraphicsView" } )
153
+ {
154
+ var @class = lib . FindCompleteClass ( name ) ;
155
+ var drawItems = @class . Methods . FirstOrDefault ( m => m . OriginalName == "drawItems" ) ;
156
+ if ( drawItems != null )
157
+ {
158
+ drawItems . ExplicitlyIgnore ( ) ;
159
+ }
160
+ }
161
+ lib . FindCompleteClass ( "QAbstractPlanarVideoBuffer" ) . ExplicitlyIgnore ( ) ;
162
+ var qAbstractVideoBuffer = lib . FindCompleteClass ( "QAbstractVideoBuffer" ) ;
163
+ var mapPlanes = qAbstractVideoBuffer . Methods . FirstOrDefault ( m => m . OriginalName == "mapPlanes" ) ;
164
+ if ( mapPlanes != null )
165
+ {
166
+ mapPlanes . ExplicitlyIgnore ( ) ;
167
+ }
136
168
}
137
169
138
170
private static void IgnorePrivateDeclarations ( DeclarationContext unit )
@@ -163,15 +195,15 @@ private static void IgnorePrivateDeclaration(Declaration declaration)
163
195
164
196
public void Postprocess ( Driver driver , ASTContext lib )
165
197
{
166
- new ClearCommentsPass ( ) . VisitLibrary ( driver . ASTContext ) ;
198
+ new ClearCommentsPass ( ) . VisitLibrary ( driver . Context . ASTContext ) ;
167
199
var modules = this . qtInfo . LibFiles . Select ( l => GetModuleNameFromLibFile ( l ) ) ;
168
200
var s = System . Diagnostics . Stopwatch . StartNew ( ) ;
169
- new GetCommentsFromQtDocsPass ( this . qtInfo . Docs , modules ) . VisitLibrary ( driver . ASTContext ) ;
201
+ new GetCommentsFromQtDocsPass ( this . qtInfo . Docs , modules ) . VisitLibrary ( driver . Context . ASTContext ) ;
170
202
System . Console . WriteLine ( "Documentation done in: {0}" , s . Elapsed ) ;
171
203
new CaseRenamePass (
172
204
RenameTargets . Function | RenameTargets . Method | RenameTargets . Property | RenameTargets . Delegate |
173
205
RenameTargets . Field | RenameTargets . Variable ,
174
- RenameCasePattern . UpperCamelCase ) . VisitLibrary ( driver . ASTContext ) ;
206
+ RenameCasePattern . UpperCamelCase ) . VisitLibrary ( driver . Context . ASTContext ) ;
175
207
176
208
var qChar = lib . FindCompleteClass ( "QChar" ) ;
177
209
var op = qChar . FindOperator ( CXXOperatorKind . ExplicitConversion )
@@ -203,18 +235,18 @@ public void Postprocess(Driver driver, ASTContext lib)
203
235
204
236
public void Setup ( Driver driver )
205
237
{
238
+ driver . ParserOptions . MicrosoftMode = false ;
239
+ driver . ParserOptions . NoBuiltinIncludes = true ;
240
+ driver . ParserOptions . TargetTriple = this . qtInfo . Target ;
241
+ driver . ParserOptions . Abi = CppAbi . Itanium ;
242
+ driver . ParserOptions . Verbose = true ;
243
+ driver . ParserOptions . addDefines ( "__float128=void" ) ;
206
244
driver . Options . GeneratorKind = GeneratorKind . CSharp ;
207
- driver . Options . MicrosoftMode = false ;
208
- driver . Options . NoBuiltinIncludes = true ;
209
- driver . Options . TargetTriple = this . qtInfo . Target ;
210
- driver . Options . Abi = CppAbi . Itanium ;
211
- driver . Options . Verbose = true ;
212
245
driver . Options . GenerateInterfacesForMultipleInheritance = true ;
213
246
driver . Options . GeneratePropertiesAdvanced = true ;
214
247
driver . Options . UnityBuild = true ;
215
248
driver . Options . IgnoreParseWarnings = true ;
216
249
driver . Options . CheckSymbols = true ;
217
- driver . Options . GenerateSingleCSharpFile = true ;
218
250
driver . Options . GenerateInlines = true ;
219
251
driver . Options . CompileCode = true ;
220
252
driver . Options . GenerateDefaultValuesForArguments = true ;
@@ -266,25 +298,27 @@ public void Setup(Driver driver)
266
298
module . CodeFiles . Add ( Path . Combine ( dir , "QObject.cs" ) ) ;
267
299
module . CodeFiles . Add ( Path . Combine ( dir , "QChar.cs" ) ) ;
268
300
module . CodeFiles . Add ( Path . Combine ( dir , "QEvent.cs" ) ) ;
269
- module . CodeFiles . Add ( Path . Combine ( dir , "_iobuf.cs" ) ) ;
270
301
}
271
302
272
303
driver . Options . Modules . Add ( module ) ;
273
304
}
274
305
275
306
foreach ( var systemIncludeDir in this . qtInfo . SystemIncludeDirs )
276
- driver . Options . addSystemIncludeDirs ( systemIncludeDir ) ;
307
+ driver . ParserOptions . addSystemIncludeDirs ( systemIncludeDir ) ;
277
308
278
309
if ( Platform . IsMacOS )
279
310
{
280
311
foreach ( var frameworkDir in this . qtInfo . FrameworkDirs )
281
- driver . Options . addArguments ( string . Format ( "-F{0}" , frameworkDir ) ) ;
282
- driver . Options . addArguments ( string . Format ( "-F{0}" , qtInfo . Libs ) ) ;
312
+ driver . ParserOptions . addArguments ( string . Format ( "-F{0}" , frameworkDir ) ) ;
313
+ driver . ParserOptions . addArguments ( string . Format ( "-F{0}" , qtInfo . Libs ) ) ;
283
314
}
284
315
285
- driver . Options . addIncludeDirs ( qtInfo . Headers ) ;
286
-
287
- driver . Options . addLibraryDirs ( Platform . IsWindows ? qtInfo . Bins : qtInfo . Libs ) ;
316
+ driver . ParserOptions . addIncludeDirs ( qtInfo . Headers ) ;
317
+
318
+ driver . ParserOptions . addLibraryDirs ( Platform . IsWindows ? qtInfo . Bins : qtInfo . Libs ) ;
319
+
320
+ // Qt defines its own GUID with the same header guard as the system GUID, so ensure the system GUID is read first
321
+ driver . Project . AddFile ( "guiddef.h" ) ;
288
322
}
289
323
290
324
public static string GetModuleNameFromLibFile ( string libFile )
@@ -299,10 +333,10 @@ public static string GetModuleNameFromLibFile(string libFile)
299
333
300
334
public void SetupPasses ( Driver driver )
301
335
{
302
- driver . TranslationUnitPasses . AddPass ( new CompileInlinesPass ( this . qtInfo . QMake , this . qtInfo . Make ) ) ;
303
- driver . TranslationUnitPasses . AddPass ( new GenerateSignalEventsPass ( ) ) ;
304
- driver . TranslationUnitPasses . AddPass ( new GenerateEventEventsPass ( ) ) ;
305
- driver . TranslationUnitPasses . AddPass ( new RemoveQObjectMembersPass ( ) ) ;
336
+ driver . Context . TranslationUnitPasses . AddPass ( new CompileInlinesPass ( this . qtInfo . QMake , this . qtInfo . Make ) ) ;
337
+ driver . Context . TranslationUnitPasses . AddPass ( new GenerateSignalEventsPass ( driver . Generator ) ) ;
338
+ driver . Context . TranslationUnitPasses . AddPass ( new GenerateEventEventsPass ( driver . Generator ) ) ;
339
+ driver . Context . TranslationUnitPasses . AddPass ( new RemoveQObjectMembersPass ( ) ) ;
306
340
}
307
341
308
342
private readonly QtInfo qtInfo ;
0 commit comments