Skip to content

Commit

Permalink
Add @cpp.AllowLegacyNonOptionalRef
Browse files Browse the repository at this point in the history
Reviewed By: yoney

Differential Revision: D67913175

fbshipit-source-id: bfafd7eeef248593d3b759f752c501b62546cfa4
  • Loading branch information
Aristidis Papaioannou authored and facebook-github-bot committed Jan 7, 2025
1 parent fca022e commit 8a87466
Show file tree
Hide file tree
Showing 2 changed files with 1,333 additions and 4 deletions.
17 changes: 13 additions & 4 deletions third-party/thrift/src/thrift/test/testset/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,19 @@ class Target(Enum):
CPP2_TYPE_NS = "type"

HACK_TYPE_ADAPTER = "|@hack.Adapter{{name = 'ConformanceTestAdapter_{}'}}"
OTHER_TYPE_ADAPTERS = "|@cpp.Adapter{{name = '::apache::thrift::test::TemplatedTestAdapter'}}|@java.Adapter{{adapterClassName = 'com.facebook.thrift.adapter.test.GenericTypeAdapter', typeClassName = 'com.facebook.thrift.adapter.test.Wrapped'}}|@python.Adapter{{name = 'thrift.python.test.adapters.noop.Wrapper', typeHint = 'thrift.python.test.adapters.noop.Wrapped[]',}}"
OTHER_TYPE_ADAPTERS = (
"|@cpp.Adapter{{name = '::apache::thrift::test::TemplatedTestAdapter'}}"
"|@java.Adapter{{adapterClassName = 'com.facebook.thrift.adapter.test.GenericTypeAdapter', typeClassName = 'com.facebook.thrift.adapter.test.Wrapped'}}"
"|@python.Adapter{{name = 'thrift.python.test.adapters.noop.Wrapper', typeHint = 'thrift.python.test.adapters.noop.Wrapped[]',}}"
)
TYPE_ADAPTERS: str = OTHER_TYPE_ADAPTERS + HACK_TYPE_ADAPTER

FIELD_ADAPTERS = "|@cpp.Adapter{{name = '::apache::thrift::test::TemplatedTestFieldAdapter'}}|@java.Wrapper{{wrapperClassName = 'com.facebook.thrift.adapter.test.GenericWrapper', typeClassName = 'com.facebook.thrift.adapter.test.Wrapped'}}|@python.Adapter{{name = 'thrift.python.test.adapters.noop.FieldWrapper', typeHint = 'thrift.python.test.adapters.noop.Wrapped[]',}}|@hack.Wrapper{{name = '\\ConformanceTestFieldWrapper'}}"
FIELD_ADAPTERS = (
"|@cpp.Adapter{{name = '::apache::thrift::test::TemplatedTestFieldAdapter'}}"
"|@java.Wrapper{{wrapperClassName = 'com.facebook.thrift.adapter.test.GenericWrapper', typeClassName = 'com.facebook.thrift.adapter.test.Wrapped'}}"
"|@python.Adapter{{name = 'thrift.python.test.adapters.noop.FieldWrapper', typeHint = 'thrift.python.test.adapters.noop.Wrapped[]',}}"
"|@hack.Wrapper{{name = '\\ConformanceTestFieldWrapper'}}"
)

PRIMATIVE_TRANSFORM: Dict[Target, str] = {
Target.NAME: "{}",
Expand Down Expand Up @@ -251,13 +260,13 @@ class Target(Enum):

CPP_REF_TRANSFORM: Dict[Target, str] = {
Target.NAME: "{}_cpp_ref",
Target.THRIFT: "{}|@cpp.Ref{{type = cpp.RefType.Unique}}",
Target.THRIFT: "{}|@cpp.Ref{{type = cpp.RefType.Unique}}|@cpp.AllowLegacyNonOptionalRef",
Target.CPP2: "{}|FieldModifier::Reference",
}

SHARED_CPP_REF_TRANSFORM: Dict[Target, str] = {
Target.NAME: "{}_shared_cpp_ref",
Target.THRIFT: "{}|@cpp.Ref{{type = cpp.RefType.SharedMutable}}",
Target.THRIFT: "{}|@cpp.Ref{{type = cpp.RefType.SharedMutable}}|@cpp.AllowLegacyNonOptionalRef",
Target.CPP2: "{}|FieldModifier::SharedReference",
}

Expand Down
Loading

0 comments on commit 8a87466

Please sign in to comment.