Skip to content

Commit

Permalink
Implement ClassTemplatePartialSpecialization::Parameters (#1809)
Browse files Browse the repository at this point in the history
* Implement ClassTemplatePartialSpecialization::Parameters

* Template.cs: Implement ClassTemplatePartialSpecialization.Parameters

* GeneratorKind: fix bug introduced while migrating from enum to class

* Implement native ClassTemplatePartialSpecialization.Parameters + ASTConverter

* regenerated bindings (#1813)

* regenerated bindings

* regenerated bindings after rebase

* Directory.Build.props: support C# 10.0

* Implement native ClassTemplatePartialSpecialization.Parameters + ASTConverter

* Regenerated bindings

* TestAST.cs: add TestASTClassTemplatePartialSpecialization
  • Loading branch information
deadlocklogic authored Dec 17, 2023
1 parent 2ecd952 commit 9071cd2
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/AST/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ public override string ToString()
/// </summary>
public class ClassTemplatePartialSpecialization : ClassTemplateSpecialization
{
public readonly List<Declaration> Parameters;

public ClassTemplatePartialSpecialization()
{
Parameters = new List<Declaration>();
}
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/CppParser/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ ClassTemplatePartialSpecialization::ClassTemplatePartialSpecialization()

ClassTemplatePartialSpecialization::~ClassTemplatePartialSpecialization() {}

DEF_VECTOR(ClassTemplatePartialSpecialization, Declaration*, Parameters)

FunctionTemplate::FunctionTemplate() : Template(DeclarationKind::FunctionTemplate) {}

FunctionTemplate::~FunctionTemplate() {}
Expand Down
49 changes: 49 additions & 0 deletions src/CppParser/Bindings/CLI/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4514,6 +4514,26 @@ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialS
NativePtr = new class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization();
}

CppSharp::Parser::AST::Declaration^ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::GetParameters(unsigned int i)
{
auto ___ret = ((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->getParameters(i);
if (___ret == nullptr) return nullptr;
return (___ret == nullptr) ? nullptr : gcnew ::CppSharp::Parser::AST::Declaration((class ::CppSharp::CppParser::AST::Declaration*)___ret);
}

void CppSharp::Parser::AST::ClassTemplatePartialSpecialization::AddParameters(CppSharp::Parser::AST::Declaration^ s)
{
if (ReferenceEquals(s, nullptr))
throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
auto __arg0 = (class ::CppSharp::CppParser::AST::Declaration*)s->NativePtr;
((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->addParameters(__arg0);
}

void CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClearParameters()
{
((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->clearParameters();
}

CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialSpecialization(CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ _0)
: CppSharp::Parser::AST::ClassTemplateSpecialization((::CppSharp::CppParser::AST::ClassTemplateSpecialization*)nullptr)
{
Expand All @@ -4524,6 +4544,35 @@ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialS
NativePtr = new class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization(__arg0);
}

::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>^ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::Parameters::get()
{
auto _tmp__Parameters = gcnew ::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>();
auto __list0 = ((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->Parameters;
for(auto _element : __list0)
{
auto _marshalElement = (_element == nullptr) ? nullptr : gcnew ::CppSharp::Parser::AST::Declaration((class ::CppSharp::CppParser::AST::Declaration*)_element);
_tmp__Parameters->Add(_marshalElement);
}
return _tmp__Parameters;
}

void CppSharp::Parser::AST::ClassTemplatePartialSpecialization::Parameters::set(::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>^ value)
{
auto _tmpvalue = std::vector<::CppSharp::CppParser::AST::Declaration*>();
for each(CppSharp::Parser::AST::Declaration^ _element in value)
{
auto _marshalElement = (class ::CppSharp::CppParser::AST::Declaration*)_element->NativePtr;
_tmpvalue.push_back(_marshalElement);
}
((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->Parameters = _tmpvalue;
}

unsigned int CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ParametersCount::get()
{
auto ___ret = ((class ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)NativePtr)->getParametersCount();
return ___ret;
}

CppSharp::Parser::AST::FunctionTemplate::FunctionTemplate(class ::CppSharp::CppParser::AST::FunctionTemplate* native)
: CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)native)
{
Expand Down
17 changes: 17 additions & 0 deletions src/CppParser/Bindings/CLI/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,23 @@ namespace CppSharp
ClassTemplatePartialSpecialization(CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ _0);

~ClassTemplatePartialSpecialization();

property ::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>^ Parameters
{
::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>^ get();
void set(::System::Collections::Generic::List<CppSharp::Parser::AST::Declaration^>^);
}

property unsigned int ParametersCount
{
unsigned int get();
}

CppSharp::Parser::AST::Declaration^ GetParameters(unsigned int i);

void AddParameters(CppSharp::Parser::AST::Declaration^ s);

void ClearParameters();
};

public ref class FunctionTemplate : CppSharp::Parser::AST::Template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13779,7 +13779,7 @@ public uint ArgumentsCount

public unsafe partial class ClassTemplatePartialSpecialization : global::CppSharp.Parser.AST.ClassTemplateSpecialization, IDisposable
{
[StructLayout(LayoutKind.Sequential, Size = 328)]
[StructLayout(LayoutKind.Sequential, Size = 340)]
public new partial struct __Internal
{
internal global::CppSharp.Parser.AST.DeclarationKind kind;
Expand Down Expand Up @@ -13834,6 +13834,7 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar
internal __IntPtr templatedDecl;
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_TemplateArgument___N_std_N___1_S_allocator__S0_ Arguments;
internal global::CppSharp.Parser.AST.TemplateSpecializationKind specializationKind;
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector_____N_CppSharp_N_CppParser_N_AST_S_Declaration___N_std_N___1_S_allocator__S0_ Parameters;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecializationC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand All @@ -13843,6 +13844,18 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecializationD2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization13getParametersEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr GetParameters(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization13addParametersERPNS1_11DeclarationE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddParameters(__IntPtr __instance, __IntPtr s);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization15clearParametersEv", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ClearParameters(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization18getParametersCountEv", CallingConvention = __CallingConvention.Cdecl)]
internal static extern uint GetParametersCount(__IntPtr __instance);
}

internal static new ClassTemplatePartialSpecialization __CreateInstance(__IntPtr native, bool skipVTables = false)
Expand Down Expand Up @@ -13923,6 +13936,36 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)
Marshal.FreeHGlobal(__Instance);
__Instance = IntPtr.Zero;
}

public global::CppSharp.Parser.AST.Declaration GetParameters(uint i)
{
var ___ret = __Internal.GetParameters(__Instance, i);
var __result0 = global::CppSharp.Parser.AST.Declaration.__GetOrCreateInstance(___ret, false);
return __result0;
}

public void AddParameters(global::CppSharp.Parser.AST.Declaration s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var ____arg0 = s.__Instance;
var __arg0 = new __IntPtr(&____arg0);
__Internal.AddParameters(__Instance, __arg0);
}

public void ClearParameters()
{
__Internal.ClearParameters(__Instance);
}

public uint ParametersCount
{
get
{
var ___ret = __Internal.GetParametersCount(__Instance);
return ___ret;
}
}
}

public unsafe partial class FunctionTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13779,7 +13779,7 @@ public uint ArgumentsCount

public unsafe partial class ClassTemplatePartialSpecialization : global::CppSharp.Parser.AST.ClassTemplateSpecialization, IDisposable
{
[StructLayout(LayoutKind.Sequential, Size = 360)]
[StructLayout(LayoutKind.Sequential, Size = 372)]
public new partial struct __Internal
{
internal global::CppSharp.Parser.AST.DeclarationKind kind;
Expand Down Expand Up @@ -13834,6 +13834,7 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar
internal __IntPtr templatedDecl;
internal global::Std.Vector.__Internalc__N_std_S_vector____N_CppSharp_N_CppParser_N_AST_S_TemplateArgument___N_std_S_allocator__S0_ Arguments;
internal global::CppSharp.Parser.AST.TemplateSpecializationKind specializationKind;
internal global::Std.Vector.__Internalc__N_std_S_vector_____N_CppSharp_N_CppParser_N_AST_S_Declaration___N_std_S_allocator__S0_ Parameters;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAE@XZ", CallingConvention = __CallingConvention.ThisCall)]
internal static extern __IntPtr ctor(__IntPtr __instance);
Expand All @@ -13843,6 +13844,18 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??1ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAE@XZ", CallingConvention = __CallingConvention.ThisCall)]
internal static extern void dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?getParameters@ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAEPAVDeclaration@234@I@Z", CallingConvention = __CallingConvention.ThisCall)]
internal static extern __IntPtr GetParameters(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?addParameters@ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAEXAAPAVDeclaration@234@@Z", CallingConvention = __CallingConvention.ThisCall)]
internal static extern void AddParameters(__IntPtr __instance, __IntPtr s);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?clearParameters@ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAEXXZ", CallingConvention = __CallingConvention.ThisCall)]
internal static extern void ClearParameters(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "?getParametersCount@ClassTemplatePartialSpecialization@AST@CppParser@CppSharp@@QAEIXZ", CallingConvention = __CallingConvention.ThisCall)]
internal static extern uint GetParametersCount(__IntPtr __instance);
}

internal static new ClassTemplatePartialSpecialization __CreateInstance(__IntPtr native, bool skipVTables = false)
Expand Down Expand Up @@ -13923,6 +13936,36 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)
Marshal.FreeHGlobal(__Instance);
__Instance = IntPtr.Zero;
}

public global::CppSharp.Parser.AST.Declaration GetParameters(uint i)
{
var ___ret = __Internal.GetParameters(__Instance, i);
var __result0 = global::CppSharp.Parser.AST.Declaration.__GetOrCreateInstance(___ret, false);
return __result0;
}

public void AddParameters(global::CppSharp.Parser.AST.Declaration s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var ____arg0 = s.__Instance;
var __arg0 = new __IntPtr(&____arg0);
__Internal.AddParameters(__Instance, __arg0);
}

public void ClearParameters()
{
__Internal.ClearParameters(__Instance);
}

public uint ParametersCount
{
get
{
var ___ret = __Internal.GetParametersCount(__Instance);
return ___ret;
}
}
}

public unsafe partial class FunctionTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13778,7 +13778,7 @@ public uint ArgumentsCount

public unsafe partial class ClassTemplatePartialSpecialization : global::CppSharp.Parser.AST.ClassTemplateSpecialization, IDisposable
{
[StructLayout(LayoutKind.Sequential, Size = 608)]
[StructLayout(LayoutKind.Sequential, Size = 632)]
public new partial struct __Internal
{
internal global::CppSharp.Parser.AST.DeclarationKind kind;
Expand Down Expand Up @@ -13833,6 +13833,7 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar
internal __IntPtr templatedDecl;
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector____N_CppSharp_N_CppParser_N_AST_S_TemplateArgument___N_std_N___1_S_allocator__S0_ Arguments;
internal global::CppSharp.Parser.AST.TemplateSpecializationKind specializationKind;
internal global::Std.Vector.__Internalc__N_std_N___1_S_vector_____N_CppSharp_N_CppParser_N_AST_S_Declaration___N_std_N___1_S_allocator__S0_ Parameters;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecializationC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand All @@ -13842,6 +13843,18 @@ public unsafe partial class ClassTemplatePartialSpecialization : global::CppShar

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecializationD2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization13getParametersEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr GetParameters(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization13addParametersERPNS1_11DeclarationE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddParameters(__IntPtr __instance, __IntPtr s);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization15clearParametersEv", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ClearParameters(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST34ClassTemplatePartialSpecialization18getParametersCountEv", CallingConvention = __CallingConvention.Cdecl)]
internal static extern uint GetParametersCount(__IntPtr __instance);
}

internal static new ClassTemplatePartialSpecialization __CreateInstance(__IntPtr native, bool skipVTables = false)
Expand Down Expand Up @@ -13922,6 +13935,36 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)
Marshal.FreeHGlobal(__Instance);
__Instance = IntPtr.Zero;
}

public global::CppSharp.Parser.AST.Declaration GetParameters(uint i)
{
var ___ret = __Internal.GetParameters(__Instance, i);
var __result0 = global::CppSharp.Parser.AST.Declaration.__GetOrCreateInstance(___ret, false);
return __result0;
}

public void AddParameters(global::CppSharp.Parser.AST.Declaration s)
{
if (ReferenceEquals(s, null))
throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
var ____arg0 = s.__Instance;
var __arg0 = new __IntPtr(&____arg0);
__Internal.AddParameters(__Instance, __arg0);
}

public void ClearParameters()
{
__Internal.ClearParameters(__Instance);
}

public uint ParametersCount
{
get
{
var ___ret = __Internal.GetParametersCount(__Instance);
return ___ret;
}
}
}

public unsafe partial class FunctionTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Loading

0 comments on commit 9071cd2

Please sign in to comment.