Skip to content

Commit 3eee343

Browse files
committed
Add parsing and AST support for RecordArgABI information in class records.
1 parent 2c14b91 commit 3eee343

File tree

13 files changed

+345
-21
lines changed

13 files changed

+345
-21
lines changed

src/AST/ClassLayout.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,33 @@ public struct VFTableInfo
7373
public VTableLayout Layout;
7474
}
7575

76+
public enum RecordArgABI
77+
{
78+
/// <summary>
79+
/// <para>Pass it using the normal C aggregate rules for the ABI,</para>
80+
/// <para>potentially introducing extra copies and passing some</para>
81+
/// <para>or all of it in registers.</para>
82+
/// </summary>
83+
Default = 0,
84+
/// <summary>
85+
/// <para>Pass it on the stack using its defined layout.</para>
86+
/// <para>The argument must be evaluated directly into the correct</para>
87+
/// <para>stack position in the arguments area, and the call machinery</para>
88+
/// <para>must not move it or introduce extra copies.</para>
89+
/// </summary>
90+
DirectInMemory = 1,
91+
/// <summary>Pass it as a pointer to temporary memory.</summary>
92+
Indirect = 2
93+
};
94+
7695
// Represents ABI-specific layout details for a class.
7796
public class ClassLayout
7897
{
7998
public CppAbi ABI { get; set; }
8099

100+
/// Provides native argument ABI information.
101+
public RecordArgABI ArgABI { get; set; }
102+
81103
/// Virtual function tables in Microsoft mode.
82104
public List<VFTableInfo> VFTables { get; set; }
83105

src/CppParser/AST.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ LayoutBase::LayoutBase(const LayoutBase& other) : offset(other.offset), _class(o
228228

229229
LayoutBase::~LayoutBase() {}
230230

231-
ClassLayout::ClassLayout() : ABI(CppAbi::Itanium), hasOwnVFPtr(false),
232-
VBPtrOffset(0), alignment(0), size(0), dataSize(0) {}
231+
ClassLayout::ClassLayout() : ABI(CppAbi::Itanium), argABI(RecordArgABI::Default),
232+
hasOwnVFPtr(false), VBPtrOffset(0), alignment(0), size(0), dataSize(0) {}
233233

234234
DEF_VECTOR(ClassLayout, VFTableInfo, VFTables)
235235

src/CppParser/Bindings/CLI/Decl.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,16 @@ void CppSharp::Parser::AST::ClassLayout::ABI::set(CppSharp::Parser::AST::CppAbi
28592859
((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->ABI = (::CppSharp::CppParser::AST::CppAbi)value;
28602860
}
28612861

2862+
CppSharp::Parser::AST::RecordArgABI CppSharp::Parser::AST::ClassLayout::ArgABI::get()
2863+
{
2864+
return (CppSharp::Parser::AST::RecordArgABI)((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->argABI;
2865+
}
2866+
2867+
void CppSharp::Parser::AST::ClassLayout::ArgABI::set(CppSharp::Parser::AST::RecordArgABI value)
2868+
{
2869+
((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->argABI = (::CppSharp::CppParser::AST::RecordArgABI)value;
2870+
}
2871+
28622872
System::Collections::Generic::List<CppSharp::Parser::AST::VFTableInfo^>^ CppSharp::Parser::AST::ClassLayout::VFTables::get()
28632873
{
28642874
auto _tmp__VFTables = gcnew System::Collections::Generic::List<CppSharp::Parser::AST::VFTableInfo^>();

src/CppParser/Bindings/CLI/Decl.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace CppSharp
2424
enum struct DeclarationKind;
2525
enum struct FriendKind;
2626
enum struct MacroLocation;
27+
enum struct RecordArgABI;
2728
enum struct RefQualifierKind;
2829
enum struct StatementClassObsolete;
2930
enum struct TemplateSpecializationKind;
@@ -246,6 +247,25 @@ namespace CppSharp
246247
iOS64 = 4
247248
};
248249

250+
public enum struct RecordArgABI
251+
{
252+
/// <summary>
253+
/// <para>Pass it using the normal C aggregate rules for the ABI,</para>
254+
/// <para>potentially introducing extra copies and passing some</para>
255+
/// <para>or all of it in registers.</para>
256+
/// </summary>
257+
Default = 0,
258+
/// <summary>
259+
/// <para>Pass it on the stack using its defined layout.</para>
260+
/// <para>The argument must be evaluated directly into the correct</para>
261+
/// <para>stack position in the arguments area, and the call machinery</para>
262+
/// <para>must not move it or introduce extra copies.</para>
263+
/// </summary>
264+
DirectInMemory = 1,
265+
/// <summary>Pass it as a pointer to temporary memory.</summary>
266+
Indirect = 2
267+
};
268+
249269
public enum struct VTableComponentKind
250270
{
251271
VCallOffset = 0,
@@ -1539,6 +1559,12 @@ namespace CppSharp
15391559
void set(CppSharp::Parser::AST::CppAbi);
15401560
}
15411561

1562+
property CppSharp::Parser::AST::RecordArgABI ArgABI
1563+
{
1564+
CppSharp::Parser::AST::RecordArgABI get();
1565+
void set(CppSharp::Parser::AST::RecordArgABI);
1566+
}
1567+
15421568
property System::Collections::Generic::List<CppSharp::Parser::AST::VFTableInfo^>^ VFTables
15431569
{
15441570
System::Collections::Generic::List<CppSharp::Parser::AST::VFTableInfo^>^ get();

src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6258,6 +6258,25 @@ public enum CppAbi
62586258
iOS64 = 4
62596259
}
62606260

6261+
public enum RecordArgABI
6262+
{
6263+
/// <summary>
6264+
/// <para>Pass it using the normal C aggregate rules for the ABI,</para>
6265+
/// <para>potentially introducing extra copies and passing some</para>
6266+
/// <para>or all of it in registers.</para>
6267+
/// </summary>
6268+
Default = 0,
6269+
/// <summary>
6270+
/// <para>Pass it on the stack using its defined layout.</para>
6271+
/// <para>The argument must be evaluated directly into the correct</para>
6272+
/// <para>stack position in the arguments area, and the call machinery</para>
6273+
/// <para>must not move it or introduce extra copies.</para>
6274+
/// </summary>
6275+
DirectInMemory = 1,
6276+
/// <summary>Pass it as a pointer to temporary memory.</summary>
6277+
Indirect = 2
6278+
}
6279+
62616280
public enum VTableComponentKind
62626281
{
62636282
VCallOffset = 0,
@@ -12138,37 +12157,40 @@ public uint Offset
1213812157

1213912158
public unsafe partial class ClassLayout : IDisposable
1214012159
{
12141-
[StructLayout(LayoutKind.Explicit, Size = 72)]
12160+
[StructLayout(LayoutKind.Explicit, Size = 76)]
1214212161
public partial struct __Internal
1214312162
{
1214412163
[FieldOffset(0)]
1214512164
internal global::CppSharp.Parser.AST.CppAbi ABI;
1214612165

1214712166
[FieldOffset(4)]
12167+
internal global::CppSharp.Parser.AST.RecordArgABI argABI;
12168+
12169+
[FieldOffset(8)]
1214812170
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_VFTableInfo___N_std_N___1_S_allocator__S0_ VFTables;
1214912171

12150-
[FieldOffset(16)]
12172+
[FieldOffset(20)]
1215112173
internal global::CppSharp.Parser.AST.VTableLayout.__Internal layout;
1215212174

12153-
[FieldOffset(28)]
12175+
[FieldOffset(32)]
1215412176
internal byte hasOwnVFPtr;
1215512177

12156-
[FieldOffset(32)]
12178+
[FieldOffset(36)]
1215712179
internal int VBPtrOffset;
1215812180

12159-
[FieldOffset(36)]
12181+
[FieldOffset(40)]
1216012182
internal int alignment;
1216112183

12162-
[FieldOffset(40)]
12184+
[FieldOffset(44)]
1216312185
internal int size;
1216412186

12165-
[FieldOffset(44)]
12187+
[FieldOffset(48)]
1216612188
internal int dataSize;
1216712189

12168-
[FieldOffset(48)]
12190+
[FieldOffset(52)]
1216912191
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_LayoutField___N_std_N___1_S_allocator__S0_ Fields;
1217012192

12171-
[FieldOffset(60)]
12193+
[FieldOffset(64)]
1217212194
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_LayoutBase___N_std_N___1_S_allocator__S0_ Bases;
1217312195

1217412196
[SuppressUnmanagedCodeSecurity]
@@ -12396,6 +12418,19 @@ public void ClearBases()
1239612418
}
1239712419
}
1239812420

12421+
public global::CppSharp.Parser.AST.RecordArgABI ArgABI
12422+
{
12423+
get
12424+
{
12425+
return ((global::CppSharp.Parser.AST.ClassLayout.__Internal*) __Instance)->argABI;
12426+
}
12427+
12428+
set
12429+
{
12430+
((global::CppSharp.Parser.AST.ClassLayout.__Internal*)__Instance)->argABI = value;
12431+
}
12432+
}
12433+
1239912434
public global::CppSharp.Parser.AST.VTableLayout Layout
1240012435
{
1240112436
get

src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6258,6 +6258,25 @@ public enum CppAbi
62586258
iOS64 = 4
62596259
}
62606260

6261+
public enum RecordArgABI
6262+
{
6263+
/// <summary>
6264+
/// <para>Pass it using the normal C aggregate rules for the ABI,</para>
6265+
/// <para>potentially introducing extra copies and passing some</para>
6266+
/// <para>or all of it in registers.</para>
6267+
/// </summary>
6268+
Default = 0,
6269+
/// <summary>
6270+
/// <para>Pass it on the stack using its defined layout.</para>
6271+
/// <para>The argument must be evaluated directly into the correct</para>
6272+
/// <para>stack position in the arguments area, and the call machinery</para>
6273+
/// <para>must not move it or introduce extra copies.</para>
6274+
/// </summary>
6275+
DirectInMemory = 1,
6276+
/// <summary>Pass it as a pointer to temporary memory.</summary>
6277+
Indirect = 2
6278+
}
6279+
62616280
public enum VTableComponentKind
62626281
{
62636282
VCallOffset = 0,
@@ -12138,37 +12157,40 @@ public uint Offset
1213812157

1213912158
public unsafe partial class ClassLayout : IDisposable
1214012159
{
12141-
[StructLayout(LayoutKind.Explicit, Size = 72)]
12160+
[StructLayout(LayoutKind.Explicit, Size = 76)]
1214212161
public partial struct __Internal
1214312162
{
1214412163
[FieldOffset(0)]
1214512164
internal global::CppSharp.Parser.AST.CppAbi ABI;
1214612165

1214712166
[FieldOffset(4)]
12167+
internal global::CppSharp.Parser.AST.RecordArgABI argABI;
12168+
12169+
[FieldOffset(8)]
1214812170
internal global::Std.Vector.__Internalc__N_std_S_vector____N_CppSharp_N_CppParser_N_AST_S_VFTableInfo___N_std_S_allocator__S0_ VFTables;
1214912171

12150-
[FieldOffset(16)]
12172+
[FieldOffset(20)]
1215112173
internal global::CppSharp.Parser.AST.VTableLayout.__Internal layout;
1215212174

12153-
[FieldOffset(28)]
12175+
[FieldOffset(32)]
1215412176
internal byte hasOwnVFPtr;
1215512177

12156-
[FieldOffset(32)]
12178+
[FieldOffset(36)]
1215712179
internal int VBPtrOffset;
1215812180

12159-
[FieldOffset(36)]
12181+
[FieldOffset(40)]
1216012182
internal int alignment;
1216112183

12162-
[FieldOffset(40)]
12184+
[FieldOffset(44)]
1216312185
internal int size;
1216412186

12165-
[FieldOffset(44)]
12187+
[FieldOffset(48)]
1216612188
internal int dataSize;
1216712189

12168-
[FieldOffset(48)]
12190+
[FieldOffset(52)]
1216912191
internal global::Std.Vector.__Internalc__N_std_S_vector____N_CppSharp_N_CppParser_N_AST_S_LayoutField___N_std_S_allocator__S0_ Fields;
1217012192

12171-
[FieldOffset(60)]
12193+
[FieldOffset(64)]
1217212194
internal global::Std.Vector.__Internalc__N_std_S_vector____N_CppSharp_N_CppParser_N_AST_S_LayoutBase___N_std_S_allocator__S0_ Bases;
1217312195

1217412196
[SuppressUnmanagedCodeSecurity]
@@ -12396,6 +12418,19 @@ public void ClearBases()
1239612418
}
1239712419
}
1239812420

12421+
public global::CppSharp.Parser.AST.RecordArgABI ArgABI
12422+
{
12423+
get
12424+
{
12425+
return ((global::CppSharp.Parser.AST.ClassLayout.__Internal*) __Instance)->argABI;
12426+
}
12427+
12428+
set
12429+
{
12430+
((global::CppSharp.Parser.AST.ClassLayout.__Internal*)__Instance)->argABI = value;
12431+
}
12432+
}
12433+
1239912434
public global::CppSharp.Parser.AST.VTableLayout Layout
1240012435
{
1240112436
get

src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6258,6 +6258,25 @@ public enum CppAbi
62586258
iOS64 = 4
62596259
}
62606260

6261+
public enum RecordArgABI
6262+
{
6263+
/// <summary>
6264+
/// <para>Pass it using the normal C aggregate rules for the ABI,</para>
6265+
/// <para>potentially introducing extra copies and passing some</para>
6266+
/// <para>or all of it in registers.</para>
6267+
/// </summary>
6268+
Default = 0,
6269+
/// <summary>
6270+
/// <para>Pass it on the stack using its defined layout.</para>
6271+
/// <para>The argument must be evaluated directly into the correct</para>
6272+
/// <para>stack position in the arguments area, and the call machinery</para>
6273+
/// <para>must not move it or introduce extra copies.</para>
6274+
/// </summary>
6275+
DirectInMemory = 1,
6276+
/// <summary>Pass it as a pointer to temporary memory.</summary>
6277+
Indirect = 2
6278+
}
6279+
62616280
public enum VTableComponentKind
62626281
{
62636282
VCallOffset = 0,
@@ -12143,6 +12162,9 @@ public partial struct __Internal
1214312162
[FieldOffset(0)]
1214412163
internal global::CppSharp.Parser.AST.CppAbi ABI;
1214512164

12165+
[FieldOffset(4)]
12166+
internal global::CppSharp.Parser.AST.RecordArgABI argABI;
12167+
1214612168
[FieldOffset(8)]
1214712169
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_VFTableInfo___N_std_N___1_S_allocator__S0_ VFTables;
1214812170

@@ -12395,6 +12417,19 @@ public void ClearBases()
1239512417
}
1239612418
}
1239712419

12420+
public global::CppSharp.Parser.AST.RecordArgABI ArgABI
12421+
{
12422+
get
12423+
{
12424+
return ((global::CppSharp.Parser.AST.ClassLayout.__Internal*) __Instance)->argABI;
12425+
}
12426+
12427+
set
12428+
{
12429+
((global::CppSharp.Parser.AST.ClassLayout.__Internal*)__Instance)->argABI = value;
12430+
}
12431+
}
12432+
1239812433
public global::CppSharp.Parser.AST.VTableLayout Layout
1239912434
{
1240012435
get

0 commit comments

Comments
 (0)