|
|
|
|
@ -26,31 +26,37 @@ namespace CppSharp.AST
@@ -26,31 +26,37 @@ namespace CppSharp.AST
|
|
|
|
|
TranslationUnits = new List<TranslationUnit>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Finds an existing module or creates a new one given a file path.
|
|
|
|
|
public TranslationUnit FindOrCreateModule(string file) |
|
|
|
|
static private string NormalizeTranslationUnitFilePath(string name) |
|
|
|
|
{ |
|
|
|
|
if (!file.StartsWith("<")) |
|
|
|
|
if (name.StartsWith("<")) |
|
|
|
|
return name; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
name = Path.GetFullPath(name); |
|
|
|
|
} |
|
|
|
|
catch (ArgumentException) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
file = Path.GetFullPath(file); |
|
|
|
|
} |
|
|
|
|
catch (ArgumentException) |
|
|
|
|
{ |
|
|
|
|
// Normalization errors are expected when dealing with virtual
|
|
|
|
|
// compiler files like <built-in>.
|
|
|
|
|
} |
|
|
|
|
// Normalization errors are expected when dealing with virtual
|
|
|
|
|
// compiler files like <built-in>.
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var module = TranslationUnits.Find(m => m.FilePath.Equals(file)); |
|
|
|
|
|
|
|
|
|
if (module == null) |
|
|
|
|
return name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Finds an existing or creates a new one translation unit given a path.
|
|
|
|
|
public TranslationUnit FindOrCreateTranslationUnit(string file) |
|
|
|
|
{ |
|
|
|
|
file = NormalizeTranslationUnitFilePath(file); |
|
|
|
|
var translationUnit = TranslationUnits.Find(m => m.FilePath.Equals(file)); |
|
|
|
|
|
|
|
|
|
if (translationUnit == null) |
|
|
|
|
{ |
|
|
|
|
module = new TranslationUnit(file); |
|
|
|
|
TranslationUnits.Add(module); |
|
|
|
|
translationUnit = new TranslationUnit(file); |
|
|
|
|
TranslationUnits.Add(translationUnit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return module; |
|
|
|
|
return translationUnit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Finds an existing enum in the library modules.
|
|
|
|
|
|