Browse Source

Properly fixed the offsets of fields in all possible cases.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/658/head
Dimitar Dobrev 9 years ago
parent
commit
e2b8f44565
  1. 3
      src/AST/ClassLayout.cs
  2. 17
      src/AST/Field.cs
  3. 28
      src/AST/LayoutField.cs
  4. 8
      src/Core/Parser/ASTConverter.cs
  5. 8
      src/CppParser/AST.cpp
  6. 13
      src/CppParser/AST.h
  7. 97
      src/CppParser/Bindings/CLI/AST.cpp
  8. 183
      src/CppParser/Bindings/CLI/AST.h
  9. 343
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
  10. 343
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
  11. 343
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs
  12. 343
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
  13. 343
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs
  14. 88
      src/CppParser/Parser.cpp
  15. 1
      src/CppParser/Parser.h
  16. 16
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  17. 47
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  18. 16
      src/Generator/Passes/CheckDuplicatedNamesPass.cs

3
src/AST/ClassLayout.cs

@ -85,8 +85,11 @@ namespace CppSharp.AST
public ClassLayout() public ClassLayout()
{ {
VFTables = new List<VFTableInfo>(); VFTables = new List<VFTableInfo>();
Fields = new List<LayoutField>();
} }
public List<LayoutField> Fields { get; private set; }
public ClassLayout(ClassLayout classLayout) public ClassLayout(ClassLayout classLayout)
: this() : this()
{ {

17
src/AST/Field.cs

@ -8,29 +8,16 @@ namespace CppSharp.AST
public Type Type { get { return QualifiedType.Type; } } public Type Type { get { return QualifiedType.Type; } }
public QualifiedType QualifiedType { get; set; } public QualifiedType QualifiedType { get; set; }
public uint Offset { get; set; }
public Class Class { get; set; } public Class Class { get; set; }
public uint OffsetInBytes
{
get { return Offset / (sizeof (byte) * 8); }
}
public Expression Expression { get; set; } public Expression Expression { get; set; }
public bool IsBitField { get; set; } public bool IsBitField { get; set; }
public uint BitWidth { get; set; } public uint BitWidth { get; set; }
public string InternalName
{
get { return internalName ?? (internalName = OriginalName); }
set { internalName = value; }
}
public Field() public Field()
{ {
Offset = 0;
} }
public Field(string name, QualifiedType type, AccessSpecifier access) public Field(string name, QualifiedType type, AccessSpecifier access)
@ -38,13 +25,11 @@ namespace CppSharp.AST
Name = name; Name = name;
QualifiedType = type; QualifiedType = type;
Access = access; Access = access;
Offset = 0;
} }
public Field(Field field): base(field) public Field(Field field): base(field)
{ {
QualifiedType = field.QualifiedType; QualifiedType = field.QualifiedType;
Offset = field.Offset;
Class = field.Class; Class = field.Class;
Expression = field.Expression; Expression = field.Expression;
IsBitField = field.IsBitField; IsBitField = field.IsBitField;
@ -55,7 +40,5 @@ namespace CppSharp.AST
{ {
return visitor.VisitFieldDecl(this); return visitor.VisitFieldDecl(this);
} }
private string internalName;
} }
} }

28
src/AST/LayoutField.cs

@ -0,0 +1,28 @@
namespace CppSharp.AST
{
public class LayoutField
{
public LayoutField(uint offset, Field field)
{
Field = field;
Offset = offset;
}
public uint Offset { get; set; }
public string Name
{
get { return name ?? Field.OriginalName; }
set { name = value; }
}
public Field Field { get; set; }
public override string ToString()
{
return string.Format("{0} | {1}", Offset, Field.OriginalName);
}
private string name;
}
}

8
src/Core/Parser/ASTConverter.cs

@ -1255,7 +1255,6 @@ namespace CppSharp
_field.QualifiedType = typeConverter.VisitQualified( _field.QualifiedType = typeConverter.VisitQualified(
decl.QualifiedType); decl.QualifiedType);
_field.Access = VisitAccessSpecifier(decl.Access); _field.Access = VisitAccessSpecifier(decl.Access);
_field.Offset = decl.Offset;
_field.Class = Visit(decl.Class) as AST.Class; _field.Class = Visit(decl.Class) as AST.Class;
_field.IsBitField = decl.IsBitField; _field.IsBitField = decl.IsBitField;
_field.BitWidth = decl.BitWidth; _field.BitWidth = decl.BitWidth;
@ -1346,6 +1345,13 @@ namespace CppSharp
_layout.VFTables.Add(_vftableInfo); _layout.VFTables.Add(_vftableInfo);
} }
for (uint i = 0; i < layout.FieldsCount; i++)
{
var field = layout.getFields(i);
_layout.Fields.Add(new AST.LayoutField(field.Offset,
(AST.Field) Visit(field.Field)));
}
return _layout; return _layout;
} }

8
src/CppParser/AST.cpp

@ -189,11 +189,17 @@ VFTableInfo::VFTableInfo(const VFTableInfo& rhs) : VBTableIndex(rhs.VBTableIndex
VFPtrOffset(rhs.VFPtrOffset), VFPtrFullOffset(rhs.VFPtrFullOffset), VFPtrOffset(rhs.VFPtrOffset), VFPtrFullOffset(rhs.VFPtrFullOffset),
Layout(rhs.Layout) {} Layout(rhs.Layout) {}
LayoutField::LayoutField() {}
LayoutField::~LayoutField() {}
ClassLayout::ClassLayout() : ABI(CppAbi::Itanium), HasOwnVFPtr(false), ClassLayout::ClassLayout() : ABI(CppAbi::Itanium), HasOwnVFPtr(false),
VBPtrOffset(0), Alignment(0), Size(0), DataSize(0) {} VBPtrOffset(0), Alignment(0), Size(0), DataSize(0) {}
DEF_VECTOR(ClassLayout, VFTableInfo, VFTables) DEF_VECTOR(ClassLayout, VFTableInfo, VFTables)
DEF_VECTOR(ClassLayout, LayoutField, Fields)
Declaration::Declaration(DeclarationKind kind) Declaration::Declaration(DeclarationKind kind)
: Kind(kind) : Kind(kind)
, Access(AccessSpecifier::Public) , Access(AccessSpecifier::Public)
@ -650,7 +656,7 @@ DEF_STRING(Variable, Mangled)
BaseClassSpecifier::BaseClassSpecifier() : Type(0), Offset(0) {} BaseClassSpecifier::BaseClassSpecifier() : Type(0), Offset(0) {}
Field::Field() : Declaration(DeclarationKind::Field), Class(0), Field::Field() : Declaration(DeclarationKind::Field), Class(0),
IsBitField(false), BitWidth(0), Offset(0) {} IsBitField(false), BitWidth(0) {}
Field::~Field() {} Field::~Field() {}

13
src/CppParser/AST.h

@ -315,6 +315,17 @@ struct CS_API VFTableInfo
VTableLayout Layout; VTableLayout Layout;
}; };
class Field;
class CS_API LayoutField
{
public:
LayoutField();
~LayoutField();
unsigned Offset;
Field* Field;
};
struct CS_API ClassLayout struct CS_API ClassLayout
{ {
ClassLayout(); ClassLayout();
@ -326,6 +337,7 @@ struct CS_API ClassLayout
int Alignment; int Alignment;
int Size; int Size;
int DataSize; int DataSize;
VECTOR(LayoutField, Fields)
}; };
#pragma endregion #pragma endregion
@ -706,7 +718,6 @@ public:
DECLARE_DECL_KIND(Field, Field) DECLARE_DECL_KIND(Field, Field)
~Field(); ~Field();
CppSharp::CppParser::AST::QualifiedType QualifiedType; CppSharp::CppParser::AST::QualifiedType QualifiedType;
unsigned Offset;
CppSharp::CppParser::AST::Class* Class; CppSharp::CppParser::AST::Class* Class;
bool IsBitField; bool IsBitField;
unsigned BitWidth; unsigned BitWidth;

97
src/CppParser/Bindings/CLI/AST.cpp

@ -1292,6 +1292,67 @@ void CppSharp::Parser::AST::VFTableInfo::Layout::set(CppSharp::Parser::AST::VTab
((::CppSharp::CppParser::AST::VFTableInfo*)NativePtr)->Layout = *(::CppSharp::CppParser::AST::VTableLayout*)value->NativePtr; ((::CppSharp::CppParser::AST::VFTableInfo*)NativePtr)->Layout = *(::CppSharp::CppParser::AST::VTableLayout*)value->NativePtr;
} }
CppSharp::Parser::AST::LayoutField::LayoutField(::CppSharp::CppParser::AST::LayoutField* native)
: __ownsNativeInstance(false)
{
NativePtr = native;
}
CppSharp::Parser::AST::LayoutField^ CppSharp::Parser::AST::LayoutField::__CreateInstance(::System::IntPtr native)
{
return gcnew ::CppSharp::Parser::AST::LayoutField((::CppSharp::CppParser::AST::LayoutField*) native.ToPointer());
}
CppSharp::Parser::AST::LayoutField::~LayoutField()
{
delete NativePtr;
}
CppSharp::Parser::AST::LayoutField::LayoutField()
{
__ownsNativeInstance = true;
NativePtr = new ::CppSharp::CppParser::AST::LayoutField();
}
CppSharp::Parser::AST::LayoutField::LayoutField(CppSharp::Parser::AST::LayoutField^ _0)
{
__ownsNativeInstance = true;
if (ReferenceEquals(_0, nullptr))
throw gcnew ::System::ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&).");
auto &__arg0 = *(::CppSharp::CppParser::AST::LayoutField*)_0->NativePtr;
NativePtr = new ::CppSharp::CppParser::AST::LayoutField(__arg0);
}
System::IntPtr CppSharp::Parser::AST::LayoutField::__Instance::get()
{
return System::IntPtr(NativePtr);
}
void CppSharp::Parser::AST::LayoutField::__Instance::set(System::IntPtr object)
{
NativePtr = (::CppSharp::CppParser::AST::LayoutField*)object.ToPointer();
}
unsigned int CppSharp::Parser::AST::LayoutField::Offset::get()
{
return ((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Offset;
}
void CppSharp::Parser::AST::LayoutField::Offset::set(unsigned int value)
{
((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Offset = value;
}
CppSharp::Parser::AST::Field^ CppSharp::Parser::AST::LayoutField::Field::get()
{
return (((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Field == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Field((::CppSharp::CppParser::AST::Field*)((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Field);
}
void CppSharp::Parser::AST::LayoutField::Field::set(CppSharp::Parser::AST::Field^ value)
{
((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Field = (::CppSharp::CppParser::AST::Field*)value->NativePtr;
}
CppSharp::Parser::AST::ClassLayout::ClassLayout(::CppSharp::CppParser::AST::ClassLayout* native) CppSharp::Parser::AST::ClassLayout::ClassLayout(::CppSharp::CppParser::AST::ClassLayout* native)
: __ownsNativeInstance(false) : __ownsNativeInstance(false)
{ {
@ -1334,6 +1395,26 @@ void CppSharp::Parser::AST::ClassLayout::clearVFTables()
((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->clearVFTables(); ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->clearVFTables();
} }
CppSharp::Parser::AST::LayoutField^ CppSharp::Parser::AST::ClassLayout::getFields(unsigned int i)
{
auto __ret = ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->getFields(i);
auto ____ret = new ::CppSharp::CppParser::AST::LayoutField(__ret);
return (____ret == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::LayoutField((::CppSharp::CppParser::AST::LayoutField*)____ret);
}
void CppSharp::Parser::AST::ClassLayout::addFields(CppSharp::Parser::AST::LayoutField^ s)
{
if (ReferenceEquals(s, nullptr))
throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
auto &__arg0 = *(::CppSharp::CppParser::AST::LayoutField*)s->NativePtr;
((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->addFields(__arg0);
}
void CppSharp::Parser::AST::ClassLayout::clearFields()
{
((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->clearFields();
}
CppSharp::Parser::AST::ClassLayout::ClassLayout(CppSharp::Parser::AST::ClassLayout^ _0) CppSharp::Parser::AST::ClassLayout::ClassLayout(CppSharp::Parser::AST::ClassLayout^ _0)
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -1359,6 +1440,12 @@ unsigned int CppSharp::Parser::AST::ClassLayout::VFTablesCount::get()
return __ret; return __ret;
} }
unsigned int CppSharp::Parser::AST::ClassLayout::FieldsCount::get()
{
auto __ret = ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->getFieldsCount();
return __ret;
}
CppSharp::Parser::AST::CppAbi CppSharp::Parser::AST::ClassLayout::ABI::get() CppSharp::Parser::AST::CppAbi CppSharp::Parser::AST::ClassLayout::ABI::get()
{ {
return (CppSharp::Parser::AST::CppAbi)((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->ABI; return (CppSharp::Parser::AST::CppAbi)((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->ABI;
@ -3064,16 +3151,6 @@ void CppSharp::Parser::AST::Field::QualifiedType::set(CppSharp::Parser::AST::Qua
((::CppSharp::CppParser::AST::Field*)NativePtr)->QualifiedType = *(::CppSharp::CppParser::AST::QualifiedType*)value->NativePtr; ((::CppSharp::CppParser::AST::Field*)NativePtr)->QualifiedType = *(::CppSharp::CppParser::AST::QualifiedType*)value->NativePtr;
} }
unsigned int CppSharp::Parser::AST::Field::Offset::get()
{
return ((::CppSharp::CppParser::AST::Field*)NativePtr)->Offset;
}
void CppSharp::Parser::AST::Field::Offset::set(unsigned int value)
{
((::CppSharp::CppParser::AST::Field*)NativePtr)->Offset = value;
}
CppSharp::Parser::AST::Class^ CppSharp::Parser::AST::Field::Class::get() CppSharp::Parser::AST::Class^ CppSharp::Parser::AST::Field::Class::get()
{ {
return (((::CppSharp::CppParser::AST::Field*)NativePtr)->Class == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*)((::CppSharp::CppParser::AST::Field*)NativePtr)->Class); return (((::CppSharp::CppParser::AST::Field*)NativePtr)->Class == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*)((::CppSharp::CppParser::AST::Field*)NativePtr)->Class);

183
src/CppParser/Bindings/CLI/AST.h

@ -61,6 +61,7 @@ namespace CppSharp
ref class InjectedClassNameType; ref class InjectedClassNameType;
ref class InlineCommandComment; ref class InlineCommandComment;
ref class InlineContentComment; ref class InlineContentComment;
ref class LayoutField;
ref class MacroDefinition; ref class MacroDefinition;
ref class MacroExpansion; ref class MacroExpansion;
ref class MemberPointerType; ref class MemberPointerType;
@ -165,14 +166,56 @@ namespace CppSharp
Public = 2 Public = 2
}; };
public enum struct CXXMethodKind public enum struct RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
};
public enum struct CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
};
public enum struct CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
};
public enum struct VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
}; };
public enum struct CXXOperatorKind public enum struct CXXOperatorKind
@ -234,18 +277,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
}; };
public enum struct StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
};
public enum struct TemplateSpecializationKind public enum struct TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -255,25 +286,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
}; };
public enum struct CppAbi public enum struct StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}; };
public enum struct VTableComponentKind public enum struct CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
}; };
public enum struct PrimitiveType public enum struct PrimitiveType
@ -307,37 +339,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
}; };
public enum struct RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
};
public enum struct CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
};
public enum struct ArchType public enum struct ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -1026,6 +1027,41 @@ namespace CppSharp
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
public ref class LayoutField : ICppInstance
{
public:
property ::CppSharp::CppParser::AST::LayoutField* NativePtr;
property System::IntPtr __Instance
{
virtual System::IntPtr get();
virtual void set(System::IntPtr instance);
}
LayoutField(::CppSharp::CppParser::AST::LayoutField* native);
static LayoutField^ __CreateInstance(::System::IntPtr native);
LayoutField();
LayoutField(CppSharp::Parser::AST::LayoutField^ _0);
~LayoutField();
property unsigned int Offset
{
unsigned int get();
void set(unsigned int);
}
property CppSharp::Parser::AST::Field^ Field
{
CppSharp::Parser::AST::Field^ get();
void set(CppSharp::Parser::AST::Field^);
}
protected:
bool __ownsNativeInstance;
};
public ref class ClassLayout : ICppInstance public ref class ClassLayout : ICppInstance
{ {
public: public:
@ -1050,6 +1086,11 @@ namespace CppSharp
unsigned int get(); unsigned int get();
} }
property unsigned int FieldsCount
{
unsigned int get();
}
property CppSharp::Parser::AST::CppAbi ABI property CppSharp::Parser::AST::CppAbi ABI
{ {
CppSharp::Parser::AST::CppAbi get(); CppSharp::Parser::AST::CppAbi get();
@ -1098,6 +1139,12 @@ namespace CppSharp
void clearVFTables(); void clearVFTables();
CppSharp::Parser::AST::LayoutField^ getFields(unsigned int i);
void addFields(CppSharp::Parser::AST::LayoutField^ s);
void clearFields();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1883,12 +1930,6 @@ namespace CppSharp
void set(CppSharp::Parser::AST::QualifiedType^); void set(CppSharp::Parser::AST::QualifiedType^);
} }
property unsigned int Offset
{
unsigned int get();
void set(unsigned int);
}
property CppSharp::Parser::AST::Class^ Class property CppSharp::Parser::AST::Class^ Class
{ {
CppSharp::Parser::AST::Class^ get(); CppSharp::Parser::AST::Class^ get();

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

@ -69,14 +69,56 @@ namespace CppSharp
Public = 2 Public = 2
} }
public enum CXXMethodKind public enum RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
}
public enum VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum CXXOperatorKind public enum CXXOperatorKind
@ -138,18 +180,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
} }
public enum StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}
public enum TemplateSpecializationKind public enum TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -159,25 +189,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
} }
public enum CppAbi public enum StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
} }
public enum VTableComponentKind public enum CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum PrimitiveType public enum PrimitiveType
@ -211,37 +242,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
} }
public enum RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum ArchType public enum ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -2985,9 +2985,137 @@ namespace CppSharp
} }
} }
public unsafe partial class LayoutField : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public partial struct Internal
{
[FieldOffset(0)]
public uint Offset;
[FieldOffset(4)]
public global::System.IntPtr Field;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2Ev")]
internal static extern void ctor_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2ERKS2_")]
internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldD2Ev")]
internal static extern void dtor_0(global::System.IntPtr instance);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static LayoutField __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new LayoutField(native.ToPointer(), skipVTables);
}
public static LayoutField __CreateInstance(LayoutField.Internal native, bool skipVTables = false)
{
return new LayoutField(native, skipVTables);
}
private static void* __CopyValue(LayoutField.Internal native)
{
var ret = Marshal.AllocHGlobal(8);
*(LayoutField.Internal*) ret = native;
return ret.ToPointer();
}
private LayoutField(LayoutField.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LayoutField(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public LayoutField()
{
__Instance = Marshal.AllocHGlobal(8);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
}
public LayoutField(CppSharp.Parser.AST.LayoutField _0)
{
__Instance = Marshal.AllocHGlobal(8);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
*((LayoutField.Internal*) __Instance) = *((LayoutField.Internal*) _0.__Instance);
}
public void Dispose()
{
Dispose(disposing: true);
}
protected virtual void Dispose(bool disposing)
{
CppSharp.Parser.AST.LayoutField __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
Internal.dtor_0((__Instance + __PointerAdjustment));
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Field Field
{
get
{
CppSharp.Parser.AST.Field __result0;
if (((Internal*) __Instance)->Field == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Field.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Field))
__result0 = (CppSharp.Parser.AST.Field) CppSharp.Parser.AST.Field.NativeToManagedMap[((Internal*) __Instance)->Field];
else __result0 = CppSharp.Parser.AST.Field.__CreateInstance(((Internal*) __Instance)->Field);
return __result0;
}
set
{
((Internal*) __Instance)->Field = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class ClassLayout : IDisposable public unsafe partial class ClassLayout : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 48)] [StructLayout(LayoutKind.Explicit, Size = 60)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -3041,10 +3169,30 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")]
internal static extern void clearVFTables_0(global::System.IntPtr instance); internal static extern void clearVFTables_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9getFieldsEj")]
internal static extern void getFields_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9addFieldsERNS1_11LayoutFieldE")]
internal static extern void addFields_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")]
internal static extern void clearFields_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")]
internal static extern uint getVFTablesCount_0(global::System.IntPtr instance); internal static extern uint getVFTablesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")]
internal static extern uint getFieldsCount_0(global::System.IntPtr instance);
} }
public global::System.IntPtr __Instance { get; protected set; } public global::System.IntPtr __Instance { get; protected set; }
@ -3067,7 +3215,7 @@ namespace CppSharp
private static void* __CopyValue(ClassLayout.Internal native) private static void* __CopyValue(ClassLayout.Internal native)
{ {
var ret = Marshal.AllocHGlobal(48); var ret = Marshal.AllocHGlobal(60);
CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -3088,7 +3236,7 @@ namespace CppSharp
public ClassLayout() public ClassLayout()
{ {
__Instance = Marshal.AllocHGlobal(48); __Instance = Marshal.AllocHGlobal(60);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -3096,7 +3244,7 @@ namespace CppSharp
public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) public ClassLayout(CppSharp.Parser.AST.ClassLayout _0)
{ {
__Instance = Marshal.AllocHGlobal(48); __Instance = Marshal.AllocHGlobal(60);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -3139,6 +3287,26 @@ namespace CppSharp
Internal.clearVFTables_0((__Instance + __PointerAdjustment)); Internal.clearVFTables_0((__Instance + __PointerAdjustment));
} }
public CppSharp.Parser.AST.LayoutField getFields(uint i)
{
var __ret = new CppSharp.Parser.AST.LayoutField.Internal();
Internal.getFields_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i);
return CppSharp.Parser.AST.LayoutField.__CreateInstance(__ret);
}
public void addFields(CppSharp.Parser.AST.LayoutField s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
Internal.addFields_0((__Instance + __PointerAdjustment), __arg0);
}
public void clearFields()
{
Internal.clearFields_0((__Instance + __PointerAdjustment));
}
public uint VFTablesCount public uint VFTablesCount
{ {
get get
@ -3148,6 +3316,15 @@ namespace CppSharp
} }
} }
public uint FieldsCount
{
get
{
var __ret = Internal.getFieldsCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public CppSharp.Parser.AST.CppAbi ABI public CppSharp.Parser.AST.CppAbi ABI
{ {
get get
@ -6840,7 +7017,7 @@ namespace CppSharp
public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 116)] [StructLayout(LayoutKind.Explicit, Size = 112)]
public new partial struct Internal public new partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -6886,15 +7063,12 @@ namespace CppSharp
public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType;
[FieldOffset(100)] [FieldOffset(100)]
public uint Offset;
[FieldOffset(104)]
public global::System.IntPtr Class; public global::System.IntPtr Class;
[FieldOffset(108)] [FieldOffset(104)]
public byte IsBitField; public byte IsBitField;
[FieldOffset(112)] [FieldOffset(108)]
public uint BitWidth; public uint BitWidth;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -6925,7 +7099,7 @@ namespace CppSharp
private static void* __CopyValue(Field.Internal native) private static void* __CopyValue(Field.Internal native)
{ {
var ret = Marshal.AllocHGlobal(116); var ret = Marshal.AllocHGlobal(112);
CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -6949,7 +7123,7 @@ namespace CppSharp
public Field() public Field()
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(116); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6958,7 +7132,7 @@ namespace CppSharp
public Field(CppSharp.Parser.AST.Field _0) public Field(CppSharp.Parser.AST.Field _0)
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(116); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -6989,19 +7163,6 @@ namespace CppSharp
} }
} }
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Class Class public CppSharp.Parser.AST.Class Class
{ {
get get

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

@ -69,14 +69,56 @@ namespace CppSharp
Public = 2 Public = 2
} }
public enum CXXMethodKind public enum RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
}
public enum VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum CXXOperatorKind public enum CXXOperatorKind
@ -138,18 +180,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
} }
public enum StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}
public enum TemplateSpecializationKind public enum TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -159,25 +189,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
} }
public enum CppAbi public enum StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
} }
public enum VTableComponentKind public enum CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum PrimitiveType public enum PrimitiveType
@ -211,37 +242,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
} }
public enum RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum ArchType public enum ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -2985,9 +2985,137 @@ namespace CppSharp
} }
} }
public unsafe partial class LayoutField : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public partial struct Internal
{
[FieldOffset(0)]
public uint Offset;
[FieldOffset(4)]
public global::System.IntPtr Field;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0LayoutField@AST@CppParser@CppSharp@@QAE@XZ")]
internal static extern global::System.IntPtr ctor_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0LayoutField@AST@CppParser@CppSharp@@QAE@ABV0123@@Z")]
internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??1LayoutField@AST@CppParser@CppSharp@@QAE@XZ")]
internal static extern void dtor_0(global::System.IntPtr instance, int delete);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static LayoutField __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new LayoutField(native.ToPointer(), skipVTables);
}
public static LayoutField __CreateInstance(LayoutField.Internal native, bool skipVTables = false)
{
return new LayoutField(native, skipVTables);
}
private static void* __CopyValue(LayoutField.Internal native)
{
var ret = Marshal.AllocHGlobal(8);
*(LayoutField.Internal*) ret = native;
return ret.ToPointer();
}
private LayoutField(LayoutField.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LayoutField(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public LayoutField()
{
__Instance = Marshal.AllocHGlobal(8);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
}
public LayoutField(CppSharp.Parser.AST.LayoutField _0)
{
__Instance = Marshal.AllocHGlobal(8);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
*((LayoutField.Internal*) __Instance) = *((LayoutField.Internal*) _0.__Instance);
}
public void Dispose()
{
Dispose(disposing: true);
}
protected virtual void Dispose(bool disposing)
{
CppSharp.Parser.AST.LayoutField __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
Internal.dtor_0((__Instance + __PointerAdjustment), 0);
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Field Field
{
get
{
CppSharp.Parser.AST.Field __result0;
if (((Internal*) __Instance)->Field == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Field.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Field))
__result0 = (CppSharp.Parser.AST.Field) CppSharp.Parser.AST.Field.NativeToManagedMap[((Internal*) __Instance)->Field];
else __result0 = CppSharp.Parser.AST.Field.__CreateInstance(((Internal*) __Instance)->Field);
return __result0;
}
set
{
((Internal*) __Instance)->Field = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class ClassLayout : IDisposable public unsafe partial class ClassLayout : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 48)] [StructLayout(LayoutKind.Explicit, Size = 60)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -3041,10 +3169,30 @@ namespace CppSharp
EntryPoint="?clearVFTables@ClassLayout@AST@CppParser@CppSharp@@QAEXXZ")] EntryPoint="?clearVFTables@ClassLayout@AST@CppParser@CppSharp@@QAEXXZ")]
internal static extern void clearVFTables_0(global::System.IntPtr instance); internal static extern void clearVFTables_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getFields@ClassLayout@AST@CppParser@CppSharp@@QAE?AVLayoutField@234@I@Z")]
internal static extern void getFields_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?addFields@ClassLayout@AST@CppParser@CppSharp@@QAEXAAVLayoutField@234@@Z")]
internal static extern void addFields_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?clearFields@ClassLayout@AST@CppParser@CppSharp@@QAEXXZ")]
internal static extern void clearFields_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QAEIXZ")] EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QAEIXZ")]
internal static extern uint getVFTablesCount_0(global::System.IntPtr instance); internal static extern uint getVFTablesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getFieldsCount@ClassLayout@AST@CppParser@CppSharp@@QAEIXZ")]
internal static extern uint getFieldsCount_0(global::System.IntPtr instance);
} }
public global::System.IntPtr __Instance { get; protected set; } public global::System.IntPtr __Instance { get; protected set; }
@ -3067,7 +3215,7 @@ namespace CppSharp
private static void* __CopyValue(ClassLayout.Internal native) private static void* __CopyValue(ClassLayout.Internal native)
{ {
var ret = Marshal.AllocHGlobal(48); var ret = Marshal.AllocHGlobal(60);
CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -3088,7 +3236,7 @@ namespace CppSharp
public ClassLayout() public ClassLayout()
{ {
__Instance = Marshal.AllocHGlobal(48); __Instance = Marshal.AllocHGlobal(60);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -3096,7 +3244,7 @@ namespace CppSharp
public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) public ClassLayout(CppSharp.Parser.AST.ClassLayout _0)
{ {
__Instance = Marshal.AllocHGlobal(48); __Instance = Marshal.AllocHGlobal(60);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -3139,6 +3287,26 @@ namespace CppSharp
Internal.clearVFTables_0((__Instance + __PointerAdjustment)); Internal.clearVFTables_0((__Instance + __PointerAdjustment));
} }
public CppSharp.Parser.AST.LayoutField getFields(uint i)
{
var __ret = new CppSharp.Parser.AST.LayoutField.Internal();
Internal.getFields_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i);
return CppSharp.Parser.AST.LayoutField.__CreateInstance(__ret);
}
public void addFields(CppSharp.Parser.AST.LayoutField s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
Internal.addFields_0((__Instance + __PointerAdjustment), __arg0);
}
public void clearFields()
{
Internal.clearFields_0((__Instance + __PointerAdjustment));
}
public uint VFTablesCount public uint VFTablesCount
{ {
get get
@ -3148,6 +3316,15 @@ namespace CppSharp
} }
} }
public uint FieldsCount
{
get
{
var __ret = Internal.getFieldsCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public CppSharp.Parser.AST.CppAbi ABI public CppSharp.Parser.AST.CppAbi ABI
{ {
get get
@ -6840,7 +7017,7 @@ namespace CppSharp
public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 152)] [StructLayout(LayoutKind.Explicit, Size = 148)]
public new partial struct Internal public new partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -6886,15 +7063,12 @@ namespace CppSharp
public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType;
[FieldOffset(136)] [FieldOffset(136)]
public uint Offset;
[FieldOffset(140)]
public global::System.IntPtr Class; public global::System.IntPtr Class;
[FieldOffset(144)] [FieldOffset(140)]
public byte IsBitField; public byte IsBitField;
[FieldOffset(148)] [FieldOffset(144)]
public uint BitWidth; public uint BitWidth;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -6925,7 +7099,7 @@ namespace CppSharp
private static void* __CopyValue(Field.Internal native) private static void* __CopyValue(Field.Internal native)
{ {
var ret = Marshal.AllocHGlobal(152); var ret = Marshal.AllocHGlobal(148);
CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -6949,7 +7123,7 @@ namespace CppSharp
public Field() public Field()
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(152); __Instance = Marshal.AllocHGlobal(148);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6958,7 +7132,7 @@ namespace CppSharp
public Field(CppSharp.Parser.AST.Field _0) public Field(CppSharp.Parser.AST.Field _0)
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(152); __Instance = Marshal.AllocHGlobal(148);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -6989,19 +7163,6 @@ namespace CppSharp
} }
} }
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Class Class public CppSharp.Parser.AST.Class Class
{ {
get get

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

@ -69,14 +69,56 @@ namespace CppSharp
Public = 2 Public = 2
} }
public enum CXXMethodKind public enum RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
}
public enum VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum CXXOperatorKind public enum CXXOperatorKind
@ -138,18 +180,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
} }
public enum StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}
public enum TemplateSpecializationKind public enum TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -159,25 +189,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
} }
public enum CppAbi public enum StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
} }
public enum VTableComponentKind public enum CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum PrimitiveType public enum PrimitiveType
@ -211,37 +242,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
} }
public enum RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum ArchType public enum ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -2984,9 +2984,137 @@ namespace CppSharp
} }
} }
public unsafe partial class LayoutField : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct Internal
{
[FieldOffset(0)]
public uint Offset;
[FieldOffset(8)]
public global::System.IntPtr Field;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2Ev")]
internal static extern void ctor_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2ERKS2_")]
internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldD2Ev")]
internal static extern void dtor_0(global::System.IntPtr instance);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static LayoutField __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new LayoutField(native.ToPointer(), skipVTables);
}
public static LayoutField __CreateInstance(LayoutField.Internal native, bool skipVTables = false)
{
return new LayoutField(native, skipVTables);
}
private static void* __CopyValue(LayoutField.Internal native)
{
var ret = Marshal.AllocHGlobal(16);
*(LayoutField.Internal*) ret = native;
return ret.ToPointer();
}
private LayoutField(LayoutField.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LayoutField(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public LayoutField()
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
}
public LayoutField(CppSharp.Parser.AST.LayoutField _0)
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
*((LayoutField.Internal*) __Instance) = *((LayoutField.Internal*) _0.__Instance);
}
public void Dispose()
{
Dispose(disposing: true);
}
protected virtual void Dispose(bool disposing)
{
CppSharp.Parser.AST.LayoutField __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
Internal.dtor_0((__Instance + __PointerAdjustment));
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Field Field
{
get
{
CppSharp.Parser.AST.Field __result0;
if (((Internal*) __Instance)->Field == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Field.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Field))
__result0 = (CppSharp.Parser.AST.Field) CppSharp.Parser.AST.Field.NativeToManagedMap[((Internal*) __Instance)->Field];
else __result0 = CppSharp.Parser.AST.Field.__CreateInstance(((Internal*) __Instance)->Field);
return __result0;
}
set
{
((Internal*) __Instance)->Field = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class ClassLayout : IDisposable public unsafe partial class ClassLayout : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 88)] [StructLayout(LayoutKind.Explicit, Size = 112)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -3040,10 +3168,30 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")]
internal static extern void clearVFTables_0(global::System.IntPtr instance); internal static extern void clearVFTables_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9getFieldsEj")]
internal static extern void getFields_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9addFieldsERNS1_11LayoutFieldE")]
internal static extern void addFields_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")]
internal static extern void clearFields_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")]
internal static extern uint getVFTablesCount_0(global::System.IntPtr instance); internal static extern uint getVFTablesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")]
internal static extern uint getFieldsCount_0(global::System.IntPtr instance);
} }
public global::System.IntPtr __Instance { get; protected set; } public global::System.IntPtr __Instance { get; protected set; }
@ -3066,7 +3214,7 @@ namespace CppSharp
private static void* __CopyValue(ClassLayout.Internal native) private static void* __CopyValue(ClassLayout.Internal native)
{ {
var ret = Marshal.AllocHGlobal(88); var ret = Marshal.AllocHGlobal(112);
CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -3087,7 +3235,7 @@ namespace CppSharp
public ClassLayout() public ClassLayout()
{ {
__Instance = Marshal.AllocHGlobal(88); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -3095,7 +3243,7 @@ namespace CppSharp
public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) public ClassLayout(CppSharp.Parser.AST.ClassLayout _0)
{ {
__Instance = Marshal.AllocHGlobal(88); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -3138,6 +3286,26 @@ namespace CppSharp
Internal.clearVFTables_0((__Instance + __PointerAdjustment)); Internal.clearVFTables_0((__Instance + __PointerAdjustment));
} }
public CppSharp.Parser.AST.LayoutField getFields(uint i)
{
var __ret = new CppSharp.Parser.AST.LayoutField.Internal();
Internal.getFields_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i);
return CppSharp.Parser.AST.LayoutField.__CreateInstance(__ret);
}
public void addFields(CppSharp.Parser.AST.LayoutField s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
Internal.addFields_0((__Instance + __PointerAdjustment), __arg0);
}
public void clearFields()
{
Internal.clearFields_0((__Instance + __PointerAdjustment));
}
public uint VFTablesCount public uint VFTablesCount
{ {
get get
@ -3147,6 +3315,15 @@ namespace CppSharp
} }
} }
public uint FieldsCount
{
get
{
var __ret = Internal.getFieldsCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public CppSharp.Parser.AST.CppAbi ABI public CppSharp.Parser.AST.CppAbi ABI
{ {
get get
@ -6839,7 +7016,7 @@ namespace CppSharp
public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 208)] [StructLayout(LayoutKind.Explicit, Size = 200)]
public new partial struct Internal public new partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -6885,15 +7062,12 @@ namespace CppSharp
public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType;
[FieldOffset(184)] [FieldOffset(184)]
public uint Offset;
[FieldOffset(192)]
public global::System.IntPtr Class; public global::System.IntPtr Class;
[FieldOffset(200)] [FieldOffset(192)]
public byte IsBitField; public byte IsBitField;
[FieldOffset(204)] [FieldOffset(196)]
public uint BitWidth; public uint BitWidth;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -6924,7 +7098,7 @@ namespace CppSharp
private static void* __CopyValue(Field.Internal native) private static void* __CopyValue(Field.Internal native)
{ {
var ret = Marshal.AllocHGlobal(208); var ret = Marshal.AllocHGlobal(200);
CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -6948,7 +7122,7 @@ namespace CppSharp
public Field() public Field()
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(208); __Instance = Marshal.AllocHGlobal(200);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6957,7 +7131,7 @@ namespace CppSharp
public Field(CppSharp.Parser.AST.Field _0) public Field(CppSharp.Parser.AST.Field _0)
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(208); __Instance = Marshal.AllocHGlobal(200);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -6988,19 +7162,6 @@ namespace CppSharp
} }
} }
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Class Class public CppSharp.Parser.AST.Class Class
{ {
get get

343
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs

@ -69,14 +69,56 @@ namespace CppSharp
Public = 2 Public = 2
} }
public enum CXXMethodKind public enum RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
}
public enum VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum CXXOperatorKind public enum CXXOperatorKind
@ -138,18 +180,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
} }
public enum StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}
public enum TemplateSpecializationKind public enum TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -159,25 +189,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
} }
public enum CppAbi public enum StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
} }
public enum VTableComponentKind public enum CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum PrimitiveType public enum PrimitiveType
@ -211,37 +242,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
} }
public enum RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum ArchType public enum ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -2984,9 +2984,137 @@ namespace CppSharp
} }
} }
public unsafe partial class LayoutField : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct Internal
{
[FieldOffset(0)]
public uint Offset;
[FieldOffset(8)]
public global::System.IntPtr Field;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2Ev")]
internal static extern void ctor_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldC2ERKS2_")]
internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11LayoutFieldD2Ev")]
internal static extern void dtor_0(global::System.IntPtr instance);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static LayoutField __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new LayoutField(native.ToPointer(), skipVTables);
}
public static LayoutField __CreateInstance(LayoutField.Internal native, bool skipVTables = false)
{
return new LayoutField(native, skipVTables);
}
private static void* __CopyValue(LayoutField.Internal native)
{
var ret = Marshal.AllocHGlobal(16);
*(LayoutField.Internal*) ret = native;
return ret.ToPointer();
}
private LayoutField(LayoutField.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LayoutField(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public LayoutField()
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
}
public LayoutField(CppSharp.Parser.AST.LayoutField _0)
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
*((LayoutField.Internal*) __Instance) = *((LayoutField.Internal*) _0.__Instance);
}
public void Dispose()
{
Dispose(disposing: true);
}
protected virtual void Dispose(bool disposing)
{
CppSharp.Parser.AST.LayoutField __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
Internal.dtor_0((__Instance + __PointerAdjustment));
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Field Field
{
get
{
CppSharp.Parser.AST.Field __result0;
if (((Internal*) __Instance)->Field == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Field.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Field))
__result0 = (CppSharp.Parser.AST.Field) CppSharp.Parser.AST.Field.NativeToManagedMap[((Internal*) __Instance)->Field];
else __result0 = CppSharp.Parser.AST.Field.__CreateInstance(((Internal*) __Instance)->Field);
return __result0;
}
set
{
((Internal*) __Instance)->Field = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class ClassLayout : IDisposable public unsafe partial class ClassLayout : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 88)] [StructLayout(LayoutKind.Explicit, Size = 112)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -3040,10 +3168,30 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13clearVFTablesEv")]
internal static extern void clearVFTables_0(global::System.IntPtr instance); internal static extern void clearVFTables_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9getFieldsEj")]
internal static extern void getFields_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout9addFieldsERNS1_11LayoutFieldE")]
internal static extern void addFields_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")]
internal static extern void clearFields_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")]
internal static extern uint getVFTablesCount_0(global::System.IntPtr instance); internal static extern uint getVFTablesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")]
internal static extern uint getFieldsCount_0(global::System.IntPtr instance);
} }
public global::System.IntPtr __Instance { get; protected set; } public global::System.IntPtr __Instance { get; protected set; }
@ -3066,7 +3214,7 @@ namespace CppSharp
private static void* __CopyValue(ClassLayout.Internal native) private static void* __CopyValue(ClassLayout.Internal native)
{ {
var ret = Marshal.AllocHGlobal(88); var ret = Marshal.AllocHGlobal(112);
CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -3087,7 +3235,7 @@ namespace CppSharp
public ClassLayout() public ClassLayout()
{ {
__Instance = Marshal.AllocHGlobal(88); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -3095,7 +3243,7 @@ namespace CppSharp
public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) public ClassLayout(CppSharp.Parser.AST.ClassLayout _0)
{ {
__Instance = Marshal.AllocHGlobal(88); __Instance = Marshal.AllocHGlobal(112);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -3138,6 +3286,26 @@ namespace CppSharp
Internal.clearVFTables_0((__Instance + __PointerAdjustment)); Internal.clearVFTables_0((__Instance + __PointerAdjustment));
} }
public CppSharp.Parser.AST.LayoutField getFields(uint i)
{
var __ret = new CppSharp.Parser.AST.LayoutField.Internal();
Internal.getFields_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i);
return CppSharp.Parser.AST.LayoutField.__CreateInstance(__ret);
}
public void addFields(CppSharp.Parser.AST.LayoutField s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
Internal.addFields_0((__Instance + __PointerAdjustment), __arg0);
}
public void clearFields()
{
Internal.clearFields_0((__Instance + __PointerAdjustment));
}
public uint VFTablesCount public uint VFTablesCount
{ {
get get
@ -3147,6 +3315,15 @@ namespace CppSharp
} }
} }
public uint FieldsCount
{
get
{
var __ret = Internal.getFieldsCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public CppSharp.Parser.AST.CppAbi ABI public CppSharp.Parser.AST.CppAbi ABI
{ {
get get
@ -6839,7 +7016,7 @@ namespace CppSharp
public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 160)] [StructLayout(LayoutKind.Explicit, Size = 152)]
public new partial struct Internal public new partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -6885,15 +7062,12 @@ namespace CppSharp
public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType;
[FieldOffset(136)] [FieldOffset(136)]
public uint Offset;
[FieldOffset(144)]
public global::System.IntPtr Class; public global::System.IntPtr Class;
[FieldOffset(152)] [FieldOffset(144)]
public byte IsBitField; public byte IsBitField;
[FieldOffset(156)] [FieldOffset(148)]
public uint BitWidth; public uint BitWidth;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -6924,7 +7098,7 @@ namespace CppSharp
private static void* __CopyValue(Field.Internal native) private static void* __CopyValue(Field.Internal native)
{ {
var ret = Marshal.AllocHGlobal(160); var ret = Marshal.AllocHGlobal(152);
CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -6948,7 +7122,7 @@ namespace CppSharp
public Field() public Field()
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(160); __Instance = Marshal.AllocHGlobal(152);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6957,7 +7131,7 @@ namespace CppSharp
public Field(CppSharp.Parser.AST.Field _0) public Field(CppSharp.Parser.AST.Field _0)
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(160); __Instance = Marshal.AllocHGlobal(152);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -6988,19 +7162,6 @@ namespace CppSharp
} }
} }
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Class Class public CppSharp.Parser.AST.Class Class
{ {
get get

343
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs

@ -69,14 +69,56 @@ namespace CppSharp
Public = 2 Public = 2
} }
public enum CXXMethodKind public enum RawCommentKind
{ {
Normal = 0, Invalid = 0,
Constructor = 1, OrdinaryBCPL = 1,
Destructor = 2, OrdinaryC = 2,
Conversion = 3, BCPLSlash = 3,
Operator = 4, BCPLExcl = 4,
UsingDirective = 5 JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum CppAbi
{
Itanium = 0,
Microsoft = 1,
ARM = 2,
iOS = 3,
iOS64 = 4
}
public enum VTableComponentKind
{
VCallOffset = 0,
VBaseOffset = 1,
OffsetToTop = 2,
RTTI = 3,
FunctionPointer = 4,
CompleteDtorPointer = 5,
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum CXXOperatorKind public enum CXXOperatorKind
@ -138,18 +180,6 @@ namespace CppSharp
Unknown = 5 Unknown = 5
} }
public enum StatementClass
{
Any = 0,
BinaryOperator = 1,
CallExprClass = 2,
DeclRefExprClass = 3,
CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
}
public enum TemplateSpecializationKind public enum TemplateSpecializationKind
{ {
Undeclared = 0, Undeclared = 0,
@ -159,25 +189,26 @@ namespace CppSharp
ExplicitInstantiationDefinition = 4 ExplicitInstantiationDefinition = 4
} }
public enum CppAbi public enum StatementClass
{ {
Itanium = 0, Any = 0,
Microsoft = 1, BinaryOperator = 1,
ARM = 2, CallExprClass = 2,
iOS = 3, DeclRefExprClass = 3,
iOS64 = 4 CXXConstructExprClass = 4,
CXXOperatorCallExpr = 5,
ImplicitCastExpr = 6,
ExplicitCastExpr = 7
} }
public enum VTableComponentKind public enum CXXMethodKind
{ {
VCallOffset = 0, Normal = 0,
VBaseOffset = 1, Constructor = 1,
OffsetToTop = 2, Destructor = 2,
RTTI = 3, Conversion = 3,
FunctionPointer = 4, Operator = 4,
CompleteDtorPointer = 5, UsingDirective = 5
DeletingDtorPointer = 6,
UnusedFunctionPointer = 7
} }
public enum PrimitiveType public enum PrimitiveType
@ -211,37 +242,6 @@ namespace CppSharp
FunctionBody = 5 FunctionBody = 5
} }
public enum RawCommentKind
{
Invalid = 0,
OrdinaryBCPL = 1,
OrdinaryC = 2,
BCPLSlash = 3,
BCPLExcl = 4,
JavaDoc = 5,
Qt = 6,
Merged = 7
}
public enum CommentKind
{
FullComment = 0,
BlockContentComment = 1,
BlockCommandComment = 2,
ParamCommandComment = 3,
TParamCommandComment = 4,
VerbatimBlockComment = 5,
VerbatimLineComment = 6,
ParagraphComment = 7,
HTMLTagComment = 8,
HTMLStartTagComment = 9,
HTMLEndTagComment = 10,
TextComment = 11,
InlineContentComment = 12,
InlineCommandComment = 13,
VerbatimBlockLineComment = 14
}
public enum ArchType public enum ArchType
{ {
UnknownArch = 0, UnknownArch = 0,
@ -2985,9 +2985,137 @@ namespace CppSharp
} }
} }
public unsafe partial class LayoutField : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct Internal
{
[FieldOffset(0)]
public uint Offset;
[FieldOffset(8)]
public global::System.IntPtr Field;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="??0LayoutField@AST@CppParser@CppSharp@@QEAA@XZ")]
internal static extern global::System.IntPtr ctor_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="??0LayoutField@AST@CppParser@CppSharp@@QEAA@AEBV0123@@Z")]
internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="??1LayoutField@AST@CppParser@CppSharp@@QEAA@XZ")]
internal static extern void dtor_0(global::System.IntPtr instance, int delete);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LayoutField>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static LayoutField __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new LayoutField(native.ToPointer(), skipVTables);
}
public static LayoutField __CreateInstance(LayoutField.Internal native, bool skipVTables = false)
{
return new LayoutField(native, skipVTables);
}
private static void* __CopyValue(LayoutField.Internal native)
{
var ret = Marshal.AllocHGlobal(16);
*(LayoutField.Internal*) ret = native;
return ret.ToPointer();
}
private LayoutField(LayoutField.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected LayoutField(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public LayoutField()
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment));
}
public LayoutField(CppSharp.Parser.AST.LayoutField _0)
{
__Instance = Marshal.AllocHGlobal(16);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
*((LayoutField.Internal*) __Instance) = *((LayoutField.Internal*) _0.__Instance);
}
public void Dispose()
{
Dispose(disposing: true);
}
protected virtual void Dispose(bool disposing)
{
CppSharp.Parser.AST.LayoutField __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
Internal.dtor_0((__Instance + __PointerAdjustment), 0);
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Field Field
{
get
{
CppSharp.Parser.AST.Field __result0;
if (((Internal*) __Instance)->Field == IntPtr.Zero) __result0 = null;
else if (CppSharp.Parser.AST.Field.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Field))
__result0 = (CppSharp.Parser.AST.Field) CppSharp.Parser.AST.Field.NativeToManagedMap[((Internal*) __Instance)->Field];
else __result0 = CppSharp.Parser.AST.Field.__CreateInstance(((Internal*) __Instance)->Field);
return __result0;
}
set
{
((Internal*) __Instance)->Field = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
public unsafe partial class ClassLayout : IDisposable public unsafe partial class ClassLayout : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 80)] [StructLayout(LayoutKind.Explicit, Size = 104)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -3041,10 +3169,30 @@ namespace CppSharp
EntryPoint="?clearVFTables@ClassLayout@AST@CppParser@CppSharp@@QEAAXXZ")] EntryPoint="?clearVFTables@ClassLayout@AST@CppParser@CppSharp@@QEAAXXZ")]
internal static extern void clearVFTables_0(global::System.IntPtr instance); internal static extern void clearVFTables_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getFields@ClassLayout@AST@CppParser@CppSharp@@QEAA?AVLayoutField@234@I@Z")]
internal static extern void getFields_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?addFields@ClassLayout@AST@CppParser@CppSharp@@QEAAXAEAVLayoutField@234@@Z")]
internal static extern void addFields_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?clearFields@ClassLayout@AST@CppParser@CppSharp@@QEAAXXZ")]
internal static extern void clearFields_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QEAAIXZ")] EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QEAAIXZ")]
internal static extern uint getVFTablesCount_0(global::System.IntPtr instance); internal static extern uint getVFTablesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getFieldsCount@ClassLayout@AST@CppParser@CppSharp@@QEAAIXZ")]
internal static extern uint getFieldsCount_0(global::System.IntPtr instance);
} }
public global::System.IntPtr __Instance { get; protected set; } public global::System.IntPtr __Instance { get; protected set; }
@ -3067,7 +3215,7 @@ namespace CppSharp
private static void* __CopyValue(ClassLayout.Internal native) private static void* __CopyValue(ClassLayout.Internal native)
{ {
var ret = Marshal.AllocHGlobal(80); var ret = Marshal.AllocHGlobal(104);
CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -3088,7 +3236,7 @@ namespace CppSharp
public ClassLayout() public ClassLayout()
{ {
__Instance = Marshal.AllocHGlobal(80); __Instance = Marshal.AllocHGlobal(104);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -3096,7 +3244,7 @@ namespace CppSharp
public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) public ClassLayout(CppSharp.Parser.AST.ClassLayout _0)
{ {
__Instance = Marshal.AllocHGlobal(80); __Instance = Marshal.AllocHGlobal(104);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -3139,6 +3287,26 @@ namespace CppSharp
Internal.clearVFTables_0((__Instance + __PointerAdjustment)); Internal.clearVFTables_0((__Instance + __PointerAdjustment));
} }
public CppSharp.Parser.AST.LayoutField getFields(uint i)
{
var __ret = new CppSharp.Parser.AST.LayoutField.Internal();
Internal.getFields_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i);
return CppSharp.Parser.AST.LayoutField.__CreateInstance(__ret);
}
public void addFields(CppSharp.Parser.AST.LayoutField s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var __arg0 = s.__Instance;
Internal.addFields_0((__Instance + __PointerAdjustment), __arg0);
}
public void clearFields()
{
Internal.clearFields_0((__Instance + __PointerAdjustment));
}
public uint VFTablesCount public uint VFTablesCount
{ {
get get
@ -3148,6 +3316,15 @@ namespace CppSharp
} }
} }
public uint FieldsCount
{
get
{
var __ret = Internal.getFieldsCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public CppSharp.Parser.AST.CppAbi ABI public CppSharp.Parser.AST.CppAbi ABI
{ {
get get
@ -6840,7 +7017,7 @@ namespace CppSharp
public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable public unsafe partial class Field : CppSharp.Parser.AST.Declaration, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 232)] [StructLayout(LayoutKind.Explicit, Size = 224)]
public new partial struct Internal public new partial struct Internal
{ {
[FieldOffset(0)] [FieldOffset(0)]
@ -6886,15 +7063,12 @@ namespace CppSharp
public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType;
[FieldOffset(208)] [FieldOffset(208)]
public uint Offset;
[FieldOffset(216)]
public global::System.IntPtr Class; public global::System.IntPtr Class;
[FieldOffset(224)] [FieldOffset(216)]
public byte IsBitField; public byte IsBitField;
[FieldOffset(228)] [FieldOffset(220)]
public uint BitWidth; public uint BitWidth;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -6925,7 +7099,7 @@ namespace CppSharp
private static void* __CopyValue(Field.Internal native) private static void* __CopyValue(Field.Internal native)
{ {
var ret = Marshal.AllocHGlobal(232); var ret = Marshal.AllocHGlobal(224);
CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.AST.Field.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -6949,7 +7123,7 @@ namespace CppSharp
public Field() public Field()
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(232); __Instance = Marshal.AllocHGlobal(224);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -6958,7 +7132,7 @@ namespace CppSharp
public Field(CppSharp.Parser.AST.Field _0) public Field(CppSharp.Parser.AST.Field _0)
: this((void*) null) : this((void*) null)
{ {
__Instance = Marshal.AllocHGlobal(232); __Instance = Marshal.AllocHGlobal(224);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -6989,19 +7163,6 @@ namespace CppSharp
} }
} }
public uint Offset
{
get
{
return ((Internal*) __Instance)->Offset;
}
set
{
((Internal*) __Instance)->Offset = value;
}
}
public CppSharp.Parser.AST.Class Class public CppSharp.Parser.AST.Class Class
{ {
get get

88
src/CppParser/Parser.cpp

@ -82,6 +82,81 @@ std::string GetCurrentLibraryDir()
#endif #endif
} }
void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl *RD,
clang::CharUnits Offset, bool IncludeVirtualBases)
{
using namespace clang;
const auto &Layout = C->getASTContext().getASTRecordLayout(RD);
auto CXXRD = dyn_cast<CXXRecordDecl>(RD);
// Dump bases.
if (CXXRD) {
// Collect nvbases.
SmallVector<const CXXRecordDecl *, 4> Bases;
for (const CXXBaseSpecifier &Base : CXXRD->bases()) {
assert(!Base.getType()->isDependentType() &&
"Cannot layout class with dependent bases.");
if (!Base.isVirtual())
Bases.push_back(Base.getType()->getAsCXXRecordDecl());
}
// Sort nvbases by offset.
std::stable_sort(Bases.begin(), Bases.end(),
[&](const CXXRecordDecl *L, const CXXRecordDecl *R) {
return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
});
// Dump (non-virtual) bases
for (const CXXRecordDecl *Base : Bases) {
CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(Base);
ReadLayoutFields(Class, Base, BaseOffset,
/*IncludeVirtualBases=*/false);
}
}
// Dump fields.
uint64_t FieldNo = 0;
for (RecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end(); I != E; ++I, ++FieldNo) {
const FieldDecl &Field = **I;
uint64_t LocalFieldOffsetInBits = Layout.getFieldOffset(FieldNo);
CharUnits FieldOffset =
Offset + C->getASTContext().toCharUnitsFromBits(LocalFieldOffsetInBits);
// Recursively dump fields of record type.
if (auto RT = Field.getType()->getAs<RecordType>())
{
auto TU = GetTranslationUnit(RT->getDecl());
if (TU->IsSystemHeader)
continue;
}
auto Parent = WalkDeclaration(RD, /*IgnoreSystemDecls =*/false);
auto F = WalkFieldCXX(&Field, static_cast<AST::Class*>(Parent));
LayoutField LayoutField;
LayoutField.Offset = FieldOffset.getQuantity();
LayoutField.Field = F;
Class->Layout->Fields.push_back(LayoutField);
}
// Dump virtual bases.
if (CXXRD && IncludeVirtualBases) {
const ASTRecordLayout::VBaseOffsetsMapTy &VtorDisps =
Layout.getVBaseOffsetsMap();
for (const CXXBaseSpecifier &Base : CXXRD->vbases()) {
assert(Base.isVirtual() && "Found non-virtual class!");
const CXXRecordDecl *VBase = Base.getType()->getAsCXXRecordDecl();
CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBase);
ReadLayoutFields(Class, VBase, VBaseOffset,
/*IncludeVirtualBases=*/false);
}
}
}
static std::string GetClangResourceDir() static std::string GetClangResourceDir()
{ {
using namespace llvm; using namespace llvm;
@ -729,6 +804,7 @@ void Parser::WalkRecord(const clang::RecordDecl* Record, Class* RC)
RC->Layout->Alignment = (int)Layout-> getAlignment().getQuantity(); RC->Layout->Alignment = (int)Layout-> getAlignment().getQuantity();
RC->Layout->Size = (int)Layout->getSize().getQuantity(); RC->Layout->Size = (int)Layout->getSize().getQuantity();
RC->Layout->DataSize = (int)Layout->getDataSize().getQuantity(); RC->Layout->DataSize = (int)Layout->getDataSize().getQuantity();
ReadLayoutFields(RC, Record, CharUnits(), true);
} }
for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it) for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it)
@ -749,11 +825,7 @@ void Parser::WalkRecord(const clang::RecordDecl* Record, Class* RC)
case Decl::Field: case Decl::Field:
{ {
auto FD = cast<FieldDecl>(D); auto FD = cast<FieldDecl>(D);
auto Field = WalkFieldCXX(FD, RC); WalkFieldCXX(FD, RC);
if (Layout)
Field->Offset = Layout->getFieldOffset(FD->getFieldIndex());
break; break;
} }
case Decl::AccessSpec: case Decl::AccessSpec:
@ -1343,6 +1415,12 @@ Field* Parser::WalkFieldCXX(const clang::FieldDecl* FD, Class* Class)
const auto& USR = GetDeclUSR(FD); const auto& USR = GetDeclUSR(FD);
auto FoundField = std::find_if(Class->Fields.begin(), Class->Fields.end(),
[&](Field* Field) { return Field->USR == USR; });
if (FoundField != Class->Fields.end())
return *FoundField;
auto F = new Field(); auto F = new Field();
HandleDeclaration(FD, F); HandleDeclaration(FD, F);

1
src/CppParser/Parser.h

@ -98,6 +98,7 @@ private:
std::vector<TemplateArgument> WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, const clang::ASTTemplateArgumentListInfo* TSTL); std::vector<TemplateArgument> WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, const clang::ASTTemplateArgumentListInfo* TSTL);
void WalkVTable(const clang::CXXRecordDecl* RD, Class* C); void WalkVTable(const clang::CXXRecordDecl* RD, Class* C);
QualifiedType GetQualifiedType(clang::QualType qual, clang::TypeLoc* TL = 0); QualifiedType GetQualifiedType(clang::QualType qual, clang::TypeLoc* TL = 0);
void ReadLayoutFields(Class * Class, const clang::RecordDecl * RD, clang::CharUnits Offset, bool IncludeVirtualBases);
VTableLayout WalkVTableLayout(const clang::VTableLayout& VTLayout); VTableLayout WalkVTableLayout(const clang::VTableLayout& VTLayout);
VTableComponent WalkVTableComponent(const clang::VTableComponent& Component); VTableComponent WalkVTableComponent(const clang::VTableComponent& Component);
PreprocessedEntity* WalkPreprocessedEntity(Declaration* Decl, PreprocessedEntity* WalkPreprocessedEntity(Declaration* Decl,

16
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -439,9 +439,9 @@ namespace CppSharp.Generators.CLI
PushIndent(); PushIndent();
// check for value types because some of the ignored fields may back properties; // check for value types because some of the ignored fields may back properties;
// not the case for ref types because the NativePtr pattern is used there // not the case for ref types because the NativePtr pattern is used there
foreach (var field in @class.Fields.Where(f => !ASTUtils.CheckIgnoreField(f))) foreach (var field in @class.Layout.Fields.Where(f => !ASTUtils.CheckIgnoreField(f.Field)))
{ {
var property = @class.Properties.FirstOrDefault(p => p.Field == field); var property = @class.Properties.FirstOrDefault(p => p.Field == field.Field);
if (property != null && !property.IsInRefTypeAndBackedByValueClassField()) if (property != null && !property.IsInRefTypeAndBackedByValueClassField())
{ {
GenerateField(@class, field); GenerateField(@class, field);
@ -450,15 +450,15 @@ namespace CppSharp.Generators.CLI
PopIndent(); PopIndent();
} }
private void GenerateField(Class @class, Field field) private void GenerateField(Class @class, LayoutField layoutField)
{ {
PushBlock(CLIBlockKind.Field, field); PushBlock(CLIBlockKind.Field, layoutField.Field);
GenerateDeclarationCommon(field); GenerateDeclarationCommon(layoutField.Field);
if (@class.IsUnion) if (@class.IsUnion)
WriteLine("[System::Runtime::InteropServices::FieldOffset({0})]", WriteLine("[System::Runtime::InteropServices::FieldOffset({0})]",
field.Offset); layoutField.Offset);
WriteLine("{0} {1};", field.Type, field.Name); WriteLine("{0} {1};", layoutField.Field.Type, layoutField.Field.Name);
PopBlock(); PopBlock();
} }
@ -630,7 +630,7 @@ namespace CppSharp.Generators.CLI
{ {
if (prop.IsInRefTypeAndBackedByValueClassField()) if (prop.IsInRefTypeAndBackedByValueClassField())
{ {
GenerateField(@class, prop.Field); GenerateField(@class, @class.Layout.Fields.Single(f => f.Field == prop.Field));
continue; continue;
} }

47
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -603,7 +603,8 @@ namespace CppSharp.Generators.CSharp
if (@class.IsDynamic) if (@class.IsDynamic)
GenerateVTablePointers(@class); GenerateVTablePointers(@class);
GenerateClassFields(@class, @class, GenerateClassInternalsField, true); foreach (var field in @class.Layout.Fields)
GenerateClassInternalsField(field);
if (@class.IsGenerated && !(@class is ClassTemplateSpecialization)) if (@class.IsGenerated && !(@class is ClassTemplateSpecialization))
{ {
var functions = GatherClassInternalFunctions(@class); var functions = GatherClassInternalFunctions(@class);
@ -790,16 +791,16 @@ namespace CppSharp.Generators.CSharp
} }
} }
private void GenerateClassInternalsField(Class owner, Field field) private void GenerateClassInternalsField(LayoutField layoutField)
{ {
// we do not support dependent fields yet, see https://github.com/mono/CppSharp/issues/197 // we do not support dependent fields yet, see https://github.com/mono/CppSharp/issues/197
Class @class; Declaration decl;
field.Type.TryGetClass(out @class); var field = layoutField.Field;
if ((field.Type.IsDependent && !field.Type.IsPointer() && field.Type.TryGetDeclaration(out decl);
!(@class != null && @class.IsUnion)) || (@class != null && @class.TranslationUnit.IsSystemHeader)) if (decl != null && decl.TranslationUnit.IsSystemHeader)
return; return;
var safeIdentifier = Helpers.SafeIdentifier(field.InternalName); var safeIdentifier = Helpers.SafeIdentifier(layoutField.Name);
if(safeIdentifier.All(c => c.Equals('_'))) if(safeIdentifier.All(c => c.Equals('_')))
{ {
@ -808,8 +809,7 @@ namespace CppSharp.Generators.CSharp
PushBlock(CSharpBlockKind.Field); PushBlock(CSharpBlockKind.Field);
WriteLine("[FieldOffset({0})]", field.OffsetInBytes + WriteLine("[FieldOffset({0})]", layoutField.Offset);
owner.ComputeNonVirtualBaseClassOffsetTo((Class) field.Namespace));
TypePrinter.PushMarshalKind(CSharpMarshalKind.NativeField); TypePrinter.PushMarshalKind(CSharpMarshalKind.NativeField);
var fieldTypePrinted = field.QualifiedType.CSharpType(TypePrinter); var fieldTypePrinted = field.QualifiedType.CSharpType(TypePrinter);
@ -822,7 +822,7 @@ namespace CppSharp.Generators.CSharp
if (!string.IsNullOrWhiteSpace(fieldTypePrinted.NameSuffix)) if (!string.IsNullOrWhiteSpace(fieldTypePrinted.NameSuffix))
fieldName += fieldTypePrinted.NameSuffix; fieldName += fieldTypePrinted.NameSuffix;
var access = @class != null && !@class.IsGenerated ? "internal" : "public"; var access = decl != null && !decl.IsGenerated ? "internal" : "public";
if (field.Expression != null) if (field.Expression != null)
{ {
var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter); var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter);
@ -848,11 +848,11 @@ namespace CppSharp.Generators.CSharp
Name = string.Format("{0}_{1}_{2}", Helpers.DummyIdentifier, Name = string.Format("{0}_{1}_{2}", Helpers.DummyIdentifier,
safeIdentifier, i), safeIdentifier, i),
QualifiedType = new QualifiedType(arrayType.Type), QualifiedType = new QualifiedType(arrayType.Type),
Offset = (uint) (field.Offset + i * arrayType.ElementSize), Namespace = field.Namespace
Namespace = owner
}; };
GenerateClassInternalsField(owner, dummy); GenerateClassInternalsField(new LayoutField(
(uint) (layoutField.Offset + i * arrayType.ElementSize / 8), dummy));
} }
} }
} }
@ -975,12 +975,13 @@ namespace CppSharp.Generators.CSharp
} }
else else
{ {
var name = @class.Layout.Fields.First(f => f.Field == field).Name;
ctx.ReturnVarName = string.Format("{0}{1}{2}", ctx.ReturnVarName = string.Format("{0}{1}{2}",
@class.IsValueType @class.IsValueType
? Helpers.InstanceField ? Helpers.InstanceField
: string.Format("((Internal*) {0})", Helpers.InstanceIdentifier), : string.Format("((Internal*) {0})", Helpers.InstanceIdentifier),
@class.IsValueType ? "." : "->", @class.IsValueType ? "." : "->",
Helpers.SafeIdentifier(field.InternalName)); Helpers.SafeIdentifier(name));
} }
param.Visit(marshal); param.Visit(marshal);
@ -1026,9 +1027,9 @@ namespace CppSharp.Generators.CSharp
type = originalType.ToString(); type = originalType.ToString();
} }
var name = ((Class) field.Namespace).Layout.Fields.First(f => f.Field == field).Name;
WriteLine(string.Format("fixed ({0} {1} = {2}.{3})", WriteLine(string.Format("fixed ({0} {1} = {2}.{3})",
type, arrPtrIden, Helpers.InstanceField, type, arrPtrIden, Helpers.InstanceField, Helpers.SafeIdentifier(name)));
Helpers.SafeIdentifier(field.InternalName)));
WriteStartBraceIndent(); WriteStartBraceIndent();
if (Driver.Options.MarshalCharAsManagedChar && isChar) if (Driver.Options.MarshalCharAsManagedChar && isChar)
WriteLine("var {0} = ({1}) {2};", arrPtr, originalType, arrPtrIden); WriteLine("var {0} = ({1}) {2};", arrPtr, originalType, arrPtrIden);
@ -1117,6 +1118,7 @@ namespace CppSharp.Generators.CSharp
NewLine(); NewLine();
WriteStartBraceIndent(); WriteStartBraceIndent();
var name = @class.Layout.Fields.First(f => f.Field == field).Name;
var ctx = new CSharpMarshalContext(Driver) var ctx = new CSharpMarshalContext(Driver)
{ {
Kind = CSharpMarshalKind.NativeField, Kind = CSharpMarshalKind.NativeField,
@ -1126,7 +1128,7 @@ namespace CppSharp.Generators.CSharp
? Helpers.InstanceField ? Helpers.InstanceField
: string.Format("((Internal*) {0})", Helpers.InstanceIdentifier), : string.Format("((Internal*) {0})", Helpers.InstanceIdentifier),
@class.IsValueType ? "." : "->", @class.IsValueType ? "." : "->",
Helpers.SafeIdentifier(field.InternalName)), Helpers.SafeIdentifier(name)),
ReturnType = decl.QualifiedType ReturnType = decl.QualifiedType
}; };
@ -1298,9 +1300,10 @@ namespace CppSharp.Generators.CSharp
ArrayType arrayType = prop.Type as ArrayType; ArrayType arrayType = prop.Type as ArrayType;
if (arrayType != null && arrayType.Type.IsPointerToPrimitiveType() && prop.Field != null) if (arrayType != null && arrayType.Type.IsPointerToPrimitiveType() && prop.Field != null)
{ {
var name = @class.Layout.Fields.First(f => f.Field == prop.Field).Name;
GenerateClassField(prop.Field); GenerateClassField(prop.Field);
WriteLine("private bool {0};", WriteLine("private bool {0};",
GeneratedIdentifier(string.Format("{0}Initialised", prop.Field.InternalName))); GeneratedIdentifier(string.Format("{0}Initialised", name)));
} }
GenerateDeclarationCommon(prop); GenerateDeclarationCommon(prop);

16
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -152,7 +152,7 @@ namespace CppSharp.Passes
public override bool VisitClassDecl(Class @class) public override bool VisitClassDecl(Class @class)
{ {
if (!VisitDeclaration(@class)) if (!base.VisitClassDecl(@class))
return false; return false;
if (@class.IsIncomplete) if (@class.IsIncomplete)
@ -166,11 +166,17 @@ namespace CppSharp.Passes
foreach (var function in @class.Functions) foreach (var function in @class.Functions)
VisitFunctionDecl(function); VisitFunctionDecl(function);
foreach (var fields in GetAllFields(@class).GroupBy(f => f.OriginalName).Where( if (!@class.IsDependent)
g => !string.IsNullOrEmpty(g.Key)).Select(g => g.ToList()))
{ {
for (var i = 1; i < fields.Count; i++) foreach (var fields in @class.Layout.Fields.GroupBy(
fields[i].InternalName = fields[i].OriginalName + i; f => f.Field.OriginalName).Select(g => g.ToList()))
{
for (var i = 1; i < fields.Count; i++)
{
var name = fields[i].Field.OriginalName;
fields[i].Name = (string.IsNullOrEmpty(name) ? "__" : name) + i;
}
}
} }
foreach (var property in @class.Properties) foreach (var property in @class.Properties)

Loading…
Cancel
Save