Browse Source

Freed C++ objects allocated by the parser.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/592/merge
Dimitar Dobrev 10 years ago
parent
commit
acbfd21b7a
  1. 6
      src/Core/Parser/ASTConverter.cs
  2. 8
      src/Core/Parser/Parser.cs
  3. 2
      src/CppParser/AST.cpp
  4. 1
      src/CppParser/AST.h
  5. 2
      src/CppParser/Target.cpp
  6. 1
      src/CppParser/Target.h
  7. 12
      src/Generator/Driver.cs

6
src/Core/Parser/ASTConverter.cs

@ -351,6 +351,8 @@ namespace CppSharp @@ -351,6 +351,8 @@ namespace CppSharp
foreach (var nativeObject in declConverter.NativeObjects)
nativeObject.Dispose();
Context.Dispose();
return _ctx;
}
}
@ -513,6 +515,7 @@ namespace CppSharp @@ -513,6 +515,7 @@ namespace CppSharp
_arg.Type = VisitQualified(arg.Type);
_arg.Declaration = declConverter.Visit(arg.Declaration);
_arg.Integral = arg.Integral;
NativeObjects.Add(arg);
return _arg;
}
@ -734,6 +737,8 @@ namespace CppSharp @@ -734,6 +737,8 @@ namespace CppSharp
_rawComment.FullComment = commentConverter.Visit(rawComment.FullCommentBlock)
as AST.FullComment;
NativeObjects.Add(rawComment);
return _rawComment;
}
@ -1477,6 +1482,7 @@ namespace CppSharp @@ -1477,6 +1482,7 @@ namespace CppSharp
_arg.Type = typeConverter.VisitQualified(arg.Type);
_arg.Declaration = Visit(arg.Declaration);
_arg.Integral = arg.Integral;
NativeObjects.Add(arg);
return _arg;
}

8
src/Core/Parser/Parser.cs

@ -48,16 +48,14 @@ namespace CppSharp @@ -48,16 +48,14 @@ namespace CppSharp
/// <summary>
/// Parses a C++ source file to a translation unit.
/// </summary>
public ParserResult ParseSourceFile(SourceFile file)
public void ParseSourceFile(SourceFile file)
{
var options = file.Options;
options.ASTContext = ASTContext;
options.FileName = file.Path;
var result = Parser.ClangParser.ParseHeader(options);
SourceParsed(file, result);
return result;
using (var result = Parser.ClangParser.ParseHeader(options))
SourceParsed(file, result);
}
/// <summary>

2
src/CppParser/AST.cpp

@ -717,6 +717,8 @@ ClassTemplatePartialSpecialization* ClassTemplate::FindPartialSpecialization(con @@ -717,6 +717,8 @@ ClassTemplatePartialSpecialization* ClassTemplate::FindPartialSpecialization(con
ASTContext::ASTContext() {}
ASTContext::~ASTContext() {}
TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
{
auto normalizedFile = normalizePath(File);

1
src/CppParser/AST.h

@ -875,6 +875,7 @@ class CS_API ASTContext @@ -875,6 +875,7 @@ class CS_API ASTContext
{
public:
ASTContext();
~ASTContext();
TranslationUnit* FindOrCreateModule(std::string File);
VECTOR(TranslationUnit*, TranslationUnits)
};

2
src/CppParser/Target.cpp

@ -42,4 +42,6 @@ ParserTargetInfo::ParserTargetInfo() : @@ -42,4 +42,6 @@ ParserTargetInfo::ParserTargetInfo() :
{
}
ParserTargetInfo::~ParserTargetInfo() {}
} }

1
src/CppParser/Target.h

@ -29,6 +29,7 @@ enum class ParserIntType @@ -29,6 +29,7 @@ enum class ParserIntType
struct CS_API ParserTargetInfo
{
ParserTargetInfo();
~ParserTargetInfo();
STRING(ABI);

12
src/Generator/Driver.cs

@ -231,12 +231,15 @@ namespace CppSharp @@ -231,12 +231,15 @@ namespace CppSharp
var parser = new ClangParser();
parser.LibraryParsed += OnFileParsed;
var res = parser.ParseLibrary(library, Options);
using (var res = parser.ParseLibrary(library, Options))
{
if (res.Kind != ParserResultKind.Success)
continue;
if (res.Kind != ParserResultKind.Success)
continue;
Symbols.Libraries.Add(ClangParser.ConvertLibrary(res.Library));
Symbols.Libraries.Add(ClangParser.ConvertLibrary(res.Library));
res.Library.Dispose();
}
}
return true;
@ -502,6 +505,7 @@ namespace CppSharp @@ -502,6 +505,7 @@ namespace CppSharp
}
driver.Generator.Dispose();
driver.TargetInfo.Dispose();
}
}
}
Loading…
Cancel
Save