Browse Source

Merge pull request #35 from ddobrev/master

Ignore any mangled declaration not found in library symbols
pull/38/merge
João Matos 12 years ago
parent
commit
c5e2216b2a
  1. 22
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 23
      src/Generator/Passes/FindSymbolsPass.cs

22
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -696,22 +696,18 @@ namespace CppSharp.Generators.CSharp
private Tuple<string, string> GetDeclarationLibrarySymbol(IMangledDecl decl) private Tuple<string, string> GetDeclarationLibrarySymbol(IMangledDecl decl)
{ {
var library = Options.SharedLibraryName; var library = Options.SharedLibraryName;
var symbol = decl.Mangled;
if (!Options.CheckSymbols) if (!Options.CheckSymbols)
goto Out; goto Out;
if (!FindMangledDeclSymbol(decl, out symbol))
goto Out;
NativeLibrary nativeLib; NativeLibrary nativeLib;
if (!Driver.LibrarySymbols.FindLibraryBySymbol(symbol, out nativeLib)) if (!Driver.LibrarySymbols.FindLibraryBySymbol(decl.Mangled, out nativeLib))
goto Out; goto Out;
library = Path.GetFileNameWithoutExtension(nativeLib.FileName); library = Path.GetFileNameWithoutExtension(nativeLib.FileName);
Out: Out:
return Tuple.Create(library, symbol); return Tuple.Create(library, decl.Mangled);
} }
private void GeneratePropertySetter<T>(T decl, Class @class) private void GeneratePropertySetter<T>(T decl, Class @class)
@ -2077,20 +2073,6 @@ namespace CppSharp.Generators.CSharp
return name; return name;
} }
bool FindMangledDeclSymbol(IMangledDecl decl, out string symbol)
{
symbol = decl.Mangled;
if (!Driver.LibrarySymbols.FindSymbol(ref symbol))
{
Driver.Diagnostics.EmitError(DiagnosticId.SymbolNotFound,
"Symbol not found: {0}", symbol);
symbol = null;
return false;
}
return true;
}
public void GenerateInternalFunction(Function function) public void GenerateInternalFunction(Function function)
{ {
if (!function.IsProcessed || function.ExplicityIgnored) if (!function.IsProcessed || function.ExplicityIgnored)

23
src/Generator/Passes/FindSymbolsPass.cs

@ -4,18 +4,27 @@ namespace CppSharp.Passes
{ {
public class FindSymbolsPass : TranslationUnitPass public class FindSymbolsPass : TranslationUnitPass
{ {
public override bool VisitFunctionDecl(Function function) public override bool VisitDeclaration(Declaration decl)
{ {
string symbol = function.Mangled; IMangledDecl mangledDecl = decl as IMangledDecl;
if (mangledDecl != null && !VisitMangledDeclaration(mangledDecl))
{
decl.ExplicityIgnored = true;
return false;
}
return base.VisitDeclaration(decl);
}
private bool VisitMangledDeclaration(IMangledDecl mangledDecl)
{
string symbol = mangledDecl.Mangled;
if (!Driver.LibrarySymbols.FindSymbol(ref symbol)) if (!Driver.LibrarySymbols.FindSymbol(ref symbol))
{ {
Driver.Diagnostics.EmitWarning(DiagnosticId.SymbolNotFound, Driver.Diagnostics.EmitWarning(DiagnosticId.SymbolNotFound, "Symbol not found: {0}", symbol);
"Symbol not found: {0}", symbol);
function.ExplicityIgnored = true;
return false; return false;
} }
function.Mangled = symbol; mangledDecl.Mangled = symbol;
return base.VisitFunctionDecl(function); return true;
} }
} }
} }

Loading…
Cancel
Save