Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attribute parsing #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CppAst/CppAst.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<VersionPrefix>0.8.0</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<BuildNumber>007</BuildNumber>
<BuildNumber>011</BuildNumber>
<PackageId>CppAst.cgnx</PackageId>
<Description>CppAst is a .NET library providing a C/C++ parser for header files with access to the full AST, comments and macros</Description>
<Copyright>Alexandre Mutel</Copyright>
Expand All @@ -25,7 +25,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>0.8.0-alpha-007</Version>
<Version>0.8.0-alpha-011</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 8 additions & 10 deletions src/CppAst/CppModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@ private uint IncOffset(int inc, uint offset)
return offset;
}

private Tuple<CXSourceRange, CXSourceRange> GetExtent(CXTranslationUnit tu, CXFile file, CXCursor cur)
private Tuple<CXSourceRange, CXSourceRange> GetExtent(CXTranslationUnit tu, CXCursor cur)
{
var cursorExtend = cur.Extent;
var begin = cursorExtend.Start;
Expand Down Expand Up @@ -2155,19 +2155,17 @@ bool HasInlineTypeDefinition(CXCursor varDecl)
CXSourceLocation GetNextLocation(CXSourceLocation loc, int inc = 1)
{
CXSourceLocation value;
uint originalOffset, u, z;
CXFile f;
loc.GetSpellingLocation(out f, out u, out z, out originalOffset);
var offset = IncOffset(inc, z);
var shouldUseLine = (z != 0 && (offset != 0 || offset != uint.MaxValue));
loc.GetSpellingLocation(out var file, out var line, out var column, out var originalOffset);
var signedOffset = (int)column + inc;
var shouldUseLine = (column != 0 && signedOffset > 0);
if (shouldUseLine)
{
value = tu.GetLocation(f, u, offset);
value = tu.GetLocation(file, line, (uint)signedOffset);
}
else
{
offset = IncOffset(inc, originalOffset);
value = tu.GetLocationForOffset(f, offset);
var offset = IncOffset(inc, originalOffset);
value = tu.GetLocationForOffset(file, offset);
}

return value;
Expand Down Expand Up @@ -2385,7 +2383,7 @@ with custom or even compiler attributes in your parsing. Thus we have
This code supports stepping back when its valid to parse attributes, it
doesn't currently support all cases but it supports most valid cases.
*/
var range = GetExtent(_tu, cursor.IncludedFile, cursor);
var range = GetExtent(_tu, cursor);

var beg = range.Item1.Start;
var end = range.Item1.End;
Expand Down