mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
using CppSharp.AST; |
|
|
|
namespace CppSharp.Passes |
|
{ |
|
public class FindSymbolsPass : TranslationUnitPass |
|
{ |
|
public FindSymbolsPass() |
|
{ |
|
Options.VisitClassBases = false; |
|
Options.VisitFunctionParameters = false; |
|
Options.VisitFunctionReturnType = false; |
|
Options.VisitNamespaceEnums = false; |
|
Options.VisitNamespaceTemplates = false; |
|
Options.VisitNamespaceTypedefs = false; |
|
Options.VisitTemplateArguments = false; |
|
Options.VisitClassFields = false; |
|
} |
|
|
|
public override bool VisitDeclaration(Declaration decl) |
|
{ |
|
if (!base.VisitDeclaration(decl)) |
|
return false; |
|
|
|
var options = Driver.Options; |
|
if (!options.CheckSymbols || options.IsCLIGenerator) |
|
return false; |
|
|
|
var mangledDecl = decl as IMangledDecl; |
|
var method = decl as Method; |
|
if (decl.IsGenerated && mangledDecl != null && |
|
!(method != null && (method.IsPure || method.IsSynthetized)) && |
|
!VisitMangledDeclaration(mangledDecl)) |
|
{ |
|
decl.ExplicitlyIgnore(); |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
private bool VisitMangledDeclaration(IMangledDecl mangledDecl) |
|
{ |
|
var symbol = mangledDecl.Mangled; |
|
|
|
if (!Driver.Symbols.FindSymbol(ref symbol)) |
|
{ |
|
Driver.Diagnostics.Warning("Symbol not found: {0}", symbol); |
|
return false; |
|
} |
|
|
|
mangledDecl.Mangled = symbol; |
|
return true; |
|
} |
|
} |
|
}
|
|
|