@@ -33,13 +33,19 @@ public ICollection<KeyValuePair<string, string>> GetVerifiedWrappedModules()
3333
3434 public void Preprocess ( Driver driver , ASTContext lib )
3535 {
36- foreach ( var unit in lib . TranslationUnits . Where ( u => u . FilePath != "<invalid>" ) )
36+ foreach ( var unit in lib . TranslationUnits . Where ( u => u . IsValid ) )
3737 {
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+ }
3947 }
4048 lib . SetClassAsValueType ( "QByteArray" ) ;
41- lib . SetClassAsValueType ( "QListData" ) ;
42- lib . SetClassAsValueType ( "QListData::Data" ) ;
4349 lib . SetClassAsValueType ( "QLocale" ) ;
4450 lib . SetClassAsValueType ( "QModelIndex" ) ;
4551 lib . SetClassAsValueType ( "QPoint" ) ;
@@ -51,8 +57,6 @@ public void Preprocess(Driver driver, ASTContext lib)
5157 lib . SetClassAsValueType ( "QGenericArgument" ) ;
5258 lib . SetClassAsValueType ( "QGenericReturnArgument" ) ;
5359 lib . SetClassAsValueType ( "QVariant" ) ;
54- lib . IgnoreClassMethodWithName ( "QString" , "fromStdWString" ) ;
55- lib . IgnoreClassMethodWithName ( "QString" , "toStdWString" ) ;
5660
5761 // QString is type-mapped to string so we only need two methods for the conversion
5862 var qString = lib . FindCompleteClass ( "QString" ) ;
@@ -133,6 +137,34 @@ where string.IsNullOrEmpty(@enum.Name)
133137 {
134138 enumeration . Name = "TypeEnum" ;
135139 }
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+ }
136168 }
137169
138170 private static void IgnorePrivateDeclarations ( DeclarationContext unit )
@@ -163,15 +195,15 @@ private static void IgnorePrivateDeclaration(Declaration declaration)
163195
164196 public void Postprocess ( Driver driver , ASTContext lib )
165197 {
166- new ClearCommentsPass ( ) . VisitLibrary ( driver . ASTContext ) ;
198+ new ClearCommentsPass ( ) . VisitLibrary ( driver . Context . ASTContext ) ;
167199 var modules = this . qtInfo . LibFiles . Select ( l => GetModuleNameFromLibFile ( l ) ) ;
168200 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 ) ;
170202 System . Console . WriteLine ( "Documentation done in: {0}" , s . Elapsed ) ;
171203 new CaseRenamePass (
172204 RenameTargets . Function | RenameTargets . Method | RenameTargets . Property | RenameTargets . Delegate |
173205 RenameTargets . Field | RenameTargets . Variable ,
174- RenameCasePattern . UpperCamelCase ) . VisitLibrary ( driver . ASTContext ) ;
206+ RenameCasePattern . UpperCamelCase ) . VisitLibrary ( driver . Context . ASTContext ) ;
175207
176208 var qChar = lib . FindCompleteClass ( "QChar" ) ;
177209 var op = qChar . FindOperator ( CXXOperatorKind . ExplicitConversion )
@@ -203,18 +235,18 @@ public void Postprocess(Driver driver, ASTContext lib)
203235
204236 public void Setup ( Driver driver )
205237 {
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" ) ;
206244 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 ;
212245 driver . Options . GenerateInterfacesForMultipleInheritance = true ;
213246 driver . Options . GeneratePropertiesAdvanced = true ;
214247 driver . Options . UnityBuild = true ;
215248 driver . Options . IgnoreParseWarnings = true ;
216249 driver . Options . CheckSymbols = true ;
217- driver . Options . GenerateSingleCSharpFile = true ;
218250 driver . Options . GenerateInlines = true ;
219251 driver . Options . CompileCode = true ;
220252 driver . Options . GenerateDefaultValuesForArguments = true ;
@@ -266,25 +298,27 @@ public void Setup(Driver driver)
266298 module . CodeFiles . Add ( Path . Combine ( dir , "QObject.cs" ) ) ;
267299 module . CodeFiles . Add ( Path . Combine ( dir , "QChar.cs" ) ) ;
268300 module . CodeFiles . Add ( Path . Combine ( dir , "QEvent.cs" ) ) ;
269- module . CodeFiles . Add ( Path . Combine ( dir , "_iobuf.cs" ) ) ;
270301 }
271302
272303 driver . Options . Modules . Add ( module ) ;
273304 }
274305
275306 foreach ( var systemIncludeDir in this . qtInfo . SystemIncludeDirs )
276- driver . Options . addSystemIncludeDirs ( systemIncludeDir ) ;
307+ driver . ParserOptions . addSystemIncludeDirs ( systemIncludeDir ) ;
277308
278309 if ( Platform . IsMacOS )
279310 {
280311 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 ) ) ;
283314 }
284315
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" ) ;
288322 }
289323
290324 public static string GetModuleNameFromLibFile ( string libFile )
@@ -299,10 +333,10 @@ public static string GetModuleNameFromLibFile(string libFile)
299333
300334 public void SetupPasses ( Driver driver )
301335 {
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 ( ) ) ;
306340 }
307341
308342 private readonly QtInfo qtInfo ;
0 commit comments