Skip to content

Commit 4daa88b

Browse files
committed
feat: allow metafunction to have an in parameter
1 parent 89308d1 commit 4daa88b

File tree

5 files changed

+122
-63
lines changed

5 files changed

+122
-63
lines changed

source/parse.h

+25-1
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,9 @@ struct function_type_node
22442244
auto is_metafunction() const
22452245
-> bool;
22462246

2247+
auto is_const_metafunction() const
2248+
-> bool;
2249+
22472250
auto has_declared_return_type() const
22482251
-> bool
22492252
{
@@ -3508,6 +3511,16 @@ struct declaration_node
35083511
return false;
35093512
}
35103513

3514+
auto is_const_metafunction() const
3515+
-> bool
3516+
{
3517+
if (auto func = std::get_if<a_function>(&type)) {
3518+
return (*func)->is_const_metafunction();
3519+
}
3520+
// else
3521+
return false;
3522+
}
3523+
35113524
auto is_binary_comparison_function() const
35123525
-> bool
35133526
{
@@ -3975,7 +3988,10 @@ auto function_type_node::is_metafunction() const
39753988
if (
39763989
(*parameters).ssize() == 1
39773990
&& this->nth_parameter_type_name(1) == "cpp2::meta::type_declaration"
3978-
&& (*parameters)[0]->direction() == passing_style::inout
3991+
&& (
3992+
(*parameters)[0]->direction() == passing_style::in
3993+
|| (*parameters)[0]->direction() == passing_style::inout
3994+
)
39793995
)
39803996
{
39813997
return true;
@@ -3984,6 +4000,14 @@ auto function_type_node::is_metafunction() const
39844000
}
39854001

39864002

4003+
auto function_type_node::is_const_metafunction() const
4004+
-> bool
4005+
{
4006+
return is_metafunction()
4007+
&& (*parameters)[0]->direction() == passing_style::in;
4008+
}
4009+
4010+
39874011
auto primary_expression_node::template_arguments() const
39884012
-> std::vector<template_argument> const&
39894013
{

0 commit comments

Comments
 (0)