Browse Source

Merge pull request #200 from ddobrev/master

Reverted "Cleared up and fixed the exported symbols of libraries." Extended the symbols with stripped of the initial '_' ones
pull/204/head
João Matos 12 years ago
parent
commit
2d13ddaa15
  1. 40
      src/AST/SymbolContext.cs

40
src/AST/SymbolContext.cs

@ -41,13 +41,10 @@ namespace CppSharp.AST @@ -41,13 +41,10 @@ namespace CppSharp.AST
/// </summary>
public Dictionary<string, NativeLibrary> Symbols;
private readonly Dictionary<string, NativeLibrary> compiledSymbols;
public SymbolContext()
{
Libraries = new List<NativeLibrary>();
Symbols = new Dictionary<string, NativeLibrary>();
compiledSymbols = new Dictionary<string, NativeLibrary>();
}
public NativeLibrary FindOrCreateLibrary(string file)
@ -70,13 +67,11 @@ namespace CppSharp.AST @@ -70,13 +67,11 @@ namespace CppSharp.AST
foreach (var symbol in library.Symbols)
{
Symbols[symbol] = library;
if (!symbol.StartsWith("_imp_") && !symbol.StartsWith("__imp_") &&
!symbol.StartsWith("_head") && !symbol.StartsWith("__head"))
{
if (symbol.StartsWith("__"))
compiledSymbols[symbol.Substring(1)] = library;
else
compiledSymbols[symbol] = library;
{
string stripped = symbol.Substring(1);
if (!Symbols.ContainsKey(stripped))
Symbols[stripped] = library;
}
}
}
@ -85,12 +80,35 @@ namespace CppSharp.AST @@ -85,12 +80,35 @@ namespace CppSharp.AST
public bool FindSymbol(ref string symbol)
{
NativeLibrary lib;
return FindLibraryBySymbol(symbol, out lib);
if (FindLibraryBySymbol(symbol, out lib))
return true;
// Check for C symbols with a leading underscore.
if (FindLibraryBySymbol("_" + symbol, out lib))
{
symbol = "_" + symbol;
return true;
}
if (FindLibraryBySymbol("_imp_" + symbol, out lib))
{
symbol = "_imp_" + symbol;
return true;
}
if (FindLibraryBySymbol("__imp_" + symbol, out lib))
{
symbol = "__imp_" + symbol;
return true;
}
return false;
}
public bool FindLibraryBySymbol(string symbol, out NativeLibrary library)
{
return compiledSymbols.TryGetValue(symbol, out library);
return Symbols.TryGetValue(symbol, out library);
}
}
}

Loading…
Cancel
Save