Skip to content

Commit

Permalink
Add type parameter to non-type template parameter decls. (mono#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao authored Jul 14, 2023
1 parent add3aba commit bb31bd6
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AST/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public class NonTypeTemplateParameter : Declaration
/// </summary>
public bool IsExpandedParameterPack { get; set; }

public QualifiedType Type { get; set; }

public override T Visit<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitNonTypeTemplateParameterDecl(this);
Expand Down
1 change: 1 addition & 0 deletions src/CppParser/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ NonTypeTemplateParameter::NonTypeTemplateParameter(const NonTypeTemplateParamete
, position(rhs.position)
, isPackExpansion(rhs.isPackExpansion)
, isExpandedParameterPack(rhs.isExpandedParameterPack)
, type(rhs.type)
{
}

Expand Down
12 changes: 12 additions & 0 deletions src/CppParser/Bindings/CLI/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4224,6 +4224,18 @@ void CppSharp::Parser::AST::NonTypeTemplateParameter::IsExpandedParameterPack::s
((class ::CppSharp::CppParser::AST::NonTypeTemplateParameter*)NativePtr)->isExpandedParameterPack = value;
}

CppSharp::Parser::AST::QualifiedType^ CppSharp::Parser::AST::NonTypeTemplateParameter::Type::get()
{
return (&((class ::CppSharp::CppParser::AST::NonTypeTemplateParameter*)NativePtr)->type == nullptr) ? nullptr : gcnew ::CppSharp::Parser::AST::QualifiedType((struct ::CppSharp::CppParser::AST::QualifiedType*)&((class ::CppSharp::CppParser::AST::NonTypeTemplateParameter*)NativePtr)->type);
}

void CppSharp::Parser::AST::NonTypeTemplateParameter::Type::set(CppSharp::Parser::AST::QualifiedType^ value)
{
if (ReferenceEquals(value, nullptr))
throw gcnew ::System::ArgumentNullException("value", "Cannot be null because it is passed by value.");
((class ::CppSharp::CppParser::AST::NonTypeTemplateParameter*)NativePtr)->type = *(struct ::CppSharp::CppParser::AST::QualifiedType*)value->NativePtr;
}

CppSharp::Parser::AST::ClassTemplate::ClassTemplate(class ::CppSharp::CppParser::AST::ClassTemplate* native)
: CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)native)
{
Expand Down
6 changes: 6 additions & 0 deletions src/CppParser/Bindings/CLI/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,12 @@ namespace CppSharp
bool get();
void set(bool);
}

property CppSharp::Parser::AST::QualifiedType^ Type
{
CppSharp::Parser::AST::QualifiedType^ get();
void set(CppSharp::Parser::AST::QualifiedType^);
}
};

public ref class ClassTemplate : CppSharp::Parser::AST::Template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13017,6 +13017,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST24NonTypeTemplateParameterC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13171,6 +13172,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13017,6 +13017,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0NonTypeTemplateParameter@AST@CppParser@CppSharp@@QAE@XZ", CallingConvention = __CallingConvention.ThisCall)]
internal static extern __IntPtr ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13171,6 +13172,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13016,6 +13016,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST24NonTypeTemplateParameterC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13170,6 +13171,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13016,6 +13016,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST24NonTypeTemplateParameterC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13170,6 +13171,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13016,6 +13016,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST24NonTypeTemplateParameterC2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13170,6 +13171,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13018,6 +13018,7 @@ public unsafe partial class NonTypeTemplateParameter : global::CppSharp.Parser.A
internal uint position;
internal byte isPackExpansion;
internal byte isExpandedParameterPack;
internal global::CppSharp.Parser.AST.QualifiedType.__Internal type;

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser.dll", EntryPoint = "??0NonTypeTemplateParameter@AST@CppParser@CppSharp@@QEAA@XZ", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr ctor(__IntPtr __instance);
Expand Down Expand Up @@ -13172,6 +13173,21 @@ public bool IsExpandedParameterPack
((__Internal*)__Instance)->isExpandedParameterPack = (byte) (value ? 1 : 0);
}
}

public global::CppSharp.Parser.AST.QualifiedType Type
{
get
{
return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(new __IntPtr(&((__Internal*)__Instance)->type));
}

set
{
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
((__Internal*)__Instance)->type = *(global::CppSharp.Parser.AST.QualifiedType.__Internal*) value.__Instance;
}
}
}

public unsafe partial class ClassTemplate : global::CppSharp.Parser.AST.Template, IDisposable
Expand Down
1 change: 1 addition & 0 deletions src/CppParser/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ namespace CppSharp
unsigned int position;
bool isPackExpansion;
bool isExpandedParameterPack;
QualifiedType type;
};

class ClassTemplateSpecialization;
Expand Down
1 change: 1 addition & 0 deletions src/CppParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ NonTypeTemplateParameter* Parser::WalkNonTypeTemplateParameter(const clang::NonT
HandleDeclaration(NTTPD, NTP);
if (NTTPD->hasDefaultArgument())
NTP->defaultArgument = WalkExpressionObsolete(NTTPD->getDefaultArgument());
NTP->type = GetQualifiedType(NTTPD->getType());
NTP->depth = NTTPD->getDepth();
NTP->index = NTTPD->getIndex();
NTP->isParameterPack = NTTPD->isParameterPack();
Expand Down
1 change: 1 addition & 0 deletions src/Parser/ASTConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,7 @@ public override AST.Declaration VisitNonTypeTemplateParameter(NonTypeTemplatePar
nonTypeTemplateParameter.IsParameterPack = decl.IsParameterPack;
nonTypeTemplateParameter.IsPackExpansion = decl.IsPackExpansion;
nonTypeTemplateParameter.IsExpandedParameterPack = decl.IsExpandedParameterPack;
nonTypeTemplateParameter.Type = typeConverter.VisitQualified(decl.Type);
return nonTypeTemplateParameter;
}

Expand Down

0 comments on commit bb31bd6

Please sign in to comment.