Browse Source

Fixed FindFunction() to search namespaces.

pull/230/merge
Tom Spilman 11 years ago committed by triton
parent
commit
2027212e85
  1. 33
      src/AST/Namespace.cs

33
src/AST/Namespace.cs

@ -166,15 +166,30 @@ namespace CppSharp.AST @@ -166,15 +166,30 @@ namespace CppSharp.AST
public Function FindFunction(string name, bool createDecl = false)
{
var function = Functions.Find(e => e.Name.Equals(name));
if (function == null && createDecl)
{
function = new Function() { Name = name, Namespace = this };
Functions.Add(function);
}
return function;
var entries = name.Split(new string[] { "::" },
StringSplitOptions.RemoveEmptyEntries).ToList();
if (entries.Count <= 1)
{
var function = Functions.Find(e => e.Name.Equals(name));
if (function == null && createDecl)
{
function = new Function() { Name = name, Namespace = this };
Functions.Add(function);
}
return function;
}
var funcName = entries[entries.Count - 1];
var namespaces = entries.Take(entries.Count - 1);
var @namespace = FindNamespace(namespaces);
if (@namespace == null)
return null;
return @namespace.FindFunction(funcName, createDecl);
}
Class CreateClass(string name, bool isComplete)

Loading…
Cancel
Save