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 @@ -696,22 +696,18 @@ namespace CppSharp.Generators.CSharp
private Tuple<string, string> GetDeclarationLibrarySymbol(IMangledDecl decl)
{
var library = Options.SharedLibraryName;
var symbol = decl.Mangled;
if (!Options.CheckSymbols)
goto Out;
if (!FindMangledDeclSymbol(decl, out symbol))
goto Out;
NativeLibrary nativeLib;
if (!Driver.LibrarySymbols.FindLibraryBySymbol(symbol, out nativeLib))
if (!Driver.LibrarySymbols.FindLibraryBySymbol(decl.Mangled, out nativeLib))
goto Out;
library = Path.GetFileNameWithoutExtension(nativeLib.FileName);
Out:
return Tuple.Create(library, symbol);
return Tuple.Create(library, decl.Mangled);
}
private void GeneratePropertySetter<T>(T decl, Class @class)
@ -2077,20 +2073,6 @@ namespace CppSharp.Generators.CSharp @@ -2077,20 +2073,6 @@ namespace CppSharp.Generators.CSharp
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)
{
if (!function.IsProcessed || function.ExplicityIgnored)

23
src/Generator/Passes/FindSymbolsPass.cs

@ -4,18 +4,27 @@ namespace CppSharp.Passes @@ -4,18 +4,27 @@ namespace CppSharp.Passes
{
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))
{
Driver.Diagnostics.EmitWarning(DiagnosticId.SymbolNotFound,
"Symbol not found: {0}", symbol);
function.ExplicityIgnored = true;
Driver.Diagnostics.EmitWarning(DiagnosticId.SymbolNotFound, "Symbol not found: {0}", symbol);
return false;
}
function.Mangled = symbol;
return base.VisitFunctionDecl(function);
mangledDecl.Mangled = symbol;
return true;
}
}
}

Loading…
Cancel
Save