From 517b1a5ccdcd69449e5266659c9d1270b8c87818 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 24 Jun 2016 03:58:05 +0300 Subject: [PATCH] Saved the offsets per base in the layout of a record. Signed-off-by: Dimitar Dobrev --- src/AST/ClassExtensions.cs | 26 -- src/AST/ClassLayout.cs | 2 + src/AST/LayoutBase.cs | 8 + src/AST/LayoutField.cs | 1 - src/Core/Parser/ASTConverter.cs | 10 +- src/CppParser/AST.cpp | 13 +- src/CppParser/AST.h | 16 +- src/CppParser/Bindings/CLI/AST.cpp | 105 ++++++-- src/CppParser/Bindings/CLI/AST.h | 55 ++++- .../CSharp/i686-apple-darwin12.4.0/AST.cs | 229 +++++++++++++++--- .../Bindings/CSharp/i686-pc-win32-msvc/AST.cs | 229 +++++++++++++++--- .../CSharp/x86_64-apple-darwin12.4.0/AST.cs | 229 +++++++++++++++--- .../Bindings/CSharp/x86_64-linux-gnu/AST.cs | 229 +++++++++++++++--- .../CSharp/x86_64-pc-win32-msvc/AST.cs | 229 +++++++++++++++--- src/CppParser/Parser.cpp | 15 +- src/CppParser/Parser.h | 2 +- .../Generators/CLI/CLIHeadersTemplate.cs | 3 +- .../Generators/CSharp/CSharpTextTemplate.cs | 9 +- 18 files changed, 1167 insertions(+), 243 deletions(-) create mode 100644 src/AST/LayoutBase.cs diff --git a/src/AST/ClassExtensions.cs b/src/AST/ClassExtensions.cs index 81a5a705..f51f9979 100644 --- a/src/AST/ClassExtensions.cs +++ b/src/AST/ClassExtensions.cs @@ -198,31 +198,5 @@ namespace CppSharp.AST return hasRefBase; } - - private static bool ComputeClassPath(this Class current, Class target, - IList path) - { - if (target == current) - return true; - - foreach (var @base in current.Bases) - { - path.Add(@base); - - var @class = @base.Class.OriginalClass ?? @base.Class; - if (@class != current && @class.ComputeClassPath(target, path)) - return false; - } - - path.RemoveAt(path.Count - 1); - return false; - } - - public static int ComputeNonVirtualBaseClassOffsetTo(this Class from, Class to) - { - var path = new List(); - @from.ComputeClassPath(to, path); - return path.Sum(@base => @base.Offset); - } } } \ No newline at end of file diff --git a/src/AST/ClassLayout.cs b/src/AST/ClassLayout.cs index ec69277d..3abd98c0 100644 --- a/src/AST/ClassLayout.cs +++ b/src/AST/ClassLayout.cs @@ -88,9 +88,11 @@ namespace CppSharp.AST { VFTables = new List(); Fields = new List(); + Bases = new List(); } public List Fields { get; private set; } + public List Bases { get; private set; } public ClassLayout(ClassLayout classLayout) : this() diff --git a/src/AST/LayoutBase.cs b/src/AST/LayoutBase.cs new file mode 100644 index 00000000..f92ecb51 --- /dev/null +++ b/src/AST/LayoutBase.cs @@ -0,0 +1,8 @@ +namespace CppSharp.AST +{ + public class LayoutBase + { + public uint Offset { get; set; } + public Class Class { get; set; } + } +} diff --git a/src/AST/LayoutField.cs b/src/AST/LayoutField.cs index 37b84fd5..8ead4d20 100644 --- a/src/AST/LayoutField.cs +++ b/src/AST/LayoutField.cs @@ -4,7 +4,6 @@ namespace CppSharp.AST { public class LayoutField { - public DeclarationContext Namespace { get; set; } public uint Offset { get; set; } public QualifiedType QualifiedType { get; set; } public string Name { get; set; } diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs index d27e0f14..260767ed 100644 --- a/src/Core/Parser/ASTConverter.cs +++ b/src/Core/Parser/ASTConverter.cs @@ -1349,7 +1349,6 @@ namespace CppSharp { var field = layout.getFields(i); var _field = new AST.LayoutField(); - _field.Namespace = (AST.DeclarationContext) Visit(field._Namespace); _field.Offset = field.Offset; _field.Name = field.Name; _field.QualifiedType = typeConverter.VisitQualified(field.QualifiedType); @@ -1357,6 +1356,15 @@ namespace CppSharp _layout.Fields.Add(_field); } + for (uint i = 0; i < layout.BasesCount; i++) + { + var @base = layout.getBases(i); + var _base = new AST.LayoutBase(); + _base.Offset = @base.Offset; + _base.Class = (AST.Class) Visit(@base.Class); + _layout.Bases.Add(_base); + } + return _layout; } diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp index 988c2806..570670fc 100644 --- a/src/CppParser/AST.cpp +++ b/src/CppParser/AST.cpp @@ -189,11 +189,10 @@ VFTableInfo::VFTableInfo(const VFTableInfo& rhs) : VBTableIndex(rhs.VBTableIndex VFPtrOffset(rhs.VFPtrOffset), VFPtrFullOffset(rhs.VFPtrFullOffset), Layout(rhs.Layout) {} -LayoutField::LayoutField() : _Namespace(0), Offset(0), FieldPtr(0) {} +LayoutField::LayoutField() : Offset(0), FieldPtr(0) {} LayoutField::LayoutField(const LayoutField & other) - : _Namespace(other._Namespace) - , Offset(other.Offset) + : Offset(other.Offset) , Name(other.Name) , QualifiedType(other.QualifiedType) , FieldPtr(other.FieldPtr) @@ -204,6 +203,12 @@ LayoutField::~LayoutField() {} DEF_STRING(LayoutField, Name) +LayoutBase::LayoutBase() : Offset(0), Class(0) {} + +LayoutBase::LayoutBase(const LayoutBase& other) : Offset(other.Offset), Class(other.Class) {} + +LayoutBase::~LayoutBase() {} + ClassLayout::ClassLayout() : ABI(CppAbi::Itanium), HasOwnVFPtr(false), VBPtrOffset(0), Alignment(0), Size(0), DataSize(0) {} @@ -211,6 +216,8 @@ DEF_VECTOR(ClassLayout, VFTableInfo, VFTables) DEF_VECTOR(ClassLayout, LayoutField, Fields) +DEF_VECTOR(ClassLayout, LayoutBase, Bases) + Declaration::Declaration(DeclarationKind kind) : Kind(kind) , Access(AccessSpecifier::Public) diff --git a/src/CppParser/AST.h b/src/CppParser/AST.h index 08163788..a270286f 100644 --- a/src/CppParser/AST.h +++ b/src/CppParser/AST.h @@ -315,21 +315,30 @@ struct CS_API VFTableInfo VTableLayout Layout; }; -class DeclarationContext; - class CS_API LayoutField { public: LayoutField(); LayoutField(const LayoutField& other); ~LayoutField(); - DeclarationContext* _Namespace; unsigned Offset; STRING(Name) QualifiedType QualifiedType; void* FieldPtr; }; +class Class; + +class CS_API LayoutBase +{ +public: + LayoutBase(); + LayoutBase(const LayoutBase& other); + ~LayoutBase(); + unsigned Offset; + Class* Class; +}; + struct CS_API ClassLayout { ClassLayout(); @@ -342,6 +351,7 @@ struct CS_API ClassLayout int Size; int DataSize; VECTOR(LayoutField, Fields) + VECTOR(LayoutBase, Bases) }; #pragma endregion diff --git a/src/CppParser/Bindings/CLI/AST.cpp b/src/CppParser/Bindings/CLI/AST.cpp index 6c4469b2..f9a92679 100644 --- a/src/CppParser/Bindings/CLI/AST.cpp +++ b/src/CppParser/Bindings/CLI/AST.cpp @@ -1314,12 +1314,12 @@ CppSharp::Parser::AST::LayoutField::LayoutField() NativePtr = new ::CppSharp::CppParser::AST::LayoutField(); } -CppSharp::Parser::AST::LayoutField::LayoutField(CppSharp::Parser::AST::LayoutField^ _0) +CppSharp::Parser::AST::LayoutField::LayoutField(CppSharp::Parser::AST::LayoutField^ other) { __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; + if (ReferenceEquals(other, nullptr)) + throw gcnew ::System::ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(::CppSharp::CppParser::AST::LayoutField*)other->NativePtr; NativePtr = new ::CppSharp::CppParser::AST::LayoutField(__arg0); } @@ -1347,16 +1347,6 @@ void CppSharp::Parser::AST::LayoutField::Name::set(System::String^ s) ((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->setName(__arg0); } -CppSharp::Parser::AST::DeclarationContext^ CppSharp::Parser::AST::LayoutField::_Namespace::get() -{ - return (((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->_Namespace == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->_Namespace); -} - -void CppSharp::Parser::AST::LayoutField::_Namespace::set(CppSharp::Parser::AST::DeclarationContext^ value) -{ - ((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->_Namespace = (::CppSharp::CppParser::AST::DeclarationContext*)value->NativePtr; -} - unsigned int CppSharp::Parser::AST::LayoutField::Offset::get() { return ((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->Offset; @@ -1387,6 +1377,67 @@ void CppSharp::Parser::AST::LayoutField::FieldPtr::set(::System::IntPtr value) ((::CppSharp::CppParser::AST::LayoutField*)NativePtr)->FieldPtr = (void*)value; } +CppSharp::Parser::AST::LayoutBase::LayoutBase(::CppSharp::CppParser::AST::LayoutBase* native) + : __ownsNativeInstance(false) +{ + NativePtr = native; +} + +CppSharp::Parser::AST::LayoutBase^ CppSharp::Parser::AST::LayoutBase::__CreateInstance(::System::IntPtr native) +{ + return gcnew ::CppSharp::Parser::AST::LayoutBase((::CppSharp::CppParser::AST::LayoutBase*) native.ToPointer()); +} + +CppSharp::Parser::AST::LayoutBase::~LayoutBase() +{ + delete NativePtr; +} + +CppSharp::Parser::AST::LayoutBase::LayoutBase() +{ + __ownsNativeInstance = true; + NativePtr = new ::CppSharp::CppParser::AST::LayoutBase(); +} + +CppSharp::Parser::AST::LayoutBase::LayoutBase(CppSharp::Parser::AST::LayoutBase^ other) +{ + __ownsNativeInstance = true; + if (ReferenceEquals(other, nullptr)) + throw gcnew ::System::ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(::CppSharp::CppParser::AST::LayoutBase*)other->NativePtr; + NativePtr = new ::CppSharp::CppParser::AST::LayoutBase(__arg0); +} + +System::IntPtr CppSharp::Parser::AST::LayoutBase::__Instance::get() +{ + return System::IntPtr(NativePtr); +} + +void CppSharp::Parser::AST::LayoutBase::__Instance::set(System::IntPtr object) +{ + NativePtr = (::CppSharp::CppParser::AST::LayoutBase*)object.ToPointer(); +} + +unsigned int CppSharp::Parser::AST::LayoutBase::Offset::get() +{ + return ((::CppSharp::CppParser::AST::LayoutBase*)NativePtr)->Offset; +} + +void CppSharp::Parser::AST::LayoutBase::Offset::set(unsigned int value) +{ + ((::CppSharp::CppParser::AST::LayoutBase*)NativePtr)->Offset = value; +} + +CppSharp::Parser::AST::Class^ CppSharp::Parser::AST::LayoutBase::Class::get() +{ + return (((::CppSharp::CppParser::AST::LayoutBase*)NativePtr)->Class == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*)((::CppSharp::CppParser::AST::LayoutBase*)NativePtr)->Class); +} + +void CppSharp::Parser::AST::LayoutBase::Class::set(CppSharp::Parser::AST::Class^ value) +{ + ((::CppSharp::CppParser::AST::LayoutBase*)NativePtr)->Class = (::CppSharp::CppParser::AST::Class*)value->NativePtr; +} + CppSharp::Parser::AST::ClassLayout::ClassLayout(::CppSharp::CppParser::AST::ClassLayout* native) : __ownsNativeInstance(false) { @@ -1449,6 +1500,26 @@ void CppSharp::Parser::AST::ClassLayout::clearFields() ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->clearFields(); } +CppSharp::Parser::AST::LayoutBase^ CppSharp::Parser::AST::ClassLayout::getBases(unsigned int i) +{ + auto __ret = ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->getBases(i); + auto ____ret = new ::CppSharp::CppParser::AST::LayoutBase(__ret); + return (____ret == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::LayoutBase((::CppSharp::CppParser::AST::LayoutBase*)____ret); +} + +void CppSharp::Parser::AST::ClassLayout::addBases(CppSharp::Parser::AST::LayoutBase^ s) +{ + if (ReferenceEquals(s, nullptr)) + throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(::CppSharp::CppParser::AST::LayoutBase*)s->NativePtr; + ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->addBases(__arg0); +} + +void CppSharp::Parser::AST::ClassLayout::clearBases() +{ + ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->clearBases(); +} + CppSharp::Parser::AST::ClassLayout::ClassLayout(CppSharp::Parser::AST::ClassLayout^ _0) { __ownsNativeInstance = true; @@ -1480,6 +1551,12 @@ unsigned int CppSharp::Parser::AST::ClassLayout::FieldsCount::get() return __ret; } +unsigned int CppSharp::Parser::AST::ClassLayout::BasesCount::get() +{ + auto __ret = ((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->getBasesCount(); + return __ret; +} + CppSharp::Parser::AST::CppAbi CppSharp::Parser::AST::ClassLayout::ABI::get() { return (CppSharp::Parser::AST::CppAbi)((::CppSharp::CppParser::AST::ClassLayout*)NativePtr)->ABI; diff --git a/src/CppParser/Bindings/CLI/AST.h b/src/CppParser/Bindings/CLI/AST.h index d541eb0c..a9eba5cf 100644 --- a/src/CppParser/Bindings/CLI/AST.h +++ b/src/CppParser/Bindings/CLI/AST.h @@ -61,6 +61,7 @@ namespace CppSharp ref class InjectedClassNameType; ref class InlineCommandComment; ref class InlineContentComment; + ref class LayoutBase; ref class LayoutField; ref class MacroDefinition; ref class MacroExpansion; @@ -1042,7 +1043,7 @@ namespace CppSharp static LayoutField^ __CreateInstance(::System::IntPtr native); LayoutField(); - LayoutField(CppSharp::Parser::AST::LayoutField^ _0); + LayoutField(CppSharp::Parser::AST::LayoutField^ other); ~LayoutField(); @@ -1052,12 +1053,6 @@ namespace CppSharp void set(System::String^); } - property CppSharp::Parser::AST::DeclarationContext^ _Namespace - { - CppSharp::Parser::AST::DeclarationContext^ get(); - void set(CppSharp::Parser::AST::DeclarationContext^); - } - property unsigned int Offset { unsigned int get(); @@ -1080,6 +1075,41 @@ namespace CppSharp bool __ownsNativeInstance; }; + public ref class LayoutBase : ICppInstance + { + public: + + property ::CppSharp::CppParser::AST::LayoutBase* NativePtr; + property System::IntPtr __Instance + { + virtual System::IntPtr get(); + virtual void set(System::IntPtr instance); + } + + LayoutBase(::CppSharp::CppParser::AST::LayoutBase* native); + static LayoutBase^ __CreateInstance(::System::IntPtr native); + LayoutBase(); + + LayoutBase(CppSharp::Parser::AST::LayoutBase^ other); + + ~LayoutBase(); + + property unsigned int Offset + { + unsigned int get(); + void set(unsigned int); + } + + property CppSharp::Parser::AST::Class^ Class + { + CppSharp::Parser::AST::Class^ get(); + void set(CppSharp::Parser::AST::Class^); + } + + protected: + bool __ownsNativeInstance; + }; + public ref class ClassLayout : ICppInstance { public: @@ -1109,6 +1139,11 @@ namespace CppSharp unsigned int get(); } + property unsigned int BasesCount + { + unsigned int get(); + } + property CppSharp::Parser::AST::CppAbi ABI { CppSharp::Parser::AST::CppAbi get(); @@ -1163,6 +1198,12 @@ namespace CppSharp void clearFields(); + CppSharp::Parser::AST::LayoutBase^ getBases(unsigned int i); + + void addBases(CppSharp::Parser::AST::LayoutBase^ s); + + void clearBases(); + protected: bool __ownsNativeInstance; }; diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs index 6ff8a292..988ff940 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs @@ -2987,19 +2987,16 @@ namespace CppSharp public unsafe partial class LayoutField : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 32)] + [StructLayout(LayoutKind.Explicit, Size = 28)] public partial struct Internal { [FieldOffset(0)] - public global::System.IntPtr _Namespace; - - [FieldOffset(4)] public uint Offset; - [FieldOffset(20)] + [FieldOffset(16)] public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; - [FieldOffset(28)] + [FieldOffset(24)] public global::System.IntPtr FieldPtr; [SuppressUnmanagedCodeSecurity] @@ -3010,7 +3007,7 @@ namespace CppSharp [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); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -3048,7 +3045,7 @@ namespace CppSharp private static void* __CopyValue(LayoutField.Internal native) { - var ret = Marshal.AllocHGlobal(32); + var ret = Marshal.AllocHGlobal(28); CppSharp.Parser.AST.LayoutField.Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3069,20 +3066,20 @@ namespace CppSharp public LayoutField() { - __Instance = Marshal.AllocHGlobal(32); + __Instance = Marshal.AllocHGlobal(28); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); } - public LayoutField(CppSharp.Parser.AST.LayoutField _0) + public LayoutField(CppSharp.Parser.AST.LayoutField other) { - __Instance = Marshal.AllocHGlobal(32); + __Instance = Marshal.AllocHGlobal(28); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } @@ -3116,67 +3113,180 @@ namespace CppSharp } } - public CppSharp.Parser.AST.DeclarationContext _Namespace + public uint Offset { get { - CppSharp.Parser.AST.DeclarationContext __result0; - if (((Internal*) __Instance)->_Namespace == IntPtr.Zero) __result0 = null; - else if (CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->_Namespace)) - __result0 = (CppSharp.Parser.AST.DeclarationContext) CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap[((Internal*) __Instance)->_Namespace]; - else __result0 = CppSharp.Parser.AST.DeclarationContext.__CreateInstance(((Internal*) __Instance)->_Namespace); - return __result0; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->_Namespace = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + ((Internal*) __Instance)->Offset = value; } } - public uint Offset + public CppSharp.Parser.AST.QualifiedType QualifiedType { get { - return ((Internal*) __Instance)->Offset; + return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); } set { - ((Internal*) __Instance)->Offset = value; + ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); } } - public CppSharp.Parser.AST.QualifiedType QualifiedType + public global::System.IntPtr FieldPtr { get { - return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); + return ((Internal*) __Instance)->FieldPtr; } set { - ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; } } + } - public global::System.IntPtr FieldPtr + public unsafe partial class LayoutBase : IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 8)] + public partial struct Internal + { + [FieldOffset(0)] + public uint Offset; + + [FieldOffset(4)] + public global::System.IntPtr Class; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseD2Ev")] + 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 NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary(); + protected void*[] __OriginalVTables; + + protected bool __ownsNativeInstance; + + public static LayoutBase __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new LayoutBase(native.ToPointer(), skipVTables); + } + + public static LayoutBase __CreateInstance(LayoutBase.Internal native, bool skipVTables = false) + { + return new LayoutBase(native, skipVTables); + } + + private static void* __CopyValue(LayoutBase.Internal native) + { + var ret = Marshal.AllocHGlobal(8); + CppSharp.Parser.AST.LayoutBase.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private LayoutBase(LayoutBase.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected LayoutBase(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public LayoutBase() + { + __Instance = Marshal.AllocHGlobal(8); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public LayoutBase(CppSharp.Parser.AST.LayoutBase other) + { + __Instance = Marshal.AllocHGlobal(8); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + CppSharp.Parser.AST.LayoutBase __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public uint Offset { get { - return ((Internal*) __Instance)->FieldPtr; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; + ((Internal*) __Instance)->Offset = value; + } + } + + public CppSharp.Parser.AST.Class Class + { + get + { + CppSharp.Parser.AST.Class __result0; + if (((Internal*) __Instance)->Class == IntPtr.Zero) __result0 = null; + else if (CppSharp.Parser.AST.Class.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Class)) + __result0 = (CppSharp.Parser.AST.Class) CppSharp.Parser.AST.Class.NativeToManagedMap[((Internal*) __Instance)->Class]; + else __result0 = CppSharp.Parser.AST.Class.__CreateInstance(((Internal*) __Instance)->Class); + return __result0; + } + + set + { + ((Internal*) __Instance)->Class = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; } } } public unsafe partial class ClassLayout : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 60)] + [StructLayout(LayoutKind.Explicit, Size = 72)] public partial struct Internal { [FieldOffset(0)] @@ -3245,6 +3355,21 @@ namespace CppSharp EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")] internal static extern void clearFields_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8getBasesEj")] + internal static extern void getBases_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8addBasesERNS1_10LayoutBaseE")] + internal static extern void addBases_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout10clearBasesEv")] + internal static extern void clearBases_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] @@ -3254,6 +3379,11 @@ namespace CppSharp [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")] internal static extern uint getFieldsCount_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13getBasesCountEv")] + internal static extern uint getBasesCount_0(global::System.IntPtr instance); } public global::System.IntPtr __Instance { get; protected set; } @@ -3276,7 +3406,7 @@ namespace CppSharp private static void* __CopyValue(ClassLayout.Internal native) { - var ret = Marshal.AllocHGlobal(60); + var ret = Marshal.AllocHGlobal(72); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3297,7 +3427,7 @@ namespace CppSharp public ClassLayout() { - __Instance = Marshal.AllocHGlobal(60); + __Instance = Marshal.AllocHGlobal(72); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); @@ -3305,7 +3435,7 @@ namespace CppSharp public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) { - __Instance = Marshal.AllocHGlobal(60); + __Instance = Marshal.AllocHGlobal(72); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; if (ReferenceEquals(_0, null)) @@ -3368,6 +3498,26 @@ namespace CppSharp Internal.clearFields_0((__Instance + __PointerAdjustment)); } + public CppSharp.Parser.AST.LayoutBase getBases(uint i) + { + var __ret = new CppSharp.Parser.AST.LayoutBase.Internal(); + Internal.getBases_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return CppSharp.Parser.AST.LayoutBase.__CreateInstance(__ret); + } + + public void addBases(CppSharp.Parser.AST.LayoutBase 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.addBases_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearBases() + { + Internal.clearBases_0((__Instance + __PointerAdjustment)); + } + public uint VFTablesCount { get @@ -3386,6 +3536,15 @@ namespace CppSharp } } + public uint BasesCount + { + get + { + var __ret = Internal.getBasesCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + public CppSharp.Parser.AST.CppAbi ABI { get diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs index cfdf45da..9cb1d92a 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs @@ -2987,19 +2987,16 @@ namespace CppSharp public unsafe partial class LayoutField : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 44)] + [StructLayout(LayoutKind.Explicit, Size = 40)] public partial struct Internal { [FieldOffset(0)] - public global::System.IntPtr _Namespace; - - [FieldOffset(4)] public uint Offset; - [FieldOffset(32)] + [FieldOffset(28)] public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; - [FieldOffset(40)] + [FieldOffset(36)] public global::System.IntPtr FieldPtr; [SuppressUnmanagedCodeSecurity] @@ -3010,7 +3007,7 @@ namespace CppSharp [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); + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr other); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, @@ -3048,7 +3045,7 @@ namespace CppSharp private static void* __CopyValue(LayoutField.Internal native) { - var ret = Marshal.AllocHGlobal(44); + var ret = Marshal.AllocHGlobal(40); CppSharp.Parser.AST.LayoutField.Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3069,20 +3066,20 @@ namespace CppSharp public LayoutField() { - __Instance = Marshal.AllocHGlobal(44); + __Instance = Marshal.AllocHGlobal(40); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); } - public LayoutField(CppSharp.Parser.AST.LayoutField _0) + public LayoutField(CppSharp.Parser.AST.LayoutField other) { - __Instance = Marshal.AllocHGlobal(44); + __Instance = Marshal.AllocHGlobal(40); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } @@ -3116,67 +3113,180 @@ namespace CppSharp } } - public CppSharp.Parser.AST.DeclarationContext _Namespace + public uint Offset { get { - CppSharp.Parser.AST.DeclarationContext __result0; - if (((Internal*) __Instance)->_Namespace == IntPtr.Zero) __result0 = null; - else if (CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->_Namespace)) - __result0 = (CppSharp.Parser.AST.DeclarationContext) CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap[((Internal*) __Instance)->_Namespace]; - else __result0 = CppSharp.Parser.AST.DeclarationContext.__CreateInstance(((Internal*) __Instance)->_Namespace); - return __result0; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->_Namespace = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + ((Internal*) __Instance)->Offset = value; } } - public uint Offset + public CppSharp.Parser.AST.QualifiedType QualifiedType { get { - return ((Internal*) __Instance)->Offset; + return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); } set { - ((Internal*) __Instance)->Offset = value; + ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); } } - public CppSharp.Parser.AST.QualifiedType QualifiedType + public global::System.IntPtr FieldPtr { get { - return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); + return ((Internal*) __Instance)->FieldPtr; } set { - ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; } } + } - public global::System.IntPtr FieldPtr + public unsafe partial class LayoutBase : IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 8)] + public partial struct Internal + { + [FieldOffset(0)] + public uint Offset; + + [FieldOffset(4)] + public global::System.IntPtr Class; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??0LayoutBase@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="??0LayoutBase@AST@CppParser@CppSharp@@QAE@ABV0123@@Z")] + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr other); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??1LayoutBase@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 NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary(); + protected void*[] __OriginalVTables; + + protected bool __ownsNativeInstance; + + public static LayoutBase __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new LayoutBase(native.ToPointer(), skipVTables); + } + + public static LayoutBase __CreateInstance(LayoutBase.Internal native, bool skipVTables = false) + { + return new LayoutBase(native, skipVTables); + } + + private static void* __CopyValue(LayoutBase.Internal native) + { + var ret = Marshal.AllocHGlobal(8); + CppSharp.Parser.AST.LayoutBase.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private LayoutBase(LayoutBase.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected LayoutBase(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public LayoutBase() + { + __Instance = Marshal.AllocHGlobal(8); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public LayoutBase(CppSharp.Parser.AST.LayoutBase other) + { + __Instance = Marshal.AllocHGlobal(8); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + CppSharp.Parser.AST.LayoutBase __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment), 0); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public uint Offset { get { - return ((Internal*) __Instance)->FieldPtr; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; + ((Internal*) __Instance)->Offset = value; + } + } + + public CppSharp.Parser.AST.Class Class + { + get + { + CppSharp.Parser.AST.Class __result0; + if (((Internal*) __Instance)->Class == IntPtr.Zero) __result0 = null; + else if (CppSharp.Parser.AST.Class.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Class)) + __result0 = (CppSharp.Parser.AST.Class) CppSharp.Parser.AST.Class.NativeToManagedMap[((Internal*) __Instance)->Class]; + else __result0 = CppSharp.Parser.AST.Class.__CreateInstance(((Internal*) __Instance)->Class); + return __result0; + } + + set + { + ((Internal*) __Instance)->Class = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; } } } public unsafe partial class ClassLayout : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 60)] + [StructLayout(LayoutKind.Explicit, Size = 72)] public partial struct Internal { [FieldOffset(0)] @@ -3245,6 +3355,21 @@ namespace CppSharp EntryPoint="?clearFields@ClassLayout@AST@CppParser@CppSharp@@QAEXXZ")] internal static extern void clearFields_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?getBases@ClassLayout@AST@CppParser@CppSharp@@QAE?AVLayoutBase@234@I@Z")] + internal static extern void getBases_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?addBases@ClassLayout@AST@CppParser@CppSharp@@QAEXAAVLayoutBase@234@@Z")] + internal static extern void addBases_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?clearBases@ClassLayout@AST@CppParser@CppSharp@@QAEXXZ")] + internal static extern void clearBases_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QAEIXZ")] @@ -3254,6 +3379,11 @@ namespace CppSharp [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); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?getBasesCount@ClassLayout@AST@CppParser@CppSharp@@QAEIXZ")] + internal static extern uint getBasesCount_0(global::System.IntPtr instance); } public global::System.IntPtr __Instance { get; protected set; } @@ -3276,7 +3406,7 @@ namespace CppSharp private static void* __CopyValue(ClassLayout.Internal native) { - var ret = Marshal.AllocHGlobal(60); + var ret = Marshal.AllocHGlobal(72); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3297,7 +3427,7 @@ namespace CppSharp public ClassLayout() { - __Instance = Marshal.AllocHGlobal(60); + __Instance = Marshal.AllocHGlobal(72); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); @@ -3305,7 +3435,7 @@ namespace CppSharp public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) { - __Instance = Marshal.AllocHGlobal(60); + __Instance = Marshal.AllocHGlobal(72); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; if (ReferenceEquals(_0, null)) @@ -3368,6 +3498,26 @@ namespace CppSharp Internal.clearFields_0((__Instance + __PointerAdjustment)); } + public CppSharp.Parser.AST.LayoutBase getBases(uint i) + { + var __ret = new CppSharp.Parser.AST.LayoutBase.Internal(); + Internal.getBases_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i); + return CppSharp.Parser.AST.LayoutBase.__CreateInstance(__ret); + } + + public void addBases(CppSharp.Parser.AST.LayoutBase 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.addBases_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearBases() + { + Internal.clearBases_0((__Instance + __PointerAdjustment)); + } + public uint VFTablesCount { get @@ -3386,6 +3536,15 @@ namespace CppSharp } } + public uint BasesCount + { + get + { + var __ret = Internal.getBasesCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + public CppSharp.Parser.AST.CppAbi ABI { get diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs index fa10e3a0..01dd0133 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs @@ -2986,19 +2986,16 @@ namespace CppSharp public unsafe partial class LayoutField : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 64)] + [StructLayout(LayoutKind.Explicit, Size = 56)] public partial struct Internal { [FieldOffset(0)] - public global::System.IntPtr _Namespace; - - [FieldOffset(8)] public uint Offset; - [FieldOffset(40)] + [FieldOffset(32)] public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; - [FieldOffset(56)] + [FieldOffset(48)] public global::System.IntPtr FieldPtr; [SuppressUnmanagedCodeSecurity] @@ -3009,7 +3006,7 @@ namespace CppSharp [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); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -3047,7 +3044,7 @@ namespace CppSharp private static void* __CopyValue(LayoutField.Internal native) { - var ret = Marshal.AllocHGlobal(64); + var ret = Marshal.AllocHGlobal(56); CppSharp.Parser.AST.LayoutField.Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3068,20 +3065,20 @@ namespace CppSharp public LayoutField() { - __Instance = Marshal.AllocHGlobal(64); + __Instance = Marshal.AllocHGlobal(56); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); } - public LayoutField(CppSharp.Parser.AST.LayoutField _0) + public LayoutField(CppSharp.Parser.AST.LayoutField other) { - __Instance = Marshal.AllocHGlobal(64); + __Instance = Marshal.AllocHGlobal(56); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } @@ -3115,67 +3112,180 @@ namespace CppSharp } } - public CppSharp.Parser.AST.DeclarationContext _Namespace + public uint Offset { get { - CppSharp.Parser.AST.DeclarationContext __result0; - if (((Internal*) __Instance)->_Namespace == IntPtr.Zero) __result0 = null; - else if (CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->_Namespace)) - __result0 = (CppSharp.Parser.AST.DeclarationContext) CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap[((Internal*) __Instance)->_Namespace]; - else __result0 = CppSharp.Parser.AST.DeclarationContext.__CreateInstance(((Internal*) __Instance)->_Namespace); - return __result0; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->_Namespace = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + ((Internal*) __Instance)->Offset = value; } } - public uint Offset + public CppSharp.Parser.AST.QualifiedType QualifiedType { get { - return ((Internal*) __Instance)->Offset; + return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); } set { - ((Internal*) __Instance)->Offset = value; + ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); } } - public CppSharp.Parser.AST.QualifiedType QualifiedType + public global::System.IntPtr FieldPtr { get { - return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); + return ((Internal*) __Instance)->FieldPtr; } set { - ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; } } + } - public global::System.IntPtr FieldPtr + public unsafe partial class LayoutBase : IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 16)] + public partial struct Internal + { + [FieldOffset(0)] + public uint Offset; + + [FieldOffset(8)] + public global::System.IntPtr Class; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseD2Ev")] + 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 NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary(); + protected void*[] __OriginalVTables; + + protected bool __ownsNativeInstance; + + public static LayoutBase __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new LayoutBase(native.ToPointer(), skipVTables); + } + + public static LayoutBase __CreateInstance(LayoutBase.Internal native, bool skipVTables = false) + { + return new LayoutBase(native, skipVTables); + } + + private static void* __CopyValue(LayoutBase.Internal native) + { + var ret = Marshal.AllocHGlobal(16); + CppSharp.Parser.AST.LayoutBase.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private LayoutBase(LayoutBase.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected LayoutBase(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public LayoutBase() + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public LayoutBase(CppSharp.Parser.AST.LayoutBase other) + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + CppSharp.Parser.AST.LayoutBase __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public uint Offset { get { - return ((Internal*) __Instance)->FieldPtr; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; + ((Internal*) __Instance)->Offset = value; + } + } + + public CppSharp.Parser.AST.Class Class + { + get + { + CppSharp.Parser.AST.Class __result0; + if (((Internal*) __Instance)->Class == IntPtr.Zero) __result0 = null; + else if (CppSharp.Parser.AST.Class.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Class)) + __result0 = (CppSharp.Parser.AST.Class) CppSharp.Parser.AST.Class.NativeToManagedMap[((Internal*) __Instance)->Class]; + else __result0 = CppSharp.Parser.AST.Class.__CreateInstance(((Internal*) __Instance)->Class); + return __result0; + } + + set + { + ((Internal*) __Instance)->Class = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; } } } public unsafe partial class ClassLayout : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 112)] + [StructLayout(LayoutKind.Explicit, Size = 136)] public partial struct Internal { [FieldOffset(0)] @@ -3244,6 +3354,21 @@ namespace CppSharp EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")] internal static extern void clearFields_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8getBasesEj")] + internal static extern void getBases_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8addBasesERNS1_10LayoutBaseE")] + internal static extern void addBases_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout10clearBasesEv")] + internal static extern void clearBases_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] @@ -3253,6 +3378,11 @@ namespace CppSharp [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")] internal static extern uint getFieldsCount_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13getBasesCountEv")] + internal static extern uint getBasesCount_0(global::System.IntPtr instance); } public global::System.IntPtr __Instance { get; protected set; } @@ -3275,7 +3405,7 @@ namespace CppSharp private static void* __CopyValue(ClassLayout.Internal native) { - var ret = Marshal.AllocHGlobal(112); + var ret = Marshal.AllocHGlobal(136); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3296,7 +3426,7 @@ namespace CppSharp public ClassLayout() { - __Instance = Marshal.AllocHGlobal(112); + __Instance = Marshal.AllocHGlobal(136); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); @@ -3304,7 +3434,7 @@ namespace CppSharp public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) { - __Instance = Marshal.AllocHGlobal(112); + __Instance = Marshal.AllocHGlobal(136); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; if (ReferenceEquals(_0, null)) @@ -3367,6 +3497,26 @@ namespace CppSharp Internal.clearFields_0((__Instance + __PointerAdjustment)); } + public CppSharp.Parser.AST.LayoutBase getBases(uint i) + { + var __ret = new CppSharp.Parser.AST.LayoutBase.Internal(); + Internal.getBases_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return CppSharp.Parser.AST.LayoutBase.__CreateInstance(__ret); + } + + public void addBases(CppSharp.Parser.AST.LayoutBase 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.addBases_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearBases() + { + Internal.clearBases_0((__Instance + __PointerAdjustment)); + } + public uint VFTablesCount { get @@ -3385,6 +3535,15 @@ namespace CppSharp } } + public uint BasesCount + { + get + { + var __ret = Internal.getBasesCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + public CppSharp.Parser.AST.CppAbi ABI { get diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs index c612ec5d..a4ec6cdf 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs @@ -2986,19 +2986,16 @@ namespace CppSharp public unsafe partial class LayoutField : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 48)] + [StructLayout(LayoutKind.Explicit, Size = 40)] public partial struct Internal { [FieldOffset(0)] - public global::System.IntPtr _Namespace; - - [FieldOffset(8)] public uint Offset; - [FieldOffset(24)] + [FieldOffset(16)] public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; - [FieldOffset(40)] + [FieldOffset(32)] public global::System.IntPtr FieldPtr; [SuppressUnmanagedCodeSecurity] @@ -3009,7 +3006,7 @@ namespace CppSharp [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); + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -3047,7 +3044,7 @@ namespace CppSharp private static void* __CopyValue(LayoutField.Internal native) { - var ret = Marshal.AllocHGlobal(48); + var ret = Marshal.AllocHGlobal(40); CppSharp.Parser.AST.LayoutField.Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3068,20 +3065,20 @@ namespace CppSharp public LayoutField() { - __Instance = Marshal.AllocHGlobal(48); + __Instance = Marshal.AllocHGlobal(40); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); } - public LayoutField(CppSharp.Parser.AST.LayoutField _0) + public LayoutField(CppSharp.Parser.AST.LayoutField other) { - __Instance = Marshal.AllocHGlobal(48); + __Instance = Marshal.AllocHGlobal(40); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } @@ -3115,67 +3112,180 @@ namespace CppSharp } } - public CppSharp.Parser.AST.DeclarationContext _Namespace + public uint Offset { get { - CppSharp.Parser.AST.DeclarationContext __result0; - if (((Internal*) __Instance)->_Namespace == IntPtr.Zero) __result0 = null; - else if (CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->_Namespace)) - __result0 = (CppSharp.Parser.AST.DeclarationContext) CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap[((Internal*) __Instance)->_Namespace]; - else __result0 = CppSharp.Parser.AST.DeclarationContext.__CreateInstance(((Internal*) __Instance)->_Namespace); - return __result0; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->_Namespace = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + ((Internal*) __Instance)->Offset = value; } } - public uint Offset + public CppSharp.Parser.AST.QualifiedType QualifiedType { get { - return ((Internal*) __Instance)->Offset; + return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); } set { - ((Internal*) __Instance)->Offset = value; + ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); } } - public CppSharp.Parser.AST.QualifiedType QualifiedType + public global::System.IntPtr FieldPtr { get { - return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); + return ((Internal*) __Instance)->FieldPtr; } set { - ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; } } + } - public global::System.IntPtr FieldPtr + public unsafe partial class LayoutBase : IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 16)] + public partial struct Internal + { + [FieldOffset(0)] + public uint Offset; + + [FieldOffset(8)] + public global::System.IntPtr Class; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr other); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10LayoutBaseD2Ev")] + 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 NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary(); + protected void*[] __OriginalVTables; + + protected bool __ownsNativeInstance; + + public static LayoutBase __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new LayoutBase(native.ToPointer(), skipVTables); + } + + public static LayoutBase __CreateInstance(LayoutBase.Internal native, bool skipVTables = false) + { + return new LayoutBase(native, skipVTables); + } + + private static void* __CopyValue(LayoutBase.Internal native) + { + var ret = Marshal.AllocHGlobal(16); + CppSharp.Parser.AST.LayoutBase.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private LayoutBase(LayoutBase.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected LayoutBase(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public LayoutBase() + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public LayoutBase(CppSharp.Parser.AST.LayoutBase other) + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + CppSharp.Parser.AST.LayoutBase __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public uint Offset { get { - return ((Internal*) __Instance)->FieldPtr; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; + ((Internal*) __Instance)->Offset = value; + } + } + + public CppSharp.Parser.AST.Class Class + { + get + { + CppSharp.Parser.AST.Class __result0; + if (((Internal*) __Instance)->Class == IntPtr.Zero) __result0 = null; + else if (CppSharp.Parser.AST.Class.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Class)) + __result0 = (CppSharp.Parser.AST.Class) CppSharp.Parser.AST.Class.NativeToManagedMap[((Internal*) __Instance)->Class]; + else __result0 = CppSharp.Parser.AST.Class.__CreateInstance(((Internal*) __Instance)->Class); + return __result0; + } + + set + { + ((Internal*) __Instance)->Class = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; } } } public unsafe partial class ClassLayout : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 112)] + [StructLayout(LayoutKind.Explicit, Size = 136)] public partial struct Internal { [FieldOffset(0)] @@ -3244,6 +3354,21 @@ namespace CppSharp EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout11clearFieldsEv")] internal static extern void clearFields_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8getBasesEj")] + internal static extern void getBases_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout8addBasesERNS1_10LayoutBaseE")] + internal static extern void addBases_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout10clearBasesEv")] + internal static extern void clearBases_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout16getVFTablesCountEv")] @@ -3253,6 +3378,11 @@ namespace CppSharp [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout14getFieldsCountEv")] internal static extern uint getFieldsCount_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST11ClassLayout13getBasesCountEv")] + internal static extern uint getBasesCount_0(global::System.IntPtr instance); } public global::System.IntPtr __Instance { get; protected set; } @@ -3275,7 +3405,7 @@ namespace CppSharp private static void* __CopyValue(ClassLayout.Internal native) { - var ret = Marshal.AllocHGlobal(112); + var ret = Marshal.AllocHGlobal(136); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3296,7 +3426,7 @@ namespace CppSharp public ClassLayout() { - __Instance = Marshal.AllocHGlobal(112); + __Instance = Marshal.AllocHGlobal(136); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); @@ -3304,7 +3434,7 @@ namespace CppSharp public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) { - __Instance = Marshal.AllocHGlobal(112); + __Instance = Marshal.AllocHGlobal(136); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; if (ReferenceEquals(_0, null)) @@ -3367,6 +3497,26 @@ namespace CppSharp Internal.clearFields_0((__Instance + __PointerAdjustment)); } + public CppSharp.Parser.AST.LayoutBase getBases(uint i) + { + var __ret = new CppSharp.Parser.AST.LayoutBase.Internal(); + Internal.getBases_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return CppSharp.Parser.AST.LayoutBase.__CreateInstance(__ret); + } + + public void addBases(CppSharp.Parser.AST.LayoutBase 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.addBases_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearBases() + { + Internal.clearBases_0((__Instance + __PointerAdjustment)); + } + public uint VFTablesCount { get @@ -3385,6 +3535,15 @@ namespace CppSharp } } + public uint BasesCount + { + get + { + var __ret = Internal.getBasesCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + public CppSharp.Parser.AST.CppAbi ABI { get diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs index 8e29fdd9..7b96b883 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/AST.cs @@ -2987,19 +2987,16 @@ namespace CppSharp public unsafe partial class LayoutField : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 72)] + [StructLayout(LayoutKind.Explicit, Size = 64)] public partial struct Internal { [FieldOffset(0)] - public global::System.IntPtr _Namespace; - - [FieldOffset(8)] public uint Offset; - [FieldOffset(48)] + [FieldOffset(40)] public CppSharp.Parser.AST.QualifiedType.Internal QualifiedType; - [FieldOffset(64)] + [FieldOffset(56)] public global::System.IntPtr FieldPtr; [SuppressUnmanagedCodeSecurity] @@ -3010,7 +3007,7 @@ namespace CppSharp [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); + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr other); [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, @@ -3048,7 +3045,7 @@ namespace CppSharp private static void* __CopyValue(LayoutField.Internal native) { - var ret = Marshal.AllocHGlobal(72); + var ret = Marshal.AllocHGlobal(64); CppSharp.Parser.AST.LayoutField.Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3069,20 +3066,20 @@ namespace CppSharp public LayoutField() { - __Instance = Marshal.AllocHGlobal(72); + __Instance = Marshal.AllocHGlobal(64); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); } - public LayoutField(CppSharp.Parser.AST.LayoutField _0) + public LayoutField(CppSharp.Parser.AST.LayoutField other) { - __Instance = Marshal.AllocHGlobal(72); + __Instance = Marshal.AllocHGlobal(64); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; - if (ReferenceEquals(_0, null)) - throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); - var __arg0 = _0.__Instance; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); } @@ -3116,67 +3113,180 @@ namespace CppSharp } } - public CppSharp.Parser.AST.DeclarationContext _Namespace + public uint Offset { get { - CppSharp.Parser.AST.DeclarationContext __result0; - if (((Internal*) __Instance)->_Namespace == IntPtr.Zero) __result0 = null; - else if (CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->_Namespace)) - __result0 = (CppSharp.Parser.AST.DeclarationContext) CppSharp.Parser.AST.DeclarationContext.NativeToManagedMap[((Internal*) __Instance)->_Namespace]; - else __result0 = CppSharp.Parser.AST.DeclarationContext.__CreateInstance(((Internal*) __Instance)->_Namespace); - return __result0; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->_Namespace = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + ((Internal*) __Instance)->Offset = value; } } - public uint Offset + public CppSharp.Parser.AST.QualifiedType QualifiedType { get { - return ((Internal*) __Instance)->Offset; + return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); } set { - ((Internal*) __Instance)->Offset = value; + ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); } } - public CppSharp.Parser.AST.QualifiedType QualifiedType + public global::System.IntPtr FieldPtr { get { - return CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->QualifiedType); + return ((Internal*) __Instance)->FieldPtr; } set { - ((Internal*) __Instance)->QualifiedType = ReferenceEquals(value, null) ? new CppSharp.Parser.AST.QualifiedType.Internal() : *(CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; } } + } - public global::System.IntPtr FieldPtr + public unsafe partial class LayoutBase : IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 16)] + public partial struct Internal + { + [FieldOffset(0)] + public uint Offset; + + [FieldOffset(8)] + public global::System.IntPtr Class; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??0LayoutBase@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="??0LayoutBase@AST@CppParser@CppSharp@@QEAA@AEBV0123@@Z")] + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr other); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??1LayoutBase@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 NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary(); + protected void*[] __OriginalVTables; + + protected bool __ownsNativeInstance; + + public static LayoutBase __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new LayoutBase(native.ToPointer(), skipVTables); + } + + public static LayoutBase __CreateInstance(LayoutBase.Internal native, bool skipVTables = false) + { + return new LayoutBase(native, skipVTables); + } + + private static void* __CopyValue(LayoutBase.Internal native) + { + var ret = Marshal.AllocHGlobal(16); + CppSharp.Parser.AST.LayoutBase.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private LayoutBase(LayoutBase.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected LayoutBase(void* native, bool skipVTables = false) + { + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public LayoutBase() + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public LayoutBase(CppSharp.Parser.AST.LayoutBase other) + { + __Instance = Marshal.AllocHGlobal(16); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(other, null)) + throw new global::System.ArgumentNullException("other", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = other.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + public void Dispose() + { + Dispose(disposing: true); + } + + protected virtual void Dispose(bool disposing) + { + CppSharp.Parser.AST.LayoutBase __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment), 0); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public uint Offset { get { - return ((Internal*) __Instance)->FieldPtr; + return ((Internal*) __Instance)->Offset; } set { - ((Internal*) __Instance)->FieldPtr = (global::System.IntPtr) value; + ((Internal*) __Instance)->Offset = value; + } + } + + public CppSharp.Parser.AST.Class Class + { + get + { + CppSharp.Parser.AST.Class __result0; + if (((Internal*) __Instance)->Class == IntPtr.Zero) __result0 = null; + else if (CppSharp.Parser.AST.Class.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Class)) + __result0 = (CppSharp.Parser.AST.Class) CppSharp.Parser.AST.Class.NativeToManagedMap[((Internal*) __Instance)->Class]; + else __result0 = CppSharp.Parser.AST.Class.__CreateInstance(((Internal*) __Instance)->Class); + return __result0; + } + + set + { + ((Internal*) __Instance)->Class = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; } } } public unsafe partial class ClassLayout : IDisposable { - [StructLayout(LayoutKind.Explicit, Size = 104)] + [StructLayout(LayoutKind.Explicit, Size = 128)] public partial struct Internal { [FieldOffset(0)] @@ -3245,6 +3355,21 @@ namespace CppSharp EntryPoint="?clearFields@ClassLayout@AST@CppParser@CppSharp@@QEAAXXZ")] internal static extern void clearFields_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?getBases@ClassLayout@AST@CppParser@CppSharp@@QEAA?AVLayoutBase@234@I@Z")] + internal static extern void getBases_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?addBases@ClassLayout@AST@CppParser@CppSharp@@QEAAXAEAVLayoutBase@234@@Z")] + internal static extern void addBases_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?clearBases@ClassLayout@AST@CppParser@CppSharp@@QEAAXXZ")] + internal static extern void clearBases_0(global::System.IntPtr instance); + [SuppressUnmanagedCodeSecurity] [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="?getVFTablesCount@ClassLayout@AST@CppParser@CppSharp@@QEAAIXZ")] @@ -3254,6 +3379,11 @@ namespace CppSharp [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); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?getBasesCount@ClassLayout@AST@CppParser@CppSharp@@QEAAIXZ")] + internal static extern uint getBasesCount_0(global::System.IntPtr instance); } public global::System.IntPtr __Instance { get; protected set; } @@ -3276,7 +3406,7 @@ namespace CppSharp private static void* __CopyValue(ClassLayout.Internal native) { - var ret = Marshal.AllocHGlobal(104); + var ret = Marshal.AllocHGlobal(128); CppSharp.Parser.AST.ClassLayout.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); } @@ -3297,7 +3427,7 @@ namespace CppSharp public ClassLayout() { - __Instance = Marshal.AllocHGlobal(104); + __Instance = Marshal.AllocHGlobal(128); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; Internal.ctor_0((__Instance + __PointerAdjustment)); @@ -3305,7 +3435,7 @@ namespace CppSharp public ClassLayout(CppSharp.Parser.AST.ClassLayout _0) { - __Instance = Marshal.AllocHGlobal(104); + __Instance = Marshal.AllocHGlobal(128); __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; if (ReferenceEquals(_0, null)) @@ -3368,6 +3498,26 @@ namespace CppSharp Internal.clearFields_0((__Instance + __PointerAdjustment)); } + public CppSharp.Parser.AST.LayoutBase getBases(uint i) + { + var __ret = new CppSharp.Parser.AST.LayoutBase.Internal(); + Internal.getBases_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i); + return CppSharp.Parser.AST.LayoutBase.__CreateInstance(__ret); + } + + public void addBases(CppSharp.Parser.AST.LayoutBase 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.addBases_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearBases() + { + Internal.clearBases_0((__Instance + __PointerAdjustment)); + } + public uint VFTablesCount { get @@ -3386,6 +3536,15 @@ namespace CppSharp } } + public uint BasesCount + { + get + { + var __ret = Internal.getBasesCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + public CppSharp.Parser.AST.CppAbi ABI { get diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index 58796142..4400c27a 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -87,13 +87,12 @@ LayoutField Parser::WalkVTablePointer(Class* Class, { LayoutField LayoutField; LayoutField.Offset = Offset.getQuantity(); - LayoutField._Namespace = Class; LayoutField.Name = prefix + "_" + Class->Name; LayoutField.QualifiedType = GetQualifiedType(C->getASTContext().VoidPtrTy); return LayoutField; } -void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, +void Parser::ReadClassLayout(Class* Class, const clang::RecordDecl* RD, clang::CharUnits Offset, bool IncludeVirtualBases) { using namespace clang; @@ -104,6 +103,11 @@ void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, auto Parent = static_cast( WalkDeclaration(RD, /*IgnoreSystemDecls =*/false)); + LayoutBase LayoutBase; + LayoutBase.Offset = Offset.getQuantity(); + LayoutBase.Class = Parent; + Class->Layout->Bases.push_back(LayoutBase); + // Dump bases. if (CXXRD) { const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase(); @@ -139,7 +143,7 @@ void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, // Dump (non-virtual) bases for (const CXXRecordDecl *Base : Bases) { CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(Base); - ReadLayoutFields(Class, Base, BaseOffset, + ReadClassLayout(Class, Base, BaseOffset, /*IncludeVirtualBases=*/false); } @@ -170,7 +174,6 @@ void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, auto F = WalkFieldCXX(Field, Parent); LayoutField LayoutField; - LayoutField._Namespace = F->_Namespace; LayoutField.Offset = FieldOffset.getQuantity(); LayoutField.Name = F->Name; LayoutField.QualifiedType = GetQualifiedType(Field->getType()); @@ -195,7 +198,7 @@ void Parser::ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, Class->Layout->Fields.push_back(VtorDisp); } - ReadLayoutFields(Class, VBase, VBaseOffset, + ReadClassLayout(Class, VBase, VBaseOffset, /*IncludeVirtualBases=*/false); } } @@ -848,7 +851,7 @@ void Parser::WalkRecord(const clang::RecordDecl* Record, Class* RC) RC->Layout->Alignment = (int)Layout-> getAlignment().getQuantity(); RC->Layout->Size = (int)Layout->getSize().getQuantity(); RC->Layout->DataSize = (int)Layout->getDataSize().getQuantity(); - ReadLayoutFields(RC, Record, CharUnits(), true); + ReadClassLayout(RC, Record, CharUnits(), true); } for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it) diff --git a/src/CppParser/Parser.h b/src/CppParser/Parser.h index b0c1c514..04a5d202 100644 --- a/src/CppParser/Parser.h +++ b/src/CppParser/Parser.h @@ -98,7 +98,7 @@ private: std::vector WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, const clang::ASTTemplateArgumentListInfo* TSTL); void WalkVTable(const clang::CXXRecordDecl* RD, Class* C); QualifiedType GetQualifiedType(clang::QualType qual, clang::TypeLoc* TL = 0); - void ReadLayoutFields(Class* Class, const clang::RecordDecl* RD, clang::CharUnits Offset, bool IncludeVirtualBases); + void ReadClassLayout(Class* Class, const clang::RecordDecl* RD, clang::CharUnits Offset, bool IncludeVirtualBases); LayoutField WalkVTablePointer(Class* Class, const clang::CharUnits& Offset, const std::string& prefix); VTableLayout WalkVTableLayout(const clang::VTableLayout& VTLayout); VTableComponent WalkVTableComponent(const clang::VTableComponent& Component); diff --git a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs index 1bb54e72..ecb67fb8 100644 --- a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs +++ b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs @@ -457,8 +457,7 @@ namespace CppSharp.Generators.CLI GenerateDeclarationCommon(field); if (@class.IsUnion) WriteLine("[System::Runtime::InteropServices::FieldOffset({0})]", - @class.Layout.Fields.Single( - f => f.Namespace == @class && f.FieldPtr == field.OriginalPtr).Offset); + @class.Layout.Fields.Single(f => f.FieldPtr == field.OriginalPtr).Offset); WriteLine("{0} {1};", field.Type, field.Name); PopBlock(); diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 03d299ed..1b2660ab 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -842,7 +842,6 @@ namespace CppSharp.Generators.CSharp { var dummy = new LayoutField { - Namespace = field.Namespace, Offset = (uint) (field.Offset + i * arrayType.ElementSize / 8), QualifiedType = new QualifiedType(arrayType.Type), Name = string.Format("{0}_{1}_{2}", Helpers.DummyIdentifier, @@ -2055,7 +2054,8 @@ namespace CppSharp.Generators.CSharp { if (@class.HasBaseClass) WriteLine("{0} = {1};", Helpers.PointerAdjustmentIdentifier, - @class.ComputeNonVirtualBaseClassOffsetTo(@class.BaseClass)); + @class.Layout.Bases.Where( + b => b.Class == @class.BaseClass).Select(b => b.Offset).FirstOrDefault()); if (!@class.IsAbstractImpl) { WriteLine("if (native == null)"); @@ -2793,11 +2793,12 @@ namespace CppSharp.Generators.CSharp var to = function.OriginalFunction == null ? @from.BaseClass : (Class) function.OriginalFunction.Namespace; - var baseOffset = 0; + var baseOffset = 0u; if (to != null) { to = to.OriginalClass ?? to; - baseOffset = @from.ComputeNonVirtualBaseClassOffsetTo(to); + baseOffset = from.Layout.Bases.Where( + b => b.Class == to).Select(b => b.Offset).FirstOrDefault(); } var isPrimaryBase = from.BaseClass == to; if (isPrimaryBase)