@@ -182,7 +182,7 @@ private CppContainerContext GetOrCreateDeclarationContainer(CXCursor cursor, voi
182
182
{
183
183
cppClass . TemplateKind = CppTemplateKind . TemplateSpecializedClass ;
184
184
}
185
-
185
+
186
186
187
187
//Just use low level api to call ClangSharp
188
188
var tempArgsCount = cursor . NumTemplateArguments ;
@@ -194,11 +194,11 @@ private CppContainerContext GetOrCreateDeclarationContainer(CXCursor cursor, voi
194
194
cppClass . TemplateParameters . Add ( param ) ;
195
195
}
196
196
197
- if ( cppClass . TemplateKind == CppTemplateKind . TemplateSpecializedClass )
197
+ if ( cppClass . TemplateKind == CppTemplateKind . TemplateSpecializedClass )
198
198
{
199
199
Debug . Assert ( cppClass . SpecializedTemplate . TemplateParameters . Count == tempArgsCount ) ;
200
200
}
201
-
201
+
202
202
203
203
for ( uint i = 0 ; i < tempArgsCount ; i ++ )
204
204
{
@@ -323,44 +323,45 @@ private CXChildVisitResult VisitMember(CXCursor cursor, CXCursor parent, void* d
323
323
case CXCursorKind . CXCursor_ClassDecl :
324
324
case CXCursorKind . CXCursor_StructDecl :
325
325
case CXCursorKind . CXCursor_UnionDecl :
326
- {
327
- bool isAnonymous = cursor . IsAnonymous ;
328
- var cppClass = VisitClassDecl ( cursor , data ) ;
329
- // Empty struct/class/union declaration are considered as fields
330
- if ( isAnonymous )
331
326
{
332
- Debug . Assert ( string . IsNullOrEmpty ( cppClass . Name ) ) ;
333
- var containerContext = GetOrCreateDeclarationContainer ( parent , data ) ;
334
-
335
- // We try to recover the offset from the previous field
336
- // Might not be always correct (with alignment rules),
337
- // but not sure how to recover the offset without recalculating the entire offsets
338
- var offset = 0 ;
339
- var cppClassContainer = containerContext . Container as CppClass ;
340
- if ( cppClassContainer is object && cppClassContainer . Fields . Count > 0 )
327
+ bool isAnonymous = cursor . IsAnonymous ;
328
+ var cppClass = VisitClassDecl ( cursor , data ) ;
329
+ // Empty struct/class/union declaration are considered as fields
330
+ if ( isAnonymous )
341
331
{
342
- var lastField = cppClassContainer . Fields [ cppClassContainer . Fields . Count - 1 ] ;
343
- offset = ( int ) lastField . Offset + lastField . Type . SizeOf ;
344
- }
332
+ cppClass . Name = string . Empty ;
333
+ Debug . Assert ( string . IsNullOrEmpty ( cppClass . Name ) ) ;
334
+ var containerContext = GetOrCreateDeclarationContainer ( parent , data ) ;
335
+
336
+ // We try to recover the offset from the previous field
337
+ // Might not be always correct (with alignment rules),
338
+ // but not sure how to recover the offset without recalculating the entire offsets
339
+ var offset = 0 ;
340
+ var cppClassContainer = containerContext . Container as CppClass ;
341
+ if ( cppClassContainer is object && cppClassContainer . Fields . Count > 0 )
342
+ {
343
+ var lastField = cppClassContainer . Fields [ cppClassContainer . Fields . Count - 1 ] ;
344
+ offset = ( int ) lastField . Offset + lastField . Type . SizeOf ;
345
+ }
345
346
346
- // Create an anonymous field for the type
347
- var cppField = new CppField ( cppClass , string . Empty )
347
+ // Create an anonymous field for the type
348
+ var cppField = new CppField ( cppClass , string . Empty )
349
+ {
350
+ Visibility = containerContext . CurrentVisibility ,
351
+ StorageQualifier = GetStorageQualifier ( cursor ) ,
352
+ IsAnonymous = true ,
353
+ Offset = offset ,
354
+ } ;
355
+ ParseAttributes ( cursor , cppField , true ) ;
356
+ containerContext . DeclarationContainer . Fields . Add ( cppField ) ;
357
+ element = cppField ;
358
+ }
359
+ else
348
360
{
349
- Visibility = containerContext . CurrentVisibility ,
350
- StorageQualifier = GetStorageQualifier ( cursor ) ,
351
- IsAnonymous = true ,
352
- Offset = offset ,
353
- } ;
354
- ParseAttributes ( cursor , cppField , true ) ;
355
- containerContext . DeclarationContainer . Fields . Add ( cppField ) ;
356
- element = cppField ;
357
- }
358
- else
359
- {
360
- element = cppClass ;
361
+ element = cppClass ;
362
+ }
363
+ break ;
361
364
}
362
- break ;
363
- }
364
365
365
366
case CXCursorKind . CXCursor_EnumDecl :
366
367
element = VisitEnumDecl ( cursor , data ) ;
@@ -372,7 +373,7 @@ private CXChildVisitResult VisitMember(CXCursor cursor, CXCursor parent, void* d
372
373
373
374
case CXCursorKind . CXCursor_TypeAliasDecl :
374
375
case CXCursorKind . CXCursor_TypeAliasTemplateDecl :
375
-
376
+
376
377
element = VisitTypeAliasDecl ( cursor , data ) ;
377
378
break ;
378
379
@@ -440,7 +441,7 @@ private CXChildVisitResult VisitMember(CXCursor cursor, CXCursor parent, void* d
440
441
441
442
var attrContainer = cppDeclaration as ICppAttributeContainer ;
442
443
//Only handle commnet attribute when we need
443
- if ( attrContainer != null && ParseCommentAttributeEnabled )
444
+ if ( attrContainer != null && ParseCommentAttributeEnabled )
444
445
{
445
446
TryToParseAttributesFromComment ( cppDeclaration . Comment , attrContainer ) ;
446
447
}
@@ -706,7 +707,7 @@ private CppMacro ParseMacro(CXCursor cursor)
706
707
var tokens = tu . Tokenize ( range ) ;
707
708
708
709
var name = GetCursorSpelling ( cursor ) ;
709
- if ( name . StartsWith ( "__cppast" ) )
710
+ if ( name . StartsWith ( "__cppast" ) )
710
711
{
711
712
//cppast system macros, just ignore here
712
713
return null ;
@@ -1453,10 +1454,10 @@ private List<CppAttribute> ParseSystemAndAnnotateAttributeInCursor(CXCursor curs
1453
1454
}
1454
1455
break ;
1455
1456
case CXCursorKind . CXCursor_FirstAttr :
1456
- {
1457
+ {
1457
1458
var attrKind = argCursor . AttrKind ;
1458
1459
var attrKindSpelling = argCursor . AttrKindSpelling . ToLower ( ) ;
1459
-
1460
+
1460
1461
var attribute = new CppAttribute ( attrKindSpelling , AttributeKind . CxxSystemAttribute )
1461
1462
{
1462
1463
Span = sourceSpan ,
@@ -1485,7 +1486,7 @@ private List<CppAttribute> ParseSystemAndAnnotateAttributeInCursor(CXCursor curs
1485
1486
collectAttributes . Add ( attribute ) ;
1486
1487
}
1487
1488
break ;
1488
-
1489
+
1489
1490
// Don't generate a warning for unsupported cursor
1490
1491
default :
1491
1492
break ;
@@ -1501,17 +1502,17 @@ private void TryToParseAttributesFromComment(CppComment comment, ICppAttributeCo
1501
1502
{
1502
1503
if ( comment == null ) return ;
1503
1504
1504
- if ( comment is CppCommentText ctxt )
1505
+ if ( comment is CppCommentText ctxt )
1505
1506
{
1506
1507
var txt = ctxt . Text . Trim ( ) ;
1507
- if ( txt . StartsWith ( "[[" ) && txt . EndsWith ( "]]" ) )
1508
+ if ( txt . StartsWith ( "[[" ) && txt . EndsWith ( "]]" ) )
1508
1509
{
1509
1510
attrContainer . Attributes . Add ( new CppAttribute ( "comment" , AttributeKind . CommentAttribute )
1510
1511
{
1511
1512
Arguments = txt ,
1512
1513
Scope = "" ,
1513
1514
IsVariadic = false ,
1514
- } ) ;
1515
+ } ) ;
1515
1516
}
1516
1517
}
1517
1518
@@ -1545,16 +1546,16 @@ private void ParseAttributes(CXCursor cursor, ICppAttributeContainer attrContain
1545
1546
}
1546
1547
1547
1548
//Parse attributes contains in cursor
1548
- if ( attrContainer is CppFunction )
1549
+ if ( attrContainer is CppFunction )
1549
1550
{
1550
1551
var func = attrContainer as CppFunction ;
1551
1552
CppTokenUtil . ParseFunctionAttributes ( cursor , func . Name , ref tokenAttributes ) ;
1552
- }
1553
+ }
1553
1554
else
1554
1555
{
1555
1556
CppTokenUtil . ParseCursorAttributs ( cursor , ref tokenAttributes ) ;
1556
1557
}
1557
-
1558
+
1558
1559
attrContainer . TokenAttributes . AddRange ( tokenAttributes ) ;
1559
1560
}
1560
1561
@@ -1572,7 +1573,7 @@ private CppType VisitTypeAliasDecl(CXCursor cursor, void* data)
1572
1573
var kind = cursor . Kind ;
1573
1574
1574
1575
CXCursor usedCursor = cursor ;
1575
- if ( kind == CXCursorKind . CXCursor_TypeAliasTemplateDecl )
1576
+ if ( kind == CXCursorKind . CXCursor_TypeAliasTemplateDecl )
1576
1577
{
1577
1578
usedCursor = cursor . TemplatedDecl ;
1578
1579
}
@@ -1644,7 +1645,8 @@ private CppType VisitTypeDefDecl(CXCursor cursor, void* data)
1644
1645
private CppType VisitElaboratedDecl ( CXCursor cursor , CXType type , CXCursor parent , void * data )
1645
1646
{
1646
1647
var fulltypeDefName = clang . getCursorUSR ( cursor ) . CString ;
1647
- if ( _typedefs . TryGetValue ( fulltypeDefName , out var typeRef ) ) {
1648
+ if ( _typedefs . TryGetValue ( fulltypeDefName , out var typeRef ) )
1649
+ {
1648
1650
return typeRef ;
1649
1651
}
1650
1652
@@ -1724,7 +1726,7 @@ private CppType GetCppTypeInternal(CXCursor cursor, CXType type, CXCursor parent
1724
1726
return CppPrimitiveType . UnsignedInt ;
1725
1727
1726
1728
case CXTypeKind . CXType_ULong :
1727
- return CppPrimitiveType . UnsignedInt ;
1729
+ return type . SizeOf == 8 ? CppPrimitiveType . UnsignedLongLong : CppPrimitiveType . UnsignedInt ;
1728
1730
1729
1731
case CXTypeKind . CXType_ULongLong :
1730
1732
return CppPrimitiveType . UnsignedLongLong ;
@@ -1895,7 +1897,7 @@ private List<CppType> ParseTemplateSpecializedArguments(CXCursor cursor, CXType
1895
1897
for ( var templateIndex = 0 ; templateIndex < numTemplateArguments ; ++ templateIndex )
1896
1898
{
1897
1899
var templateArg = type . GetTemplateArgument ( ( uint ) templateIndex ) ;
1898
-
1900
+
1899
1901
switch ( templateArg . kind )
1900
1902
{
1901
1903
case CXTemplateArgumentKind . CXTemplateArgumentKind_Type :
0 commit comments