diff --git a/third-party/thrift/src/thrift/annotation/python.thrift b/third-party/thrift/src/thrift/annotation/python.thrift index 69c36273785052..2276ed29235585 100644 --- a/third-party/thrift/src/thrift/annotation/python.thrift +++ b/third-party/thrift/src/thrift/annotation/python.thrift @@ -100,3 +100,6 @@ struct UseCAPI { /// It is only available for typedefs that resolve to binary, string, and container type. @scope.Typedef struct Py3EnableCppAdapter {} + +@scope.Structured +struct MigrationBlockingAllowInheritance {} diff --git a/third-party/thrift/src/thrift/compiler/ast/uri.h b/third-party/thrift/src/thrift/compiler/ast/uri.h index 2bf19fa10cda53..bdd85c9c76bd31 100644 --- a/third-party/thrift/src/thrift/compiler/ast/uri.h +++ b/third-party/thrift/src/thrift/compiler/ast/uri.h @@ -141,6 +141,8 @@ inline constexpr auto kPythonUseCAPIUri = "facebook.com/thrift/annotation/python/UseCAPI"; inline constexpr auto kPythonPy3EnableCppAdapterUri = "facebook.com/thrift/annotation/python/Py3EnableCppAdapter"; +inline constexpr auto kPythonMigrationBlockingAllowInheritanceUri = + "facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance"; // Hack: inline constexpr auto kHackAdapterUri = diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/android/gen-android/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/android/gen-android/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java new file mode 100644 index 00000000000000..2ffef59236cc3f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/android/gen-android/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java @@ -0,0 +1,116 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.facebook.thrift.annotation.python_deprecated; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import java.util.BitSet; +import java.util.Arrays; +import com.facebook.thrift.*; +import com.facebook.thrift.annotations.*; +import com.facebook.thrift.async.*; +import com.facebook.thrift.meta_data.*; +import com.facebook.thrift.server.*; +import com.facebook.thrift.transport.*; +import com.facebook.thrift.protocol.*; + +@SuppressWarnings({ "unused", "serial" }) +public class MigrationBlockingAllowInheritance implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("MigrationBlockingAllowInheritance"); + + + public MigrationBlockingAllowInheritance() { + } + + /** + * Performs a deep copy on other. + */ + public MigrationBlockingAllowInheritance(MigrationBlockingAllowInheritance other) { + } + + public MigrationBlockingAllowInheritance deepCopy() { + return new MigrationBlockingAllowInheritance(this); + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof MigrationBlockingAllowInheritance)) + return false; + MigrationBlockingAllowInheritance that = (MigrationBlockingAllowInheritance)_that; + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {}); + } + + // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. + public void read(TProtocol iprot) throws TException { + throw new TException("unimplemented in android immutable structure"); + } + + public static MigrationBlockingAllowInheritance deserialize(TProtocol iprot) throws TException { + TField __field; + iprot.readStructBegin(); + while (true) + { + __field = iprot.readFieldBegin(); + if (__field.type == TType.STOP) { + break; + } + switch (__field.id) + { + default: + TProtocolUtil.skip(iprot, __field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + MigrationBlockingAllowInheritance _that; + _that = new MigrationBlockingAllowInheritance( + ); + _that.validate(); + return _that; + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + return toString(1, true); + } + + @Override + public String toString(int indent, boolean prettyPrint) { + return TBaseHelper.toStringHelper(this, indent, prettyPrint); + } + + public void validate() throws TException { + // check for required fields + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/codec.go b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/codec.go index 5386e040995df3..9a959de453074b 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/codec.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/codec.go @@ -108,6 +108,17 @@ var ( NewFunc: func() thrift.Struct { return NewPy3EnableCppAdapter() }, }, + } + }() + premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "python.MigrationBlockingAllowInheritance", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "python.MigrationBlockingAllowInheritance", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewMigrationBlockingAllowInheritance() }, +}, + } }() ) @@ -260,6 +271,20 @@ var ( }, FieldSpecNameToIndex: map[string]int{ }, +} + }() + premadeStructSpec_MigrationBlockingAllowInheritance = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "MigrationBlockingAllowInheritance", + ScopedName: "python.MigrationBlockingAllowInheritance", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + }, + FieldSpecIDToIndex: map[int16]int{ + }, + FieldSpecNameToIndex: map[string]int{ + }, } }() ) @@ -274,6 +299,7 @@ var premadeStructSpecs = func() []*thrift.StructSpec { fbthriftResults = append(fbthriftResults, premadeStructSpec_Adapter) fbthriftResults = append(fbthriftResults, premadeStructSpec_UseCAPI) fbthriftResults = append(fbthriftResults, premadeStructSpec_Py3EnableCppAdapter) + fbthriftResults = append(fbthriftResults, premadeStructSpec_MigrationBlockingAllowInheritance) return fbthriftResults }() @@ -288,6 +314,7 @@ var premadeCodecSpecsMap = func() map[string]*thrift.TypeSpec { fbthriftTypeSpecsMap[premadeCodecTypeSpec_bool.FullName] = premadeCodecTypeSpec_bool fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_UseCAPI.FullName] = premadeCodecTypeSpec_python_UseCAPI fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_Py3EnableCppAdapter.FullName] = premadeCodecTypeSpec_python_Py3EnableCppAdapter + fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance.FullName] = premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance return fbthriftTypeSpecsMap }() diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/metadata.go b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/metadata.go index ddcd009bc61592..ef9d6fcc70bd71 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/metadata.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/metadata.go @@ -71,6 +71,12 @@ var ( SetName("python.Py3EnableCppAdapter"), ) }() + premadeThriftType_python_MigrationBlockingAllowInheritance = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("python.MigrationBlockingAllowInheritance"), + ) + }() ) // Helper type to allow us to store Thrift types in a slice at compile time, @@ -92,6 +98,7 @@ var premadeThriftTypesMap = func() map[string]*metadata.ThriftType { thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "bool", premadeThriftType_bool }) thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.UseCAPI", premadeThriftType_python_UseCAPI }) thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.Py3EnableCppAdapter", premadeThriftType_python_Py3EnableCppAdapter }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.MigrationBlockingAllowInheritance", premadeThriftType_python_MigrationBlockingAllowInheritance }) fbthriftThriftTypesMap := make(map[string]*metadata.ThriftType, len(thriftTypesWithFullName)) for _, value := range thriftTypesWithFullName { diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/types.go b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/types.go index fe6b64da588409..93d7b9bc79d32a 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/types.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/go/gen-go/thrift/annotation/python/types.go @@ -756,6 +756,78 @@ func (x *Py3EnableCppAdapter) setDefaults() *Py3EnableCppAdapter { return x } +type MigrationBlockingAllowInheritance struct { +} +// Compile time interface enforcer +var _ thrift.Struct = (*MigrationBlockingAllowInheritance)(nil) + +func NewMigrationBlockingAllowInheritance() *MigrationBlockingAllowInheritance { + return (&MigrationBlockingAllowInheritance{}).setDefaults() +} + + + +func (x *MigrationBlockingAllowInheritance) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("MigrationBlockingAllowInheritance"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err) + } + + + if err := p.WriteFieldStop(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", x), err) + } + + if err := p.WriteStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", x), err) + } + return nil +} + +func (x *MigrationBlockingAllowInheritance) Read(p thrift.Decoder) error { + if _, err := p.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", x), err) + } + + for { + fieldName, wireType, id, err := p.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d ('%s') read error: ", x, id, fieldName), err) + } + + if wireType == thrift.STOP { + break; + } + + var fieldReadErr error + switch { + default: + fieldReadErr = p.Skip(wireType) + } + + if fieldReadErr != nil { + return fieldReadErr + } + + if err := p.ReadFieldEnd(); err != nil { + return err + } + } + + if err := p.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", x), err) + } + + return nil +} + +func (x *MigrationBlockingAllowInheritance) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *MigrationBlockingAllowInheritance) setDefaults() *MigrationBlockingAllowInheritance { + return x +} + // RegisterTypes registers types found in this file that have a thrift_uri with the passed in registry. @@ -769,5 +841,6 @@ func RegisterTypes(registry interface { registry.RegisterType("facebook.com/thrift/annotation/python/Adapter", func() any { return NewAdapter() }) registry.RegisterType("facebook.com/thrift/annotation/python/UseCAPI", func() any { return NewUseCAPI() }) registry.RegisterType("facebook.com/thrift/annotation/python/Py3EnableCppAdapter", func() any { return NewPy3EnableCppAdapter() }) + registry.RegisterType("facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance", func() any { return NewMigrationBlockingAllowInheritance() }) } diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/hack/gen-hack/python_types.php b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/hack/gen-hack/python_types.php index 20e2564b0e79bf..d6233629f719f4 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/hack/gen-hack/python_types.php +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/hack/gen-hack/python_types.php @@ -798,3 +798,85 @@ public function readFromJson(string $jsonText): void { } +/** + * Original thrift struct:- + * MigrationBlockingAllowInheritance + */ +<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance'))>> +class MigrationBlockingAllowInheritance implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct { + use \ThriftSerializationTrait; + + const \ThriftStructTypes::TSpec SPEC = dict[ + ]; + const dict FIELDMAP = dict[ + ]; + + const type TConstructorShape = shape( + ); + + const type TShape = shape( + ); + const int STRUCTURAL_ID = 957977401221134810; + + public function __construct()[] { + } + + public static function withDefaultValues()[]: this { + return new static(); + } + + public static function fromShape(self::TConstructorShape $shape)[]: this { + return new static( + ); + } + + public function getName()[]: string { + return 'MigrationBlockingAllowInheritance'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "python.MigrationBlockingAllowInheritance", + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[ + '\facebook\thrift\annotation\Structured' => \facebook\thrift\annotation\Structured::fromShape( + shape( + ) + ), + ], + 'fields' => dict[ + ], + ); + } + + public static function __fromShape(self::TShape $shape)[]: this { + return new static( + ); + } + + public function __toShape()[]: self::TShape { + return shape( + ); + } + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + + public function readFromJson(string $jsonText): void { + $parsed = json_decode($jsonText, true); + + if ($parsed === null || !($parsed is KeyedContainer<_, _>)) { + throw new \TProtocolException("Cannot parse the given json string."); + } + + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java new file mode 100644 index 00000000000000..0945dd654ff1b8 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java @@ -0,0 +1,174 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.facebook.thrift.annotation.python_deprecated; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import java.util.BitSet; +import java.util.Arrays; +import com.facebook.thrift.*; +import com.facebook.thrift.annotations.*; +import com.facebook.thrift.async.*; +import com.facebook.thrift.meta_data.*; +import com.facebook.thrift.server.*; +import com.facebook.thrift.transport.*; +import com.facebook.thrift.protocol.*; + +@SuppressWarnings({ "unused", "serial" }) +public class MigrationBlockingAllowInheritance implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("MigrationBlockingAllowInheritance"); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(MigrationBlockingAllowInheritance.class, metaDataMap); + } + + public MigrationBlockingAllowInheritance() { + } + + public static class Builder { + + public Builder() { + } + + public MigrationBlockingAllowInheritance build() { + MigrationBlockingAllowInheritance result = new MigrationBlockingAllowInheritance(); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public MigrationBlockingAllowInheritance(MigrationBlockingAllowInheritance other) { + } + + public MigrationBlockingAllowInheritance deepCopy() { + return new MigrationBlockingAllowInheritance(this); + } + + public void setFieldValue(int fieldID, Object __value) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + public Object getFieldValue(int fieldID) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof MigrationBlockingAllowInheritance)) + return false; + MigrationBlockingAllowInheritance that = (MigrationBlockingAllowInheritance)_that; + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {}); + } + + @Override + public int compareTo(MigrationBlockingAllowInheritance other) { + if (other == null) { + // See java.lang.Comparable docs + throw new NullPointerException(); + } + + if (other == this) { + return 0; + } + int lastComparison = 0; + + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField __field; + iprot.readStructBegin(metaDataMap); + while (true) + { + __field = iprot.readFieldBegin(); + if (__field.type == TType.STOP) { + break; + } + switch (__field.id) + { + default: + TProtocolUtil.skip(iprot, __field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + return toString(1, true); + } + + @Override + public String toString(int indent, boolean prettyPrint) { + String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : ""; + String newLine = prettyPrint ? "\n" : ""; + String space = prettyPrint ? " " : ""; + StringBuilder sb = new StringBuilder("MigrationBlockingAllowInheritance"); + sb.append(space); + sb.append("("); + sb.append(newLine); + boolean first = true; + + sb.append(newLine + TBaseHelper.reduceIndent(indentStr)); + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/json/gen-json/python.json b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/json/gen-json/python.json index becdedc76800b5..04a066cc68b410 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/json/gen-json/python.json +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/json/gen-json/python.json @@ -204,6 +204,24 @@ "column" : 30 } } + }, + "MigrationBlockingAllowInheritance" : { + "lineno" : 104, + "is_exception" : false, + "is_union" : false, + "fields" : { + + }, + "source_range" : { + "begin" : { + "line" : 104, + "column" : 1 + }, + "end" : { + "line" : 105, + "column" : 44 + } + } } } } diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/constants.py b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/constants.py index 0b34e08b668fd0..c8081637fb8c86 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/constants.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/constants.py @@ -17,5 +17,5 @@ long = int -from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter +from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter, MigrationBlockingAllowInheritance diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/ttypes.py b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/ttypes.py index 8243f7e6a32ff3..4a81e05ee29274 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/ttypes.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py/gen-py/thrift/annotation/python/ttypes.py @@ -52,7 +52,7 @@ def __repr__(self): all_structs = [] UTF8STRINGS = bool(0) or sys.version_info.major >= 3 -__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter'] +__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter', 'MigrationBlockingAllowInheritance'] class Py3Hidden: r""" @@ -882,6 +882,103 @@ def _to_py3(self): def _to_py_deprecated(self): return self +class MigrationBlockingAllowInheritance: + + thrift_spec = None + thrift_field_annotations = None + thrift_struct_annotations = None + @staticmethod + def isUnion(): + return False + + def read(self, iprot): + if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0) + return + if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)) + return + if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)) + return + oprot.writeStructBegin('MigrationBlockingAllowInheritance') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def readFromJson(self, json, is_text=True, **kwargs): + kwargs_copy = dict(kwargs) + relax_enum_validation = bool(kwargs_copy.pop('relax_enum_validation', False)) + set_cls = kwargs_copy.pop('custom_set_cls', set) + dict_cls = kwargs_copy.pop('custom_dict_cls', dict) + wrap_enum_constants = kwargs_copy.pop('wrap_enum_constants', False) + if wrap_enum_constants and relax_enum_validation: + raise ValueError( + 'wrap_enum_constants cannot be used together with relax_enum_validation' + ) + if kwargs_copy: + extra_kwargs = ', '.join(kwargs_copy.keys()) + raise ValueError( + 'Unexpected keyword arguments: ' + extra_kwargs + ) + json_obj = json + if is_text: + json_obj = loads(json) + + def __repr__(self): + L = [] + padding = ' ' * 4 + return "%s(%s)" % (self.__class__.__name__, "\n" + ",\n".join(L) if L else '') + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + def __dir__(self): + return ( + ) + + __hash__ = object.__hash__ + + def _to_python(self): + import importlib + import thrift.python.converter + python_types = importlib.import_module("facebook.thrift.annotation.python.thrift_types") + return thrift.python.converter.to_python_struct(python_types.MigrationBlockingAllowInheritance, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.annotation.python.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.MigrationBlockingAllowInheritance, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.annotation.python.types") + return thrift.py3.converter.to_py3_struct(py3_types.MigrationBlockingAllowInheritance, self) + + def _to_py_deprecated(self): + return self + all_structs.append(Py3Hidden) Py3Hidden.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( ))) @@ -1000,5 +1097,14 @@ def UseCAPI__setstate__(self, state): Py3EnableCppAdapter.thrift_field_annotations = { } +all_structs.append(MigrationBlockingAllowInheritance) +MigrationBlockingAllowInheritance.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( +))) + +MigrationBlockingAllowInheritance.thrift_struct_annotations = { +} +MigrationBlockingAllowInheritance.thrift_field_annotations = { +} + fix_spec(all_structs) del all_structs diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/metadata.cpp index f72b1d36b490ce..ebe87e55e946b2 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/metadata.cpp +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/metadata.cpp @@ -21,6 +21,7 @@ ::apache::thrift::metadata::ThriftMetadata python_getThriftModuleMetadata() { ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); return metadata; } } // namespace facebook diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/types.h index e9cf646209f7ef..b7f07be51708ee 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/types.h +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/py3/gen-py3/python/types.h @@ -82,6 +82,13 @@ inline void reset_field<::facebook::thrift::annotation::python::Py3EnableCppAdap } } +template<> +inline void reset_field<::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>( + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance& obj, uint16_t index) { + switch (index) { + } +} + template<> inline const std::unordered_map& PyStructTraits< ::facebook::thrift::annotation::python::Py3Hidden>::namesmap() { @@ -151,5 +158,15 @@ inline const std::unordered_map& PyStructTra }; return *map; } + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} } // namespace py3 } // namespace thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/pyi/gen-py/thrift/annotation/python/ttypes.pyi b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/pyi/gen-py/thrift/annotation/python/ttypes.pyi index 9bae115f27e2e7..65532d9270eb49 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/pyi/gen-py/thrift/annotation/python/ttypes.pyi +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/adapter/out/pyi/gen-py/thrift/annotation/python/ttypes.pyi @@ -246,3 +246,32 @@ class Py3EnableCppAdapter: def _to_py_deprecated(self) -> Py3EnableCppAdapter: ... +class MigrationBlockingAllowInheritance: + thrift_spec: __T.Tuple[__T.Optional[__T.Tuple[int, int, str, __T.Any, __T.Optional[int], int]]] + thrift_field_annotations: __T.Dict[int, __T.Dict[str, str]] + thrift_struct_annotations: __T.Dict[str, str] + + def __init__( + self + ) -> None: + ... + + + + def isUnion(self) -> bool: ... + def checkRequired(self) -> None: ... + def read(self, iprot: TProtocolBase) -> None: ... + @__T.overload + def readFromJson(self, json: __T.Dict[str, __T.Any], is_text: bool = ..., **kwargs: __T.Any) -> None: ... + @__T.overload + def readFromJson(self, json: str, is_text: bool = ..., **kwargs: __T.Any) -> None: ... + def write(self, oprot: TProtocolBase) -> None: ... + def __eq__(self, other: __T.Any) -> bool: ... + def __ne__(self, other: __T.Any) -> bool: ... + def __dir__(self) -> __T.Sequence[str]: ... + def _to_python(self) -> "facebook.thrift.annotation.python.thrift_types.MigrationBlockingAllowInheritance": ... # type: ignore + def _to_mutable_python(self) -> "facebook.thrift.annotation.python.thrift_mutable_types.MigrationBlockingAllowInheritance": ... # type: ignore + def _to_py3(self) -> "facebook.thrift.annotation.python.types.MigrationBlockingAllowInheritance": ... # type: ignore + def _to_py_deprecated(self) -> MigrationBlockingAllowInheritance: ... + + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/codec.go b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/codec.go index 5386e040995df3..9a959de453074b 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/codec.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/codec.go @@ -108,6 +108,17 @@ var ( NewFunc: func() thrift.Struct { return NewPy3EnableCppAdapter() }, }, + } + }() + premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "python.MigrationBlockingAllowInheritance", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "python.MigrationBlockingAllowInheritance", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewMigrationBlockingAllowInheritance() }, +}, + } }() ) @@ -260,6 +271,20 @@ var ( }, FieldSpecNameToIndex: map[string]int{ }, +} + }() + premadeStructSpec_MigrationBlockingAllowInheritance = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "MigrationBlockingAllowInheritance", + ScopedName: "python.MigrationBlockingAllowInheritance", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + }, + FieldSpecIDToIndex: map[int16]int{ + }, + FieldSpecNameToIndex: map[string]int{ + }, } }() ) @@ -274,6 +299,7 @@ var premadeStructSpecs = func() []*thrift.StructSpec { fbthriftResults = append(fbthriftResults, premadeStructSpec_Adapter) fbthriftResults = append(fbthriftResults, premadeStructSpec_UseCAPI) fbthriftResults = append(fbthriftResults, premadeStructSpec_Py3EnableCppAdapter) + fbthriftResults = append(fbthriftResults, premadeStructSpec_MigrationBlockingAllowInheritance) return fbthriftResults }() @@ -288,6 +314,7 @@ var premadeCodecSpecsMap = func() map[string]*thrift.TypeSpec { fbthriftTypeSpecsMap[premadeCodecTypeSpec_bool.FullName] = premadeCodecTypeSpec_bool fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_UseCAPI.FullName] = premadeCodecTypeSpec_python_UseCAPI fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_Py3EnableCppAdapter.FullName] = premadeCodecTypeSpec_python_Py3EnableCppAdapter + fbthriftTypeSpecsMap[premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance.FullName] = premadeCodecTypeSpec_python_MigrationBlockingAllowInheritance return fbthriftTypeSpecsMap }() diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/metadata.go b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/metadata.go index ddcd009bc61592..ef9d6fcc70bd71 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/metadata.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/metadata.go @@ -71,6 +71,12 @@ var ( SetName("python.Py3EnableCppAdapter"), ) }() + premadeThriftType_python_MigrationBlockingAllowInheritance = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("python.MigrationBlockingAllowInheritance"), + ) + }() ) // Helper type to allow us to store Thrift types in a slice at compile time, @@ -92,6 +98,7 @@ var premadeThriftTypesMap = func() map[string]*metadata.ThriftType { thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "bool", premadeThriftType_bool }) thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.UseCAPI", premadeThriftType_python_UseCAPI }) thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.Py3EnableCppAdapter", premadeThriftType_python_Py3EnableCppAdapter }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "python.MigrationBlockingAllowInheritance", premadeThriftType_python_MigrationBlockingAllowInheritance }) fbthriftThriftTypesMap := make(map[string]*metadata.ThriftType, len(thriftTypesWithFullName)) for _, value := range thriftTypesWithFullName { diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/types.go b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/types.go index fe6b64da588409..93d7b9bc79d32a 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/types.go +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/go/gen-go/thrift/annotation/python/types.go @@ -756,6 +756,78 @@ func (x *Py3EnableCppAdapter) setDefaults() *Py3EnableCppAdapter { return x } +type MigrationBlockingAllowInheritance struct { +} +// Compile time interface enforcer +var _ thrift.Struct = (*MigrationBlockingAllowInheritance)(nil) + +func NewMigrationBlockingAllowInheritance() *MigrationBlockingAllowInheritance { + return (&MigrationBlockingAllowInheritance{}).setDefaults() +} + + + +func (x *MigrationBlockingAllowInheritance) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("MigrationBlockingAllowInheritance"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err) + } + + + if err := p.WriteFieldStop(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", x), err) + } + + if err := p.WriteStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", x), err) + } + return nil +} + +func (x *MigrationBlockingAllowInheritance) Read(p thrift.Decoder) error { + if _, err := p.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", x), err) + } + + for { + fieldName, wireType, id, err := p.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d ('%s') read error: ", x, id, fieldName), err) + } + + if wireType == thrift.STOP { + break; + } + + var fieldReadErr error + switch { + default: + fieldReadErr = p.Skip(wireType) + } + + if fieldReadErr != nil { + return fieldReadErr + } + + if err := p.ReadFieldEnd(); err != nil { + return err + } + } + + if err := p.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", x), err) + } + + return nil +} + +func (x *MigrationBlockingAllowInheritance) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *MigrationBlockingAllowInheritance) setDefaults() *MigrationBlockingAllowInheritance { + return x +} + // RegisterTypes registers types found in this file that have a thrift_uri with the passed in registry. @@ -769,5 +841,6 @@ func RegisterTypes(registry interface { registry.RegisterType("facebook.com/thrift/annotation/python/Adapter", func() any { return NewAdapter() }) registry.RegisterType("facebook.com/thrift/annotation/python/UseCAPI", func() any { return NewUseCAPI() }) registry.RegisterType("facebook.com/thrift/annotation/python/Py3EnableCppAdapter", func() any { return NewPy3EnableCppAdapter() }) + registry.RegisterType("facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance", func() any { return NewMigrationBlockingAllowInheritance() }) } diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/hack/gen-hack/python_types.php b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/hack/gen-hack/python_types.php index 36ca21f1af32f7..e9812a171a6c59 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/hack/gen-hack/python_types.php +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/hack/gen-hack/python_types.php @@ -628,3 +628,65 @@ public function getInstanceKey()[write_props]: string { } +/** + * Original thrift struct:- + * MigrationBlockingAllowInheritance + */ +<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance'))>> +class MigrationBlockingAllowInheritance implements \IThriftSyncStruct, \IThriftStructMetadata { + use \ThriftSerializationTrait; + + const \ThriftStructTypes::TSpec SPEC = dict[ + ]; + const dict FIELDMAP = dict[ + ]; + + const type TConstructorShape = shape( + ); + + const int STRUCTURAL_ID = 957977401221134810; + + public function __construct()[] { + } + + public static function withDefaultValues()[]: this { + return new static(); + } + + public static function fromShape(self::TConstructorShape $shape)[]: this { + return new static( + ); + } + + public function getName()[]: string { + return 'MigrationBlockingAllowInheritance'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "python.MigrationBlockingAllowInheritance", + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[ + '\facebook\thrift\annotation\Structured' => \facebook\thrift\annotation\Structured::fromShape( + shape( + ) + ), + ], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java new file mode 100644 index 00000000000000..0945dd654ff1b8 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/java_deprecated/gen-javadeprecated/com/facebook/thrift/annotation/python_deprecated/MigrationBlockingAllowInheritance.java @@ -0,0 +1,174 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.facebook.thrift.annotation.python_deprecated; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import java.util.BitSet; +import java.util.Arrays; +import com.facebook.thrift.*; +import com.facebook.thrift.annotations.*; +import com.facebook.thrift.async.*; +import com.facebook.thrift.meta_data.*; +import com.facebook.thrift.server.*; +import com.facebook.thrift.transport.*; +import com.facebook.thrift.protocol.*; + +@SuppressWarnings({ "unused", "serial" }) +public class MigrationBlockingAllowInheritance implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("MigrationBlockingAllowInheritance"); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(MigrationBlockingAllowInheritance.class, metaDataMap); + } + + public MigrationBlockingAllowInheritance() { + } + + public static class Builder { + + public Builder() { + } + + public MigrationBlockingAllowInheritance build() { + MigrationBlockingAllowInheritance result = new MigrationBlockingAllowInheritance(); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public MigrationBlockingAllowInheritance(MigrationBlockingAllowInheritance other) { + } + + public MigrationBlockingAllowInheritance deepCopy() { + return new MigrationBlockingAllowInheritance(this); + } + + public void setFieldValue(int fieldID, Object __value) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + public Object getFieldValue(int fieldID) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof MigrationBlockingAllowInheritance)) + return false; + MigrationBlockingAllowInheritance that = (MigrationBlockingAllowInheritance)_that; + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {}); + } + + @Override + public int compareTo(MigrationBlockingAllowInheritance other) { + if (other == null) { + // See java.lang.Comparable docs + throw new NullPointerException(); + } + + if (other == this) { + return 0; + } + int lastComparison = 0; + + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField __field; + iprot.readStructBegin(metaDataMap); + while (true) + { + __field = iprot.readFieldBegin(); + if (__field.type == TType.STOP) { + break; + } + switch (__field.id) + { + default: + TProtocolUtil.skip(iprot, __field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + return toString(1, true); + } + + @Override + public String toString(int indent, boolean prettyPrint) { + String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : ""; + String newLine = prettyPrint ? "\n" : ""; + String space = prettyPrint ? " " : ""; + StringBuilder sb = new StringBuilder("MigrationBlockingAllowInheritance"); + sb.append(space); + sb.append("("); + sb.append(newLine); + boolean first = true; + + sb.append(newLine + TBaseHelper.reduceIndent(indentStr)); + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/constants.py b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/constants.py index a5342202d68658..32d4f75f6c77c0 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/constants.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/constants.py @@ -13,5 +13,5 @@ -from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter +from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter, MigrationBlockingAllowInheritance diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/ttypes.py b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/ttypes.py index 490457d8709c04..ec7aa58ef3226f 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/ttypes.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py/gen-py/thrift/annotation/python/ttypes.py @@ -48,7 +48,7 @@ def __repr__(self): all_structs = [] UTF8STRINGS = bool(0) or sys.version_info.major >= 3 -__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter'] +__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter', 'MigrationBlockingAllowInheritance'] class Py3Hidden: r""" @@ -735,6 +735,84 @@ def _to_py3(self): def _to_py_deprecated(self): return self +class MigrationBlockingAllowInheritance: + + thrift_spec = None + thrift_field_annotations = None + thrift_struct_annotations = None + @staticmethod + def isUnion(): + return False + + def read(self, iprot): + if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0) + return + if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)) + return + if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)) + return + oprot.writeStructBegin('MigrationBlockingAllowInheritance') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def __repr__(self): + L = [] + padding = ' ' * 4 + return "%s(%s)" % (self.__class__.__name__, "\n" + ",\n".join(L) if L else '') + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + def __dir__(self): + return ( + ) + + __hash__ = object.__hash__ + + def _to_python(self): + import importlib + import thrift.python.converter + python_types = importlib.import_module("facebook.thrift.annotation.python.thrift_types") + return thrift.python.converter.to_python_struct(python_types.MigrationBlockingAllowInheritance, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.annotation.python.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.MigrationBlockingAllowInheritance, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.annotation.python.types") + return thrift.py3.converter.to_py3_struct(py3_types.MigrationBlockingAllowInheritance, self) + + def _to_py_deprecated(self): + return self + all_structs.append(Py3Hidden) Py3Hidden.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( ))) @@ -853,5 +931,14 @@ def UseCAPI__setstate__(self, state): Py3EnableCppAdapter.thrift_field_annotations = { } +all_structs.append(MigrationBlockingAllowInheritance) +MigrationBlockingAllowInheritance.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( +))) + +MigrationBlockingAllowInheritance.thrift_struct_annotations = { +} +MigrationBlockingAllowInheritance.thrift_field_annotations = { +} + fix_spec(all_structs) del all_structs diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/metadata.cpp index 86460f55969ef2..de7caf8882ca6e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/metadata.cpp +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/metadata.cpp @@ -21,6 +21,7 @@ ::apache::thrift::metadata::ThriftMetadata python_getThriftModuleMetadata() { ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); return metadata; } } // namespace facebook diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/types.h index bcd1667b26c9b7..5a9771066cf382 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/types.h +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/exceptions/out/py3/gen-py3/python/types.h @@ -82,6 +82,13 @@ inline void reset_field<::facebook::thrift::annotation::python::Py3EnableCppAdap } } +template<> +inline void reset_field<::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>( + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance& obj, uint16_t index) { + switch (index) { + } +} + template<> inline const std::unordered_map& PyStructTraits< ::facebook::thrift::annotation::python::Py3Hidden>::namesmap() { @@ -151,5 +158,15 @@ inline const std::unordered_map& PyStructTra }; return *map; } + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} } // namespace py3 } // namespace thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/python_types.php b/third-party/thrift/src/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/python_types.php index 36ca21f1af32f7..e9812a171a6c59 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/python_types.php +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/python_types.php @@ -628,3 +628,65 @@ public function getInstanceKey()[write_props]: string { } +/** + * Original thrift struct:- + * MigrationBlockingAllowInheritance + */ +<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/python/MigrationBlockingAllowInheritance'))>> +class MigrationBlockingAllowInheritance implements \IThriftSyncStruct, \IThriftStructMetadata { + use \ThriftSerializationTrait; + + const \ThriftStructTypes::TSpec SPEC = dict[ + ]; + const dict FIELDMAP = dict[ + ]; + + const type TConstructorShape = shape( + ); + + const int STRUCTURAL_ID = 957977401221134810; + + public function __construct()[] { + } + + public static function withDefaultValues()[]: this { + return new static(); + } + + public static function fromShape(self::TConstructorShape $shape)[]: this { + return new static( + ); + } + + public function getName()[]: string { + return 'MigrationBlockingAllowInheritance'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "python.MigrationBlockingAllowInheritance", + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[ + '\facebook\thrift\annotation\Structured' => \facebook\thrift\annotation\Structured::fromShape( + shape( + ) + ), + ], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/constants.py b/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/constants.py index 0b34e08b668fd0..c8081637fb8c86 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/constants.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/constants.py @@ -17,5 +17,5 @@ long = int -from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter +from .ttypes import UTF8STRINGS, Py3Hidden, PyDeprecatedHidden, Flags, Name, Adapter, UseCAPI, Py3EnableCppAdapter, MigrationBlockingAllowInheritance diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/ttypes.py b/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/ttypes.py index 8243f7e6a32ff3..4a81e05ee29274 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/ttypes.py +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py-hidden/out/py/gen-py/thrift/annotation/python/ttypes.py @@ -52,7 +52,7 @@ def __repr__(self): all_structs = [] UTF8STRINGS = bool(0) or sys.version_info.major >= 3 -__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter'] +__all__ = ['UTF8STRINGS', 'Py3Hidden', 'PyDeprecatedHidden', 'Flags', 'Name', 'Adapter', 'UseCAPI', 'Py3EnableCppAdapter', 'MigrationBlockingAllowInheritance'] class Py3Hidden: r""" @@ -882,6 +882,103 @@ def _to_py3(self): def _to_py_deprecated(self): return self +class MigrationBlockingAllowInheritance: + + thrift_spec = None + thrift_field_annotations = None + thrift_struct_annotations = None + @staticmethod + def isUnion(): + return False + + def read(self, iprot): + if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0) + return + if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None: + fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)) + return + if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None: + oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)) + return + oprot.writeStructBegin('MigrationBlockingAllowInheritance') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def readFromJson(self, json, is_text=True, **kwargs): + kwargs_copy = dict(kwargs) + relax_enum_validation = bool(kwargs_copy.pop('relax_enum_validation', False)) + set_cls = kwargs_copy.pop('custom_set_cls', set) + dict_cls = kwargs_copy.pop('custom_dict_cls', dict) + wrap_enum_constants = kwargs_copy.pop('wrap_enum_constants', False) + if wrap_enum_constants and relax_enum_validation: + raise ValueError( + 'wrap_enum_constants cannot be used together with relax_enum_validation' + ) + if kwargs_copy: + extra_kwargs = ', '.join(kwargs_copy.keys()) + raise ValueError( + 'Unexpected keyword arguments: ' + extra_kwargs + ) + json_obj = json + if is_text: + json_obj = loads(json) + + def __repr__(self): + L = [] + padding = ' ' * 4 + return "%s(%s)" % (self.__class__.__name__, "\n" + ",\n".join(L) if L else '') + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + def __dir__(self): + return ( + ) + + __hash__ = object.__hash__ + + def _to_python(self): + import importlib + import thrift.python.converter + python_types = importlib.import_module("facebook.thrift.annotation.python.thrift_types") + return thrift.python.converter.to_python_struct(python_types.MigrationBlockingAllowInheritance, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.annotation.python.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.MigrationBlockingAllowInheritance, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.annotation.python.types") + return thrift.py3.converter.to_py3_struct(py3_types.MigrationBlockingAllowInheritance, self) + + def _to_py_deprecated(self): + return self + all_structs.append(Py3Hidden) Py3Hidden.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( ))) @@ -1000,5 +1097,14 @@ def UseCAPI__setstate__(self, state): Py3EnableCppAdapter.thrift_field_annotations = { } +all_structs.append(MigrationBlockingAllowInheritance) +MigrationBlockingAllowInheritance.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( +))) + +MigrationBlockingAllowInheritance.thrift_struct_annotations = { +} +MigrationBlockingAllowInheritance.thrift_field_annotations = { +} + fix_spec(all_structs) del all_structs diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/metadata.cpp index 0c391fb6b3ec41..4a47fb14e5d0e5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/metadata.cpp +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/metadata.cpp @@ -21,6 +21,7 @@ ::apache::thrift::metadata::ThriftMetadata python_getThriftModuleMetadata() { ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); return metadata; } } // namespace facebook diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/types.h index 56d31bb856cb63..9c2cbc22ff343c 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/types.h +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3/gen-py3/python/types.h @@ -82,6 +82,13 @@ inline void reset_field<::facebook::thrift::annotation::python::Py3EnableCppAdap } } +template<> +inline void reset_field<::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>( + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance& obj, uint16_t index) { + switch (index) { + } +} + template<> inline const std::unordered_map& PyStructTraits< ::facebook::thrift::annotation::python::Py3Hidden>::namesmap() { @@ -151,5 +158,15 @@ inline const std::unordered_map& PyStructTra }; return *map; } + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} } // namespace py3 } // namespace thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/metadata.cpp index 0c391fb6b3ec41..4a47fb14e5d0e5 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/metadata.cpp +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/metadata.cpp @@ -21,6 +21,7 @@ ::apache::thrift::metadata::ThriftMetadata python_getThriftModuleMetadata() { ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); return metadata; } } // namespace facebook diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/types.h index 2f83bd25905c35..d70ba896ce7e0e 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/types.h +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/py3/out/py3_legacy_container_converters/gen-py3/python/types.h @@ -82,6 +82,13 @@ inline void reset_field<::facebook::thrift::annotation::python::Py3EnableCppAdap } } +template<> +inline void reset_field<::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>( + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance& obj, uint16_t index) { + switch (index) { + } +} + template<> inline const std::unordered_map& PyStructTraits< ::facebook::thrift::annotation::python::Py3Hidden>::namesmap() { @@ -151,5 +158,15 @@ inline const std::unordered_map& PyStructTra }; return *map; } + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::annotation::python::MigrationBlockingAllowInheritance>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} } // namespace py3 } // namespace thrift