Skip to content

Commit

Permalink
fbcode/thrift/compiler/ [B]
Browse files Browse the repository at this point in the history
Reviewed By: yoney

Differential Revision: D67462900

fbshipit-source-id: 199413f1debd8b94f445b57e2f505f640d76b5e9
  • Loading branch information
Aristidis Papaioannou authored and facebook-github-bot committed Dec 19, 2024
1 parent 75dbbc5 commit 0f2fbb6
Show file tree
Hide file tree
Showing 29 changed files with 452 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ::std::string_view*> _fbthrift_schema_461f120cd2880445_includes() {
::folly::Range<const ::std::string_view*> _fbthrift_schema_f3ff3c4acd06e9b9_includes() {
return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ namespace module_constants {
return constEnumB_;
}

FOLLY_EXPORT ::std::string_view _fbthrift_schema_461f120cd2880445();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_461f120cd2880445_includes();
FOLLY_EXPORT ::std::string_view _fbthrift_schema_f3ff3c4acd06e9b9();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_f3ff3c4acd06e9b9_includes();

} // namespace module_constants
} // namespace some::valid::ns

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions thrift/compiler/test/fixtures/mcpp2-compare/src/module.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ union ComplexUnion {
21: binary MyBinaryField2;
23: list<binary> 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;
Expand Down Expand Up @@ -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)
Expand All @@ -275,16 +278,22 @@ typedef map<i64, string> 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<i32, list<string>> 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<string> req_container_with_ref;
@cpp.Ref{type = cpp.RefType.Unique}
8: optional containerStruct opt_cpp_unique_ref;
Expand All @@ -293,16 +302,22 @@ struct AnnotatedStruct {
@cpp.Ref{type = cpp.RefType.Unique}
10: optional set<i32> 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<i32, list<string>> 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<string> req_ref_type_unique;
@cpp.Ref{type = cpp.RefType.Shared}
17: optional containerStruct opt_ref_type_const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ::std::string_view*> _fbthrift_schema_547276426adfb34f_includes() {
::folly::Range<const ::std::string_view*> _fbthrift_schema_e4876d5bf5fad44e_includes() {
return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ::std::string_view*> _fbthrift_schema_547276426adfb34f_includes();
FOLLY_EXPORT ::std::string_view _fbthrift_schema_e4876d5bf5fad44e();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_e4876d5bf5fad44e_includes();

} // namespace module_constants
} // namespace test::fixtures::python_capi
Original file line number Diff line number Diff line change
Expand Up @@ -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<EncodedThriftField, 10>{ {
{ 1, "enum_", false, std::make_unique<Enum<::test::fixtures::python_capi::MyEnum>>("module.MyEnum"), std::vector<ThriftConstStruct>{ }}, { 2, "renamed_", false, std::make_unique<Enum<::test::fixtures::python_capi::NormalDecentEnum>>("module.AnnoyingEnum"), std::vector<ThriftConstStruct>{ }}, { 3, "primitive", false, std::make_unique<Struct<::test::fixtures::python_capi::PrimitiveStruct>>("module.PrimitiveStruct"), std::vector<ThriftConstStruct>{ }}, { 4, "aliased", false, std::make_unique<Typedef>("module.ListAlias", std::make_unique<Struct<::test::fixtures::python_capi::ListStruct>>("module.ListStruct"), std::vector<ThriftConstStruct>{ }), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 6, "xstruct", false, std::make_unique<Struct<::test::fixtures::python_capi::DepStruct>>("thrift_dep.DepStruct"), std::vector<ThriftConstStruct>{ }}, { 5, "xenum", false, std::make_unique<Enum<::test::fixtures::python_capi::DepEnum>>("thrift_dep.DepEnum"), std::vector<ThriftConstStruct>{ }}, { 8, "serial_struct", false, std::make_unique<Struct<::test::fixtures::python_capi::SerializedStruct>>("serialized_dep.SerializedStruct"), std::vector<ThriftConstStruct>{ }}, { 7, "friends", false, std::make_unique<List>(std::make_unique<Struct<::test::fixtures::python_capi::DepStruct>>("thrift_dep.DepStruct")), std::vector<ThriftConstStruct>{ }}, { 9, "serial_union", false, std::make_unique<Union<::test::fixtures::python_capi::SerializedUnion>>("serialized_dep.SerializedUnion"), std::vector<ThriftConstStruct>{ }}, { 10, "serial_error", false, std::make_unique<Struct<::test::fixtures::python_capi::SerializedError>>("serialized_dep.SerializedError"), std::vector<ThriftConstStruct>{ }}, }};
{ 1, "enum_", false, std::make_unique<Enum<::test::fixtures::python_capi::MyEnum>>("module.MyEnum"), std::vector<ThriftConstStruct>{ }}, { 2, "renamed_", false, std::make_unique<Enum<::test::fixtures::python_capi::NormalDecentEnum>>("module.AnnoyingEnum"), std::vector<ThriftConstStruct>{ }}, { 3, "primitive", false, std::make_unique<Struct<::test::fixtures::python_capi::PrimitiveStruct>>("module.PrimitiveStruct"), std::vector<ThriftConstStruct>{ }}, { 4, "aliased", false, std::make_unique<Typedef>("module.ListAlias", std::make_unique<Struct<::test::fixtures::python_capi::ListStruct>>("module.ListStruct"), std::vector<ThriftConstStruct>{ }), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 6, "xstruct", false, std::make_unique<Struct<::test::fixtures::python_capi::DepStruct>>("thrift_dep.DepStruct"), std::vector<ThriftConstStruct>{ }}, { 5, "xenum", false, std::make_unique<Enum<::test::fixtures::python_capi::DepEnum>>("thrift_dep.DepEnum"), std::vector<ThriftConstStruct>{ }}, { 8, "serial_struct", false, std::make_unique<Struct<::test::fixtures::python_capi::SerializedStruct>>("serialized_dep.SerializedStruct"), std::vector<ThriftConstStruct>{ }}, { 7, "friends", false, std::make_unique<List>(std::make_unique<Struct<::test::fixtures::python_capi::DepStruct>>("thrift_dep.DepStruct")), std::vector<ThriftConstStruct>{ }}, { 9, "serial_union", false, std::make_unique<Union<::test::fixtures::python_capi::SerializedUnion>>("serialized_dep.SerializedUnion"), std::vector<ThriftConstStruct>{ }}, { 10, "serial_error", false, std::make_unique<Struct<::test::fixtures::python_capi::SerializedError>>("serialized_dep.SerializedError"), std::vector<ThriftConstStruct>{ }}, }};
for (const auto& f : *module_ComposeStruct_fields) {
::apache::thrift::metadata::ThriftField field;
field.id() = f.id;
Expand All @@ -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<EncodedThriftField, 7>{ {
{ 1, "myEnum", false, std::make_unique<Enum<::test::fixtures::python_capi::MyEnum>>("module.MyEnum"), std::vector<ThriftConstStruct>{ }}, { 2, "myStruct", false, std::make_unique<Struct<::test::fixtures::python_capi::PrimitiveStruct>>("module.PrimitiveStruct"), std::vector<ThriftConstStruct>{ }}, { 6, "intSet", false, std::make_unique<Set>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("thrift.Box", { }).cv_struct_ref(), }}, { 4, "myString", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{ }}, { 8, "doubleList", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 9, "strMap", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), }}, { 10, "adapted_int", false, std::make_unique<Typedef>("id.ProtocolId", std::make_unique<Typedef>("id.ExternId", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{ *cvStruct("thrift.Experimental", { }).cv_struct_ref(), }), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::type::detail::StrongIntegerAdapter<::apache::thrift::type::ProtocolId>") } }).cv_struct_ref(), }), std::vector<ThriftConstStruct>{ }}, }};
{ 1, "myEnum", false, std::make_unique<Enum<::test::fixtures::python_capi::MyEnum>>("module.MyEnum"), std::vector<ThriftConstStruct>{ }}, { 2, "myStruct", false, std::make_unique<Struct<::test::fixtures::python_capi::PrimitiveStruct>>("module.PrimitiveStruct"), std::vector<ThriftConstStruct>{ }}, { 6, "intSet", false, std::make_unique<Set>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("thrift.Box", { }).cv_struct_ref(), }}, { 4, "myString", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{ }}, { 8, "doubleList", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 9, "strMap", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Ref", { {"type", cvInteger(0) } }).cv_struct_ref(), *cvStruct("cpp.AllowLegacyNonOptionalRef", { }).cv_struct_ref(), }}, { 10, "adapted_int", false, std::make_unique<Typedef>("id.ProtocolId", std::make_unique<Typedef>("id.ExternId", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{ *cvStruct("thrift.Experimental", { }).cv_struct_ref(), }), std::vector<ThriftConstStruct>{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::type::detail::StrongIntegerAdapter<::apache::thrift::type::ProtocolId>") } }).cv_struct_ref(), }), std::vector<ThriftConstStruct>{ }}, }};
for (const auto& f : *module_Onion_fields) {
::apache::thrift::metadata::ThriftField field;
field.id() = f.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
]),
Expand Down Expand Up @@ -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=[
]),
Expand Down
3 changes: 3 additions & 0 deletions thrift/compiler/test/fixtures/python_capi/src/module.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -200,8 +201,10 @@ union Onion {
6: set<i64> intSet;
4: string myString;
@cpp.Ref{type = cpp.RefType.Shared}
@cpp.AllowLegacyNonOptionalRef
8: list<double> doubleList;
@cpp.Ref{type = cpp.RefType.Unique}
@cpp.AllowLegacyNonOptionalRef
9: map<binary, string> strMap;
10: id.ProtocolId adapted_int;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ ::cpp2::StructWithRefTypeSharedConst const& kStructWithRefTypeSharedConst() {
}


::std::string_view _fbthrift_schema_1a3968d5a44d4338() {
::std::string_view _fbthrift_schema_5aa2598542e3e360() {
return "";
}
::folly::Range<const ::std::string_view*> _fbthrift_schema_1a3968d5a44d4338_includes() {
::folly::Range<const ::std::string_view*> _fbthrift_schema_5aa2598542e3e360_includes() {
return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ::std::string_view*> _fbthrift_schema_1a3968d5a44d4338_includes();
FOLLY_EXPORT ::std::string_view _fbthrift_schema_5aa2598542e3e360();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_5aa2598542e3e360_includes();

} // namespace module_constants
} // namespace cpp2
Loading

0 comments on commit 0f2fbb6

Please sign in to comment.