diff --git a/thrift/compiler/generate/mstch_objects.cc b/thrift/compiler/generate/mstch_objects.cc index 256a277beb0..d712e1c0565 100644 --- a/thrift/compiler/generate/mstch_objects.cc +++ b/thrift/compiler/generate/mstch_objects.cc @@ -61,10 +61,12 @@ std::string mstch_base::get_option(const std::string& option) const { } void mstch_base::register_has_option(std::string key, std::string option) { - register_cached_method( - std::move(key), [this, option = std::move(option)]() -> mstch::node { - return has_option(option); - }); + register_method( + std::move(key), + std::function( + [this, option = std::move(option)]() -> mstch::node { + return has_option(option); + })); } mstch::node mstch_base::is_struct() { diff --git a/thrift/compiler/generate/mstch_objects.h b/thrift/compiler/generate/mstch_objects.h index d81e776ef57..9481ab2f38c 100644 --- a/thrift/compiler/generate/mstch_objects.h +++ b/thrift/compiler/generate/mstch_objects.h @@ -290,7 +290,7 @@ class mstch_base : public mstch::object { public: mstch_base(mstch_context& ctx, mstch_element_position pos) : context_(ctx), pos_(pos) { - register_cached_methods( + register_methods( this, { {"first?", &mstch_base::first}, @@ -432,7 +432,7 @@ class mstch_program : public mstch_base { mstch_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), program_(p) { - register_cached_methods( + register_methods( this, { {"program:name", &mstch_program::name}, @@ -510,7 +510,7 @@ class mstch_service : public mstch_base { containing_service_(containing_service) { assert(containing_service_ == nullptr || service_->is_interaction()); - register_cached_methods( + register_methods( this, { {"service:name", &mstch_service::name}, @@ -534,7 +534,7 @@ class mstch_service : public mstch_base { }); if (service_->is_interaction()) { - register_cached_methods( + register_methods( this, { {"interaction:serial?", &mstch_service::is_serial_interaction}, @@ -630,7 +630,7 @@ class mstch_function : public mstch_base { mstch_element_position pos, const t_interface* iface) : mstch_base(ctx, pos), function_(f), interface_(iface) { - register_cached_methods( + register_methods( this, { {"function:name", &mstch_function::name}, @@ -809,7 +809,7 @@ class mstch_type : public mstch_base { mstch_type(const t_type* t, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), type_(t), resolved_type_(t->get_true_type()) { - register_cached_methods( + register_methods( this, { {"type:name", &mstch_type::name}, @@ -902,7 +902,7 @@ class mstch_typedef : public mstch_base { mstch_typedef( const t_typedef* t, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), typedef_(t) { - register_cached_methods( + register_methods( this, { {"typedef:type", &mstch_typedef::type}, @@ -933,7 +933,7 @@ class mstch_struct : public mstch_base { mstch_struct( const t_structured* s, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), struct_(s) { - register_cached_methods( + register_methods( this, { {"struct:name", &mstch_struct::name}, @@ -1047,7 +1047,7 @@ class mstch_field : public mstch_base { mstch_element_position pos, const field_generator_context* field_context) : mstch_base(ctx, pos), field_(f), field_context_(field_context) { - register_cached_methods( + register_methods( this, { {"field:name", &mstch_field::name}, @@ -1197,7 +1197,7 @@ class mstch_enum : public mstch_base { mstch_enum(const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), enum_(e) { - register_cached_methods( + register_methods( this, { {"enum:name", &mstch_enum::name}, @@ -1278,7 +1278,7 @@ class mstch_enum_value : public mstch_base { mstch_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), enum_value_(ev) { - register_cached_methods( + register_methods( this, { {"enum_value:name", &mstch_enum_value::name}, @@ -1308,7 +1308,7 @@ class mstch_const : public mstch_base { current_const_(current_const), expected_type_(expected_type), field_(field) { - register_cached_methods( + register_methods( this, { {"constant:name", &mstch_const::name}, @@ -1349,7 +1349,7 @@ class mstch_const_value : public mstch_base { current_const_(current_const), expected_type_(expected_type), type_(cv->kind()) { - register_cached_methods( + register_methods( this, { {"value:bool?", &mstch_const_value::is_bool}, @@ -1453,7 +1453,7 @@ class mstch_const_map_element : public mstch_base { element_(*e), current_const_(current_const), expected_types_(expected_types) { - register_cached_methods( + register_methods( this, { {"element:key", &mstch_const_map_element::element_key}, @@ -1476,7 +1476,7 @@ class mstch_structured_annotation : public mstch_base { mstch_structured_annotation( const t_const* c, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), const_(*c) { - register_cached_methods( + register_methods( this, {{"structured_annotation:const", &mstch_structured_annotation::constant}, @@ -1508,7 +1508,7 @@ class mstch_deprecated_annotation : public mstch_base { mstch_deprecated_annotation( const t_annotation* a, mstch_context& ctx, mstch_element_position pos) : mstch_base(ctx, pos), key_(a->first), val_(a->second) { - register_cached_methods( + register_methods( this, { {"annotation:key", &mstch_deprecated_annotation::key}, diff --git a/thrift/compiler/generate/t_json_experimental_generator.cc b/thrift/compiler/generate/t_json_experimental_generator.cc index bcacfc71bb8..de84d9a75fd 100644 --- a/thrift/compiler/generate/t_json_experimental_generator.cc +++ b/thrift/compiler/generate/t_json_experimental_generator.cc @@ -70,7 +70,7 @@ class json_experimental_program : public mstch_program { json_experimental_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_program(p, ctx, pos) { - register_cached_methods( + register_methods( this, { {"program:py_namespace", @@ -89,8 +89,8 @@ class json_experimental_program : public mstch_program { // To allow rendering a brace not surrounded by whitespace, without // interfering with the `{{` `}}` used by the mustache syntax. - register_cached_method("open_object", [] { return mstch::node("{"); }); - register_cached_method("close_object", [] { return mstch::node("}"); }); + register_method("open_object", [] { return mstch::node("{"); }); + register_method("close_object", [] { return mstch::node("}"); }); } mstch::node get_py_namespace() { return program_->get_namespace("py"); } @@ -168,7 +168,7 @@ class json_experimental_service : public mstch_service { mstch_element_position pos, json_codegen_data d) : mstch_service(s, ctx, pos), data_(d) { - register_cached_methods( + register_methods( this, { {"service:lineno", &json_experimental_service::get_lineno}, @@ -199,7 +199,7 @@ class json_experimental_function : public mstch_function { const t_interface* iface, source_manager* sm) : mstch_function(f, ctx, pos, iface), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"function:lineno", &json_experimental_function::get_lineno}, @@ -225,7 +225,7 @@ class json_experimental_struct : public mstch_struct { mstch_element_position pos, source_manager* sm) : mstch_struct(s, ctx, pos), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"struct:lineno", &json_experimental_struct::get_lineno}, @@ -251,7 +251,7 @@ class json_experimental_type : public mstch_type { mstch_element_position pos, json_codegen_data d) : mstch_type(t, ctx, pos), data_(d) { - register_cached_methods( + register_methods( this, { {"type:lineno", &json_experimental_type::get_lineno}, @@ -281,7 +281,7 @@ class json_experimental_field : public mstch_field { const field_generator_context* field_context, source_manager* sm) : mstch_field(f, ctx, pos, field_context), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"field:lineno", &json_experimental_field::get_lineno}, @@ -307,7 +307,7 @@ class json_experimental_typedef : public mstch_typedef { mstch_element_position pos, source_manager* sm) : mstch_typedef(t, ctx, pos), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"typedef:lineno", &json_experimental_typedef::get_lineno}, @@ -335,7 +335,7 @@ class json_experimental_enum : public mstch_enum { mstch_element_position pos, source_manager* sm) : mstch_enum(e, ctx, pos), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"enum:empty?", &json_experimental_enum::is_empty}, @@ -361,7 +361,7 @@ class json_experimental_enum_value : public mstch_enum_value { mstch_element_position pos, source_manager* sm) : mstch_enum_value(ev, ctx, pos), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"enum_value:lineno", &json_experimental_enum_value::get_lineno}, @@ -392,7 +392,7 @@ class json_experimental_const_value : public mstch_const_value { source_manager* sm) : mstch_const_value(cv, ctx, pos, current_const, expected_type), source_mgr_(*sm) { - register_cached_methods( + register_methods( this, { {"value:integer_or_enum?", diff --git a/thrift/compiler/generate/t_mstch_cpp2_generator.cc b/thrift/compiler/generate/t_mstch_cpp2_generator.cc index a61bc9590ef..e3f72a63fe4 100644 --- a/thrift/compiler/generate/t_mstch_cpp2_generator.cc +++ b/thrift/compiler/generate/t_mstch_cpp2_generator.cc @@ -339,7 +339,7 @@ class cpp_mstch_program : public mstch_program { split_id_(split_id), split_structs_(split_structs), sm_(sm) { - register_cached_methods( + register_methods( this, {{"program:cpp_includes", &cpp_mstch_program::cpp_includes}, {"program:qualified_namespace", @@ -797,7 +797,7 @@ class cpp_mstch_service : public mstch_service { int32_t split_id = 0, int32_t split_count = 1) : mstch_service(service, ctx, pos, containing_service), sm_(sm) { - register_cached_methods( + register_methods( this, { {"service:program_name", &cpp_mstch_service::program_name}, @@ -948,7 +948,7 @@ class cpp_mstch_function : public mstch_function { std::shared_ptr cpp_ctx) : mstch_function(function, ctx, pos, iface), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"function:eb", &cpp_mstch_function::event_based}, @@ -1062,7 +1062,7 @@ class cpp_mstch_type : public mstch_type { mstch_element_position pos, std::shared_ptr cpp_ctx) : mstch_type(type, ctx, pos), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"type:resolves_to_base?", &cpp_mstch_type::resolves_to_base}, @@ -1241,7 +1241,7 @@ class cpp_mstch_typedef : public mstch_typedef { mstch_element_position pos, std::shared_ptr cpp_ctx) : mstch_typedef(t, ctx, pos), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"typedef:cpp_type", &cpp_mstch_typedef::cpp_type}, @@ -1263,7 +1263,7 @@ class cpp_mstch_struct : public mstch_struct { mstch_element_position pos, std::shared_ptr cpp_ctx) : mstch_struct(s, ctx, pos), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"struct:fields_size", &cpp_mstch_struct::fields_size}, @@ -1819,7 +1819,7 @@ class cpp_mstch_field : public mstch_field { std::shared_ptr cpp_ctx) : mstch_field(f, ctx, pos, field_context), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"field:name_hash", &cpp_mstch_field::name_hash}, @@ -2178,7 +2178,7 @@ class cpp_mstch_enum : public mstch_enum { cpp_mstch_enum( const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_enum(e, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum:empty?", &cpp_mstch_enum::is_empty}, @@ -2294,7 +2294,7 @@ class cpp_mstch_enum_value : public mstch_enum_value { cpp_mstch_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_enum_value(ev, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum_value:name_hash", &cpp_mstch_enum_value::name_hash}, @@ -2330,7 +2330,7 @@ class cpp_mstch_const : public mstch_const { std::shared_ptr cpp_ctx) : mstch_const(c, ctx, pos, current_const, expected_type, field), cpp_context_(std::move(cpp_ctx)) { - register_cached_methods( + register_methods( this, { {"constant:enum_value", &cpp_mstch_const::enum_value}, @@ -2409,7 +2409,7 @@ class cpp_mstch_const_value : public mstch_const_value { const t_const* current_const, const t_type* expected_type) : mstch_const_value(cv, ctx, pos, current_const, expected_type) { - register_cached_methods( + register_methods( this, { {"value:default_construct?", @@ -2446,7 +2446,7 @@ class cpp_mstch_deprecated_annotation : public mstch_deprecated_annotation { cpp_mstch_deprecated_annotation( const t_annotation* a, mstch_context& ctx, mstch_element_position pos) : mstch_deprecated_annotation(a, ctx, pos) { - register_cached_methods( + register_methods( this, { {"annotation:safe_key", &cpp_mstch_deprecated_annotation::safe_key}, diff --git a/thrift/compiler/generate/t_mstch_go_generator.cc b/thrift/compiler/generate/t_mstch_go_generator.cc index c81f8a23ea7..26a777f313e 100644 --- a/thrift/compiler/generate/t_mstch_go_generator.cc +++ b/thrift/compiler/generate/t_mstch_go_generator.cc @@ -71,7 +71,7 @@ class mstch_go_program : public mstch_program { mstch_element_position pos, go::codegen_data* data) : mstch_program(p, ctx, pos), data_(*data) { - register_cached_methods( + register_methods( this, { {"program:go_pkg_name", &mstch_go_program::go_pkg_name}, @@ -174,7 +174,7 @@ class mstch_go_enum : public mstch_enum { mstch_element_position pos, go::codegen_data* data) : mstch_enum(e, ctx, pos), data_(*data) { - register_cached_methods( + register_methods( this, { {"enum:go_name", &mstch_go_enum::go_name}, @@ -222,7 +222,7 @@ class mstch_go_const : public mstch_const { go::codegen_data* data) : mstch_const(c, ctx, pos, current_const, expected_type, field), data_(*data) { - register_cached_methods( + register_methods( this, { {"constant:go_name", &mstch_go_const::go_name}, @@ -265,7 +265,7 @@ class mstch_go_const_value : public mstch_const_value { : mstch_const_value(cv, ctx, pos, current_const, expected_type), data_(*data) { (void)data_; - register_cached_methods( + register_methods( this, { {"value:go_quoted_value", &mstch_go_const_value::go_quoted_value}, @@ -291,7 +291,7 @@ class mstch_go_field : public mstch_field { go::codegen_data* data) : mstch_field(f, ctx, pos, field_context), data_(*data) { (void)data_; - register_cached_methods( + register_methods( this, { {"field:go_name", &mstch_go_field::go_name}, @@ -456,7 +456,7 @@ class mstch_go_struct : public mstch_struct { mstch_element_position pos, go::codegen_data* data) : mstch_struct(s, ctx, pos), data_(*data) { - register_cached_methods( + register_methods( this, { {"struct:go_name", &mstch_go_struct::go_name}, @@ -558,7 +558,7 @@ class mstch_go_service : public mstch_service { mstch_element_position pos, go::codegen_data* data) : mstch_service(s, ctx, pos), data_(*data) { - register_cached_methods( + register_methods( this, { {"service:go_name", &mstch_go_service::go_name}, @@ -606,7 +606,7 @@ class mstch_go_function : public mstch_function { go::codegen_data* data) : mstch_function(f, ctx, pos, iface), data_(*data) { (void)data_; - register_cached_methods( + register_methods( this, { {"function:go_name", &mstch_go_function::go_name}, @@ -695,7 +695,7 @@ class mstch_go_type : public mstch_type { go::codegen_data* data) : mstch_type(t, ctx, pos), data_(*data) { (void)data_; - register_cached_methods( + register_methods( this, { {"type:go_comparable?", &mstch_go_type::is_go_comparable}, @@ -789,7 +789,7 @@ class mstch_go_typedef : public mstch_typedef { mstch_element_position pos, go::codegen_data* data) : mstch_typedef(t, ctx, pos), data_(*data) { - register_cached_methods( + register_methods( this, { {"typedef:go_name", &mstch_go_typedef::go_name}, diff --git a/thrift/compiler/generate/t_mstch_java_generator.cc b/thrift/compiler/generate/t_mstch_java_generator.cc index da451bd73d8..ed49381c3df 100644 --- a/thrift/compiler/generate/t_mstch_java_generator.cc +++ b/thrift/compiler/generate/t_mstch_java_generator.cc @@ -453,7 +453,7 @@ class mstch_java_program : public mstch_program { mstch_java_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_program(p, ctx, pos) { - register_cached_methods( + register_methods( this, { {"program:javaPackage", &mstch_java_program::java_package}, @@ -502,7 +502,7 @@ class mstch_java_struct : public mstch_struct { mstch_java_struct( const t_structured* s, mstch_context& ctx, mstch_element_position pos) : mstch_struct(s, ctx, pos) { - register_cached_methods( + register_methods( this, { {"struct:javaPackage", &mstch_java_struct::java_package}, @@ -618,7 +618,7 @@ class mstch_java_service : public mstch_service { mstch_element_position pos, const t_service* containing_service = nullptr) : mstch_service(s, ctx, pos, containing_service) { - register_cached_methods( + register_methods( this, { {"service:javaPackage", &mstch_java_service::java_package}, @@ -700,7 +700,7 @@ class mstch_java_interaction : public mstch_java_service { mstch_element_position pos, const t_service* containing_service) : mstch_java_service(interaction, ctx, pos, containing_service) { - register_cached_methods( + register_methods( this, {{"interaction:javaParentCapitalName", &mstch_java_interaction::java_parent_capital_name}}); @@ -719,29 +719,31 @@ class mstch_java_function : public mstch_function { mstch_element_position pos, const t_interface* iface) : mstch_function(f, ctx, pos, iface) { - register_cached_methods( + register_methods( this, { {"function:javaName", &mstch_java_function::java_name}, {"function:voidType", &mstch_java_function::is_void_type}, - }); - register_volatile_methods( - this, - { - {"function:nestedDepth", &mstch_java_function::get_nested_depth}, + + {"function:nestedDepth", + {with_no_caching, &mstch_java_function::get_nested_depth}}, {"function:nestedDepth++", - &mstch_java_function::increment_nested_depth}, + {with_no_caching, &mstch_java_function::increment_nested_depth}}, {"function:nestedDepth--", - &mstch_java_function::decrement_nested_depth}, - {"function:isFirstDepth?", &mstch_java_function::is_first_depth}, + {with_no_caching, &mstch_java_function::decrement_nested_depth}}, + {"function:isFirstDepth?", + {with_no_caching, &mstch_java_function::is_first_depth}}, {"function:prevNestedDepth", - &mstch_java_function::preceding_nested_depth}, + {with_no_caching, &mstch_java_function::preceding_nested_depth}}, {"function:isNested?", - &mstch_java_function::get_nested_container_flag}, + {with_no_caching, + &mstch_java_function::get_nested_container_flag}}, {"function:setIsNested", - &mstch_java_function::set_nested_container_flag}, + {with_no_caching, + &mstch_java_function::set_nested_container_flag}}, {"function:unsetIsNested", - &mstch_java_function::unset_nested_container_flag}, + {with_no_caching, + &mstch_java_function::unset_nested_container_flag}}, }); } @@ -786,7 +788,7 @@ class mstch_java_field : public mstch_field { mstch_element_position pos, const field_generator_context* field_context) : mstch_field(f, ctx, pos, field_context) { - register_cached_methods( + register_methods( this, { {"field:javaName", &mstch_java_field::java_name}, @@ -829,18 +831,21 @@ class mstch_java_field : public mstch_field { &mstch_java_field::get_field_adapter_class_name}, {"field:FieldNameUnmangled?", &mstch_java_field::is_field_name_unmangled}, - }); - register_volatile_methods( - this, - { - {"field:nestedDepth", &mstch_java_field::get_nested_depth}, - {"field:nestedDepth++", &mstch_java_field::increment_nested_depth}, - {"field:nestedDepth--", &mstch_java_field::decrement_nested_depth}, - {"field:isFirstDepth?", &mstch_java_field::is_first_depth}, + + {"field:nestedDepth", + {with_no_caching, &mstch_java_field::get_nested_depth}}, + {"field:nestedDepth++", + {with_no_caching, &mstch_java_field::increment_nested_depth}}, + {"field:nestedDepth--", + {with_no_caching, &mstch_java_field::decrement_nested_depth}}, + {"field:isFirstDepth?", + {with_no_caching, &mstch_java_field::is_first_depth}}, {"field:prevNestedDepth", - &mstch_java_field::preceding_nested_depth}, - {"field:isNested?", &mstch_java_field::get_nested_container_flag}, - {"field:setIsNested", &mstch_java_field::set_nested_container_flag}, + {with_no_caching, &mstch_java_field::preceding_nested_depth}}, + {"field:isNested?", + {with_no_caching, &mstch_java_field::get_nested_container_flag}}, + {"field:setIsNested", + {with_no_caching, &mstch_java_field::set_nested_container_flag}}, }); } @@ -1096,7 +1101,7 @@ class mstch_java_enum : public mstch_enum { mstch_java_enum( const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_enum(e, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum:javaPackage", &mstch_java_enum::java_package}, @@ -1145,7 +1150,7 @@ class mstch_java_enum_value : public mstch_enum_value { mstch_java_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_enum_value(ev, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum_value:javaConstantName", @@ -1169,7 +1174,7 @@ class mstch_java_const : public mstch_const { const t_type* expected_type, const t_field* field) : mstch_const(c, ctx, pos, current_const, expected_type, field) { - register_cached_methods( + register_methods( this, { {"constant:javaCapitalName", &mstch_java_const::java_capital_name}, @@ -1225,7 +1230,7 @@ class mstch_java_const_value : public mstch_const_value { const t_const* current_const, const t_type* expected_type) : mstch_const_value(cv, ctx, pos, current_const, expected_type) { - register_cached_methods( + register_methods( this, { {"value:quotedString", &mstch_java_const_value::quote_java_string}, @@ -1254,7 +1259,7 @@ class mstch_java_type : public mstch_type { mstch_java_type( const t_type* t, mstch_context& ctx, mstch_element_position pos) : mstch_type(t, ctx, pos) { - register_cached_methods( + register_methods( this, { {"type:isContainer?", &mstch_java_type::is_container_type}, @@ -1265,23 +1270,33 @@ class mstch_java_type : public mstch_type { &mstch_java_type::get_structured_adapter_class_name}, {"type:typeClassName", &mstch_java_type::get_structured_type_class_name}, - }); - register_volatile_methods( - this, - { - {"type:setIsMapKey", &mstch_java_type::set_is_map_key}, - {"type:isMapKey?", &mstch_java_type::get_map_key_flag}, - {"type:setIsMapValue", &mstch_java_type::set_is_map_value}, - {"type:isMapValue?", &mstch_java_type::get_map_value_flag}, - {"type:setIsNotMap", &mstch_java_type::set_is_not_map}, - {"type:setAdapter", &mstch_java_type::set_adapter}, - {"type:unsetAdapter", &mstch_java_type::unset_adapter}, - {"type:isAdapterSet?", &mstch_java_type::is_adapter_set}, - {"type:addAdapter", &mstch_java_type::add_type_adapter}, - {"type:adapterDefined?", &mstch_java_type::is_type_adapter_defined}, - {"type:lastAdapter?", &mstch_java_type::is_last_type_adapter}, - {"type:setTypeName", &mstch_java_type::set_type_name}, - {"type:getTypeName", &mstch_java_type::get_type_name}, + + {"type:setIsMapKey", + {with_no_caching, &mstch_java_type::set_is_map_key}}, + {"type:isMapKey?", + {with_no_caching, &mstch_java_type::get_map_key_flag}}, + {"type:setIsMapValue", + {with_no_caching, &mstch_java_type::set_is_map_value}}, + {"type:isMapValue?", + {with_no_caching, &mstch_java_type::get_map_value_flag}}, + {"type:setIsNotMap", + {with_no_caching, &mstch_java_type::set_is_not_map}}, + {"type:setAdapter", + {with_no_caching, &mstch_java_type::set_adapter}}, + {"type:unsetAdapter", + {with_no_caching, &mstch_java_type::unset_adapter}}, + {"type:isAdapterSet?", + {with_no_caching, &mstch_java_type::is_adapter_set}}, + {"type:addAdapter", + {with_no_caching, &mstch_java_type::add_type_adapter}}, + {"type:adapterDefined?", + {with_no_caching, &mstch_java_type::is_type_adapter_defined}}, + {"type:lastAdapter?", + {with_no_caching, &mstch_java_type::is_last_type_adapter}}, + {"type:setTypeName", + {with_no_caching, &mstch_java_type::set_type_name}}, + {"type:getTypeName", + {with_no_caching, &mstch_java_type::get_type_name}}, }); } bool isMapValueFlag = false; diff --git a/thrift/compiler/generate/t_mstch_py3_generator.cc b/thrift/compiler/generate/t_mstch_py3_generator.cc index 288b6643709..425eabb076b 100644 --- a/thrift/compiler/generate/t_mstch_py3_generator.cc +++ b/thrift/compiler/generate/t_mstch_py3_generator.cc @@ -142,7 +142,7 @@ class py3_mstch_program : public mstch_program { py3_mstch_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_program(p, ctx, pos) { - register_cached_methods( + register_methods( this, { {"program:unique_functions_by_return_type", @@ -431,7 +431,7 @@ class py3_mstch_service : public mstch_service { const t_program* prog, const t_service* containing_service = nullptr) : mstch_service(service, ctx, pos, containing_service), prog_{prog} { - register_cached_methods( + register_methods( this, { {"service:externalProgram?", &py3_mstch_service::isExternalProgram}, @@ -529,7 +529,7 @@ class py3_mstch_interaction : public py3_mstch_service { const t_service* containing_service, const t_program* prog) : py3_mstch_service(interaction, ctx, pos, prog, containing_service) { - register_cached_methods( + register_methods( this, {{"interaction:parent_service_cpp_name", &py3_mstch_interaction::parent_service_cpp_name}}); @@ -548,7 +548,7 @@ class py3_mstch_function : public mstch_function { mstch_element_position pos, const t_interface* iface) : mstch_function(f, ctx, pos, iface), cppName_(cpp2::get_name(f)) { - register_cached_methods( + register_methods( this, { {"function:eb", &py3_mstch_function::event_based}, @@ -603,7 +603,7 @@ class py3_mstch_type : public mstch_type { : mstch_type(type->get_true_type(), ctx, pos), prog_(c.program), cached_props_(get_cached_props(type, c)) { - register_cached_methods( + register_methods( this, { {"type:modulePath", &py3_mstch_type::modulePath}, @@ -634,12 +634,11 @@ class py3_mstch_type : public mstch_type { {"type:simple?", &py3_mstch_type::isSimple}, {"type:resolves_to_complex_return?", &py3_mstch_type::resolves_to_complex_return}, - }); - register_volatile_methods( - this, - { - {"type:need_module_path?", &py3_mstch_type::need_module_path}, - {"type:need_cbinding_path?", &py3_mstch_type::need_cbinding_path}, + + {"type:need_module_path?", + {with_no_caching, &py3_mstch_type::need_module_path}}, + {"type:need_cbinding_path?", + {with_no_caching, &py3_mstch_type::need_cbinding_path}}, }); } @@ -825,7 +824,7 @@ class py3_mstch_typedef : public mstch_typedef { py3_mstch_typedef( const t_typedef* type, mstch_context& ctx, mstch_element_position pos) : mstch_typedef(type, ctx, pos) { - register_cached_methods( + register_methods( this, { {"typedef:asType", &py3_mstch_typedef::asType}, @@ -842,7 +841,7 @@ class py3_mstch_struct : public mstch_struct { py3_mstch_struct( const t_structured* s, mstch_context& ctx, mstch_element_position pos) : mstch_struct(s, ctx, pos) { - register_cached_methods( + register_methods( this, { {"struct:size", &py3_mstch_struct::getSize}, @@ -950,7 +949,7 @@ class py3_mstch_field : public mstch_field { : mstch_field(field, ctx, pos, field_context), pyName_(python::get_py3_name(*field)), cppName_(cpp2::get_name(field)) { - register_cached_methods( + register_methods( this, { {"field:py_name", &py3_mstch_field::pyName}, @@ -1070,7 +1069,7 @@ class py3_mstch_enum : public mstch_enum { py3_mstch_enum( const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_enum(e, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum:flags?", &py3_mstch_enum::hasFlags}, @@ -1090,7 +1089,7 @@ class py3_mstch_enum_value : public mstch_enum_value { py3_mstch_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_enum_value(ev, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum_value:py_name", &py3_mstch_enum_value::pyName}, @@ -1117,7 +1116,7 @@ class py3_mstch_const_value : public mstch_const_value { const t_const* current_const, const t_type* expected_type) : mstch_const_value(cv, ctx, pos, current_const, expected_type) { - register_cached_methods( + register_methods( this, { {"value:value_for_bool?", &py3_mstch_const_value::is_bool_value}, @@ -1191,7 +1190,7 @@ class py3_mstch_deprecated_annotation : public mstch_deprecated_annotation { py3_mstch_deprecated_annotation( const t_annotation* a, mstch_context& ctx, mstch_element_position pos) : mstch_deprecated_annotation(a, ctx, pos) { - register_cached_methods( + register_methods( this, { {"annotation:value?", &py3_mstch_deprecated_annotation::has_value}, diff --git a/thrift/compiler/generate/t_mstch_pyi_generator.cc b/thrift/compiler/generate/t_mstch_pyi_generator.cc index 116573c6966..1f2344a3749 100644 --- a/thrift/compiler/generate/t_mstch_pyi_generator.cc +++ b/thrift/compiler/generate/t_mstch_pyi_generator.cc @@ -204,7 +204,7 @@ class pyi_mstch_program : public mstch_program { mstch_context& context, mstch_element_position position) : mstch_program(program, context, position) { - register_cached_methods( + register_methods( this, { {"program:returnTypes", &pyi_mstch_program::get_return_types}, @@ -361,7 +361,7 @@ class pyi_mstch_field : public mstch_field { mstch_element_position position, const field_generator_context* field_context) : mstch_field(field, context, position, field_context) { - register_cached_methods( + register_methods( this, { {"field:requireValue?", &pyi_mstch_field::get_require_value}, @@ -420,7 +420,7 @@ class pyi_mstch_type : public mstch_type { mstch_element_position position, const t_program* program) : mstch_type(type, context, position), program_(program) { - register_cached_methods( + register_methods( this, { {"type:modulePath", &pyi_mstch_type::get_module_path}, @@ -469,7 +469,7 @@ class pyi_mstch_service : public mstch_service { mstch_element_position position, const t_program* program) : mstch_service(service, context, position), program_(program) { - register_cached_methods( + register_methods( this, { {"service:externalProgram?", @@ -533,7 +533,7 @@ class pyi_mstch_function : public mstch_function { mstch_element_position position, const t_interface* iface) : mstch_function(function, context, position, iface) { - register_cached_methods( + register_methods( this, { {"function:isSupported?", &pyi_mstch_function::is_supported}, diff --git a/thrift/compiler/generate/t_mstch_python_capi_generator.cc b/thrift/compiler/generate/t_mstch_python_capi_generator.cc index 0ca080677da..31b0561af16 100644 --- a/thrift/compiler/generate/t_mstch_python_capi_generator.cc +++ b/thrift/compiler/generate/t_mstch_python_capi_generator.cc @@ -297,7 +297,7 @@ class python_capi_mstch_program : public mstch_program { python_capi_mstch_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_program(p, ctx, pos) { - register_cached_methods( + register_methods( this, { {"program:capi_includes", @@ -451,7 +451,7 @@ class python_capi_mstch_struct : public mstch_struct { python_capi_mstch_struct( const t_structured* s, mstch_context& ctx, mstch_element_position pos) : mstch_struct(s, ctx, pos) { - register_cached_methods( + register_methods( this, { {"struct:py_name", &python_capi_mstch_struct::py_name}, @@ -624,7 +624,7 @@ class python_capi_mstch_field : public mstch_field { const field_generator_context* field_context) : mstch_field(field, ctx, pos, field_context), py_name_(python::get_py3_name(*field)) { - register_cached_methods( + register_methods( this, { {"field:cpp_name", &python_capi_mstch_field::cpp_name}, @@ -645,7 +645,7 @@ class python_capi_mstch_enum : public mstch_enum { python_capi_mstch_enum( const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_enum(e, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum:cpp_name", &python_capi_mstch_enum::cpp_name}, diff --git a/thrift/compiler/generate/t_mstch_python_generator.cc b/thrift/compiler/generate/t_mstch_python_generator.cc index d289dcc8938..03b484073cc 100644 --- a/thrift/compiler/generate/t_mstch_python_generator.cc +++ b/thrift/compiler/generate/t_mstch_python_generator.cc @@ -150,7 +150,7 @@ class python_mstch_program : public mstch_program { python_mstch_program( const t_program* p, mstch_context& ctx, mstch_element_position pos) : mstch_program(p, ctx, pos) { - register_cached_methods( + register_methods( this, { {"program:module_path", &python_mstch_program::module_path}, @@ -173,21 +173,22 @@ class python_mstch_program : public mstch_program { &python_mstch_program::adapter_type_hint_modules}, {"program:py3_auto_migrate?", &python_mstch_program::py3_auto_migrate}, - }); - register_volatile_methods( - this, - { - {"program:is_types_file?", &python_mstch_program::is_types_file}, - {"program:is_source_file?", &python_mstch_program::is_source_file}, - {"program:is_type_stub?", &python_mstch_program::is_type_stub}, + + {"program:is_types_file?", + {with_no_caching, &python_mstch_program::is_types_file}}, + {"program:is_source_file?", + {with_no_caching, &python_mstch_program::is_source_file}}, + {"program:is_type_stub?", + {with_no_caching, &python_mstch_program::is_type_stub}}, {"program:generate_abstract_types", - &python_mstch_program::generate_abstract_types}, + {with_no_caching, &python_mstch_program::generate_abstract_types}}, {"program:generate_mutable_types", - &python_mstch_program::generate_mutable_types}, + {with_no_caching, &python_mstch_program::generate_mutable_types}}, {"program:generate_immutable_types", - &python_mstch_program::generate_immutable_types}, + {with_no_caching, + &python_mstch_program::generate_immutable_types}}, {"program:enable_abstract_types?", - &python_mstch_program::enable_abstract_types}, + {with_no_caching, &python_mstch_program::enable_abstract_types}}, }); register_has_option("program:import_static?", "import_static"); gather_included_program_namespaces(); @@ -490,7 +491,7 @@ class python_mstch_service : public mstch_service { const t_program* prog, const t_service* containing_service = nullptr) : mstch_service(s, ctx, pos, containing_service), prog_(prog) { - register_cached_methods( + register_methods( this, { {"service:module_path", &python_mstch_service::module_path}, @@ -600,7 +601,7 @@ class python_mstch_function : public mstch_function { mstch_element_position pos, const t_interface* iface) : mstch_function(f, ctx, pos, iface) { - register_cached_methods( + register_methods( this, { {"function:created_interaction", @@ -663,7 +664,7 @@ class python_mstch_type : public mstch_type { adapter_annotation_(find_structured_adapter_annotation(*type)), transitive_adapter_annotation_( get_transitive_annotation_of_adapter_or_null(*type)) { - register_cached_methods( + register_methods( this, { {"type:program_name", &python_mstch_type::program_name}, @@ -675,16 +676,17 @@ class python_mstch_type : public mstch_type { {"type:contains_unsafe_patch?", &python_mstch_type::contains_unsafe_patch}, {"type:has_adapter?", &python_mstch_type::adapter}, - }); - register_volatile_methods( - this, - { - {"type:module_name", &python_mstch_type::module_name}, - {"type:module_mangle", &python_mstch_type::module_mangle}, - {"type:patch_module_path", &python_mstch_type::patch_module_path}, - {"type:need_module_path?", &python_mstch_type::need_module_path}, + + {"type:module_name", + {with_no_caching, &python_mstch_type::module_name}}, + {"type:module_mangle", + {with_no_caching, &python_mstch_type::module_mangle}}, + {"type:patch_module_path", + {with_no_caching, &python_mstch_type::patch_module_path}}, + {"type:need_module_path?", + {with_no_caching, &python_mstch_type::need_module_path}}, {"type:need_patch_module_path?", - &python_mstch_type::need_patch_module_path}, + {with_no_caching, &python_mstch_type::need_patch_module_path}}, }); } @@ -815,7 +817,7 @@ class python_mstch_typedef : public mstch_typedef { const t_typedef* t, mstch_context& ctx, mstch_element_position pos) : mstch_typedef(t, ctx, pos), adapter_annotation_(find_structured_adapter_annotation(*t)) { - register_cached_methods( + register_methods( this, { {"typedef:has_adapter?", &python_mstch_typedef::adapter}, @@ -836,7 +838,7 @@ class python_mstch_struct : public mstch_struct { const t_structured* s, mstch_context& ctx, mstch_element_position pos) : mstch_struct(s, ctx, pos), adapter_annotation_(find_structured_adapter_annotation(*s)) { - register_cached_methods( + register_methods( this, { {"struct:py_name", &python_mstch_struct::py_name}, @@ -909,7 +911,7 @@ class python_mstch_field : public mstch_field { adapter_annotation_(find_structured_adapter_annotation(*field)), transitive_adapter_annotation_( get_transitive_annotation_of_adapter_or_null(*field)) { - register_cached_methods( + register_methods( this, { {"field:py_name", &python_mstch_field::py_name}, @@ -995,7 +997,7 @@ class python_mstch_enum : public mstch_enum { python_mstch_enum( const t_enum* e, mstch_context& ctx, mstch_element_position pos) : mstch_enum(e, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum:flags?", &python_mstch_enum::has_flags}, @@ -1018,7 +1020,7 @@ class python_mstch_enum_value : public mstch_enum_value { python_mstch_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_enum_value(ev, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum_value:py_name", &python_mstch_enum_value::py_name}, @@ -1203,7 +1205,7 @@ class python_mstch_const : public mstch_const { adapter_annotation_(find_structured_adapter_annotation(*c)), transitive_adapter_annotation_( get_transitive_annotation_of_adapter_or_null(*c)) { - register_cached_methods( + register_methods( this, { {"constant:has_adapter?", &python_mstch_const::has_adapter}, @@ -1257,7 +1259,7 @@ class python_mstch_const_value : public mstch_const_value { const t_const* current_const, const t_type* expected_type) : mstch_const_value(cv, ctx, pos, current_const, expected_type) { - register_cached_methods( + register_methods( this, { {"value:py3_enum_value_name", @@ -1369,7 +1371,7 @@ class python_mstch_deprecated_annotation : public mstch_deprecated_annotation { python_mstch_deprecated_annotation( const t_annotation* a, mstch_context& ctx, mstch_element_position pos) : mstch_deprecated_annotation(a, ctx, pos) { - register_cached_methods( + register_methods( this, { {"annotation:value?", diff --git a/thrift/compiler/generate/t_mstch_rust_generator.cc b/thrift/compiler/generate/t_mstch_rust_generator.cc index 338b50a9ccc..a22ffdbbbf8 100644 --- a/thrift/compiler/generate/t_mstch_rust_generator.cc +++ b/thrift/compiler/generate/t_mstch_rust_generator.cc @@ -646,7 +646,7 @@ class rust_mstch_program : public mstch_program { mstch_element_position pos, const rust_codegen_options* options) : mstch_program(program, ctx, pos), options_(*options) { - register_cached_methods( + register_methods( this, { {"program:direct_dependencies?", @@ -1010,7 +1010,7 @@ class rust_mstch_service : public mstch_service { for (auto function : service->get_functions()) { function_upcamel_names_.insert(camelcase(function->get_name())); } - register_cached_methods( + register_methods( this, {{"service:rust_name", &rust_mstch_service::rust_name}, {"service:rustFunctions", &rust_mstch_service::rust_functions}, @@ -1114,7 +1114,7 @@ class rust_mstch_function : public mstch_function { const std::unordered_multiset& function_upcamel_names) : mstch_function(function, ctx, pos, iface), function_upcamel_names_(function_upcamel_names) { - register_cached_methods( + register_methods( this, {{"function:rust_name", &rust_mstch_function::rust_name}, {"function:upcamel", &rust_mstch_function::rust_upcamel}, @@ -1314,7 +1314,7 @@ class rust_mstch_struct : public mstch_struct { : mstch_struct(s, ctx, pos), options_(*options), adapter_annotation_(find_structured_adapter_annotation(*s)) { - register_cached_methods( + register_methods( this, { {"struct:rust_name", &rust_mstch_struct::rust_name}, @@ -1465,7 +1465,7 @@ class rust_mstch_enum_value : public mstch_enum_value { rust_mstch_enum_value( const t_enum_value* ev, mstch_context& ctx, mstch_element_position pos) : mstch_enum_value(ev, ctx, pos) { - register_cached_methods( + register_methods( this, { {"enum_value:rust_name", &rust_mstch_enum_value::rust_name}, @@ -1486,7 +1486,7 @@ class rust_mstch_enum : public mstch_enum { mstch_element_position pos, const rust_codegen_options* options) : mstch_enum(e, ctx, pos), options_(*options) { - register_cached_methods( + register_methods( this, { {"enum:rust_name", &rust_mstch_enum::rust_name}, @@ -1566,7 +1566,7 @@ class rust_mstch_type : public mstch_type { mstch_element_position pos, const rust_codegen_options* options) : mstch_type(type, ctx, pos), options_(*options) { - register_cached_methods( + register_methods( this, { {"type:rust_name", &rust_mstch_type::rust_name}, @@ -1623,7 +1623,7 @@ class mstch_rust_value : public mstch_base { type_(step_through_typedefs(type, false)), depth_(depth), options_(options) { - register_cached_methods( + register_methods( this, { {"value:type", &mstch_rust_value::type}, @@ -1884,7 +1884,7 @@ class mstch_rust_map_entry : public mstch_base { value_type_(value_type), depth_(depth), options_(options) { - register_cached_methods( + register_methods( this, { {"entry:key", &mstch_rust_map_entry::key}, @@ -1924,7 +1924,7 @@ class mstch_rust_struct_field : public mstch_base { depth_(depth), options_(options), adapter_annotation_(find_structured_adapter_annotation(*field)) { - register_cached_methods( + register_methods( this, { {"field:key", &mstch_rust_struct_field::key}, @@ -2051,7 +2051,7 @@ class rust_mstch_const : public mstch_const { const rust_codegen_options* options) : mstch_const(c, ctx, pos, current_const, expected_type, field), options_(*options) { - register_cached_methods( + register_methods( this, { {"constant:lazy?", &rust_mstch_const::rust_lazy}, @@ -2092,7 +2092,7 @@ class rust_mstch_field : public mstch_field { : mstch_field(field, ctx, pos, field_context), options_(*options), adapter_annotation_(find_structured_adapter_annotation(*field)) { - register_cached_methods( + register_methods( this, { {"field:rust_name", &rust_mstch_field::rust_name}, @@ -2173,7 +2173,7 @@ class rust_mstch_typedef : public mstch_typedef { : mstch_typedef(t, ctx, pos), options_(*options), adapter_annotation_(find_structured_adapter_annotation(*t)) { - register_cached_methods( + register_methods( this, { {"typedef:rust_name", &rust_mstch_typedef::rust_name}, @@ -2265,7 +2265,7 @@ class rust_mstch_deprecated_annotation : public mstch_deprecated_annotation { rust_mstch_deprecated_annotation( const t_annotation* a, mstch_context& ctx, mstch_element_position pos) : mstch_deprecated_annotation(a, ctx, pos) { - register_cached_methods( + register_methods( this, { {"annotation:value?", diff --git a/thrift/compiler/generate/t_starlark_generator.cc b/thrift/compiler/generate/t_starlark_generator.cc index 4d087edae69..9aae1c0cf95 100644 --- a/thrift/compiler/generate/t_starlark_generator.cc +++ b/thrift/compiler/generate/t_starlark_generator.cc @@ -39,7 +39,7 @@ class mstch_starlark_type : public mstch_type { mstch_starlark_type( const t_type* t, mstch_context& ctx, mstch_element_position pos) : mstch_type(t, ctx, pos) { - register_cached_methods( + register_methods( this, { {"type:starlark_supported?", diff --git a/thrift/compiler/whisker/mstch_compat.h b/thrift/compiler/whisker/mstch_compat.h index 7faae2e2b78..93d4b07f80e 100644 --- a/thrift/compiler/whisker/mstch_compat.h +++ b/thrift/compiler/whisker/mstch_compat.h @@ -124,25 +124,36 @@ class object_t { }; }) {} - /* implicit */ property_descriptor(std::function method) - : bind([method = std::move(method)](Self*) -> property_dispatcher { - return [method = std::move(method), - cache = std::optional()]() mutable -> lookup_result { - if (!cache) { - cache = method(); - } - return node_ref(*cache); - }; - }) {} - - property_descriptor(with_no_caching_t, std::function method) - : bind([method = std::move(method)](Self*) -> property_dispatcher { - return [method = std::move(method), - uncache = std::optional()]() mutable -> lookup_result { - uncache = method(); - return node_ref(*uncache); - }; - }) {} + template < + typename F, + std::enable_if_t, N>>* = nullptr> + /* implicit */ property_descriptor(F&& method) + : bind( + [method = std::function(std::forward(method))]( + Self*) -> property_dispatcher { + return [method = std::move(method), + cache = std::optional()]() mutable -> lookup_result { + if (!cache) { + cache = method(); + } + return node_ref(*cache); + }; + }) {} + + template < + typename F, + std::enable_if_t, N>>* = nullptr> + property_descriptor(with_no_caching_t, F&& method) + : bind( + [method = std::function(std::forward(method))]( + Self*) -> property_dispatcher { + return + [method = std::move(method), + uncache = std::optional()]() mutable -> lookup_result { + uncache = method(); + return node_ref(*uncache); + }; + }) {} private: template @@ -165,39 +176,13 @@ class object_t { } }; - template - std::enable_if_t, N>> - register_volatile_method(std::string name, F method) { - do_register_method( - std::move(name), - property_descriptor( - with_no_caching, std::forward(method)) - .bind(nullptr)); - } - - // Cached methods are invoked at most once on the same object. - template - std::enable_if_t, N>> - register_cached_method(std::string name, F method) { - do_register_method( - std::move(name), - property_descriptor(std::forward(method)) - .bind(nullptr)); - } - - template - void register_volatile_methods( - Self* self, - const std::unordered_map& methods) { - for (const auto& method : methods) { - do_register_method( - method.first, - property_descriptor(with_no_caching, method.second).bind(self)); - } + void register_method( + std::string name, property_descriptor method) { + do_register_method(std::move(name), method.bind(nullptr)); } template - void register_cached_methods( + void register_methods( Self* self, const std::unordered_map>& methods) { diff --git a/thrift/compiler/whisker/test/mstch_compat_test.cc b/thrift/compiler/whisker/test/mstch_compat_test.cc index 510d28805db..e10816eb409 100644 --- a/thrift/compiler/whisker/test/mstch_compat_test.cc +++ b/thrift/compiler/whisker/test/mstch_compat_test.cc @@ -180,7 +180,7 @@ TEST_F(MstchCompatTest, mstch_object) { public std::enable_shared_from_this { public: object_impl() { - register_cached_methods( + register_methods( this, { {"foo:bar", &object_impl::foo_bar}, @@ -194,12 +194,12 @@ TEST_F(MstchCompatTest, mstch_object) { {"w_self_handle", &object_impl::w_self_handle}, {"w_invoke_cpp_only_method", &object_impl::w_invoke_cpp_only_method}, - }); - register_volatile_methods( - this, {{"volatile", &object_impl::volatile_func}}); - register_volatile_method( - "volatile_counter", [next = 0]() mutable -> mstch_node { - return mstch_map({{"next", fmt::format("{}", next++)}}); + {"volatile", {with_no_caching, &object_impl::volatile_func}}, + {"volatile_counter", + {with_no_caching, + [next = 0]() mutable -> mstch_node { + return mstch_map({{"next", fmt::format("{}", next++)}}); + }}}, }); }