From 9d897649652789810a46fa7daa66738a7eb6f1a8 Mon Sep 17 00:00:00 2001 From: realvictorprm Date: Sat, 8 Apr 2017 14:44:37 +0200 Subject: [PATCH] Wrapped injected classes in order to ease binding lists of redeclarations. Signed-off-by: Dimitar Dobrev --- src/AST/Class.cs | 2 ++ src/CppParser/AST.cpp | 1 + src/CppParser/AST.h | 1 + src/CppParser/Bindings/CLI/AST.cpp | 10 +++++++ src/CppParser/Bindings/CLI/AST.h | 12 ++++++-- .../CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../i686-pc-win32-msvc/CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../Bindings/CSharp/i686-pc-win32-msvc/Std.cs | 8 +++--- .../CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../CSharp/x86_64-apple-darwin12.4.0/Std.cs | 8 +++--- .../CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../CSharp/x86_64-linux-gnu-cxx11abi/Std.cs | 18 ++++++------ .../x86_64-linux-gnu/CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../Bindings/CSharp/x86_64-linux-gnu/Std.cs | 14 +++++----- .../CppSharp.CppParser.cs | 28 +++++++++++++++++-- .../CSharp/x86_64-pc-win32-msvc/Std.cs | 10 +++---- src/CppParser/Parser.cpp | 4 +-- .../Generators/CSharp/CSharpSources.cs | 2 +- src/Generator/Passes/CheckIgnoredDecls.cs | 21 +++++++++++++- src/Parser/ASTConverter.cs | 5 ++-- 20 files changed, 227 insertions(+), 57 deletions(-) diff --git a/src/AST/Class.cs b/src/AST/Class.cs index ad3d88f4..51dc1e15 100644 --- a/src/AST/Class.cs +++ b/src/AST/Class.cs @@ -98,6 +98,8 @@ namespace CppSharp.AST private bool? isOpaque = null; + public bool IsInjected { get; set; } + // True if the type is to be treated as opaque. public bool IsOpaque { diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp index 596f828b..86a2ee3e 100644 --- a/src/CppParser/AST.cpp +++ b/src/CppParser/AST.cpp @@ -723,6 +723,7 @@ Class::Class() , hasNonTrivialCopyConstructor(false) , hasNonTrivialDestructor(false) , isExternCContext(false) + , isInjected(false) , layout(0) { } diff --git a/src/CppParser/AST.h b/src/CppParser/AST.h index 7785664b..f6495f57 100644 --- a/src/CppParser/AST.h +++ b/src/CppParser/AST.h @@ -862,6 +862,7 @@ public: bool hasNonTrivialCopyConstructor; bool hasNonTrivialDestructor; bool isExternCContext; + bool isInjected; ClassLayout* layout; }; diff --git a/src/CppParser/Bindings/CLI/AST.cpp b/src/CppParser/Bindings/CLI/AST.cpp index 53730453..d82df074 100644 --- a/src/CppParser/Bindings/CLI/AST.cpp +++ b/src/CppParser/Bindings/CLI/AST.cpp @@ -3944,6 +3944,16 @@ void CppSharp::Parser::AST::Class::IsExternCContext::set(bool value) ((::CppSharp::CppParser::AST::Class*)NativePtr)->isExternCContext = value; } +bool CppSharp::Parser::AST::Class::IsInjected::get() +{ + return ((::CppSharp::CppParser::AST::Class*)NativePtr)->isInjected; +} + +void CppSharp::Parser::AST::Class::IsInjected::set(bool value) +{ + ((::CppSharp::CppParser::AST::Class*)NativePtr)->isInjected = value; +} + CppSharp::Parser::AST::ClassLayout^ CppSharp::Parser::AST::Class::Layout::get() { return (((::CppSharp::CppParser::AST::Class*)NativePtr)->layout == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::ClassLayout((::CppSharp::CppParser::AST::ClassLayout*)((::CppSharp::CppParser::AST::Class*)NativePtr)->layout); diff --git a/src/CppParser/Bindings/CLI/AST.h b/src/CppParser/Bindings/CLI/AST.h index 84256f4c..bb2d77ec 100644 --- a/src/CppParser/Bindings/CLI/AST.h +++ b/src/CppParser/Bindings/CLI/AST.h @@ -343,8 +343,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 }; public enum struct VTableComponentKind @@ -405,7 +405,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 }; public ref class Type : ICppInstance @@ -2327,6 +2327,12 @@ namespace CppSharp void set(bool); } + property bool IsInjected + { + bool get(); + void set(bool); + } + property CppSharp::Parser::AST::ClassLayout^ Layout { CppSharp::Parser::AST::ClassLayout^ get(); diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs index 922a1efb..cd3f3c7f 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8907,6 +8907,9 @@ namespace CppSharp [FieldOffset(272)] public byte isExternCContext; + [FieldOffset(273)] + public byte isInjected; + [FieldOffset(276)] public global::System.IntPtr layout; @@ -9283,6 +9286,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10799,6 +10815,9 @@ namespace CppSharp [FieldOffset(272)] public byte isExternCContext; + [FieldOffset(273)] + public byte isInjected; + [FieldOffset(276)] public global::System.IntPtr layout; @@ -11100,6 +11119,9 @@ namespace CppSharp [FieldOffset(272)] public byte isExternCContext; + [FieldOffset(273)] + public byte isInjected; + [FieldOffset(276)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs index 9357b21a..ee891633 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8907,6 +8907,9 @@ namespace CppSharp [FieldOffset(304)] public byte isExternCContext; + [FieldOffset(305)] + public byte isInjected; + [FieldOffset(308)] public global::System.IntPtr layout; @@ -9283,6 +9286,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10799,6 +10815,9 @@ namespace CppSharp [FieldOffset(304)] public byte isExternCContext; + [FieldOffset(305)] + public byte isInjected; + [FieldOffset(308)] public global::System.IntPtr layout; @@ -11100,6 +11119,9 @@ namespace CppSharp [FieldOffset(304)] public byte isExternCContext; + [FieldOffset(305)] + public byte isInjected; + [FieldOffset(308)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std.cs index da1e4d91..7c902e4b 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std.cs +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std.cs @@ -63,7 +63,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="?eof@?$char_traits@D@std@@SAHXZ")] internal static extern int Eofc__N_std_S_char_traits__C_0(); } @@ -477,7 +477,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, EntryPoint="??0?$allocator@D@std@@QAE@XZ")] internal static extern global::System.IntPtr ctorc__N_std_S_allocator__C_0(global::System.IntPtr instance); } @@ -568,12 +568,12 @@ namespace Std internal global::Std.CompressedPair.__Internalc__N_std_S__Compressed_pair____N_std_S__Wrap_alloc____N_std_S_allocator__C___N_std_S__String_val____N_std_S__Simple_types__C_Vb1 _Mypair; [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, EntryPoint="??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ")] internal static extern void dtorc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance, int delete); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, EntryPoint="?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ")] internal static extern global::System.IntPtr CStrc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); } diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs index 3c3abc1b..b8445922 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8906,6 +8906,9 @@ namespace CppSharp [FieldOffset(520)] public byte isExternCContext; + [FieldOffset(521)] + public byte isInjected; + [FieldOffset(528)] public global::System.IntPtr layout; @@ -9282,6 +9285,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10798,6 +10814,9 @@ namespace CppSharp [FieldOffset(520)] public byte isExternCContext; + [FieldOffset(521)] + public byte isInjected; + [FieldOffset(528)] public global::System.IntPtr layout; @@ -11099,6 +11118,9 @@ namespace CppSharp [FieldOffset(520)] public byte isExternCContext; + [FieldOffset(521)] + public byte isInjected; + [FieldOffset(528)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs index ca4dbfd9..8292be6e 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs @@ -153,7 +153,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt3__19allocatorIcEC2Ev")] internal static extern void ctorc__N_std_N___1_S_allocator__C_0(global::System.IntPtr instance); } @@ -1266,7 +1266,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt3__111char_traitsIcE3eofEv")] internal static extern int Eofc__N_std_N___1_S_char_traits__C_0(); } @@ -1346,12 +1346,12 @@ namespace Std internal global::Std.__1.CompressedPair.__Internal __r_; [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev")] internal static extern void dtorc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C_0(global::System.IntPtr instance); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv")] internal static extern global::System.IntPtr CStrc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C_0(global::System.IntPtr instance); } diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs index 80f38400..e40adbe7 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8906,6 +8906,9 @@ namespace CppSharp [FieldOffset(568)] public byte isExternCContext; + [FieldOffset(569)] + public byte isInjected; + [FieldOffset(576)] public global::System.IntPtr layout; @@ -9282,6 +9285,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10798,6 +10814,9 @@ namespace CppSharp [FieldOffset(568)] public byte isExternCContext; + [FieldOffset(569)] + public byte isInjected; + [FieldOffset(576)] public global::System.IntPtr layout; @@ -11099,6 +11118,9 @@ namespace CppSharp [FieldOffset(568)] public byte isExternCContext; + [FieldOffset(569)] + public byte isInjected; + [FieldOffset(576)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs index afbbde3c..425f27ce 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs @@ -45,12 +45,12 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSaIcEC2Ev")] internal static extern void ctorc__N_std_S_allocator__C_0(global::System.IntPtr instance); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSaIcED2Ev")] internal static extern void dtorc__N_std_S_allocator__C_0(global::System.IntPtr instance); } @@ -204,8 +204,8 @@ namespace Std { public enum RbTreeColor : uint { - SRed = 0, - SBlack = 1 + S_red = 0, + S_black = 1 } namespace RbTree @@ -340,7 +340,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt11char_traitsIcE3eofEv")] internal static extern int Eofc__N_std_S_char_traits__C_0(); } @@ -657,19 +657,19 @@ namespace Std internal global::Std.Cxx11.BasicString._.__Internal _; [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev")] internal static extern void dtorc__N_std_N___cxx11_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv")] internal static extern global::System.IntPtr CStrc__N_std_N___cxx11_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); } - internal enum SLocalCapacity : uint + internal enum S_localCapacity : uint { - SLocalCapacity = 15 + S_localCapacity = 15 } public unsafe partial class AllocHider diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs index a1e60778..e9ebb463 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8906,6 +8906,9 @@ namespace CppSharp [FieldOffset(496)] public byte isExternCContext; + [FieldOffset(497)] + public byte isInjected; + [FieldOffset(504)] public global::System.IntPtr layout; @@ -9282,6 +9285,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10798,6 +10814,9 @@ namespace CppSharp [FieldOffset(496)] public byte isExternCContext; + [FieldOffset(497)] + public byte isInjected; + [FieldOffset(504)] public global::System.IntPtr layout; @@ -11099,6 +11118,9 @@ namespace CppSharp [FieldOffset(496)] public byte isExternCContext; + [FieldOffset(497)] + public byte isInjected; + [FieldOffset(504)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs index a5ced3d3..3eae662e 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs @@ -45,12 +45,12 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSaIcEC2Ev")] internal static extern void ctorc__N_std_S_allocator__C_0(global::System.IntPtr instance); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSaIcED2Ev")] internal static extern void dtorc__N_std_S_allocator__C_0(global::System.IntPtr instance); } @@ -204,8 +204,8 @@ namespace Std { public enum RbTreeColor : uint { - SRed = 0, - SBlack = 1 + S_red = 0, + S_black = 1 } namespace RbTree @@ -333,7 +333,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSt11char_traitsIcE3eofEv")] internal static extern int Eofc__N_std_S_char_traits__C_0(); } @@ -634,12 +634,12 @@ namespace Std internal global::Std.BasicString.AllocHider.__Internal _M_dataplus; [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNSsD2Ev")] internal static extern void dtorc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="_ZNKSs5c_strEv")] internal static extern global::System.IntPtr CStrc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); } diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs index 02532cbb..c2e44882 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs @@ -230,8 +230,8 @@ namespace CppSharp Itanium = 0, Microsoft = 1, ARM = 2, - IOS = 3, - IOS64 = 4 + iOS = 3, + iOS64 = 4 } public enum VTableComponentKind @@ -292,7 +292,7 @@ namespace CppSharp { UnknownArch = 0, X86 = 1, - X8664 = 2 + X86_64 = 2 } public unsafe partial class Type : IDisposable @@ -8907,6 +8907,9 @@ namespace CppSharp [FieldOffset(536)] public byte isExternCContext; + [FieldOffset(537)] + public byte isInjected; + [FieldOffset(544)] public global::System.IntPtr layout; @@ -9283,6 +9286,19 @@ namespace CppSharp } } + public bool IsInjected + { + get + { + return ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected != 0; + } + + set + { + ((global::CppSharp.Parser.AST.Class.__Internal*) __Instance)->isInjected = (byte) (value ? 1 : 0); + } + } + public global::CppSharp.Parser.AST.ClassLayout Layout { get @@ -10799,6 +10815,9 @@ namespace CppSharp [FieldOffset(536)] public byte isExternCContext; + [FieldOffset(537)] + public byte isInjected; + [FieldOffset(544)] public global::System.IntPtr layout; @@ -11100,6 +11119,9 @@ namespace CppSharp [FieldOffset(536)] public byte isExternCContext; + [FieldOffset(537)] + public byte isInjected; + [FieldOffset(544)] public global::System.IntPtr layout; diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std.cs b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std.cs index 8cdb231d..7ed372c2 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std.cs @@ -63,7 +63,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="?eof@?$char_traits@D@std@@SAHXZ")] internal static extern int Eofc__N_std_S_char_traits__C_0(); } @@ -477,7 +477,7 @@ namespace Std public unsafe partial struct __Internal { [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="??0?$allocator@D@std@@QEAA@XZ")] internal static extern global::System.IntPtr ctorc__N_std_S_allocator__C_0(global::System.IntPtr instance); } @@ -553,7 +553,7 @@ namespace Std } } -public unsafe partial class _SETJMP_FLOAT128 +public unsafe partial class SETJMP_FLOAT128 { [StructLayout(LayoutKind.Explicit, Size = 16)] public partial struct __Internal @@ -578,12 +578,12 @@ namespace Std internal global::Std.CompressedPair.__Internalc__N_std_S__Compressed_pair____N_std_S__Wrap_alloc____N_std_S_allocator__C___N_std_S__String_val____N_std_S__Simple_types__C_Vb1 _Mypair; [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ")] internal static extern void dtorc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance, int delete); [SuppressUnmanagedCodeSecurity] - [DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + [DllImport("Std-symbols", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint="?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ")] internal static extern global::System.IntPtr CStrc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C_0(global::System.IntPtr instance); } diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index edff832c..6e866aef 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -795,9 +795,6 @@ Class* Parser::GetRecord(const clang::RecordDecl* Record, bool& Process) using namespace clang; Process = false; - if (Record->isInjectedClassName()) - return nullptr; - auto NS = GetNamespace(Record); assert(NS && "Expected a valid namespace"); @@ -823,6 +820,7 @@ Class* Parser::GetRecord(const clang::RecordDecl* Record, bool& Process) return RC; RC = NS->FindClass(Name, isCompleteDefinition, /*Create=*/true); + RC->isInjected = Record->isInjectedClassName(); HandleDeclaration(Record, RC); EnsureCompleteRecord(Record, NS, RC); diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index dfdd125e..72e31858 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -144,7 +144,7 @@ namespace CppSharp.Generators.CSharp foreach (var typedef in context.Typedefs) typedef.Visit(this); - foreach (var @class in context.Classes) + foreach (var @class in context.Classes.Where(c => !(c is ClassTemplateSpecialization))) @class.Visit(this); foreach (var @event in context.Events) diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 4dbc2cea..fcb6e0ce 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -2,6 +2,7 @@ using CppSharp.AST; using CppSharp.AST.Extensions; using CppSharp.Types; +using System.Collections.Generic; namespace CppSharp.Passes { @@ -38,7 +39,13 @@ namespace CppSharp.Passes public override bool VisitClassDecl(Class @class) { - if (!base.VisitClassDecl(@class) || !@class.IsDependent) + if (!base.VisitClassDecl(@class)) + return false; + + if (@class.IsInjected) + injectedClasses.Add(@class); + + if (!@class.IsDependent) return false; // templates are not supported yet @@ -323,6 +330,16 @@ namespace CppSharp.Passes return true; } + public override bool VisitASTContext(ASTContext c) + { + base.VisitASTContext(c); + + foreach (var injectedClass in injectedClasses) + injectedClass.Namespace.Declarations.Remove(injectedClass); + + return true; + } + #region Helpers /// @@ -448,5 +465,7 @@ namespace CppSharp.Passes } #endregion + + private HashSet injectedClasses = new HashSet(); } } diff --git a/src/Parser/ASTConverter.cs b/src/Parser/ASTConverter.cs index b0c89826..b1079615 100644 --- a/src/Parser/ASTConverter.cs +++ b/src/Parser/ASTConverter.cs @@ -1509,6 +1509,7 @@ namespace CppSharp _class.HasNonTrivialCopyConstructor = @class.HasNonTrivialCopyConstructor; _class.HasNonTrivialDestructor = @class.HasNonTrivialDestructor; _class.IsExternCContext = @class.IsExternCContext; + _class.IsInjected = @class.IsInjected; if (@class.Layout != null) _class.Layout = VisitClassLayout(@class.Layout); @@ -1575,9 +1576,9 @@ namespace CppSharp return AST.CppAbi.Microsoft; case CppAbi.ARM: return AST.CppAbi.ARM; - case CppAbi.IOS: + case CppAbi.iOS: return AST.CppAbi.iOS; - case CppAbi.IOS64: + case CppAbi.iOS64: return AST.CppAbi.iOS64; default: throw new ArgumentOutOfRangeException("abi");