diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.cpp index 14148dee6b4..116832639f0 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.cpp @@ -85,10 +85,10 @@ ::std::vector<::std::int32_t> const& ListOfIntsFromEnums() { -::std::string_view _fbthrift_schema_461f120cd2880445() { +::std::string_view _fbthrift_schema_f3ff3c4acd06e9b9() { return ""; } -::folly::Range _fbthrift_schema_461f120cd2880445_includes() { +::folly::Range _fbthrift_schema_f3ff3c4acd06e9b9_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.h index 905e621af11..a626218c385 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_constants.h @@ -115,8 +115,8 @@ namespace module_constants { return constEnumB_; } - FOLLY_EXPORT ::std::string_view _fbthrift_schema_461f120cd2880445(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_461f120cd2880445_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_f3ff3c4acd06e9b9(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_f3ff3c4acd06e9b9_includes(); } // namespace module_constants } // namespace some::valid::ns diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_metadata.cpp index 87d387b9070..760d8c21111 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_metadata.cpp @@ -190,7 +190,7 @@ StructMetadata<::some::valid::ns::ComplexUnion>::gen(ThriftMetadata& metadata) { module_ComplexUnion.is_union() = true; static const auto* const module_ComplexUnion_fields = new std::array{ { - { 1, "intValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }}, { 201, "opt_intValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }}, { 3, "stringValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 203, "opt_stringValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 4, "intValue2", false, std::make_unique(ThriftPrimitiveType::THRIFT_I16_TYPE), std::vector{ }}, { 6, "intValue3", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 7, "doubelValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, { 8, "boolValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 9, "union_list", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 10, "union_set", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ }}, { 11, "union_map", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 211, "opt_union_map", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 12, "enum_field", false, std::make_unique>("module.MyEnumA"), std::vector{ }}, { 13, "enum_container", false, std::make_unique(std::make_unique>("module.MyEnumA")), std::vector{ }}, { 14, "a_struct", false, std::make_unique>("module.MyStruct"), std::vector{ }}, { 15, "a_set_struct", false, std::make_unique(std::make_unique>("module.MyStruct")), std::vector{ }}, { 16, "a_union", false, std::make_unique>("module.SimpleUnion"), std::vector{ }}, { 216, "opt_a_union", false, std::make_unique>("module.SimpleUnion"), std::vector{ }}, { 17, "a_union_list", false, std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ }}, { 18, "a_union_typedef", false, std::make_unique("module.unionTypeDef", std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ }), std::vector{ }}, { 19, "a_union_typedef_list", false, std::make_unique(std::make_unique("module.unionTypeDef", std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ })), std::vector{ }}, { 20, "MyBinaryField", false, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ }}, { 21, "MyBinaryField2", false, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ }}, { 23, "MyBinaryListField4", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE)), std::vector{ }}, { 24, "ref_field", false, std::make_unique>("module.MyStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 25, "ref_field2", false, std::make_unique>("module.MyStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 26, "excp_field", false, std::make_unique>("module.AnException"), std::vector{ }}, { 27, "MyCustomField", false, std::make_unique("module.CustomProtocolType", std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::CustomProtocolAdapter") } }).cv_struct_ref(), }), std::vector{ }}, }}; + { 1, "intValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }}, { 201, "opt_intValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }}, { 3, "stringValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 203, "opt_stringValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 4, "intValue2", false, std::make_unique(ThriftPrimitiveType::THRIFT_I16_TYPE), std::vector{ }}, { 6, "intValue3", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 7, "doubelValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, { 8, "boolValue", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 9, "union_list", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 10, "union_set", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ }}, { 11, "union_map", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 211, "opt_union_map", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 12, "enum_field", false, std::make_unique>("module.MyEnumA"), std::vector{ }}, { 13, "enum_container", false, std::make_unique(std::make_unique>("module.MyEnumA")), std::vector{ }}, { 14, "a_struct", false, std::make_unique>("module.MyStruct"), std::vector{ }}, { 15, "a_set_struct", false, std::make_unique(std::make_unique>("module.MyStruct")), std::vector{ }}, { 16, "a_union", false, std::make_unique>("module.SimpleUnion"), std::vector{ }}, { 216, "opt_a_union", false, std::make_unique>("module.SimpleUnion"), std::vector{ }}, { 17, "a_union_list", false, std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ }}, { 18, "a_union_typedef", false, std::make_unique("module.unionTypeDef", std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ }), std::vector{ }}, { 19, "a_union_typedef_list", false, std::make_unique(std::make_unique("module.unionTypeDef", std::make_unique(std::make_unique>("module.SimpleUnion")), std::vector{ })), std::vector{ }}, { 20, "MyBinaryField", false, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ }}, { 21, "MyBinaryField2", false, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ }}, { 23, "MyBinaryListField4", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE)), std::vector{ }}, { 24, "ref_field", false, std::make_unique>("module.MyStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 25, "ref_field2", false, std::make_unique>("module.MyStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 26, "excp_field", false, std::make_unique>("module.AnException"), std::vector{ }}, { 27, "MyCustomField", false, std::make_unique("module.CustomProtocolType", std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::CustomProtocolAdapter") } }).cv_struct_ref(), }), std::vector{ }}, }}; for (const auto& f : *module_ComplexUnion_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -282,7 +282,7 @@ StructMetadata<::some::valid::ns::MyIncludedStruct>::gen(ThriftMetadata& metadat module_MyIncludedStruct.is_union() = false; static const auto* const module_MyIncludedStruct_fields = new std::array{ { - { 1, "MyIncludedInt", false, std::make_unique("includes.IncludedInt64", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }), std::vector{ }}, { 2, "MyIncludedStruct", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ }}, { 3, "ARefField", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 4, "ARequiredField", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ }}, }}; + { 1, "MyIncludedInt", false, std::make_unique("includes.IncludedInt64", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }), std::vector{ }}, { 2, "MyIncludedStruct", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ }}, { 3, "ARefField", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 4, "ARequiredField", false, std::make_unique("module.AStruct", std::make_unique>("includes.AStruct"), std::vector{ }), std::vector{ }}, }}; for (const auto& f : *module_MyIncludedStruct_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -305,7 +305,7 @@ StructMetadata<::some::valid::ns::AnnotatedStruct>::gen(ThriftMetadata& metadata module_AnnotatedStruct.is_union() = false; static const auto* const module_AnnotatedStruct_fields = new std::array{ { - { 1, "no_annotation", false, std::make_unique>("module.containerStruct"), std::vector{ }}, { 2, "cpp_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "cpp2_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 4, "container_with_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 5, "req_cpp_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 6, "req_cpp2_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 7, "req_container_with_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 8, "opt_cpp_unique_ref", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 9, "opt_cpp2_unique_ref", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 10, "opt_container_with_ref", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 11, "ref_type_unique", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 12, "ref_type_shared", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 13, "ref_type_const", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 14, "req_ref_type_shared", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 15, "req_ref_type_const", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 16, "req_ref_type_unique", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 17, "opt_ref_type_const", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 18, "opt_ref_type_unique", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 19, "opt_ref_type_shared", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 20, "base_type", false, std::make_unique("module.CppFakeI32", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("CppFakeI32") } }).cv_struct_ref(), }), std::vector{ }}, { 21, "list_type", false, std::make_unique("module.FollySmallVectorI64", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::small_vector") } }).cv_struct_ref(), }), std::vector{ }}, { 22, "set_type", false, std::make_unique("module.SortedVectorSetString", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }), std::vector{ }}, { 23, "map_type", false, std::make_unique("module.FakeMap", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("FakeMap") } }).cv_struct_ref(), }), std::vector{ }}, { 24, "map_struct_type", false, std::make_unique("module.UnorderedMapStruct", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique>("module.containerStruct")), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unordered_map") } }).cv_struct_ref(), }), std::vector{ }}, { 25, "iobuf_type", false, std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ }}, { 26, "iobuf_ptr", false, std::make_unique("module.IOBufPtr", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unique_ptr") } }).cv_struct_ref(), }), std::vector{ }}, { 27, "list_i32_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::list") } }).cv_struct_ref(), }}, { 28, "list_string_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::deque") } }).cv_struct_ref(), }}, { 29, "set_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }}, { 30, "map_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_map") } }).cv_struct_ref(), }}, { 31, "typedef_list_template", false, std::make_unique("module.std_list", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::list") } }).cv_struct_ref(), }), std::vector{ }}, { 32, "typedef_deque_template", false, std::make_unique("module.std_deque", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::deque") } }).cv_struct_ref(), }), std::vector{ }}, { 33, "typedef_set_template", false, std::make_unique("module.folly_set", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }), std::vector{ }}, { 34, "typedef_map_template", false, std::make_unique("module.folly_map", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_map") } }).cv_struct_ref(), }), std::vector{ }}, { 35, "indirection_a", false, std::make_unique("module.IndirectionA", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Foo") } }).cv_struct_ref(), }), std::vector{ }}, { 36, "indirection_b", false, std::make_unique(std::make_unique("module.IndirectionB", std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Bar") } }).cv_struct_ref(), })), std::vector{ }}, { 37, "indirection_c", false, std::make_unique(std::make_unique("module.IndirectionC", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Baz") } }).cv_struct_ref(), })), std::vector{ }}, { 38, "iobuf_type_val", false, std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ }}, { 39, "iobuf_ptr_val", false, std::make_unique("module.IOBufPtr", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unique_ptr") } }).cv_struct_ref(), }), std::vector{ }}, { 40, "struct_struct", false, std::make_unique>("module.containerStruct"), std::vector{ }}, }}; + { 1, "no_annotation", false, std::make_unique>("module.containerStruct"), std::vector{ }}, { 2, "cpp_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "cpp2_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 4, "container_with_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 5, "req_cpp_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 6, "req_cpp2_unique_ref", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 7, "req_container_with_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 8, "opt_cpp_unique_ref", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 9, "opt_cpp2_unique_ref", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 10, "opt_container_with_ref", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 11, "ref_type_unique", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 12, "ref_type_shared", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 13, "ref_type_const", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 14, "req_ref_type_shared", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 15, "req_ref_type_const", false, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 16, "req_ref_type_unique", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 17, "opt_ref_type_const", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 18, "opt_ref_type_unique", true, std::make_unique>("module.containerStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 19, "opt_ref_type_shared", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 20, "base_type", false, std::make_unique("module.CppFakeI32", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("CppFakeI32") } }).cv_struct_ref(), }), std::vector{ }}, { 21, "list_type", false, std::make_unique("module.FollySmallVectorI64", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::small_vector") } }).cv_struct_ref(), }), std::vector{ }}, { 22, "set_type", false, std::make_unique("module.SortedVectorSetString", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }), std::vector{ }}, { 23, "map_type", false, std::make_unique("module.FakeMap", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("FakeMap") } }).cv_struct_ref(), }), std::vector{ }}, { 24, "map_struct_type", false, std::make_unique("module.UnorderedMapStruct", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique>("module.containerStruct")), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unordered_map") } }).cv_struct_ref(), }), std::vector{ }}, { 25, "iobuf_type", false, std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ }}, { 26, "iobuf_ptr", false, std::make_unique("module.IOBufPtr", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unique_ptr") } }).cv_struct_ref(), }), std::vector{ }}, { 27, "list_i32_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::list") } }).cv_struct_ref(), }}, { 28, "list_string_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::deque") } }).cv_struct_ref(), }}, { 29, "set_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }}, { 30, "map_template", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_map") } }).cv_struct_ref(), }}, { 31, "typedef_list_template", false, std::make_unique("module.std_list", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::list") } }).cv_struct_ref(), }), std::vector{ }}, { 32, "typedef_deque_template", false, std::make_unique("module.std_deque", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("std::deque") } }).cv_struct_ref(), }), std::vector{ }}, { 33, "typedef_set_template", false, std::make_unique("module.folly_set", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_set") } }).cv_struct_ref(), }), std::vector{ }}, { 34, "typedef_map_template", false, std::make_unique("module.folly_map", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Type", { {"template", cvString("folly::sorted_vector_map") } }).cv_struct_ref(), }), std::vector{ }}, { 35, "indirection_a", false, std::make_unique("module.IndirectionA", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Foo") } }).cv_struct_ref(), }), std::vector{ }}, { 36, "indirection_b", false, std::make_unique(std::make_unique("module.IndirectionB", std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Bar") } }).cv_struct_ref(), })), std::vector{ }}, { 37, "indirection_c", false, std::make_unique(std::make_unique("module.IndirectionC", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Baz") } }).cv_struct_ref(), })), std::vector{ }}, { 38, "iobuf_type_val", false, std::make_unique("module.IOBuf", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("folly::IOBuf") } }).cv_struct_ref(), }), std::vector{ }}, { 39, "iobuf_ptr_val", false, std::make_unique("module.IOBufPtr", std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("std::unique_ptr") } }).cv_struct_ref(), }), std::vector{ }}, { 40, "struct_struct", false, std::make_unique>("module.containerStruct"), std::vector{ }}, }}; for (const auto& f : *module_AnnotatedStruct_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/src/module.thrift b/thrift/compiler/test/fixtures/mcpp2-compare/src/module.thrift index 93305e2b98e..3e1c0f47f56 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/src/module.thrift +++ b/thrift/compiler/test/fixtures/mcpp2-compare/src/module.thrift @@ -142,8 +142,10 @@ union ComplexUnion { 21: binary MyBinaryField2; 23: list MyBinaryListField4; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 24: MyStruct ref_field; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 25: MyStruct ref_field2; 26: AnException excp_field; 27: CustomProtocolType MyCustomField; @@ -249,6 +251,7 @@ struct MyIncludedStruct { 1: includes.IncludedInt64 MyIncludedInt = includes.IncludedConstant; 2: AStruct MyIncludedStruct; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: AStruct ARefField; 4: required AStruct ARequiredField; } (cpp2.declare_hash = 1, cpp2.declare_equal_to) @@ -275,16 +278,22 @@ typedef map folly_map struct AnnotatedStruct { 1: containerStruct no_annotation; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: containerStruct cpp_unique_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: containerStruct cpp2_unique_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 4: map> container_with_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 5: required containerStruct req_cpp_unique_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 6: required containerStruct req_cpp2_unique_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 7: required list req_container_with_ref; @cpp.Ref{type = cpp.RefType.Unique} 8: optional containerStruct opt_cpp_unique_ref; @@ -293,16 +302,22 @@ struct AnnotatedStruct { @cpp.Ref{type = cpp.RefType.Unique} 10: optional set opt_container_with_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 11: containerStruct ref_type_unique; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 12: containerStruct ref_type_shared; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 13: map> ref_type_const; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 14: required containerStruct req_ref_type_shared; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 15: required containerStruct req_ref_type_const; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 16: required list req_ref_type_unique; @cpp.Ref{type = cpp.RefType.Shared} 17: optional containerStruct opt_ref_type_const; diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.cpp index e7726c1f864..3c662a1fc7a 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.cpp @@ -18,10 +18,10 @@ namespace test::fixtures::python_capi { namespace module_constants { -::std::string_view _fbthrift_schema_547276426adfb34f() { +::std::string_view _fbthrift_schema_e4876d5bf5fad44e() { return ""; } -::folly::Range _fbthrift_schema_547276426adfb34f_includes() { +::folly::Range _fbthrift_schema_e4876d5bf5fad44e_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.h index 4c903624d42..1167901680e 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_constants.h @@ -14,8 +14,8 @@ namespace test::fixtures::python_capi { /** Glean {"file": "thrift/compiler/test/fixtures/python_capi/src/module.thrift"} */ namespace module_constants { - FOLLY_EXPORT ::std::string_view _fbthrift_schema_547276426adfb34f(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_547276426adfb34f_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_e4876d5bf5fad44e(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_e4876d5bf5fad44e_includes(); } // namespace module_constants } // namespace test::fixtures::python_capi diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp index f84867babeb..6eea435befe 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp @@ -295,7 +295,7 @@ StructMetadata<::test::fixtures::python_capi::ComposeStruct>::gen(ThriftMetadata module_ComposeStruct.is_union() = false; static const auto* const module_ComposeStruct_fields = new std::array{ { - { 1, "enum_", false, std::make_unique>("module.MyEnum"), std::vector{ }}, { 2, "renamed_", false, std::make_unique>("module.AnnoyingEnum"), std::vector{ }}, { 3, "primitive", false, std::make_unique>("module.PrimitiveStruct"), std::vector{ }}, { 4, "aliased", false, std::make_unique("module.ListAlias", std::make_unique>("module.ListStruct"), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 6, "xstruct", false, std::make_unique>("thrift_dep.DepStruct"), std::vector{ }}, { 5, "xenum", false, std::make_unique>("thrift_dep.DepEnum"), std::vector{ }}, { 8, "serial_struct", false, std::make_unique>("serialized_dep.SerializedStruct"), std::vector{ }}, { 7, "friends", false, std::make_unique(std::make_unique>("thrift_dep.DepStruct")), std::vector{ }}, { 9, "serial_union", false, std::make_unique>("serialized_dep.SerializedUnion"), std::vector{ }}, { 10, "serial_error", false, std::make_unique>("serialized_dep.SerializedError"), std::vector{ }}, }}; + { 1, "enum_", false, std::make_unique>("module.MyEnum"), std::vector{ }}, { 2, "renamed_", false, std::make_unique>("module.AnnoyingEnum"), std::vector{ }}, { 3, "primitive", false, std::make_unique>("module.PrimitiveStruct"), std::vector{ }}, { 4, "aliased", false, std::make_unique("module.ListAlias", std::make_unique>("module.ListStruct"), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 6, "xstruct", false, std::make_unique>("thrift_dep.DepStruct"), std::vector{ }}, { 5, "xenum", false, std::make_unique>("thrift_dep.DepEnum"), std::vector{ }}, { 8, "serial_struct", false, std::make_unique>("serialized_dep.SerializedStruct"), std::vector{ }}, { 7, "friends", false, std::make_unique(std::make_unique>("thrift_dep.DepStruct")), std::vector{ }}, { 9, "serial_union", false, std::make_unique>("serialized_dep.SerializedUnion"), std::vector{ }}, { 10, "serial_error", false, std::make_unique>("serialized_dep.SerializedError"), std::vector{ }}, }}; for (const auto& f : *module_ComposeStruct_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -318,7 +318,7 @@ StructMetadata<::test::fixtures::python_capi::Shallot>::gen(ThriftMetadata& meta module_Onion.is_union() = true; static const auto* const module_Onion_fields = new std::array{ { - { 1, "myEnum", false, std::make_unique>("module.MyEnum"), std::vector{ }}, { 2, "myStruct", false, std::make_unique>("module.PrimitiveStruct"), std::vector{ }}, { 6, "intSet", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ *cvStruct("thrift.Box", { }).cv_struct_ref(), }}, { 4, "myString", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 8, "doubleList", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 9, "strMap", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 10, "adapted_int", false, std::make_unique("id.ProtocolId", std::make_unique("id.ExternId", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("thrift.Experimental", { }).cv_struct_ref(), }), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::type::detail::StrongIntegerAdapter<::apache::thrift::type::ProtocolId>") } }).cv_struct_ref(), }), std::vector{ }}, }}; + { 1, "myEnum", false, std::make_unique>("module.MyEnum"), std::vector{ }}, { 2, "myStruct", false, std::make_unique>("module.PrimitiveStruct"), std::vector{ }}, { 6, "intSet", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector{ *cvStruct("thrift.Box", { }).cv_struct_ref(), }}, { 4, "myString", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 8, "doubleList", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 9, "strMap", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 10, "adapted_int", false, std::make_unique("id.ProtocolId", std::make_unique("id.ExternId", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("thrift.Experimental", { }).cv_struct_ref(), }), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::type::detail::StrongIntegerAdapter<::apache::thrift::type::ProtocolId>") } }).cv_struct_ref(), }), std::vector{ }}, }}; for (const auto& f : *module_Onion_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py index 1c5187eb069..c9ab8027138 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py @@ -488,6 +488,7 @@ def _fbthrift_gen_metadata_struct_ComposeStruct(metadata_struct: _fbthrift_metad ]), _fbthrift_metadata.ThriftField(id=4, type=_fbthrift_metadata.ThriftType(t_struct=_fbthrift_metadata.ThriftStructType(name="module.ListStruct")), name="aliased", is_optional=False, structured_annotations=[ _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Ref"), fields= { "type": _fbthrift_metadata.ThriftConstValue(cv_integer=1), }), + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.AllowLegacyNonOptionalRef"), fields= { }), ]), _fbthrift_metadata.ThriftField(id=5, type=_fbthrift_metadata.ThriftType(t_enum=_fbthrift_metadata.ThriftEnumType(name="thrift_dep.DepEnum")), name="xenum", is_optional=False, structured_annotations=[ ]), @@ -543,9 +544,11 @@ def _fbthrift_gen_metadata_struct_Onion(metadata_struct: _fbthrift_metadata.Thri ]), _fbthrift_metadata.ThriftField(id=8, type=_fbthrift_metadata.ThriftType(t_list=_fbthrift_metadata.ThriftListType(valueType=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_DOUBLE_TYPE))), name="doubleList", is_optional=False, structured_annotations=[ _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Ref"), fields= { "type": _fbthrift_metadata.ThriftConstValue(cv_integer=1), }), + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.AllowLegacyNonOptionalRef"), fields= { }), ]), _fbthrift_metadata.ThriftField(id=9, type=_fbthrift_metadata.ThriftType(t_map=_fbthrift_metadata.ThriftMapType(keyType=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_BINARY_TYPE),valueType=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_STRING_TYPE))), name="strMap", is_optional=False, structured_annotations=[ _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Ref"), fields= { "type": _fbthrift_metadata.ThriftConstValue(cv_integer=0), }), + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.AllowLegacyNonOptionalRef"), fields= { }), ]), _fbthrift_metadata.ThriftField(id=10, type=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I64_TYPE), name="adapted_int", is_optional=False, structured_annotations=[ ]), diff --git a/thrift/compiler/test/fixtures/python_capi/src/module.thrift b/thrift/compiler/test/fixtures/python_capi/src/module.thrift index 4983eb50382..78cb97bca9c 100644 --- a/thrift/compiler/test/fixtures/python_capi/src/module.thrift +++ b/thrift/compiler/test/fixtures/python_capi/src/module.thrift @@ -183,6 +183,7 @@ struct ComposeStruct { 2: AnnoyingEnum renamed_; 3: PrimitiveStruct primitive; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 4: ListAlias aliased; 6: thrift_dep.DepStruct xstruct; 5: thrift_dep.DepEnum xenum; @@ -200,8 +201,10 @@ union Onion { 6: set intSet; 4: string myString; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 8: list doubleList; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 9: map strMap; 10: id.ProtocolId adapted_int; } diff --git a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.cpp index fdb3564baa4..34b196b27cb 100644 --- a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.cpp @@ -34,10 +34,10 @@ ::cpp2::StructWithRefTypeSharedConst const& kStructWithRefTypeSharedConst() { } -::std::string_view _fbthrift_schema_1a3968d5a44d4338() { +::std::string_view _fbthrift_schema_5aa2598542e3e360() { return ""; } -::folly::Range _fbthrift_schema_1a3968d5a44d4338_includes() { +::folly::Range _fbthrift_schema_5aa2598542e3e360_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.h index 4f4e88707a2..57ea71081b3 100644 --- a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_constants.h @@ -26,8 +26,8 @@ namespace module_constants { /** Glean {"constant": "kStructWithRefTypeSharedConst"} */ ::cpp2::StructWithRefTypeSharedConst const& kStructWithRefTypeSharedConst(); - FOLLY_EXPORT ::std::string_view _fbthrift_schema_1a3968d5a44d4338(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_1a3968d5a44d4338_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_5aa2598542e3e360(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_5aa2598542e3e360_includes(); } // namespace module_constants } // namespace cpp2 diff --git a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_metadata.cpp index ad4a3299b81..ace0dbb3faa 100644 --- a/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/refs/out/cpp2/gen-cpp2/module_metadata.cpp @@ -62,7 +62,7 @@ StructMetadata<::cpp2::MyUnion>::gen(ThriftMetadata& metadata) { module_MyUnion.is_union() = true; static const auto* const module_MyUnion_fields = new std::array{ { - { 1, "anInteger", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "aString", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "anInteger", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "aString", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_MyUnion_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -85,7 +85,7 @@ StructMetadata<::cpp2::NonTriviallyDestructibleUnion>::gen(ThriftMetadata& metad module_NonTriviallyDestructibleUnion.is_union() = true; static const auto* const module_NonTriviallyDestructibleUnion_fields = new std::array{ { - { 1, "int_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, }}; + { 1, "int_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_NonTriviallyDestructibleUnion_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -108,7 +108,7 @@ StructMetadata<::cpp2::MyField>::gen(ThriftMetadata& metadata) { module_MyField.is_union() = false; static const auto* const module_MyField_fields = new std::array{ { - { 1, "opt_value", true, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "value", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 4, "opt_enum_value", true, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 5, "enum_value", false, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 6, "req_enum_value", false, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 7, "opt_str_value", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 8, "str_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 9, "req_str_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "opt_value", true, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "value", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "req_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 4, "opt_enum_value", true, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 5, "enum_value", false, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 6, "req_enum_value", false, std::make_unique>("module.MyEnum"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 7, "opt_str_value", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 8, "str_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 9, "req_str_value", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_MyField_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -131,7 +131,7 @@ StructMetadata<::cpp2::MyStruct>::gen(ThriftMetadata& metadata) { module_MyStruct.is_union() = false; static const auto* const module_MyStruct_fields = new std::array{ { - { 1, "opt_ref", true, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "ref", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_ref", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "opt_ref", true, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "ref", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "req_ref", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_MyStruct_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -154,7 +154,7 @@ StructMetadata<::cpp2::StructWithUnion>::gen(ThriftMetadata& metadata) { module_StructWithUnion.is_union() = false; static const auto* const module_StructWithUnion_fields = new std::array{ { - { 1, "u", false, std::make_unique>("module.MyUnion"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "aDouble", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "f", false, std::make_unique>("module.MyField"), std::vector{ }}, }}; + { 1, "u", false, std::make_unique>("module.MyUnion"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "aDouble", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "f", false, std::make_unique>("module.MyField"), std::vector{ }}, }}; for (const auto& f : *module_StructWithUnion_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -200,7 +200,7 @@ StructMetadata<::cpp2::StructWithContainers>::gen(ThriftMetadata& metadata) { module_StructWithContainers.is_union() = false; static const auto* const module_StructWithContainers_fields = new std::array{ { - { 1, "list_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "set_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "map_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 4, "list_ref_unique", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 5, "set_ref_shared", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 6, "list_ref_shared_const", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, }}; + { 1, "list_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "set_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "map_ref", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 4, "list_ref_unique", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 5, "set_ref_shared", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 6, "list_ref_shared_const", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithContainers_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -223,7 +223,7 @@ StructMetadata<::cpp2::StructWithSharedConst>::gen(ThriftMetadata& metadata) { module_StructWithSharedConst.is_union() = false; static const auto* const module_StructWithSharedConst_fields = new std::array{ { - { 1, "opt_shared_const", true, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 2, "shared_const", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 3, "req_shared_const", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, }}; + { 1, "opt_shared_const", true, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 2, "shared_const", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "req_shared_const", false, std::make_unique>("module.MyField"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithSharedConst_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -257,7 +257,7 @@ StructMetadata<::cpp2::StructWithRef>::gen(ThriftMetadata& metadata) { module_StructWithRef.is_union() = false; static const auto* const module_StructWithRef_fields = new std::array{ { - { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithRef_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -397,7 +397,7 @@ StructMetadata<::cpp2::StructWithRefTypeUnique>::gen(ThriftMetadata& metadata) { module_StructWithRefTypeUnique.is_union() = false; static const auto* const module_StructWithRefTypeUnique_fields = new std::array{ { - { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithRefTypeUnique_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -420,7 +420,7 @@ StructMetadata<::cpp2::StructWithRefTypeShared>::gen(ThriftMetadata& metadata) { module_StructWithRefTypeShared.is_union() = false; static const auto* const module_StructWithRefTypeShared_fields = new std::array{ { - { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, }}; + { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithRefTypeShared_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -443,7 +443,7 @@ StructMetadata<::cpp2::StructWithRefTypeSharedConst>::gen(ThriftMetadata& metada module_StructWithRefTypeSharedConst.is_union() = false; static const auto* const module_StructWithRefTypeSharedConst_fields = new std::array{ { - { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, }}; + { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "opt_field", true, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 3, "req_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithRefTypeSharedConst_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -466,7 +466,7 @@ StructMetadata<::cpp2::StructWithRefAndAnnotCppNoexceptMoveCtor>::gen(ThriftMeta module_StructWithRefAndAnnotCppNoexceptMoveCtor.is_union() = false; static const auto* const module_StructWithRefAndAnnotCppNoexceptMoveCtor_fields = new std::array{ { - { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "def_field", false, std::make_unique>("module.Empty"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithRefAndAnnotCppNoexceptMoveCtor_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; @@ -489,7 +489,7 @@ StructMetadata<::cpp2::StructWithString>::gen(ThriftMetadata& metadata) { module_StructWithString.is_union() = false; static const auto* const module_StructWithString_fields = new std::array{ { - { 1, "def_unique_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 2, "def_shared_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 3, "def_shared_string_const_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 4, "unique_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 5, "shared_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, }}; + { 1, "def_unique_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 2, "def_shared_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 3, "def_shared_string_const_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 4, "unique_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 5, "shared_string_ref", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_StructWithString_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/refs/out/rust/gen-rust/types.rs b/thrift/compiler/test/fixtures/refs/out/rust/gen-rust/types.rs index 22910107e7f..b15c8963fe0 100644 --- a/thrift/compiler/test/fixtures/refs/out/rust/gen-rust/types.rs +++ b/thrift/compiler/test/fixtures/refs/out/rust/gen-rust/types.rs @@ -605,6 +605,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyUnion { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -617,6 +626,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyUnion { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -731,6 +749,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for NonTriviallyDestructibleUnion { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -933,6 +960,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { @@ -945,6 +981,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 4 => { @@ -969,6 +1014,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 6 => { @@ -981,6 +1035,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 7 => { @@ -1005,6 +1068,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 9 => { @@ -1017,6 +1089,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyField { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -1162,6 +1243,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyStruct { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { @@ -1174,6 +1264,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for MyStruct { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -1305,6 +1404,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithUnion { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -1317,6 +1425,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithUnion { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { }, @@ -1592,6 +1709,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -1604,6 +1730,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { @@ -1616,6 +1751,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 4 => { @@ -1628,6 +1772,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 5 => { @@ -1640,6 +1793,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 6 => { @@ -1652,6 +1814,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithContainers { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -1797,6 +1968,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithSharedConst { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { @@ -1809,6 +1989,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithSharedConst { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -2036,6 +2225,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRef { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -2060,6 +2258,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRef { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -3012,6 +3219,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeUnique { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -3036,6 +3252,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeUnique { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -3169,6 +3394,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeShared { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -3193,6 +3427,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeShared { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -3326,6 +3569,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeSharedConst { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -3350,6 +3602,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefTypeSharedConst { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -3463,6 +3724,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithRefAndAnnotCppNoexcep let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } @@ -3612,6 +3882,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithString { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 2 => { @@ -3624,6 +3903,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithString { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 3 => { @@ -3636,6 +3924,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithString { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 4 => { @@ -3648,6 +3945,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithString { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 5 => { @@ -3660,6 +3966,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for StructWithString { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } diff --git a/thrift/compiler/test/fixtures/refs/src/module.thrift b/thrift/compiler/test/fixtures/refs/src/module.thrift index 1244df5d872..18e17c70cf5 100644 --- a/thrift/compiler/test/fixtures/refs/src/module.thrift +++ b/thrift/compiler/test/fixtures/refs/src/module.thrift @@ -27,13 +27,16 @@ enum MyEnum { union MyUnion { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: i32 anInteger; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: string aString; } union NonTriviallyDestructibleUnion { @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 1: i32 int_field; } @@ -41,22 +44,28 @@ struct MyField { @cpp.Ref{type = cpp.RefType.Unique} 1: optional i64 opt_value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: i64 value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: required i64 req_value; @cpp.Ref{type = cpp.RefType.Unique} 4: optional MyEnum opt_enum_value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 5: MyEnum enum_value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 6: required MyEnum req_enum_value; @cpp.Ref{type = cpp.RefType.Unique} 7: optional string opt_str_value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 8: string str_value; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 9: required string req_str_value; } @@ -64,15 +73,19 @@ struct MyStruct { @cpp.Ref{type = cpp.RefType.Unique} 1: optional MyField opt_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: MyField ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: required MyField req_ref; } struct StructWithUnion { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: MyUnion u; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: double aDouble; 3: MyField f; } @@ -84,16 +97,22 @@ struct RecursiveStruct { struct StructWithContainers { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: list list_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 2: set set_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: map map_ref; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 4: list list_ref_unique; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 5: set set_ref_shared; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 6: list list_ref_shared_const; } @@ -101,8 +120,10 @@ struct StructWithSharedConst { @cpp.Ref{type = cpp.RefType.Shared} 1: optional MyField opt_shared_const; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 2: MyField shared_const; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 3: required MyField req_shared_const; } @@ -116,10 +137,12 @@ struct Empty {} struct StructWithRef { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: Empty def_field; @cpp.Ref{type = cpp.RefType.Unique} 2: optional Empty opt_field; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: required Empty req_field; } @@ -178,10 +201,12 @@ const StructWithRef kStructWithRef = { struct StructWithRefTypeUnique { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: Empty def_field; @cpp.Ref{type = cpp.RefType.Unique} 2: optional Empty opt_field; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 3: required Empty req_field; } @@ -193,10 +218,12 @@ const StructWithRefTypeUnique kStructWithRefTypeUnique = { struct StructWithRefTypeShared { @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 1: Empty def_field; @cpp.Ref{type = cpp.RefType.SharedMutable} 2: optional Empty opt_field; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 3: required Empty req_field; } @@ -208,10 +235,12 @@ const StructWithRefTypeShared kStructWithRefTypeShared = { struct StructWithRefTypeSharedConst { @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 1: Empty def_field; @cpp.Ref{type = cpp.RefType.Shared} 2: optional Empty opt_field; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 3: required Empty req_field; } @@ -223,18 +252,24 @@ const StructWithRefTypeSharedConst kStructWithRefTypeSharedConst = { struct StructWithRefAndAnnotCppNoexceptMoveCtor { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: Empty def_field; } struct StructWithString { @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 1: string def_unique_string_ref = "..."; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 2: string def_shared_string_ref = "..."; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 3: string def_shared_string_const_ref = "..."; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 4: string unique_string_ref; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 5: string shared_string_ref; } diff --git a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.cpp index e3824d27880..8210234ffa5 100644 --- a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.cpp @@ -14,10 +14,10 @@ namespace cpp2 { namespace module_constants { -::std::string_view _fbthrift_schema_16d25f1b9abc78f8() { +::std::string_view _fbthrift_schema_79fef6ae2eeda778() { return ""; } -::folly::Range _fbthrift_schema_16d25f1b9abc78f8_includes() { +::folly::Range _fbthrift_schema_79fef6ae2eeda778_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.h index 5efcd40cbc5..66147123f4e 100644 --- a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_constants.h @@ -14,8 +14,8 @@ namespace cpp2 { /** Glean {"file": "thrift/compiler/test/fixtures/templated-deserialize/src/module.thrift"} */ namespace module_constants { - FOLLY_EXPORT ::std::string_view _fbthrift_schema_16d25f1b9abc78f8(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_16d25f1b9abc78f8_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_79fef6ae2eeda778(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_79fef6ae2eeda778_includes(); } // namespace module_constants } // namespace cpp2 diff --git a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_metadata.cpp index 1e7505168f3..926966cfb4e 100644 --- a/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/templated-deserialize/out/cpp2/gen-cpp2/module_metadata.cpp @@ -72,7 +72,7 @@ StructMetadata<::cpp2::containerStruct>::gen(ThriftMetadata& metadata) { module_containerStruct.is_union() = false; static const auto* const module_containerStruct_fields = new std::array{ { - { 1, "fieldA", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 2, "fieldB", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)), std::vector{ }}, { 3, "fieldC", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 4, "fieldD", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 5, "fieldE", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 6, "fieldF", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)))), std::vector{ }}, { 7, "fieldG", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)))), std::vector{ }}, { 8, "fieldH", false, std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::vector{ }}, { 9, "fieldI", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 10, "fieldJ", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::vector{ }}, { 11, "fieldK", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))))), std::vector{ }}, { 12, "fieldL", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)))), std::vector{ }}, { 13, "fieldM", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ }}, { 14, "fieldN", false, std::make_unique(std::make_unique("module.IndirectionA", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Foo") } }).cv_struct_ref(), })), std::vector{ }}, { 15, "fieldO", false, std::make_unique(std::make_unique("module.IndirectionB", std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Bar") } }).cv_struct_ref(), })), std::vector{ }}, { 16, "fieldP", false, std::make_unique(std::make_unique("module.IndirectionC", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Baz") } }).cv_struct_ref(), })), std::vector{ }}, { 17, "fieldQ", false, std::make_unique>("module.MyEnumA"), std::vector{ }}, { 18, "fieldR", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 19, "fieldS", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 20, "fieldT", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, { 21, "fieldU", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 23, "fieldX", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "fieldA", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 2, "fieldB", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)), std::vector{ }}, { 3, "fieldC", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 4, "fieldD", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 5, "fieldE", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 6, "fieldF", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)))), std::vector{ }}, { 7, "fieldG", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)))), std::vector{ }}, { 8, "fieldH", false, std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::vector{ }}, { 9, "fieldI", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 10, "fieldJ", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::vector{ }}, { 11, "fieldK", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))))), std::vector{ }}, { 12, "fieldL", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)))), std::vector{ }}, { 13, "fieldM", false, std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::make_unique(std::make_unique(std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE))), std::vector{ }}, { 14, "fieldN", false, std::make_unique(std::make_unique("module.IndirectionA", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Foo") } }).cv_struct_ref(), })), std::vector{ }}, { 15, "fieldO", false, std::make_unique(std::make_unique("module.IndirectionB", std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Bar") } }).cv_struct_ref(), })), std::vector{ }}, { 16, "fieldP", false, std::make_unique(std::make_unique("module.IndirectionC", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ *cvStruct("cpp.Type", { {"name", cvString("Baz") } }).cv_struct_ref(), })), std::vector{ }}, { 17, "fieldQ", false, std::make_unique>("module.MyEnumA"), std::vector{ }}, { 18, "fieldR", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE)), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 19, "fieldS", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 20, "fieldT", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 21, "fieldU", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 23, "fieldX", false, std::make_unique>("module.SmallStruct"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_containerStruct_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/templated-deserialize/src/module.thrift b/thrift/compiler/test/fixtures/templated-deserialize/src/module.thrift index 2ac669b012b..4ffa3e7b965 100644 --- a/thrift/compiler/test/fixtures/templated-deserialize/src/module.thrift +++ b/thrift/compiler/test/fixtures/templated-deserialize/src/module.thrift @@ -56,13 +56,18 @@ struct containerStruct { 16: list fieldP; 17: MyEnumA fieldQ; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 18: map fieldR; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 19: SmallStruct fieldS; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 20: SmallStruct fieldT; @cpp.Ref{type = cpp.RefType.Shared} + @cpp.AllowLegacyNonOptionalRef 21: SmallStruct fieldU; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 23: SmallStruct fieldX; } diff --git a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.cpp index a30551aca9b..62abdccccf3 100644 --- a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.cpp @@ -15,10 +15,10 @@ namespace apache::thrift::fixtures::types { namespace module_constants { -::std::string_view _fbthrift_schema_e891a7857e533163() { +::std::string_view _fbthrift_schema_cbf7f73e50f28c81() { return ""; } -::folly::Range _fbthrift_schema_e891a7857e533163_includes() { +::folly::Range _fbthrift_schema_cbf7f73e50f28c81_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.h index 5de1c936273..dafc97ed8a8 100644 --- a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_constants.h @@ -14,8 +14,8 @@ namespace apache::thrift::fixtures::types { /** Glean {"file": "thrift/compiler/test/fixtures/types/src/module.thrift"} */ namespace module_constants { - FOLLY_EXPORT ::std::string_view _fbthrift_schema_e891a7857e533163(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_e891a7857e533163_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_cbf7f73e50f28c81(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_cbf7f73e50f28c81_includes(); } // namespace module_constants } // namespace apache::thrift::fixtures::types diff --git a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_metadata.cpp index d4fa489f9d6..2586bd3fbb5 100644 --- a/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/types/out/cpp2/gen-cpp2/module_metadata.cpp @@ -721,7 +721,7 @@ StructMetadata<::apache::thrift::fixtures::types::AllocatorAware>::gen(ThriftMet module_AllocatorAware.is_union() = false; static const auto* const module_AllocatorAware_fields = new std::array{ { - { 1, "aa_list", false, std::make_unique("module.list_i32_9187", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 2, "aa_set", false, std::make_unique("module.set_i32_7070", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 3, "aa_map", false, std::make_unique("module.map_i32_i32_9565", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 4, "aa_string", false, std::make_unique("module.string_5252", std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }), std::vector{ }}, { 5, "not_a_container", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 6, "aa_unique", false, std::make_unique("module.i32_9314", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 7, "aa_shared", false, std::make_unique("module.i32_9314", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), }}, }}; + { 1, "aa_list", false, std::make_unique("module.list_i32_9187", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 2, "aa_set", false, std::make_unique("module.set_i32_7070", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 3, "aa_map", false, std::make_unique("module.map_i32_i32_9565", std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }), std::vector{ }}, { 4, "aa_string", false, std::make_unique("module.string_5252", std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }), std::vector{ }}, { 5, "not_a_container", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 6, "aa_unique", false, std::make_unique("module.i32_9314", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 7, "aa_shared", false, std::make_unique("module.i32_9314", std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(2) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_AllocatorAware_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/types/out/hack/gen-hack/module_types.php b/thrift/compiler/test/fixtures/types/out/hack/gen-hack/module_types.php index ae9708646fc..8db91169161 100644 --- a/thrift/compiler/test/fixtures/types/out/hack/gen-hack/module_types.php +++ b/thrift/compiler/test/fixtures/types/out/hack/gen-hack/module_types.php @@ -4853,6 +4853,10 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot "type" => \facebook\thrift\annotation\cpp\RefType::Unique, ) ), + '\facebook\thrift\annotation\cpp\AllowLegacyNonOptionalRef' => \facebook\thrift\annotation\cpp\AllowLegacyNonOptionalRef::fromShape( + shape( + ) + ), ], 'type' => dict[], ), @@ -4863,6 +4867,10 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot "type" => \facebook\thrift\annotation\cpp\RefType::SharedMutable, ) ), + '\facebook\thrift\annotation\cpp\AllowLegacyNonOptionalRef' => \facebook\thrift\annotation\cpp\AllowLegacyNonOptionalRef::fromShape( + shape( + ) + ), ], 'type' => dict[], ), diff --git a/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_metadata.py b/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_metadata.py index cd7195ce9c5..35d5f049cee 100644 --- a/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_metadata.py +++ b/thrift/compiler/test/fixtures/types/out/python/gen-python/apache/thrift/fixtures/types/module/thrift_metadata.py @@ -865,9 +865,11 @@ def _fbthrift_gen_metadata_struct_AllocatorAware(metadata_struct: _fbthrift_meta ]), _fbthrift_metadata.ThriftField(id=6, type=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I32_TYPE), name="aa_unique", is_optional=False, structured_annotations=[ _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Ref"), fields= { "type": _fbthrift_metadata.ThriftConstValue(cv_integer=0), }), + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.AllowLegacyNonOptionalRef"), fields= { }), ]), _fbthrift_metadata.ThriftField(id=7, type=_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I32_TYPE), name="aa_shared", is_optional=False, structured_annotations=[ _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Ref"), fields= { "type": _fbthrift_metadata.ThriftConstValue(cv_integer=2), }), + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.AllowLegacyNonOptionalRef"), fields= { }), ]), ] struct_dict = dict(metadata_struct.structs) diff --git a/thrift/compiler/test/fixtures/types/out/rust/gen-rust/types.rs b/thrift/compiler/test/fixtures/types/out/rust/gen-rust/types.rs index f5e05909f70..07cd13e9238 100644 --- a/thrift/compiler/test/fixtures/types/out/rust/gen-rust/types.rs +++ b/thrift/compiler/test/fixtures/types/out/rust/gen-rust/types.rs @@ -4929,6 +4929,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for AllocatorAware { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, 7 => { @@ -4941,6 +4950,15 @@ impl ::fbthrift::metadata::ThriftAnnotations for AllocatorAware { let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); return r.take(); } + + if type_id == ::std::any::TypeId::of::() { + let mut tmp = ::std::option::Option::Some(cpp__types::AllowLegacyNonOptionalRef { + ..::std::default::Default::default() + }); + let r: &mut dyn ::std::any::Any = &mut tmp; + let r: &mut ::std::option::Option = r.downcast_mut().unwrap(); + return r.take(); + } }, _ => {} } diff --git a/thrift/compiler/test/fixtures/types/src/module.thrift b/thrift/compiler/test/fixtures/types/src/module.thrift index 5c924d85125..248d757bc89 100644 --- a/thrift/compiler/test/fixtures/types/src/module.thrift +++ b/thrift/compiler/test/fixtures/types/src/module.thrift @@ -214,8 +214,10 @@ struct AllocatorAware { 4: string_5252 aa_string; 5: i32 not_a_container; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 6: i32_9314 aa_unique; @cpp.Ref{type = cpp.RefType.SharedMutable} + @cpp.AllowLegacyNonOptionalRef 7: i32_9314 aa_shared; } (cpp.allocator = "some_allocator") diff --git a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.cpp b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.cpp index 569b04c124e..db86f8aa6fc 100644 --- a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.cpp +++ b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.cpp @@ -20,10 +20,10 @@ namespace module_constants { -::std::string_view _fbthrift_schema_c10aed29f43b19bb() { +::std::string_view _fbthrift_schema_40bdae2065fd0caf() { return ""; } -::folly::Range _fbthrift_schema_c10aed29f43b19bb_includes() { +::folly::Range _fbthrift_schema_40bdae2065fd0caf_includes() { return {}; } diff --git a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.h b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.h index 7ed1f039bac..98a58b7e2ce 100644 --- a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.h +++ b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_constants.h @@ -42,8 +42,8 @@ namespace module_constants { return constant_with_special_name_; } - FOLLY_EXPORT ::std::string_view _fbthrift_schema_c10aed29f43b19bb(); - FOLLY_EXPORT ::folly::Range _fbthrift_schema_c10aed29f43b19bb_includes(); + FOLLY_EXPORT ::std::string_view _fbthrift_schema_40bdae2065fd0caf(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_40bdae2065fd0caf_includes(); } // namespace module_constants } // namespace test_cpp2::cpp_reflection diff --git a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_metadata.cpp index dacb1b1f662..8cd0cabafe7 100644 --- a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_metadata.cpp @@ -315,7 +315,7 @@ StructMetadata<::test_cpp2::cpp_reflection::struct4>::gen(ThriftMetadata& metada module_struct4.is_union() = false; static const auto* const module_struct4_fields = new std::array{ { - { 1, "field0", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 2, "field1", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 3, "field2", false, std::make_unique>("module.enum1"), std::vector{ }}, { 6, "field3", false, std::make_unique>("module.structA"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, }}; + { 1, "field0", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 2, "field1", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 3, "field2", false, std::make_unique>("module.enum1"), std::vector{ }}, { 6, "field3", false, std::make_unique>("module.structA"), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, }}; for (const auto& f : *module_struct4_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; diff --git a/thrift/compiler/test/fixtures/visitation/src/module.thrift b/thrift/compiler/test/fixtures/visitation/src/module.thrift index dd45b4eacd3..a7f2453326c 100644 --- a/thrift/compiler/test/fixtures/visitation/src/module.thrift +++ b/thrift/compiler/test/fixtures/visitation/src/module.thrift @@ -180,6 +180,7 @@ struct struct4 { 2: optional string field1; 3: enum1 field2; @cpp.Ref{type = cpp.RefType.Unique} + @cpp.AllowLegacyNonOptionalRef 6: structA field3; }