diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/cmd b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/cmd new file mode 100644 index 00000000000000..ea63038e2be698 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/cmd @@ -0,0 +1,13 @@ +android: android src/module.thrift +ast: thrift2ast-ast:protocol=debug,root_program_only,use_hash,no_backcompat src/module.thrift +cpp2: mstch_cpp2 src/module.thrift +go: mstch_go src/module.thrift +hack: hack:hack_collections=1 src/module.thrift +java: mstch_java src/module.thrift +java_deprecated: java_deprecated src/module.thrift +json: json src/module.thrift +json_experimental: json_experimental src/module.thrift +py3: mstch_py3 src/module.thrift +py: py src/module.thrift +python: mstch_python src/module.thrift +rust: mstch_rust src/module.thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/android/gen-android/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/android/gen-android/EmptyStruct.java new file mode 100644 index 00000000000000..017c2be236e9aa --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/android/gen-android/EmptyStruct.java @@ -0,0 +1,114 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 EmptyStruct implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); + + + public EmptyStruct() { + } + + /** + * Performs a deep copy on other. + */ + public EmptyStruct(EmptyStruct other) { + } + + public EmptyStruct deepCopy() { + return new EmptyStruct(this); + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof EmptyStruct)) + return false; + EmptyStruct that = (EmptyStruct)_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 EmptyStruct 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(); + + EmptyStruct _that; + _that = new EmptyStruct( + ); + _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/default_values_rectification_after/out/android/gen-android/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/android/gen-android/TestStruct.java new file mode 100644 index 00000000000000..d7392b979ae5e5 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/android/gen-android/TestStruct.java @@ -0,0 +1,438 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 TestStruct implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + + public final Integer unqualified_int_field; + public final Boolean unqualified_bool_field; + public final List unqualified_list_field; + public final EmptyStruct unqualified_struct_field; + public final Integer optional_int_field; + public final Boolean optional_bool_field; + public final List optional_list_field; + public final EmptyStruct optional_struct_field; + public static final int UNQUALIFIED_INT_FIELD = 1; + public static final int UNQUALIFIED_BOOL_FIELD = 2; + public static final int UNQUALIFIED_LIST_FIELD = 3; + public static final int UNQUALIFIED_STRUCT_FIELD = 4; + public static final int OPTIONAL_INT_FIELD = 5; + public static final int OPTIONAL_BOOL_FIELD = 6; + public static final int OPTIONAL_LIST_FIELD = 7; + public static final int OPTIONAL_STRUCT_FIELD = 8; + + public TestStruct( + Integer unqualified_int_field, + Boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field, + Integer optional_int_field, + Boolean optional_bool_field, + List optional_list_field, + EmptyStruct optional_struct_field) { + this.unqualified_int_field = unqualified_int_field; + this.unqualified_bool_field = unqualified_bool_field; + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + this.optional_int_field = optional_int_field; + this.optional_bool_field = optional_bool_field; + this.optional_list_field = optional_list_field; + this.optional_struct_field = optional_struct_field; + } + + /** + * Performs a deep copy on other. + */ + public TestStruct(TestStruct other) { + if (other.isSetUnqualified_int_field()) { + this.unqualified_int_field = TBaseHelper.deepCopy(other.unqualified_int_field); + } else { + this.unqualified_int_field = null; + } + if (other.isSetUnqualified_bool_field()) { + this.unqualified_bool_field = TBaseHelper.deepCopy(other.unqualified_bool_field); + } else { + this.unqualified_bool_field = null; + } + if (other.isSetUnqualified_list_field()) { + this.unqualified_list_field = TBaseHelper.deepCopy(other.unqualified_list_field); + } else { + this.unqualified_list_field = null; + } + if (other.isSetUnqualified_struct_field()) { + this.unqualified_struct_field = TBaseHelper.deepCopy(other.unqualified_struct_field); + } else { + this.unqualified_struct_field = null; + } + if (other.isSetOptional_int_field()) { + this.optional_int_field = TBaseHelper.deepCopy(other.optional_int_field); + } else { + this.optional_int_field = null; + } + if (other.isSetOptional_bool_field()) { + this.optional_bool_field = TBaseHelper.deepCopy(other.optional_bool_field); + } else { + this.optional_bool_field = null; + } + if (other.isSetOptional_list_field()) { + this.optional_list_field = TBaseHelper.deepCopy(other.optional_list_field); + } else { + this.optional_list_field = null; + } + if (other.isSetOptional_struct_field()) { + this.optional_struct_field = TBaseHelper.deepCopy(other.optional_struct_field); + } else { + this.optional_struct_field = null; + } + } + + public TestStruct deepCopy() { + return new TestStruct(this); + } + + public Integer getUnqualified_int_field() { + return this.unqualified_int_field; + } + + // Returns true if field unqualified_int_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_int_field() { + return this.unqualified_int_field != null; + } + + public Boolean isUnqualified_bool_field() { + return this.unqualified_bool_field; + } + + // Returns true if field unqualified_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_bool_field() { + return this.unqualified_bool_field != null; + } + + public List getUnqualified_list_field() { + return this.unqualified_list_field; + } + + // Returns true if field unqualified_list_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_list_field() { + return this.unqualified_list_field != null; + } + + public EmptyStruct getUnqualified_struct_field() { + return this.unqualified_struct_field; + } + + // Returns true if field unqualified_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_struct_field() { + return this.unqualified_struct_field != null; + } + + public Integer getOptional_int_field() { + return this.optional_int_field; + } + + // Returns true if field optional_int_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_int_field() { + return this.optional_int_field != null; + } + + public Boolean isOptional_bool_field() { + return this.optional_bool_field; + } + + // Returns true if field optional_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_bool_field() { + return this.optional_bool_field != null; + } + + public List getOptional_list_field() { + return this.optional_list_field; + } + + // Returns true if field optional_list_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_list_field() { + return this.optional_list_field != null; + } + + public EmptyStruct getOptional_struct_field() { + return this.optional_struct_field; + } + + // Returns true if field optional_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_struct_field() { + return this.optional_struct_field != null; + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof TestStruct)) + return false; + TestStruct that = (TestStruct)_that; + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_int_field(), that.isSetUnqualified_int_field(), this.unqualified_int_field, that.unqualified_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_bool_field(), that.isSetUnqualified_bool_field(), this.unqualified_bool_field, that.unqualified_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_list_field(), that.isSetUnqualified_list_field(), this.unqualified_list_field, that.unqualified_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_struct_field(), that.isSetUnqualified_struct_field(), this.unqualified_struct_field, that.unqualified_struct_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_int_field(), that.isSetOptional_int_field(), this.optional_int_field, that.optional_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_bool_field(), that.isSetOptional_bool_field(), this.optional_bool_field, that.optional_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_list_field(), that.isSetOptional_list_field(), this.optional_list_field, that.optional_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_struct_field(), that.isSetOptional_struct_field(), this.optional_struct_field, that.optional_struct_field)) { return false; } + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {unqualified_int_field, unqualified_bool_field, unqualified_list_field, unqualified_struct_field, optional_int_field, optional_bool_field, optional_list_field, optional_struct_field}); + } + + // 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 TestStruct deserialize(TProtocol iprot) throws TException { + Integer tmp_unqualified_int_field = null; + Boolean tmp_unqualified_bool_field = null; + List tmp_unqualified_list_field = null; + EmptyStruct tmp_unqualified_struct_field = null; + Integer tmp_optional_int_field = null; + Boolean tmp_optional_bool_field = null; + List tmp_optional_list_field = null; + EmptyStruct tmp_optional_struct_field = null; + TField __field; + iprot.readStructBegin(); + while (true) + { + __field = iprot.readFieldBegin(); + if (__field.type == TType.STOP) { + break; + } + switch (__field.id) + { + case UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + tmp_unqualified_int_field = iprot.readI32(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + tmp_unqualified_bool_field = iprot.readBool(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list0 = iprot.readListBegin(); + tmp_unqualified_list_field = new ArrayList(Math.max(0, _list0.size)); + for (int _i1 = 0; + (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); + ++_i1) + { + Integer _elem2; + _elem2 = iprot.readI32(); + tmp_unqualified_list_field.add(_elem2); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + tmp_unqualified_struct_field = EmptyStruct.deserialize(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + tmp_optional_int_field = iprot.readI32(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + tmp_optional_bool_field = iprot.readBool(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list3 = iprot.readListBegin(); + tmp_optional_list_field = new ArrayList(Math.max(0, _list3.size)); + for (int _i4 = 0; + (_list3.size < 0) ? iprot.peekList() : (_i4 < _list3.size); + ++_i4) + { + Integer _elem5; + _elem5 = iprot.readI32(); + tmp_optional_list_field.add(_elem5); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + tmp_optional_struct_field = EmptyStruct.deserialize(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + default: + TProtocolUtil.skip(iprot, __field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + TestStruct _that; + _that = new TestStruct( + tmp_unqualified_int_field + ,tmp_unqualified_bool_field + ,tmp_unqualified_list_field + ,tmp_unqualified_struct_field + ,tmp_optional_int_field + ,tmp_optional_bool_field + ,tmp_optional_list_field + ,tmp_optional_struct_field + ); + _that.validate(); + return _that; + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.unqualified_int_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualified_int_field); + oprot.writeFieldEnd(); + } + if (this.unqualified_bool_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualified_bool_field); + oprot.writeFieldEnd(); + } + if (this.unqualified_list_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.unqualified_list_field.size())); + for (Integer _iter6 : this.unqualified_list_field) { + oprot.writeI32(_iter6); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (this.unqualified_struct_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualified_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + if (this.optional_int_field != null) { + if (isSetOptional_int_field()) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optional_int_field); + oprot.writeFieldEnd(); + } + } + if (this.optional_bool_field != null) { + if (isSetOptional_bool_field()) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optional_bool_field); + oprot.writeFieldEnd(); + } + } + if (this.optional_list_field != null) { + if (isSetOptional_list_field()) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.optional_list_field.size())); + for (Integer _iter7 : this.optional_list_field) { + oprot.writeI32(_iter7); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.optional_struct_field != null) { + if (isSetOptional_struct_field()) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optional_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + } + 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/default_values_rectification_after/out/ast/gen-ast/module.ast b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/ast/gen-ast/module.ast new file mode 100644 index 00000000000000..dba8485126c5e4 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/ast/gen-ast/module.ast @@ -0,0 +1,232 @@ +Schema { + 1: programs (list) = list[1] { + [0] = Program { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "module", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification", + }, + 2: id (i64) = -8019751949614625057, + 8: definitionKeys (list) = list[2] { + [0] = ">\364\204\333\021k\245\343\272\021\231}\266l\332\212", + [1] = "\323\255\366\333\327\007\024\003\277|K\330\201dL\324", + }, + 5: path (string) = "thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift", + }, + }, + 8: definitionsMap (map) = map[2] { + ">\364\204\333\021k\245\343\272\021\231}\266l\332\212" -> Definition { + 1: structDef (struct) = Struct { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "EmptyStruct", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 19, + 3: beginColumn (i32) = 1, + 4: endLine (i32) = 19, + 5: endColumn (i32) = 22, + }, + }, + }, + }, + "\323\255\366\333\327\007\024\003\277|K\330\201dL\324" -> Definition { + 1: structDef (struct) = Struct { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "TestStruct", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 21, + 3: beginColumn (i32) = 1, + 4: endLine (i32) = 37, + 5: endColumn (i32) = 2, + }, + }, + 2: fields (list) = list[8] { + [0] = Field { + 1: id (i16) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_int_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 22, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 22, + 5: endColumn (i32) = 32, + }, + }, + }, + [1] = Field { + 1: id (i16) = 2, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 1: boolType (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_bool_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 24, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 24, + 5: endColumn (i32) = 34, + }, + }, + }, + [2] = Field { + 1: id (i16) = 3, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 14: listType (i32) = 0, + }, + 2: params (list) = list[1] { + [0] = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_list_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 26, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 26, + 5: endColumn (i32) = 39, + }, + }, + }, + [3] = Field { + 1: id (i16) = 4, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 11: structType (struct) = TypeUri { + 4: definitionKey (string) = ">\364\204\333\021k\245\343\272\021\231}\266l\332\212", + }, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_struct_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 28, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 28, + 5: endColumn (i32) = 43, + }, + }, + }, + [4] = Field { + 1: id (i16) = 5, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_int_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 30, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 30, + 5: endColumn (i32) = 38, + }, + }, + }, + [5] = Field { + 1: id (i16) = 6, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 1: boolType (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_bool_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 32, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 32, + 5: endColumn (i32) = 40, + }, + }, + }, + [6] = Field { + 1: id (i16) = 7, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 14: listType (i32) = 0, + }, + 2: params (list) = list[1] { + [0] = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_list_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 34, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 34, + 5: endColumn (i32) = 45, + }, + }, + }, + [7] = Field { + 1: id (i16) = 8, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 11: structType (struct) = TypeUri { + 4: definitionKey (string) = ">\364\204\333\021k\245\343\272\021\231}\266l\332\212", + }, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_struct_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -8019751949614625057, + 2: beginLine (i32) = 36, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 36, + 5: endColumn (i32) = 49, + }, + }, + }, + }, + }, + }, + }, +} \ No newline at end of file diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_clients.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_clients.h new file mode 100644 index 00000000000000..63856004a06e3b --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_clients.h @@ -0,0 +1,8 @@ +/** + * Autogenerated by Thrift for + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.cpp new file mode 100644 index 00000000000000..94ad553dc78b9f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.cpp @@ -0,0 +1,25 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_constants.h" + +#include + + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +namespace module_constants { + + +::std::string_view _fbthrift_schema_90b41e17a0794edf() { + return ""; +} +::folly::Range _fbthrift_schema_90b41e17a0794edf_includes() { + return {}; +} + +} // namespace module_constants +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.h new file mode 100644 index 00000000000000..62f3f7f04c2eef --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_constants.h @@ -0,0 +1,21 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift"} */ +namespace module_constants { + + FOLLY_EXPORT ::std::string_view _fbthrift_schema_90b41e17a0794edf(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_90b41e17a0794edf_includes(); + +} // namespace module_constants +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.cpp new file mode 100644 index 00000000000000..1ef2972872f8b4 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.cpp @@ -0,0 +1,101 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_data.h" + +#include + +FOLLY_CLANG_DISABLE_WARNING("-Wunused-macros") + +#if defined(__GNUC__) && defined(__linux__) && !FOLLY_MOBILE +// These attributes are applied to the static data members to ensure that they +// are not stripped from the compiled binary, in order to keep them available +// for use by debuggers at runtime. +// +// The "used" attribute is required to ensure the compiler always emits unused +// data. +// +// The "section" attribute is required to stop the linker from stripping used +// data. It works by forcing all of the data members (both used and unused ones) +// into the same section. As the linker strips data on a per-section basis, it +// is then unable to remove unused data without also removing used data. +// This has a similar effect to the "retain" attribute, but works with older +// toolchains. +#define THRIFT_DATA_MEMBER [[gnu::used]] [[gnu::section(".rodata.thrift.data")]] +#else +#define THRIFT_DATA_MEMBER +#endif + +namespace apache { +namespace thrift { + +THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::name = "EmptyStruct"; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_names = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_ids = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_types = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::storage_names = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::isset_indexes = { { +}}; + +THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::name = "TestStruct"; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_names = { { + "unqualified_int_field"sv, + "unqualified_bool_field"sv, + "unqualified_list_field"sv, + "unqualified_struct_field"sv, + "optional_int_field"sv, + "optional_bool_field"sv, + "optional_list_field"sv, + "optional_struct_field"sv, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_ids = { { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_types = { { + TType::T_I32, + TType::T_BOOL, + TType::T_LIST, + TType::T_STRUCT, + TType::T_I32, + TType::T_BOOL, + TType::T_LIST, + TType::T_STRUCT, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::storage_names = { { + "__fbthrift_field_unqualified_int_field"sv, + "__fbthrift_field_unqualified_bool_field"sv, + "__fbthrift_field_unqualified_list_field"sv, + "__fbthrift_field_unqualified_struct_field"sv, + "__fbthrift_field_optional_int_field"sv, + "__fbthrift_field_optional_bool_field"sv, + "__fbthrift_field_optional_list_field"sv, + "__fbthrift_field_optional_struct_field"sv, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::isset_indexes = { { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, +}}; + +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.h new file mode 100644 index 00000000000000..1323f796c571b2 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_data.h @@ -0,0 +1,47 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" + +namespace apache { namespace thrift { + +template <> struct TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + static constexpr const std::size_t fields_size = 0; + static const std::string_view name; + static const std::array fields_names; + static const std::array fields_ids; + static const std::array fields_types; + + private: + // The following fields describe internal storage metadata, and are private to + // prevent user logic from accessing them, but they can be inspected by + // debuggers. + static const std::array storage_names; + // -1 if the field has no isset. + static const std::array isset_indexes; +}; + +template <> struct TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + static constexpr const std::size_t fields_size = 8; + static const std::string_view name; + static const std::array fields_names; + static const std::array fields_ids; + static const std::array fields_types; + + private: + // The following fields describe internal storage metadata, and are private to + // prevent user logic from accessing them, but they can be inspected by + // debuggers. + static const std::array storage_names; + // -1 if the field has no isset. + static const std::array isset_indexes; +}; + +}} // apache::thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_for_each_field.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_for_each_field.h new file mode 100644 index 00000000000000..2b90092e96887a --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_for_each_field.h @@ -0,0 +1,39 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" +#include + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct ForEachField<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + template + void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const { + } +}; + +template <> +struct ForEachField<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + template + void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const { + f(0, static_cast(t).unqualified_int_field_ref()...); + f(1, static_cast(t).unqualified_bool_field_ref()...); + f(2, static_cast(t).unqualified_list_field_ref()...); + f(3, static_cast(t).unqualified_struct_field_ref()...); + f(4, static_cast(t).optional_int_field_ref()...); + f(5, static_cast(t).optional_bool_field_ref()...); + f(6, static_cast(t).optional_list_field_ref()...); + f(7, static_cast(t).optional_struct_field_ref()...); + } +}; +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_handlers.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_handlers.h new file mode 100644 index 00000000000000..63856004a06e3b --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_handlers.h @@ -0,0 +1,8 @@ +/** + * Autogenerated by Thrift for + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.cpp new file mode 100644 index 00000000000000..e8ea31ab5a6a83 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.cpp @@ -0,0 +1,67 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" + +// some of these functions can be so large that the compiler gives up optimizing +// them - and issues a warning which may be treated as an error! +// +// these functions are so rarely called that it is probably okay for them not to +// be optimized in practice +FOLLY_CLANG_DISABLE_WARNING("-Wignored-optimization-argument") + +namespace apache { +namespace thrift { +namespace detail { +namespace md { +using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata; +using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType; +using ThriftType = ::apache::thrift::metadata::ThriftType; +using ThriftService = ::apache::thrift::metadata::ThriftService; +using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext; +using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&); + + +const ::apache::thrift::metadata::ThriftStruct& +StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::gen(ThriftMetadata& metadata) { + auto res = metadata.structs()->emplace("module.EmptyStruct", ::apache::thrift::metadata::ThriftStruct{}); + if (!res.second) { + return res.first->second; + } + ::apache::thrift::metadata::ThriftStruct& module_EmptyStruct = res.first->second; + module_EmptyStruct.name() = "module.EmptyStruct"; + module_EmptyStruct.is_union() = false; + return res.first->second; +} +const ::apache::thrift::metadata::ThriftStruct& +StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::gen(ThriftMetadata& metadata) { + auto res = metadata.structs()->emplace("module.TestStruct", ::apache::thrift::metadata::ThriftStruct{}); + if (!res.second) { + return res.first->second; + } + ::apache::thrift::metadata::ThriftStruct& module_TestStruct = res.first->second; + module_TestStruct.name() = "module.TestStruct"; + module_TestStruct.is_union() = false; + static const auto* const + module_TestStruct_fields = new std::array{ { + { 1, "unqualified_int_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 2, "unqualified_bool_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 3, "unqualified_list_field", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 4, "unqualified_struct_field", false, std::make_unique>("module.EmptyStruct"), std::vector{ }}, { 5, "optional_int_field", true, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 6, "optional_bool_field", true, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 7, "optional_list_field", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 8, "optional_struct_field", true, std::make_unique>("module.EmptyStruct"), std::vector{ }}, }}; + for (const auto& f : *module_TestStruct_fields) { + ::apache::thrift::metadata::ThriftField field; + field.id() = f.id; + field.name() = f.name; + field.is_optional() = f.is_optional; + f.metadata_type_interface->writeAndGenType(*field.type(), metadata); + field.structured_annotations() = f.structured_annotations; + module_TestStruct.fields()->push_back(std::move(field)); + } + return res.first->second; +} + +} // namespace md +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.h new file mode 100644 index 00000000000000..fc03367c2059a5 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_metadata.h @@ -0,0 +1,33 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" + + +namespace apache { +namespace thrift { +namespace detail { +namespace md { + +template <> +class StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + public: + static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata); +}; +template <> +class StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + public: + static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata); +}; +} // namespace md +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.cpp new file mode 100644 index 00000000000000..55903afcf250b0 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.cpp @@ -0,0 +1,329 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.tcc" + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_data.h" +[[maybe_unused]] static constexpr std::string_view kModuleName = "module"; + + +namespace apache { +namespace thrift { +namespace detail { + +void TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept { + using data = apache::thrift::TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>; + static const st::translate_field_name_table table{ + data::fields_size, + data::fields_names.data(), + data::fields_ids.data(), + data::fields_types.data()}; + st::translate_field_name(_fname, fid, _ftype, table); +} + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +const char* EmptyStruct::__fbthrift_thrift_uri() { + return "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct"; +} + +std::string_view EmptyStruct::__fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord) { + if (ord == ::apache::thrift::FieldOrdinal{0}) { return {}; } + return apache::thrift::TStructDataStorage::fields_names[folly::to_underlying(ord) - 1]; +} +std::string_view EmptyStruct::__fbthrift_get_class_name() { + return apache::thrift::TStructDataStorage::name; +} + + +EmptyStruct::EmptyStruct(apache::thrift::FragileConstructor) {} + + +void EmptyStruct::__fbthrift_clear() { + // clear all fields +} + +void EmptyStruct::__fbthrift_clear_terse_fields() { +} + +bool EmptyStruct::__fbthrift_is_empty() const { + return true; +} + +bool EmptyStruct::operator==([[maybe_unused]] const EmptyStruct& rhs) const { + return ::apache::thrift::op::detail::StructEquality{}(*this, rhs); +} + +bool EmptyStruct::operator<([[maybe_unused]] const EmptyStruct& rhs) const { + return ::apache::thrift::op::detail::StructLessThan{}(*this, rhs); +} + + +void swap([[maybe_unused]] EmptyStruct& a, [[maybe_unused]] EmptyStruct& b) { + using ::std::swap; +} + +template void EmptyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +template uint32_t EmptyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +template uint32_t EmptyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +template void EmptyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +template uint32_t EmptyStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +template uint32_t EmptyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification + +namespace apache { +namespace thrift { +namespace detail { + +void TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept { + using data = apache::thrift::TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>; + static const st::translate_field_name_table table{ + data::fields_size, + data::fields_names.data(), + data::fields_ids.data(), + data::fields_types.data()}; + st::translate_field_name(_fname, fid, _ftype, table); +} + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +const char* TestStruct::__fbthrift_thrift_uri() { + return "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct"; +} + +std::string_view TestStruct::__fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord) { + if (ord == ::apache::thrift::FieldOrdinal{0}) { return {}; } + return apache::thrift::TStructDataStorage::fields_names[folly::to_underlying(ord) - 1]; +} +std::string_view TestStruct::__fbthrift_get_class_name() { + return apache::thrift::TStructDataStorage::name; +} + +TestStruct::TestStruct(const TestStruct&) = default; +TestStruct& TestStruct::operator=(const TestStruct&) = default; +TestStruct::TestStruct() : + __fbthrift_field_unqualified_int_field(), + __fbthrift_field_unqualified_bool_field(), + __fbthrift_field_optional_int_field(), + __fbthrift_field_optional_bool_field() { +} + + +TestStruct::~TestStruct() {} + +TestStruct::TestStruct([[maybe_unused]] TestStruct&& other) noexcept : + __fbthrift_field_unqualified_int_field(std::move(other.__fbthrift_field_unqualified_int_field)), + __fbthrift_field_unqualified_bool_field(std::move(other.__fbthrift_field_unqualified_bool_field)), + __fbthrift_field_unqualified_list_field(std::move(other.__fbthrift_field_unqualified_list_field)), + __fbthrift_field_unqualified_struct_field(std::move(other.__fbthrift_field_unqualified_struct_field)), + __fbthrift_field_optional_int_field(std::move(other.__fbthrift_field_optional_int_field)), + __fbthrift_field_optional_bool_field(std::move(other.__fbthrift_field_optional_bool_field)), + __fbthrift_field_optional_list_field(std::move(other.__fbthrift_field_optional_list_field)), + __fbthrift_field_optional_struct_field(std::move(other.__fbthrift_field_optional_struct_field)), + __isset(other.__isset) { +} + +TestStruct& TestStruct::operator=([[maybe_unused]] TestStruct&& other) noexcept { + this->__fbthrift_field_unqualified_int_field = std::move(other.__fbthrift_field_unqualified_int_field); + this->__fbthrift_field_unqualified_bool_field = std::move(other.__fbthrift_field_unqualified_bool_field); + this->__fbthrift_field_unqualified_list_field = std::move(other.__fbthrift_field_unqualified_list_field); + this->__fbthrift_field_unqualified_struct_field = std::move(other.__fbthrift_field_unqualified_struct_field); + this->__fbthrift_field_optional_int_field = std::move(other.__fbthrift_field_optional_int_field); + this->__fbthrift_field_optional_bool_field = std::move(other.__fbthrift_field_optional_bool_field); + this->__fbthrift_field_optional_list_field = std::move(other.__fbthrift_field_optional_list_field); + this->__fbthrift_field_optional_struct_field = std::move(other.__fbthrift_field_optional_struct_field); + __isset = other.__isset; + return *this; +} + + +TestStruct::TestStruct(apache::thrift::FragileConstructor, ::std::int32_t unqualified_int_field__arg, bool unqualified_bool_field__arg, ::std::vector<::std::int32_t> unqualified_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct unqualified_struct_field__arg, ::std::int32_t optional_int_field__arg, bool optional_bool_field__arg, ::std::vector<::std::int32_t> optional_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct optional_struct_field__arg) : + __fbthrift_field_unqualified_int_field(std::move(unqualified_int_field__arg)), + __fbthrift_field_unqualified_bool_field(std::move(unqualified_bool_field__arg)), + __fbthrift_field_unqualified_list_field(std::move(unqualified_list_field__arg)), + __fbthrift_field_unqualified_struct_field(std::move(unqualified_struct_field__arg)), + __fbthrift_field_optional_int_field(std::move(optional_int_field__arg)), + __fbthrift_field_optional_bool_field(std::move(optional_bool_field__arg)), + __fbthrift_field_optional_list_field(std::move(optional_list_field__arg)), + __fbthrift_field_optional_struct_field(std::move(optional_struct_field__arg)) { + __isset.set(folly::index_constant<0>(), true); + __isset.set(folly::index_constant<1>(), true); + __isset.set(folly::index_constant<2>(), true); + __isset.set(folly::index_constant<3>(), true); + __isset.set(folly::index_constant<4>(), true); + __isset.set(folly::index_constant<5>(), true); + __isset.set(folly::index_constant<6>(), true); + __isset.set(folly::index_constant<7>(), true); +} + + +void TestStruct::__fbthrift_clear() { + // clear all fields + this->__fbthrift_field_unqualified_int_field = ::std::int32_t(); + this->__fbthrift_field_unqualified_bool_field = bool(); + this->__fbthrift_field_unqualified_list_field.clear(); + this->__fbthrift_field_optional_int_field = ::std::int32_t(); + this->__fbthrift_field_optional_bool_field = bool(); + this->__fbthrift_field_optional_list_field.clear(); + __isset = {}; +} + +void TestStruct::__fbthrift_clear_terse_fields() { +} + +bool TestStruct::__fbthrift_is_empty() const { + return false; +} + +bool TestStruct::operator==([[maybe_unused]] const TestStruct& rhs) const { + return ::apache::thrift::op::detail::StructEquality{}(*this, rhs); +} + +bool TestStruct::operator<([[maybe_unused]] const TestStruct& rhs) const { + return ::apache::thrift::op::detail::StructLessThan{}(*this, rhs); +} + + +::std::int32_t TestStruct::get_unqualified_int_field() const { + return __fbthrift_field_unqualified_int_field; +} + +::std::int32_t& TestStruct::set_unqualified_int_field(::std::int32_t unqualified_int_field_) { + unqualified_int_field_ref() = unqualified_int_field_; + return __fbthrift_field_unqualified_int_field; +} + +bool TestStruct::get_unqualified_bool_field() const { + return __fbthrift_field_unqualified_bool_field; +} + +bool& TestStruct::set_unqualified_bool_field(bool unqualified_bool_field_) { + unqualified_bool_field_ref() = unqualified_bool_field_; + return __fbthrift_field_unqualified_bool_field; +} + +const ::std::vector<::std::int32_t>& TestStruct::get_unqualified_list_field() const& { + return __fbthrift_field_unqualified_list_field; +} + +::std::vector<::std::int32_t> TestStruct::get_unqualified_list_field() && { + return static_cast<::std::vector<::std::int32_t>&&>(__fbthrift_field_unqualified_list_field); +} + +const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& TestStruct::get_unqualified_struct_field() const& { + return __fbthrift_field_unqualified_struct_field; +} + +::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct TestStruct::get_unqualified_struct_field() && { + return static_cast<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct&&>(__fbthrift_field_unqualified_struct_field); +} + +const ::std::int32_t* TestStruct::get_optional_int_field() const& { + return optional_int_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_int_field) : nullptr; +} + +::std::int32_t* TestStruct::get_optional_int_field() & { + return optional_int_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_int_field) : nullptr; +} + +::std::int32_t& TestStruct::set_optional_int_field(::std::int32_t optional_int_field_) { + optional_int_field_ref() = optional_int_field_; + return __fbthrift_field_optional_int_field; +} + +const bool* TestStruct::get_optional_bool_field() const& { + return optional_bool_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_bool_field) : nullptr; +} + +bool* TestStruct::get_optional_bool_field() & { + return optional_bool_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_bool_field) : nullptr; +} + +bool& TestStruct::set_optional_bool_field(bool optional_bool_field_) { + optional_bool_field_ref() = optional_bool_field_; + return __fbthrift_field_optional_bool_field; +} + +const ::std::vector<::std::int32_t>* TestStruct::get_optional_list_field() const& { + return optional_list_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_list_field) : nullptr; +} + +::std::vector<::std::int32_t>* TestStruct::get_optional_list_field() & { + return optional_list_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_list_field) : nullptr; +} + +const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* TestStruct::get_optional_struct_field() const& { + return optional_struct_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_struct_field) : nullptr; +} + +::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* TestStruct::get_optional_struct_field() & { + return optional_struct_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_struct_field) : nullptr; +} + +void swap([[maybe_unused]] TestStruct& a, [[maybe_unused]] TestStruct& b) { + using ::std::swap; + swap(a.__fbthrift_field_unqualified_int_field, b.__fbthrift_field_unqualified_int_field); + swap(a.__fbthrift_field_unqualified_bool_field, b.__fbthrift_field_unqualified_bool_field); + swap(a.__fbthrift_field_unqualified_list_field, b.__fbthrift_field_unqualified_list_field); + swap(a.__fbthrift_field_unqualified_struct_field, b.__fbthrift_field_unqualified_struct_field); + swap(a.__fbthrift_field_optional_int_field, b.__fbthrift_field_optional_int_field); + swap(a.__fbthrift_field_optional_bool_field, b.__fbthrift_field_optional_bool_field); + swap(a.__fbthrift_field_optional_list_field, b.__fbthrift_field_optional_list_field); + swap(a.__fbthrift_field_optional_struct_field, b.__fbthrift_field_optional_struct_field); + swap(a.__isset, b.__isset); +} + +template void TestStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +template uint32_t TestStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +template uint32_t TestStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +template void TestStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +template uint32_t TestStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +template uint32_t TestStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + +static_assert( + ::apache::thrift::detail::st::gen_check_json< + TestStruct, + ::apache::thrift::type_class::structure, + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + "inconsistent use of json option"); +static_assert( + ::apache::thrift::detail::st::gen_check_json< + TestStruct, + ::apache::thrift::type_class::structure, + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + "inconsistent use of json option"); + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { namespace { +[[maybe_unused]] FOLLY_ERASE void validateAdapters() { +} +}} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +namespace apache::thrift::detail::annotation { +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.h new file mode 100644 index 00000000000000..8a5fb161e65eb9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.h @@ -0,0 +1,818 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + + + +namespace apache { +namespace thrift { +namespace ident { +struct unqualified_int_field; +struct unqualified_bool_field; +struct unqualified_list_field; +struct unqualified_struct_field; +struct optional_int_field; +struct optional_bool_field; +struct optional_list_field; +struct optional_struct_field; +} // namespace ident +namespace detail { +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_int_field +#define APACHE_THRIFT_ACCESSOR_unqualified_int_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_int_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_bool_field +#define APACHE_THRIFT_ACCESSOR_unqualified_bool_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_bool_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_list_field +#define APACHE_THRIFT_ACCESSOR_unqualified_list_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_list_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_struct_field +#define APACHE_THRIFT_ACCESSOR_unqualified_struct_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_struct_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_int_field +#define APACHE_THRIFT_ACCESSOR_optional_int_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_int_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_bool_field +#define APACHE_THRIFT_ACCESSOR_optional_bool_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_bool_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_list_field +#define APACHE_THRIFT_ACCESSOR_optional_list_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_list_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_struct_field +#define APACHE_THRIFT_ACCESSOR_optional_struct_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_struct_field); +#endif +} // namespace detail +} // namespace thrift +} // namespace apache + +// BEGIN declare_enums + +// END declare_enums +// BEGIN forward_declare +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +class EmptyStruct; +class TestStruct; +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +// END forward_declare +namespace apache::thrift::detail::annotation { +} // namespace apache::thrift::detail::annotation + +namespace apache::thrift::detail::qualifier { +} // namespace apache::thrift::detail::qualifier + +// BEGIN hash_and_equal_to +// END hash_and_equal_to +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +using ::apache::thrift::detail::operator!=; +using ::apache::thrift::detail::operator>; +using ::apache::thrift::detail::operator<=; +using ::apache::thrift::detail::operator>=; + + +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift", "name": "EmptyStruct", "kind": "struct" } */ +class EmptyStruct final { + private: + friend struct ::apache::thrift::detail::st::struct_private_access; + template friend struct ::apache::thrift::detail::invoke_reffer; + + // used by a static_assert in the corresponding source + static constexpr bool __fbthrift_cpp2_gen_json = false; + static constexpr bool __fbthrift_cpp2_is_runtime_annotation = false; + static const char* __fbthrift_thrift_uri(); + static std::string_view __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord); + static std::string_view __fbthrift_get_class_name(); + template + FOLLY_ERASE static constexpr std::string_view __fbthrift_get_module_name() noexcept { + return "module"; + } + using __fbthrift_reflection_ident_list = folly::tag_t< + >; + + static constexpr std::int16_t __fbthrift_reflection_field_id_list[] = {0}; + using __fbthrift_reflection_type_tags = folly::tag_t< + >; + + static constexpr std::size_t __fbthrift_field_size_v = 0; + + template + using __fbthrift_id = ::apache::thrift::type::field_id<__fbthrift_reflection_field_id_list[folly::to_underlying(T::value)]>; + + template + using __fbthrift_type_tag = ::apache::thrift::detail::at<__fbthrift_reflection_type_tags, T::value>; + + template + using __fbthrift_ident = ::apache::thrift::detail::at<__fbthrift_reflection_ident_list, T::value>; + + template using __fbthrift_ordinal = ::apache::thrift::type::ordinal_tag< + ::apache::thrift::detail::getFieldOrdinal( + __fbthrift_reflection_field_id_list + ) + >; + void __fbthrift_clear(); + void __fbthrift_clear_terse_fields(); + bool __fbthrift_is_empty() const; + + public: + using __fbthrift_cpp2_type = EmptyStruct; + static constexpr bool __fbthrift_cpp2_is_union = + false; + static constexpr bool __fbthrift_cpp2_uses_op_encode = + false; + + + public: + + EmptyStruct() { + } + // FragileConstructor for use in initialization lists only. + [[deprecated("This constructor is deprecated")]] + EmptyStruct(apache::thrift::FragileConstructor); + + EmptyStruct(EmptyStruct&&) = default; + + EmptyStruct(const EmptyStruct&) = default; + + + EmptyStruct& operator=(EmptyStruct&&) = default; + + EmptyStruct& operator=(const EmptyStruct&) = default; + + public: + + bool operator==(const EmptyStruct&) const; + bool operator<(const EmptyStruct&) const; + + template + unsigned long read(Protocol_* iprot); + template + uint32_t serializedSize(Protocol_ const* prot_) const; + template + uint32_t serializedSizeZC(Protocol_ const* prot_) const; + template + uint32_t write(Protocol_* prot_) const; + + private: + template + void readNoXfer(Protocol_* iprot); + + friend class ::apache::thrift::Cpp2Ops; + friend void swap(EmptyStruct& a, EmptyStruct& b); +}; + +template +unsigned long EmptyStruct::read(Protocol_* iprot) { + auto _xferStart = iprot->getCursorPosition(); + readNoXfer(iprot); + return iprot->getCursorPosition() - _xferStart; +} + + +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift", "name": "TestStruct", "kind": "struct" } */ +class TestStruct final { + private: + friend struct ::apache::thrift::detail::st::struct_private_access; + template friend struct ::apache::thrift::detail::invoke_reffer; + + // used by a static_assert in the corresponding source + static constexpr bool __fbthrift_cpp2_gen_json = false; + static constexpr bool __fbthrift_cpp2_is_runtime_annotation = false; + static const char* __fbthrift_thrift_uri(); + static std::string_view __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord); + static std::string_view __fbthrift_get_class_name(); + template + FOLLY_ERASE static constexpr std::string_view __fbthrift_get_module_name() noexcept { + return "module"; + } + using __fbthrift_reflection_ident_list = folly::tag_t< + ::apache::thrift::ident::unqualified_int_field, + ::apache::thrift::ident::unqualified_bool_field, + ::apache::thrift::ident::unqualified_list_field, + ::apache::thrift::ident::unqualified_struct_field, + ::apache::thrift::ident::optional_int_field, + ::apache::thrift::ident::optional_bool_field, + ::apache::thrift::ident::optional_list_field, + ::apache::thrift::ident::optional_struct_field + >; + + static constexpr std::int16_t __fbthrift_reflection_field_id_list[] = {0,1,2,3,4,5,6,7,8}; + using __fbthrift_reflection_type_tags = folly::tag_t< + ::apache::thrift::type::i32_t, + ::apache::thrift::type::bool_t, + ::apache::thrift::type::list<::apache::thrift::type::i32_t>, + ::apache::thrift::type::struct_t<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + ::apache::thrift::type::i32_t, + ::apache::thrift::type::bool_t, + ::apache::thrift::type::list<::apache::thrift::type::i32_t>, + ::apache::thrift::type::struct_t<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> + >; + + static constexpr std::size_t __fbthrift_field_size_v = 8; + + template + using __fbthrift_id = ::apache::thrift::type::field_id<__fbthrift_reflection_field_id_list[folly::to_underlying(T::value)]>; + + template + using __fbthrift_type_tag = ::apache::thrift::detail::at<__fbthrift_reflection_type_tags, T::value>; + + template + using __fbthrift_ident = ::apache::thrift::detail::at<__fbthrift_reflection_ident_list, T::value>; + + template using __fbthrift_ordinal = ::apache::thrift::type::ordinal_tag< + ::apache::thrift::detail::getFieldOrdinal( + __fbthrift_reflection_field_id_list + ) + >; + void __fbthrift_clear(); + void __fbthrift_clear_terse_fields(); + bool __fbthrift_is_empty() const; + + public: + using __fbthrift_cpp2_type = TestStruct; + static constexpr bool __fbthrift_cpp2_is_union = + false; + static constexpr bool __fbthrift_cpp2_uses_op_encode = + false; + + + public: + + TestStruct(); + + // FragileConstructor for use in initialization lists only. + [[deprecated("This constructor is deprecated")]] + TestStruct(apache::thrift::FragileConstructor, ::std::int32_t unqualified_int_field__arg, bool unqualified_bool_field__arg, ::std::vector<::std::int32_t> unqualified_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct unqualified_struct_field__arg, ::std::int32_t optional_int_field__arg, bool optional_bool_field__arg, ::std::vector<::std::int32_t> optional_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct optional_struct_field__arg); + + TestStruct(TestStruct&&) noexcept; + + TestStruct(const TestStruct& src); + + + TestStruct& operator=(TestStruct&&) noexcept; + TestStruct& operator=(const TestStruct& src); + + ~TestStruct(); + + private: + ::std::int32_t __fbthrift_field_unqualified_int_field; + private: + bool __fbthrift_field_unqualified_bool_field; + private: + ::std::vector<::std::int32_t> __fbthrift_field_unqualified_list_field; + private: + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct __fbthrift_field_unqualified_struct_field; + private: + ::std::int32_t __fbthrift_field_optional_int_field; + private: + bool __fbthrift_field_optional_bool_field; + private: + ::std::vector<::std::int32_t> __fbthrift_field_optional_list_field; + private: + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct __fbthrift_field_optional_struct_field; + private: + apache::thrift::detail::isset_bitset<8, apache::thrift::detail::IssetBitsetOption::Unpacked> __isset; + + public: + + bool operator==(const TestStruct&) const; + bool operator<(const TestStruct&) const; + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() const& { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() & { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() const& { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() & { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() && { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() const& { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() & { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() const& { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() & { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() && { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() const& { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() & { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() const& { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() & { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() && { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() const& { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() & { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() const& { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() & { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() && { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() const& { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() & { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() const& { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() const&& { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() & { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() && { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() const& { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() & { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() const& { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() const&& { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() & { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() && { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() const& { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() & { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() const& { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() const&& { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() & { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() && { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() const& { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() & { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() const& { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() const&& { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() & { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() && { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + [[deprecated("Use `FOO.unqualified_int_field().value();` instead of `FOO.get_unqualified_int_field();`")]] + ::std::int32_t get_unqualified_int_field() const; + + /** Glean { "field": "unqualified_int_field" } */ + [[deprecated("Use `FOO.unqualified_int_field() = BAR;` instead of `FOO.set_unqualified_int_field(BAR);`")]] + ::std::int32_t& set_unqualified_int_field(::std::int32_t unqualified_int_field_); + + /** Glean { "field": "unqualified_bool_field" } */ + [[deprecated("Use `FOO.unqualified_bool_field().value();` instead of `FOO.get_unqualified_bool_field();`")]] + bool get_unqualified_bool_field() const; + + /** Glean { "field": "unqualified_bool_field" } */ + [[deprecated("Use `FOO.unqualified_bool_field() = BAR;` instead of `FOO.set_unqualified_bool_field(BAR);`")]] + bool& set_unqualified_bool_field(bool unqualified_bool_field_); + + /** Glean { "field": "unqualified_list_field" } */ + [[deprecated("Use `FOO.unqualified_list_field().value();` instead of `FOO.get_unqualified_list_field();`")]] + const ::std::vector<::std::int32_t>& get_unqualified_list_field() const&; + + /** Glean { "field": "unqualified_list_field" } */ + [[deprecated("Use `FOO.unqualified_list_field().value();` instead of `FOO.get_unqualified_list_field();`")]] + ::std::vector<::std::int32_t> get_unqualified_list_field() &&; + + /** Glean { "field": "unqualified_list_field" } */ + template > + [[deprecated("Use `FOO.unqualified_list_field() = BAR;` instead of `FOO.set_unqualified_list_field(BAR);`")]] + ::std::vector<::std::int32_t>& set_unqualified_list_field(T_TestStruct_unqualified_list_field_struct_setter&& unqualified_list_field_) { + unqualified_list_field_ref() = std::forward(unqualified_list_field_); + return __fbthrift_field_unqualified_list_field; + } + + /** Glean { "field": "unqualified_struct_field" } */ + [[deprecated("Use `FOO.unqualified_struct_field().value();` instead of `FOO.get_unqualified_struct_field();`")]] + const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& get_unqualified_struct_field() const&; + + /** Glean { "field": "unqualified_struct_field" } */ + [[deprecated("Use `FOO.unqualified_struct_field().value();` instead of `FOO.get_unqualified_struct_field();`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct get_unqualified_struct_field() &&; + + /** Glean { "field": "unqualified_struct_field" } */ + template + [[deprecated("Use `FOO.unqualified_struct_field() = BAR;` instead of `FOO.set_unqualified_struct_field(BAR);`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& set_unqualified_struct_field(T_TestStruct_unqualified_struct_field_struct_setter&& unqualified_struct_field_) { + unqualified_struct_field_ref() = std::forward(unqualified_struct_field_); + return __fbthrift_field_unqualified_struct_field; + } + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field().value();` instead of `FOO.get_optional_int_field();`")]] + const ::std::int32_t* get_optional_int_field() const&; + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field().value();` instead of `FOO.get_optional_int_field();`")]] + ::std::int32_t* get_optional_int_field() &; + + ::std::int32_t* get_optional_int_field() && = delete; + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field() = BAR;` instead of `FOO.set_optional_int_field(BAR);`")]] + ::std::int32_t& set_optional_int_field(::std::int32_t optional_int_field_); + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field().value();` instead of `FOO.get_optional_bool_field();`")]] + const bool* get_optional_bool_field() const&; + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field().value();` instead of `FOO.get_optional_bool_field();`")]] + bool* get_optional_bool_field() &; + + bool* get_optional_bool_field() && = delete; + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field() = BAR;` instead of `FOO.set_optional_bool_field(BAR);`")]] + bool& set_optional_bool_field(bool optional_bool_field_); + + /** Glean { "field": "optional_list_field" } */ + [[deprecated("Use `FOO.optional_list_field().value();` instead of `FOO.get_optional_list_field();`")]] + const ::std::vector<::std::int32_t>* get_optional_list_field() const&; + + /** Glean { "field": "optional_list_field" } */ + [[deprecated("Use `FOO.optional_list_field().value();` instead of `FOO.get_optional_list_field();`")]] + ::std::vector<::std::int32_t>* get_optional_list_field() &; + + ::std::vector<::std::int32_t>* get_optional_list_field() && = delete; + + /** Glean { "field": "optional_list_field" } */ + template > + [[deprecated("Use `FOO.optional_list_field() = BAR;` instead of `FOO.set_optional_list_field(BAR);`")]] + ::std::vector<::std::int32_t>& set_optional_list_field(T_TestStruct_optional_list_field_struct_setter&& optional_list_field_) { + optional_list_field_ref() = std::forward(optional_list_field_); + return __fbthrift_field_optional_list_field; + } + + /** Glean { "field": "optional_struct_field" } */ + [[deprecated("Use `FOO.optional_struct_field().value();` instead of `FOO.get_optional_struct_field();`")]] + const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() const&; + + /** Glean { "field": "optional_struct_field" } */ + [[deprecated("Use `FOO.optional_struct_field().value();` instead of `FOO.get_optional_struct_field();`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() &; + + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() && = delete; + + /** Glean { "field": "optional_struct_field" } */ + template + [[deprecated("Use `FOO.optional_struct_field() = BAR;` instead of `FOO.set_optional_struct_field(BAR);`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& set_optional_struct_field(T_TestStruct_optional_struct_field_struct_setter&& optional_struct_field_) { + optional_struct_field_ref() = std::forward(optional_struct_field_); + return __fbthrift_field_optional_struct_field; + } + + template + unsigned long read(Protocol_* iprot); + template + uint32_t serializedSize(Protocol_ const* prot_) const; + template + uint32_t serializedSizeZC(Protocol_ const* prot_) const; + template + uint32_t write(Protocol_* prot_) const; + + private: + template + void readNoXfer(Protocol_* iprot); + + friend class ::apache::thrift::Cpp2Ops; + friend void swap(TestStruct& a, TestStruct& b); +}; + +template +unsigned long TestStruct::read(Protocol_* iprot) { + auto _xferStart = iprot->getCursorPosition(); + readNoXfer(iprot); + return iprot->getCursorPosition() - _xferStart; +} + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.tcc b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.tcc new file mode 100644 index 00000000000000..81467d5fc05e55 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types.tcc @@ -0,0 +1,509 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" + +#include + + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + static void translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept; +}; +template <> +struct TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + static void translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept; +}; + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +template +void EmptyStruct::readNoXfer(Protocol_* iprot) { + __fbthrift_clear_terse_fields(); + + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(iprot); + + using apache::thrift::TProtocolException; + + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 0, + 0, + apache::thrift::protocol::T_STOP))) { + goto _loop; + } + +_end: + _readState.readStructEnd(iprot); + + return; + + goto _advance_failure; // Avoid compiler warnings about unused labels. + _advance_failure: + _readState.afterAdvanceFailure(iprot); +_loop: + if (_readState.atStop()) { + goto _end; + } + if (iprot->kUsesFieldNames()) { + _readState.template fillFieldTraitsFromName>(); + } + + switch (_readState.fieldId) { + default: + { + _readState.skip(iprot); + _readState.readFieldEnd(iprot); + _readState.readFieldBeginNoInline(iprot); + goto _loop; + } + } +} + +template +uint32_t EmptyStruct::serializedSize(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("EmptyStruct"); + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t EmptyStruct::serializedSizeZC(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("EmptyStruct"); + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t EmptyStruct::write(Protocol_* prot_) const { + uint32_t xfer = 0; + xfer += prot_->writeStructBegin("EmptyStruct"); + xfer += prot_->writeFieldStop(); + xfer += prot_->writeStructEnd(); + return xfer; +} + +extern template void EmptyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +extern template uint32_t EmptyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +extern template uint32_t EmptyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template void EmptyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +extern template uint32_t EmptyStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +extern template uint32_t EmptyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +extern template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +template +void TestStruct::readNoXfer(Protocol_* iprot) { + __fbthrift_clear_terse_fields(); + + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(iprot); + + using apache::thrift::TProtocolException; + + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 0, + 1, + apache::thrift::protocol::T_I32))) { + goto _advance_failure; + } +_readField_unqualified_int_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::readWithContext(*iprot, this->__fbthrift_field_unqualified_int_field, _readState); + } + this->__isset.set(0, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 1, + 2, + apache::thrift::protocol::T_BOOL))) { + goto _advance_failure; + } +_readField_unqualified_bool_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->__fbthrift_field_unqualified_bool_field, _readState); + } + this->__isset.set(1, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 2, + 3, + apache::thrift::protocol::T_LIST))) { + goto _advance_failure; + } +_readField_unqualified_list_field: + { + _readState.beforeSubobject(iprot); + this->__fbthrift_field_unqualified_list_field = ::std::vector<::std::int32_t>(); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::readWithContext(*iprot, this->__fbthrift_field_unqualified_list_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(2, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 3, + 4, + apache::thrift::protocol::T_STRUCT))) { + goto _advance_failure; + } +_readField_unqualified_struct_field: + { + _readState.beforeSubobject(iprot); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::readWithContext(*iprot, this->__fbthrift_field_unqualified_struct_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(3, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 4, + 5, + apache::thrift::protocol::T_I32))) { + goto _advance_failure; + } +_readField_optional_int_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::readWithContext(*iprot, this->__fbthrift_field_optional_int_field, _readState); + } + this->__isset.set(4, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 5, + 6, + apache::thrift::protocol::T_BOOL))) { + goto _advance_failure; + } +_readField_optional_bool_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->__fbthrift_field_optional_bool_field, _readState); + } + this->__isset.set(5, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 6, + 7, + apache::thrift::protocol::T_LIST))) { + goto _advance_failure; + } +_readField_optional_list_field: + { + _readState.beforeSubobject(iprot); + this->__fbthrift_field_optional_list_field = ::std::vector<::std::int32_t>(); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::readWithContext(*iprot, this->__fbthrift_field_optional_list_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(6, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 7, + 8, + apache::thrift::protocol::T_STRUCT))) { + goto _advance_failure; + } +_readField_optional_struct_field: + { + _readState.beforeSubobject(iprot); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::readWithContext(*iprot, this->__fbthrift_field_optional_struct_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(7, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 8, + 0, + apache::thrift::protocol::T_STOP))) { + goto _advance_failure; + } + +_end: + _readState.readStructEnd(iprot); + + return; + + goto _advance_failure; // Avoid compiler warnings about unused labels. + _advance_failure: + _readState.afterAdvanceFailure(iprot); +_loop: + if (_readState.atStop()) { + goto _end; + } + if (iprot->kUsesFieldNames()) { + _readState.template fillFieldTraitsFromName>(); + } + + switch (_readState.fieldId) { + case 1: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_I32))) { + goto _readField_unqualified_int_field; + } else { + goto _skip; + } + } + case 2: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_unqualified_bool_field; + } else { + goto _skip; + } + } + case 3: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_LIST))) { + goto _readField_unqualified_list_field; + } else { + goto _skip; + } + } + case 4: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRUCT))) { + goto _readField_unqualified_struct_field; + } else { + goto _skip; + } + } + case 5: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_I32))) { + goto _readField_optional_int_field; + } else { + goto _skip; + } + } + case 6: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_optional_bool_field; + } else { + goto _skip; + } + } + case 7: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_LIST))) { + goto _readField_optional_list_field; + } else { + goto _skip; + } + } + case 8: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRUCT))) { + goto _readField_optional_struct_field; + } else { + goto _skip; + } + } + default: + { +_skip: + _readState.skip(iprot); + _readState.readFieldEnd(iprot); + _readState.readFieldBeginNoInline(iprot); + goto _loop; + } + } +} + +template +uint32_t TestStruct::serializedSize(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("TestStruct"); + { + xfer += prot_->serializedFieldSize("unqualified_int_field", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_unqualified_int_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_bool_field", apache::thrift::protocol::T_BOOL, 2); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_unqualified_bool_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_list_field", apache::thrift::protocol::T_LIST, 3); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_unqualified_list_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_struct_field", apache::thrift::protocol::T_STRUCT, 4); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_unqualified_struct_field); + } + if (this->__isset.get(4)) { + xfer += prot_->serializedFieldSize("optional_int_field", apache::thrift::protocol::T_I32, 5); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_optional_int_field); + } + if (this->__isset.get(5)) { + xfer += prot_->serializedFieldSize("optional_bool_field", apache::thrift::protocol::T_BOOL, 6); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_optional_bool_field); + } + if (this->__isset.get(6)) { + xfer += prot_->serializedFieldSize("optional_list_field", apache::thrift::protocol::T_LIST, 7); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_optional_list_field); + } + if (this->__isset.get(7)) { + xfer += prot_->serializedFieldSize("optional_struct_field", apache::thrift::protocol::T_STRUCT, 8); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_optional_struct_field); + } + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t TestStruct::serializedSizeZC(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("TestStruct"); + { + xfer += prot_->serializedFieldSize("unqualified_int_field", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_unqualified_int_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_bool_field", apache::thrift::protocol::T_BOOL, 2); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_unqualified_bool_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_list_field", apache::thrift::protocol::T_LIST, 3); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_unqualified_list_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_struct_field", apache::thrift::protocol::T_STRUCT, 4); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_unqualified_struct_field); + } + if (this->__isset.get(4)) { + xfer += prot_->serializedFieldSize("optional_int_field", apache::thrift::protocol::T_I32, 5); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_optional_int_field); + } + if (this->__isset.get(5)) { + xfer += prot_->serializedFieldSize("optional_bool_field", apache::thrift::protocol::T_BOOL, 6); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_optional_bool_field); + } + if (this->__isset.get(6)) { + xfer += prot_->serializedFieldSize("optional_list_field", apache::thrift::protocol::T_LIST, 7); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_optional_list_field); + } + if (this->__isset.get(7)) { + xfer += prot_->serializedFieldSize("optional_struct_field", apache::thrift::protocol::T_STRUCT, 8); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_optional_struct_field); + } + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t TestStruct::write(Protocol_* prot_) const { + uint32_t xfer = 0; + xfer += prot_->writeStructBegin("TestStruct"); + bool previousFieldHasValue = true; + { + constexpr int16_t kPrevFieldId = 0; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_int_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::write(*prot_, this->__fbthrift_field_unqualified_int_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 1; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_bool_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::write(*prot_, this->__fbthrift_field_unqualified_bool_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 2; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_list_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::write(*prot_, this->__fbthrift_field_unqualified_list_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 3; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_struct_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::write(*prot_, this->__fbthrift_field_unqualified_struct_field); + xfer += prot_->writeFieldEnd(); + } + if (this->__isset.get(4)) { + constexpr int16_t kPrevFieldId = 4; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_int_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::write(*prot_, this->__fbthrift_field_optional_int_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(5)) { + constexpr int16_t kPrevFieldId = 5; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_bool_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::write(*prot_, this->__fbthrift_field_optional_bool_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(6)) { + constexpr int16_t kPrevFieldId = 6; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_list_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::write(*prot_, this->__fbthrift_field_optional_list_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(7)) { + constexpr int16_t kPrevFieldId = 7; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_struct_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::write(*prot_, this->__fbthrift_field_optional_struct_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + xfer += prot_->writeFieldStop(); + xfer += prot_->writeStructEnd(); + return xfer; +} + +extern template void TestStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +extern template uint32_t TestStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +extern template uint32_t TestStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template void TestStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +extern template uint32_t TestStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +extern template uint32_t TestStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +extern template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_custom_protocol.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_custom_protocol.h new file mode 100644 index 00000000000000..d1a4a986ce6bfc --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_custom_protocol.h @@ -0,0 +1,18 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + + +/** + * This header file includes the tcc files of the corresponding header file + * and the header files of its dependent types. Include this header file + * only when you need to use custom protocols (e.g. DebugProtocol, + * VirtualProtocol) to read/write thrift structs. + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.tcc" + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_fwd.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_fwd.h new file mode 100644 index 00000000000000..b9afd610a4e4b3 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_types_fwd.h @@ -0,0 +1,14 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +// BEGIN forward_declare +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +class EmptyStruct; +class TestStruct; +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +// END forward_declare diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h new file mode 100644 index 00000000000000..e1cca71153b2a8 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h @@ -0,0 +1,55 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct VisitByFieldId<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + template + void operator()([[maybe_unused]] F&& f, int32_t fieldId, [[maybe_unused]] T&& t) const { + switch (fieldId) { + default: + throwInvalidThriftId(fieldId, "::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct"); + } + } +}; + +template <> +struct VisitByFieldId<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + template + void operator()([[maybe_unused]] F&& f, int32_t fieldId, [[maybe_unused]] T&& t) const { + switch (fieldId) { + case 1: + return f(0, static_cast(t).unqualified_int_field_ref()); + case 2: + return f(1, static_cast(t).unqualified_bool_field_ref()); + case 3: + return f(2, static_cast(t).unqualified_list_field_ref()); + case 4: + return f(3, static_cast(t).unqualified_struct_field_ref()); + case 5: + return f(4, static_cast(t).optional_int_field_ref()); + case 6: + return f(5, static_cast(t).optional_bool_field_ref()); + case 7: + return f(6, static_cast(t).optional_list_field_ref()); + case 8: + return f(7, static_cast(t).optional_struct_field_ref()); + default: + throwInvalidThriftId(fieldId, "::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct"); + } + } +}; +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_union.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_union.h new file mode 100644 index 00000000000000..27d843d1879d9f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visit_union.h @@ -0,0 +1,18 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" +#include + +namespace apache { +namespace thrift { +namespace detail { + +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visitation.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visitation.h new file mode 100644 index 00000000000000..b2fe0293f7f0f2 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/cpp2/gen-cpp2/module_visitation.h @@ -0,0 +1,10 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_for_each_field.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_visit_union.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_visit_by_thrift_field_metadata.h" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/codec.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/codec.go new file mode 100644 index 00000000000000..7883ee036bbf71 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/codec.go @@ -0,0 +1,203 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + + +import ( + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO + +// Premade codec specs +var ( + premadeCodecTypeSpec_module_EmptyStruct = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "module.EmptyStruct", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "module.EmptyStruct", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewEmptyStruct() }, +}, + + } + }() + premadeCodecTypeSpec_i32 = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "i32", + CodecPrimitiveSpec: &thrift.CodecPrimitiveSpec{ + PrimitiveType: thrift.CODEC_PRIMITIVE_TYPE_I32, +}, + + } + }() + premadeCodecTypeSpec_bool = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "bool", + CodecPrimitiveSpec: &thrift.CodecPrimitiveSpec{ + PrimitiveType: thrift.CODEC_PRIMITIVE_TYPE_BOOL, +}, + + } + }() + premadeCodecTypeSpec_list_i32 = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "list", + CodecListSpec: &thrift.CodecListSpec{ + ElementWireType: thrift.I32, + ElementTypeSpec: premadeCodecTypeSpec_i32, +}, + + } + }() + premadeCodecTypeSpec_module_TestStruct = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "module.TestStruct", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "module.TestStruct", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewTestStruct() }, +}, + + } + }() +) + +// Premade struct specs +var ( + premadeStructSpec_EmptyStruct = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "EmptyStruct", + ScopedName: "module.EmptyStruct", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + }, + FieldSpecIDToIndex: map[int16]int{ + }, + FieldSpecNameToIndex: map[string]int{ + }, +} + }() + premadeStructSpec_TestStruct = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "TestStruct", + ScopedName: "module.TestStruct", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + { + ID: 1, + WireType: thrift.I32, + Name: "unqualified_int_field", + ReflectIndex: 0, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_i32, + MustBeSetToSerialize: false, + }, { + ID: 2, + WireType: thrift.BOOL, + Name: "unqualified_bool_field", + ReflectIndex: 1, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_bool, + MustBeSetToSerialize: false, + }, { + ID: 3, + WireType: thrift.LIST, + Name: "unqualified_list_field", + ReflectIndex: 2, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_list_i32, + MustBeSetToSerialize: false, + }, { + ID: 4, + WireType: thrift.STRUCT, + Name: "unqualified_struct_field", + ReflectIndex: 3, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_module_EmptyStruct, + MustBeSetToSerialize: true, + }, { + ID: 5, + WireType: thrift.I32, + Name: "optional_int_field", + ReflectIndex: 4, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_i32, + MustBeSetToSerialize: true, + }, { + ID: 6, + WireType: thrift.BOOL, + Name: "optional_bool_field", + ReflectIndex: 5, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_bool, + MustBeSetToSerialize: true, + }, { + ID: 7, + WireType: thrift.LIST, + Name: "optional_list_field", + ReflectIndex: 6, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_list_i32, + MustBeSetToSerialize: true, + }, { + ID: 8, + WireType: thrift.STRUCT, + Name: "optional_struct_field", + ReflectIndex: 7, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_module_EmptyStruct, + MustBeSetToSerialize: true, + }, }, + FieldSpecIDToIndex: map[int16]int{ + 1: 0, + 2: 1, + 3: 2, + 4: 3, + 5: 4, + 6: 5, + 7: 6, + 8: 7, + }, + FieldSpecNameToIndex: map[string]int{ + "unqualified_int_field": 0, + "unqualified_bool_field": 1, + "unqualified_list_field": 2, + "unqualified_struct_field": 3, + "optional_int_field": 4, + "optional_bool_field": 5, + "optional_list_field": 6, + "optional_struct_field": 7, + }, +} + }() +) + +// Premade slice of all struct specs +var premadeStructSpecs = func() []*thrift.StructSpec { + fbthriftResults := make([]*thrift.StructSpec, 0) + fbthriftResults = append(fbthriftResults, premadeStructSpec_EmptyStruct) + fbthriftResults = append(fbthriftResults, premadeStructSpec_TestStruct) + return fbthriftResults +}() + +var premadeCodecSpecsMap = func() map[string]*thrift.TypeSpec { + fbthriftTypeSpecsMap := make(map[string]*thrift.TypeSpec) + fbthriftTypeSpecsMap[premadeCodecTypeSpec_module_EmptyStruct.FullName] = premadeCodecTypeSpec_module_EmptyStruct + fbthriftTypeSpecsMap[premadeCodecTypeSpec_i32.FullName] = premadeCodecTypeSpec_i32 + fbthriftTypeSpecsMap[premadeCodecTypeSpec_bool.FullName] = premadeCodecTypeSpec_bool + fbthriftTypeSpecsMap[premadeCodecTypeSpec_module_TestStruct.FullName] = premadeCodecTypeSpec_module_TestStruct + return fbthriftTypeSpecsMap +}() + +// GetMetadataThriftType (INTERNAL USE ONLY). +// Returns metadata TypeSpec for a given full type name. +func GetCodecTypeSpec(fullName string) *thrift.TypeSpec { + return premadeCodecSpecsMap[fullName] +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/const.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/const.go new file mode 100644 index 00000000000000..2e27589f88b06f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/const.go @@ -0,0 +1,16 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO + +var GoUnusedProtection__ int + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/metadata.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/metadata.go new file mode 100644 index 00000000000000..0f9d0c83a5e67f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/metadata.go @@ -0,0 +1,293 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + "maps" + + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" + metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO +var _ = maps.Copy[map[int]int, map[int]int] +var _ = metadata.GoUnusedProtection__ + +// Premade Thrift types +var ( + premadeThriftType_module_EmptyStruct = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("module.EmptyStruct"), + ) + }() + premadeThriftType_i32 = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTPrimitive( + metadata.ThriftPrimitiveType_THRIFT_I32_TYPE.Ptr(), + ) + }() + premadeThriftType_bool = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTPrimitive( + metadata.ThriftPrimitiveType_THRIFT_BOOL_TYPE.Ptr(), + ) + }() + premadeThriftType_list_i32 = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTList( + metadata.NewThriftListType(). + SetValueType(premadeThriftType_i32), + ) + }() + premadeThriftType_module_TestStruct = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("module.TestStruct"), + ) + }() +) + +// Helper type to allow us to store Thrift types in a slice at compile time, +// and put them in a map at runtime. See comment at the top of template +// about a compilation limitation that affects map literals. +type thriftTypeWithFullName struct { + fullName string + thriftType *metadata.ThriftType +} + +var premadeThriftTypesMap = func() map[string]*metadata.ThriftType { + thriftTypesWithFullName := make([]thriftTypeWithFullName, 0) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "module.EmptyStruct", premadeThriftType_module_EmptyStruct }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "i32", premadeThriftType_i32 }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "bool", premadeThriftType_bool }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "module.TestStruct", premadeThriftType_module_TestStruct }) + + fbthriftThriftTypesMap := make(map[string]*metadata.ThriftType, len(thriftTypesWithFullName)) + for _, value := range thriftTypesWithFullName { + fbthriftThriftTypesMap[value.fullName] = value.thriftType + } + return fbthriftThriftTypesMap +}() + +var structMetadatas = func() []*metadata.ThriftStruct { + fbthriftResults := make([]*metadata.ThriftStruct, 0) + for _, fbthriftStructSpec := range premadeStructSpecs { + if !fbthriftStructSpec.IsException { + fbthriftResults = append(fbthriftResults, getMetadataThriftStruct(fbthriftStructSpec)) + } + } + return fbthriftResults +}() + +var exceptionMetadatas = func() []*metadata.ThriftException { + fbthriftResults := make([]*metadata.ThriftException, 0) + for _, fbthriftStructSpec := range premadeStructSpecs { + if fbthriftStructSpec.IsException { + fbthriftResults = append(fbthriftResults, getMetadataThriftException(fbthriftStructSpec)) + } + } + return fbthriftResults +}() + +var enumMetadatas = func() []*metadata.ThriftEnum { + fbthriftResults := make([]*metadata.ThriftEnum, 0) + return fbthriftResults +}() + +var serviceMetadatas = func() []*metadata.ThriftService { + fbthriftResults := make([]*metadata.ThriftService, 0) + return fbthriftResults +}() + +// GetMetadataThriftType (INTERNAL USE ONLY). +// Returns metadata ThriftType for a given full type name. +func GetMetadataThriftType(fullName string) *metadata.ThriftType { + return premadeThriftTypesMap[fullName] +} + +// GetThriftMetadata returns complete Thrift metadata for current and imported packages. +func GetThriftMetadata() *metadata.ThriftMetadata { + allEnumsMap := make(map[string]*metadata.ThriftEnum) + allStructsMap := make(map[string]*metadata.ThriftStruct) + allExceptionsMap := make(map[string]*metadata.ThriftException) + allServicesMap := make(map[string]*metadata.ThriftService) + + // Add enum metadatas from the current program... + for _, enumMetadata := range enumMetadatas { + allEnumsMap[enumMetadata.GetName()] = enumMetadata + } + // Add struct metadatas from the current program... + for _, structMetadata := range structMetadatas { + allStructsMap[structMetadata.GetName()] = structMetadata + } + // Add exception metadatas from the current program... + for _, exceptionMetadata := range exceptionMetadatas { + allExceptionsMap[exceptionMetadata.GetName()] = exceptionMetadata + } + // Add service metadatas from the current program... + for _, serviceMetadata := range serviceMetadatas { + allServicesMap[serviceMetadata.GetName()] = serviceMetadata + } + + // Obtain Thrift metadatas from recursively included programs... + var recursiveThriftMetadatas []*metadata.ThriftMetadata + + // ...now merge metadatas from recursively included programs. + for _, thriftMetadata := range recursiveThriftMetadatas { + maps.Copy(allEnumsMap, thriftMetadata.GetEnums()) + maps.Copy(allStructsMap, thriftMetadata.GetStructs()) + maps.Copy(allExceptionsMap, thriftMetadata.GetExceptions()) + maps.Copy(allServicesMap, thriftMetadata.GetServices()) + } + + return metadata.NewThriftMetadata(). + SetEnums(allEnumsMap). + SetStructs(allStructsMap). + SetExceptions(allExceptionsMap). + SetServices(allServicesMap) +} + +// GetThriftMetadataForService returns Thrift metadata for the given service. +func GetThriftMetadataForService(scopedServiceName string) *metadata.ThriftMetadata { + thriftMetadata := GetThriftMetadata() + + allServicesMap := thriftMetadata.GetServices() + relevantServicesMap := make(map[string]*metadata.ThriftService) + + serviceMetadata := allServicesMap[scopedServiceName] + // Visit and record all recursive parents of the target service. + for serviceMetadata != nil { + relevantServicesMap[serviceMetadata.GetName()] = serviceMetadata + if serviceMetadata.IsSetParent() { + serviceMetadata = allServicesMap[serviceMetadata.GetParent()] + } else { + serviceMetadata = nil + } + } + + thriftMetadata.SetServices(relevantServicesMap) + + return thriftMetadata +} + +func getMetadataThriftPrimitiveType(s *thrift.CodecPrimitiveSpec) *metadata.ThriftPrimitiveType { + var value metadata.ThriftPrimitiveType + + switch s.PrimitiveType { + case thrift.CODEC_PRIMITIVE_TYPE_BYTE: + value = metadata.ThriftPrimitiveType_THRIFT_BYTE_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_BOOL: + value = metadata.ThriftPrimitiveType_THRIFT_BOOL_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I16: + value = metadata.ThriftPrimitiveType_THRIFT_I16_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I32: + value = metadata.ThriftPrimitiveType_THRIFT_I32_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I64: + value = metadata.ThriftPrimitiveType_THRIFT_I64_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_FLOAT: + value = metadata.ThriftPrimitiveType_THRIFT_FLOAT_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_DOUBLE: + value = metadata.ThriftPrimitiveType_THRIFT_DOUBLE_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_BINARY: + value = metadata.ThriftPrimitiveType_THRIFT_BINARY_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_STRING: + value = metadata.ThriftPrimitiveType_THRIFT_STRING_TYPE + } + + return value.Ptr() +} + +func getMetadataThriftEnumType(s *thrift.CodecEnumSpec) *metadata.ThriftEnumType { + return metadata.NewThriftEnumType(). + SetName(s.ScopedName) +} + +func getMetadataThriftSetType(s *thrift.CodecSetSpec) *metadata.ThriftSetType { + return metadata.NewThriftSetType(). + SetValueType(getMetadataThriftType(s.ElementTypeSpec)) +} + +func getMetadataThriftListType(s *thrift.CodecListSpec) *metadata.ThriftListType { + return metadata.NewThriftListType(). + SetValueType(getMetadataThriftType(s.ElementTypeSpec)) +} + +func getMetadataThriftMapType(s *thrift.CodecMapSpec) *metadata.ThriftMapType { + return metadata.NewThriftMapType(). + SetKeyType(getMetadataThriftType(s.KeyTypeSpec)). + SetValueType(getMetadataThriftType(s.ValueTypeSpec)) +} + +func getMetadataThriftTypedefType(s *thrift.CodecTypedefSpec) *metadata.ThriftTypedefType { + return metadata.NewThriftTypedefType(). + SetName(s.ScopedName). + SetUnderlyingType(getMetadataThriftType(s.UnderlyingTypeSpec)) +} + +func getMetadataThriftStructType(s *thrift.CodecStructSpec) *metadata.ThriftStructType { + return metadata.NewThriftStructType(). + SetName(s.ScopedName) +} + +func getMetadataThriftUnionType(s *thrift.CodecStructSpec) *metadata.ThriftUnionType { + return metadata.NewThriftUnionType(). + SetName(s.ScopedName) +} + +func getMetadataThriftType(s *thrift.TypeSpec) *metadata.ThriftType { + thriftType := metadata.NewThriftType() + switch { + case s.CodecPrimitiveSpec != nil: + thriftType.SetTPrimitive(getMetadataThriftPrimitiveType(s.CodecPrimitiveSpec)) + case s.CodecEnumSpec != nil: + thriftType.SetTEnum(getMetadataThriftEnumType(s.CodecEnumSpec)) + case s.CodecSetSpec != nil: + thriftType.SetTSet(getMetadataThriftSetType(s.CodecSetSpec)) + case s.CodecListSpec != nil: + thriftType.SetTList(getMetadataThriftListType(s.CodecListSpec)) + case s.CodecMapSpec != nil: + thriftType.SetTMap(getMetadataThriftMapType(s.CodecMapSpec)) + case s.CodecTypedefSpec != nil: + thriftType.SetTTypedef(getMetadataThriftTypedefType(s.CodecTypedefSpec)) + case s.CodecStructSpec != nil: + if s.CodecStructSpec.IsUnion { + thriftType.SetTUnion(getMetadataThriftUnionType(s.CodecStructSpec)) + } else { + thriftType.SetTStruct(getMetadataThriftStructType(s.CodecStructSpec)) + } + } + return thriftType +} + +func getMetadataThriftField(s *thrift.FieldSpec) *metadata.ThriftField { + return metadata.NewThriftField(). + SetId(int32(s.ID)). + SetName(s.Name). + SetIsOptional(s.IsOptional). + SetType(getMetadataThriftType(s.ValueTypeSpec)) +} + +func getMetadataThriftStruct(s *thrift.StructSpec) *metadata.ThriftStruct { + metadataThriftFields := make([]*metadata.ThriftField, len(s.FieldSpecs), len(s.FieldSpecs)) + for i, fieldSpec := range s.FieldSpecs { + metadataThriftFields[i] = getMetadataThriftField(&fieldSpec) + } + + return metadata.NewThriftStruct(). + SetName(s.ScopedName). + SetIsUnion(s.IsUnion). + SetFields(metadataThriftFields) +} + +func getMetadataThriftException(s *thrift.StructSpec) *metadata.ThriftException { + metadataThriftFields := make([]*metadata.ThriftField, len(s.FieldSpecs), len(s.FieldSpecs)) + for i, fieldSpec := range s.FieldSpecs { + metadataThriftFields[i] = getMetadataThriftField(&fieldSpec) + } + + return metadata.NewThriftException(). + SetName(s.ScopedName). + SetFields(metadataThriftFields) +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/svcs.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/svcs.go new file mode 100644 index 00000000000000..647849b1c04da1 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/svcs.go @@ -0,0 +1,7 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/types.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/types.go new file mode 100644 index 00000000000000..d6f737c3511b3f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/go/gen-go/module/types.go @@ -0,0 +1,685 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + "fmt" + "reflect" + + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = fmt.Printf +var _ = reflect.Ptr +var _ = thrift.ZERO + +type EmptyStruct struct { +} +// Compile time interface enforcer +var _ thrift.Struct = (*EmptyStruct)(nil) + +func NewEmptyStruct() *EmptyStruct { + return (&EmptyStruct{}).setDefaults() +} + + + +func (x *EmptyStruct) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("EmptyStruct"); 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 *EmptyStruct) 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 *EmptyStruct) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *EmptyStruct) setDefaults() *EmptyStruct { + return x +} + +type TestStruct struct { + UnqualifiedIntField int32 `thrift:"unqualified_int_field,1" json:"unqualified_int_field" db:"unqualified_int_field"` + UnqualifiedBoolField bool `thrift:"unqualified_bool_field,2" json:"unqualified_bool_field" db:"unqualified_bool_field"` + UnqualifiedListField []int32 `thrift:"unqualified_list_field,3" json:"unqualified_list_field" db:"unqualified_list_field"` + UnqualifiedStructField *EmptyStruct `thrift:"unqualified_struct_field,4" json:"unqualified_struct_field" db:"unqualified_struct_field"` + OptionalIntField *int32 `thrift:"optional_int_field,5,optional" json:"optional_int_field,omitempty" db:"optional_int_field"` + OptionalBoolField *bool `thrift:"optional_bool_field,6,optional" json:"optional_bool_field,omitempty" db:"optional_bool_field"` + OptionalListField []int32 `thrift:"optional_list_field,7,optional" json:"optional_list_field,omitempty" db:"optional_list_field"` + OptionalStructField *EmptyStruct `thrift:"optional_struct_field,8,optional" json:"optional_struct_field,omitempty" db:"optional_struct_field"` +} +// Compile time interface enforcer +var _ thrift.Struct = (*TestStruct)(nil) + +func NewTestStruct() *TestStruct { + return (&TestStruct{}).setDefaults() +} + +func (x *TestStruct) GetUnqualifiedIntField() int32 { + return x.UnqualifiedIntField +} + +func (x *TestStruct) GetUnqualifiedBoolField() bool { + return x.UnqualifiedBoolField +} + +func (x *TestStruct) GetUnqualifiedListField() []int32 { + if !x.IsSetUnqualifiedListField() { + return make([]int32, 0) + } + return x.UnqualifiedListField +} + +func (x *TestStruct) GetUnqualifiedStructField() *EmptyStruct { + if !x.IsSetUnqualifiedStructField() { + return nil + } + return x.UnqualifiedStructField +} + +func (x *TestStruct) GetOptionalIntField() int32 { + if !x.IsSetOptionalIntField() { + return 0 + } + return *x.OptionalIntField +} + +func (x *TestStruct) GetOptionalBoolField() bool { + if !x.IsSetOptionalBoolField() { + return false + } + return *x.OptionalBoolField +} + +func (x *TestStruct) GetOptionalListField() []int32 { + if !x.IsSetOptionalListField() { + return make([]int32, 0) + } + return x.OptionalListField +} + +func (x *TestStruct) GetOptionalStructField() *EmptyStruct { + if !x.IsSetOptionalStructField() { + return nil + } + return x.OptionalStructField +} + +func (x *TestStruct) SetUnqualifiedIntFieldNonCompat(value int32) *TestStruct { + x.UnqualifiedIntField = value + return x +} + +func (x *TestStruct) SetUnqualifiedIntField(value int32) *TestStruct { + x.UnqualifiedIntField = value + return x +} + +func (x *TestStruct) SetUnqualifiedBoolFieldNonCompat(value bool) *TestStruct { + x.UnqualifiedBoolField = value + return x +} + +func (x *TestStruct) SetUnqualifiedBoolField(value bool) *TestStruct { + x.UnqualifiedBoolField = value + return x +} + +func (x *TestStruct) SetUnqualifiedListFieldNonCompat(value []int32) *TestStruct { + x.UnqualifiedListField = value + return x +} + +func (x *TestStruct) SetUnqualifiedListField(value []int32) *TestStruct { + x.UnqualifiedListField = value + return x +} + +func (x *TestStruct) SetUnqualifiedStructFieldNonCompat(value *EmptyStruct) *TestStruct { + x.UnqualifiedStructField = value + return x +} + +func (x *TestStruct) SetUnqualifiedStructField(value *EmptyStruct) *TestStruct { + x.UnqualifiedStructField = value + return x +} + +func (x *TestStruct) SetOptionalIntFieldNonCompat(value int32) *TestStruct { + x.OptionalIntField = &value + return x +} + +func (x *TestStruct) SetOptionalIntField(value *int32) *TestStruct { + x.OptionalIntField = value + return x +} + +func (x *TestStruct) SetOptionalBoolFieldNonCompat(value bool) *TestStruct { + x.OptionalBoolField = &value + return x +} + +func (x *TestStruct) SetOptionalBoolField(value *bool) *TestStruct { + x.OptionalBoolField = value + return x +} + +func (x *TestStruct) SetOptionalListFieldNonCompat(value []int32) *TestStruct { + x.OptionalListField = value + return x +} + +func (x *TestStruct) SetOptionalListField(value []int32) *TestStruct { + x.OptionalListField = value + return x +} + +func (x *TestStruct) SetOptionalStructFieldNonCompat(value *EmptyStruct) *TestStruct { + x.OptionalStructField = value + return x +} + +func (x *TestStruct) SetOptionalStructField(value *EmptyStruct) *TestStruct { + x.OptionalStructField = value + return x +} + +func (x *TestStruct) IsSetUnqualifiedListField() bool { + return x != nil && x.UnqualifiedListField != nil +} + +func (x *TestStruct) IsSetUnqualifiedStructField() bool { + return x != nil && x.UnqualifiedStructField != nil +} + +func (x *TestStruct) IsSetOptionalIntField() bool { + return x != nil && x.OptionalIntField != nil +} + +func (x *TestStruct) IsSetOptionalBoolField() bool { + return x != nil && x.OptionalBoolField != nil +} + +func (x *TestStruct) IsSetOptionalListField() bool { + return x != nil && x.OptionalListField != nil +} + +func (x *TestStruct) IsSetOptionalStructField() bool { + return x != nil && x.OptionalStructField != nil +} + +func (x *TestStruct) writeField1(p thrift.Encoder) error { // UnqualifiedIntField + if err := p.WriteFieldBegin("unqualified_int_field", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedIntField + if err := p.WriteI32(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField2(p thrift.Encoder) error { // UnqualifiedBoolField + if err := p.WriteFieldBegin("unqualified_bool_field", thrift.BOOL, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedBoolField + if err := p.WriteBool(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField3(p thrift.Encoder) error { // UnqualifiedListField + if err := p.WriteFieldBegin("unqualified_list_field", thrift.LIST, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedListField + if err := p.WriteListBegin(thrift.I32, len(item)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range item { + { + item := v + if err := p.WriteI32(item); err != nil { + return err + } + } + } + if err := p.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField4(p thrift.Encoder) error { // UnqualifiedStructField + if !x.IsSetUnqualifiedStructField() { + return nil + } + + if err := p.WriteFieldBegin("unqualified_struct_field", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedStructField + if err := item.Write(p); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField5(p thrift.Encoder) error { // OptionalIntField + if !x.IsSetOptionalIntField() { + return nil + } + + if err := p.WriteFieldBegin("optional_int_field", thrift.I32, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := *x.OptionalIntField + if err := p.WriteI32(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField6(p thrift.Encoder) error { // OptionalBoolField + if !x.IsSetOptionalBoolField() { + return nil + } + + if err := p.WriteFieldBegin("optional_bool_field", thrift.BOOL, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := *x.OptionalBoolField + if err := p.WriteBool(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField7(p thrift.Encoder) error { // OptionalListField + if !x.IsSetOptionalListField() { + return nil + } + + if err := p.WriteFieldBegin("optional_list_field", thrift.LIST, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.OptionalListField + if err := p.WriteListBegin(thrift.I32, len(item)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range item { + { + item := v + if err := p.WriteI32(item); err != nil { + return err + } + } + } + if err := p.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField8(p thrift.Encoder) error { // OptionalStructField + if !x.IsSetOptionalStructField() { + return nil + } + + if err := p.WriteFieldBegin("optional_struct_field", thrift.STRUCT, 8); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.OptionalStructField + if err := item.Write(p); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) readField1(p thrift.Decoder) error { // UnqualifiedIntField + result, err := p.ReadI32() + if err != nil { + return err + } + + x.UnqualifiedIntField = result + return nil +} + +func (x *TestStruct) readField2(p thrift.Decoder) error { // UnqualifiedBoolField + result, err := p.ReadBool() + if err != nil { + return err + } + + x.UnqualifiedBoolField = result + return nil +} + +func (x *TestStruct) readField3(p thrift.Decoder) error { // UnqualifiedListField + _ /* elemType */, size, err := p.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + + listResult := make([]int32, 0, size) + for i := 0; i < size; i++ { + var elem int32 + { + result, err := p.ReadI32() + if err != nil { + return err + } + elem = result + } + listResult = append(listResult, elem) + } + + if err := p.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + result := listResult + + x.UnqualifiedListField = result + return nil +} + +func (x *TestStruct) readField4(p thrift.Decoder) error { // UnqualifiedStructField + result := NewEmptyStruct() + err := result.Read(p) + if err != nil { + return err + } + + x.UnqualifiedStructField = result + return nil +} + +func (x *TestStruct) readField5(p thrift.Decoder) error { // OptionalIntField + result, err := p.ReadI32() + if err != nil { + return err + } + + x.OptionalIntField = &result + return nil +} + +func (x *TestStruct) readField6(p thrift.Decoder) error { // OptionalBoolField + result, err := p.ReadBool() + if err != nil { + return err + } + + x.OptionalBoolField = &result + return nil +} + +func (x *TestStruct) readField7(p thrift.Decoder) error { // OptionalListField + _ /* elemType */, size, err := p.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + + listResult := make([]int32, 0, size) + for i := 0; i < size; i++ { + var elem int32 + { + result, err := p.ReadI32() + if err != nil { + return err + } + elem = result + } + listResult = append(listResult, elem) + } + + if err := p.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + result := listResult + + x.OptionalListField = result + return nil +} + +func (x *TestStruct) readField8(p thrift.Decoder) error { // OptionalStructField + result := NewEmptyStruct() + err := result.Read(p) + if err != nil { + return err + } + + x.OptionalStructField = result + return nil +} + +// Deprecated: Use NewTestStruct().GetUnqualifiedStructField() instead. +func (x *TestStruct) DefaultGetUnqualifiedStructField() *EmptyStruct { + if !x.IsSetUnqualifiedStructField() { + return NewEmptyStruct() + } + return x.UnqualifiedStructField +} + + + +// Deprecated: Use NewTestStruct().GetOptionalStructField() instead. +func (x *TestStruct) DefaultGetOptionalStructField() *EmptyStruct { + if !x.IsSetOptionalStructField() { + return NewEmptyStruct() + } + return x.OptionalStructField +} + + + +func (x *TestStruct) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("TestStruct"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err) + } + + if err := x.writeField1(p); err != nil { + return err + } + if err := x.writeField2(p); err != nil { + return err + } + if err := x.writeField3(p); err != nil { + return err + } + if err := x.writeField4(p); err != nil { + return err + } + if err := x.writeField5(p); err != nil { + return err + } + if err := x.writeField6(p); err != nil { + return err + } + if err := x.writeField7(p); err != nil { + return err + } + if err := x.writeField8(p); err != nil { + return 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 *TestStruct) 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 { + case ((id == 1 && wireType == thrift.I32) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_int_field")): // unqualified_int_field + fieldReadErr = x.readField1(p) + case ((id == 2 && wireType == thrift.BOOL) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_bool_field")): // unqualified_bool_field + fieldReadErr = x.readField2(p) + case ((id == 3 && wireType == thrift.LIST) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_list_field")): // unqualified_list_field + fieldReadErr = x.readField3(p) + case ((id == 4 && wireType == thrift.STRUCT) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_struct_field")): // unqualified_struct_field + fieldReadErr = x.readField4(p) + case ((id == 5 && wireType == thrift.I32) || (id == thrift.NO_FIELD_ID && fieldName == "optional_int_field")): // optional_int_field + fieldReadErr = x.readField5(p) + case ((id == 6 && wireType == thrift.BOOL) || (id == thrift.NO_FIELD_ID && fieldName == "optional_bool_field")): // optional_bool_field + fieldReadErr = x.readField6(p) + case ((id == 7 && wireType == thrift.LIST) || (id == thrift.NO_FIELD_ID && fieldName == "optional_list_field")): // optional_list_field + fieldReadErr = x.readField7(p) + case ((id == 8 && wireType == thrift.STRUCT) || (id == thrift.NO_FIELD_ID && fieldName == "optional_struct_field")): // optional_struct_field + fieldReadErr = x.readField8(p) + 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 *TestStruct) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *TestStruct) setDefaults() *TestStruct { + return x. + SetUnqualifiedIntFieldNonCompat(0). + SetUnqualifiedBoolFieldNonCompat(false). + SetUnqualifiedListFieldNonCompat(make([]int32, 0)). + SetUnqualifiedStructFieldNonCompat(NewEmptyStruct()) +} + + + +// RegisterTypes registers types found in this file that have a thrift_uri with the passed in registry. +func RegisterTypes(registry interface { + RegisterType(name string, initializer func() any) +}) { + registry.RegisterType("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", func() any { return NewEmptyStruct() }) + registry.RegisterType("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", func() any { return NewTestStruct() }) + +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/hack/gen-hack/module_types.php b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/hack/gen-hack/module_types.php new file mode 100644 index 00000000000000..15eab6020e5d94 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/hack/gen-hack/module_types.php @@ -0,0 +1,358 @@ + 'facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct'))>> +class EmptyStruct 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 'EmptyStruct'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "module.EmptyStruct", + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + +/** + * Original thrift struct:- + * TestStruct + */ +<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct'))>> +class TestStruct implements \IThriftSyncStruct, \IThriftStructMetadata { + use \ThriftSerializationTrait; + + const \ThriftStructTypes::TSpec SPEC = dict[ + 1 => shape( + 'var' => 'unqualified_int_field', + 'type' => \TType::I32, + ), + 2 => shape( + 'var' => 'unqualified_bool_field', + 'type' => \TType::BOOL, + ), + 3 => shape( + 'var' => 'unqualified_list_field', + 'type' => \TType::LST, + 'etype' => \TType::I32, + 'elem' => shape( + 'type' => \TType::I32, + ), + 'format' => 'collection', + ), + 4 => shape( + 'var' => 'unqualified_struct_field', + 'type' => \TType::STRUCT, + 'class' => \facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct::class, + ), + 5 => shape( + 'var' => 'optional_int_field', + 'type' => \TType::I32, + ), + 6 => shape( + 'var' => 'optional_bool_field', + 'type' => \TType::BOOL, + ), + 7 => shape( + 'var' => 'optional_list_field', + 'type' => \TType::LST, + 'etype' => \TType::I32, + 'elem' => shape( + 'type' => \TType::I32, + ), + 'format' => 'collection', + ), + 8 => shape( + 'var' => 'optional_struct_field', + 'type' => \TType::STRUCT, + 'class' => \facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct::class, + ), + ]; + const dict FIELDMAP = dict[ + 'unqualified_int_field' => 1, + 'unqualified_bool_field' => 2, + 'unqualified_list_field' => 3, + 'unqualified_struct_field' => 4, + 'optional_int_field' => 5, + 'optional_bool_field' => 6, + 'optional_list_field' => 7, + 'optional_struct_field' => 8, + ]; + + const type TConstructorShape = shape( + ?'unqualified_int_field' => ?int, + ?'unqualified_bool_field' => ?bool, + ?'unqualified_list_field' => ?Vector, + ?'unqualified_struct_field' => ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct, + ?'optional_int_field' => ?int, + ?'optional_bool_field' => ?bool, + ?'optional_list_field' => ?Vector, + ?'optional_struct_field' => ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct, + ); + + const int STRUCTURAL_ID = 7991153564712628734; + /** + * Original thrift field:- + * 1: i32 unqualified_int_field + */ + public int $unqualified_int_field; + /** + * Original thrift field:- + * 2: bool unqualified_bool_field + */ + public bool $unqualified_bool_field; + /** + * Original thrift field:- + * 3: list unqualified_list_field + */ + public Vector $unqualified_list_field; + /** + * Original thrift field:- + * 4: module.EmptyStruct unqualified_struct_field + */ + public ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $unqualified_struct_field; + /** + * Original thrift field:- + * 5: i32 optional_int_field + */ + public ?int $optional_int_field; + /** + * Original thrift field:- + * 6: bool optional_bool_field + */ + public ?bool $optional_bool_field; + /** + * Original thrift field:- + * 7: list optional_list_field + */ + public ?Vector $optional_list_field; + /** + * Original thrift field:- + * 8: module.EmptyStruct optional_struct_field + */ + public ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $optional_struct_field; + + public function __construct(?int $unqualified_int_field = null, ?bool $unqualified_bool_field = null, ?Vector $unqualified_list_field = null, ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $unqualified_struct_field = null, ?int $optional_int_field = null, ?bool $optional_bool_field = null, ?Vector $optional_list_field = null, ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $optional_struct_field = null)[] { + $this->unqualified_int_field = $unqualified_int_field ?? 0; + $this->unqualified_bool_field = $unqualified_bool_field ?? false; + $this->unqualified_list_field = $unqualified_list_field ?? Vector {}; + $this->unqualified_struct_field = $unqualified_struct_field; + $this->optional_int_field = $optional_int_field; + $this->optional_bool_field = $optional_bool_field; + $this->optional_list_field = $optional_list_field; + $this->optional_struct_field = $optional_struct_field; + } + + public static function withDefaultValues()[]: this { + return new static(); + } + + public static function fromShape(self::TConstructorShape $shape)[]: this { + return new static( + Shapes::idx($shape, 'unqualified_int_field'), + Shapes::idx($shape, 'unqualified_bool_field'), + Shapes::idx($shape, 'unqualified_list_field'), + Shapes::idx($shape, 'unqualified_struct_field'), + Shapes::idx($shape, 'optional_int_field'), + Shapes::idx($shape, 'optional_bool_field'), + Shapes::idx($shape, 'optional_list_field'), + Shapes::idx($shape, 'optional_struct_field'), + ); + } + + public function getName()[]: string { + return 'TestStruct'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "module.TestStruct", + "fields" => vec[ + \tmeta_ThriftField::fromShape( + shape( + "id" => 1, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + "name" => "unqualified_int_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 2, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE, + ) + ), + "name" => "unqualified_bool_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 3, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_list" => \tmeta_ThriftListType::fromShape( + shape( + "valueType" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + ) + ), + ) + ), + "name" => "unqualified_list_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 4, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_struct" => \tmeta_ThriftStructType::fromShape( + shape( + "name" => "module.EmptyStruct", + ) + ), + ) + ), + "name" => "unqualified_struct_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 5, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + "name" => "optional_int_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 6, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE, + ) + ), + "name" => "optional_bool_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 7, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_list" => \tmeta_ThriftListType::fromShape( + shape( + "valueType" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + ) + ), + ) + ), + "name" => "optional_list_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 8, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_struct" => \tmeta_ThriftStructType::fromShape( + shape( + "name" => "module.EmptyStruct", + ) + ), + ) + ), + "name" => "optional_struct_field", + "is_optional" => true, + ) + ), + ], + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module new file mode 100644 index 00000000000000..8b137891791fe9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module @@ -0,0 +1 @@ + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java new file mode 100644 index 00000000000000..651a87db2d2785 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java @@ -0,0 +1,126 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.swift.codec.*; +import com.facebook.swift.codec.ThriftField.Requiredness; +import com.facebook.swift.codec.ThriftField.Recursiveness; +import com.google.common.collect.*; +import java.util.*; +import javax.annotation.Nullable; +import org.apache.thrift.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.protocol.*; +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.MoreObjects.ToStringHelper; + +@SwiftGenerated +@com.facebook.swift.codec.ThriftStruct(value="EmptyStruct", builder=EmptyStruct.Builder.class) +public final class EmptyStruct implements com.facebook.thrift.payload.ThriftSerializable { + @ThriftConstructor + public EmptyStruct( + ) { + } + + + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(EmptyStruct other) { + return new Builder(other); + } + + public static class Builder { + + public Builder() { } + public Builder(EmptyStruct other) { + } + + @ThriftConstructor + public EmptyStruct build() { + EmptyStruct result = new EmptyStruct ( + ); + return result; + } + } + + public static final Map NAMES_TO_IDS = new HashMap<>(); + public static final Map THRIFT_NAMES_TO_IDS = new HashMap<>(); + public static final Map FIELD_METADATA = new HashMap<>(); + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); +static { + com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( + new com.facebook.thrift.type.UniversalName("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct"), + EmptyStruct.class, EmptyStruct::read0)); + } + @java.lang.Override + public String toString() { + ToStringHelper helper = toStringHelper(this); + return helper.toString(); + } + + @java.lang.Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + EmptyStruct other = (EmptyStruct)o; + + return + true; + } + + @java.lang.Override + public int hashCode() { + return Arrays.deepHashCode(new java.lang.Object[] { + }); + } + + + public static com.facebook.thrift.payload.Reader asReader() { + return EmptyStruct::read0; + } + + public static EmptyStruct read0(TProtocol oprot) throws TException { + TField __field; + oprot.readStructBegin(EmptyStruct.NAMES_TO_IDS, EmptyStruct.THRIFT_NAMES_TO_IDS, EmptyStruct.FIELD_METADATA); + EmptyStruct.Builder builder = new EmptyStruct.Builder(); + while (true) { + __field = oprot.readFieldBegin(); + if (__field.type == TType.STOP) { break; } + switch (__field.id) { + default: + TProtocolUtil.skip(oprot, __field.type); + break; + } + oprot.readFieldEnd(); + } + oprot.readStructEnd(); + return builder.build(); + } + + public void write0(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + private static class _EmptyStructLazy { + private static final EmptyStruct _DEFAULT = new EmptyStruct.Builder().build(); + } + + public static EmptyStruct defaultInstance() { + return _EmptyStructLazy._DEFAULT; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java new file mode 100644 index 00000000000000..be431d7923c7c9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java @@ -0,0 +1,474 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.swift.codec.*; +import com.facebook.swift.codec.ThriftField.Requiredness; +import com.facebook.swift.codec.ThriftField.Recursiveness; +import com.google.common.collect.*; +import java.util.*; +import javax.annotation.Nullable; +import org.apache.thrift.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.protocol.*; +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.MoreObjects.ToStringHelper; + +@SwiftGenerated +@com.facebook.swift.codec.ThriftStruct(value="TestStruct", builder=TestStruct.Builder.class) +public final class TestStruct implements com.facebook.thrift.payload.ThriftSerializable { + @ThriftConstructor + public TestStruct( + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) final int unqualifiedIntField, + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) final boolean unqualifiedBoolField, + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) final List unqualifiedListField, + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField, + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) final Integer optionalIntField, + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) final Boolean optionalBoolField, + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) final List optionalListField, + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField + ) { + this.unqualifiedIntField = unqualifiedIntField; + this.unqualifiedBoolField = unqualifiedBoolField; + this.unqualifiedListField = unqualifiedListField; + this.unqualifiedStructField = unqualifiedStructField; + this.optionalIntField = optionalIntField; + this.optionalBoolField = optionalBoolField; + this.optionalListField = optionalListField; + this.optionalStructField = optionalStructField; + } + + @ThriftConstructor + protected TestStruct() { + this.unqualifiedIntField = 0; + this.unqualifiedBoolField = false; + this.unqualifiedListField = null; + this.unqualifiedStructField = null; + this.optionalIntField = null; + this.optionalBoolField = null; + this.optionalListField = null; + this.optionalStructField = null; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(TestStruct other) { + return new Builder(other); + } + + public static class Builder { + private int unqualifiedIntField = 0; + private boolean unqualifiedBoolField = false; + private List unqualifiedListField = null; + private com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField = null; + private Integer optionalIntField = null; + private Boolean optionalBoolField = null; + private List optionalListField = null; + private com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField = null; + + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedIntField(int unqualifiedIntField) { + this.unqualifiedIntField = unqualifiedIntField; + return this; + } + + public int getUnqualifiedIntField() { return unqualifiedIntField; } + + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedBoolField(boolean unqualifiedBoolField) { + this.unqualifiedBoolField = unqualifiedBoolField; + return this; + } + + public boolean isUnqualifiedBoolField() { return unqualifiedBoolField; } + + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedListField(List unqualifiedListField) { + this.unqualifiedListField = unqualifiedListField; + return this; + } + + public List getUnqualifiedListField() { return unqualifiedListField; } + + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedStructField(com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField) { + this.unqualifiedStructField = unqualifiedStructField; + return this; + } + + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getUnqualifiedStructField() { return unqualifiedStructField; } + + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalIntField(Integer optionalIntField) { + this.optionalIntField = optionalIntField; + return this; + } + + public Integer getOptionalIntField() { return optionalIntField; } + + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalBoolField(Boolean optionalBoolField) { + this.optionalBoolField = optionalBoolField; + return this; + } + + public Boolean isOptionalBoolField() { return optionalBoolField; } + + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalListField(List optionalListField) { + this.optionalListField = optionalListField; + return this; + } + + public List getOptionalListField() { return optionalListField; } + + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalStructField(com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField) { + this.optionalStructField = optionalStructField; + return this; + } + + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getOptionalStructField() { return optionalStructField; } + + public Builder() { } + public Builder(TestStruct other) { + this.unqualifiedIntField = other.unqualifiedIntField; + this.unqualifiedBoolField = other.unqualifiedBoolField; + this.unqualifiedListField = other.unqualifiedListField; + this.unqualifiedStructField = other.unqualifiedStructField; + this.optionalIntField = other.optionalIntField; + this.optionalBoolField = other.optionalBoolField; + this.optionalListField = other.optionalListField; + this.optionalStructField = other.optionalStructField; + } + + @ThriftConstructor + public TestStruct build() { + TestStruct result = new TestStruct ( + this.unqualifiedIntField, + this.unqualifiedBoolField, + this.unqualifiedListField, + this.unqualifiedStructField, + this.optionalIntField, + this.optionalBoolField, + this.optionalListField, + this.optionalStructField + ); + return result; + } + } + + public static final Map NAMES_TO_IDS = new HashMap<>(); + public static final Map THRIFT_NAMES_TO_IDS = new HashMap<>(); + public static final Map FIELD_METADATA = new HashMap<>(); + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private final int unqualifiedIntField; + public static final int _UNQUALIFIED_INT_FIELD = 1; + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private final boolean unqualifiedBoolField; + public static final int _UNQUALIFIED_BOOL_FIELD = 2; + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private final List unqualifiedListField; + public static final int _UNQUALIFIED_LIST_FIELD = 3; + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField; + public static final int _UNQUALIFIED_STRUCT_FIELD = 4; + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private final Integer optionalIntField; + public static final int _OPTIONAL_INT_FIELD = 5; + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private final Boolean optionalBoolField; + public static final int _OPTIONAL_BOOL_FIELD = 6; + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private final List optionalListField; + public static final int _OPTIONAL_LIST_FIELD = 7; + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField; + public static final int _OPTIONAL_STRUCT_FIELD = 8; + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + static { + NAMES_TO_IDS.put("unqualifiedIntField", 1); + THRIFT_NAMES_TO_IDS.put("unqualified_int_field", 1); + FIELD_METADATA.put(1, UNQUALIFIED_INT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedBoolField", 2); + THRIFT_NAMES_TO_IDS.put("unqualified_bool_field", 2); + FIELD_METADATA.put(2, UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedListField", 3); + THRIFT_NAMES_TO_IDS.put("unqualified_list_field", 3); + FIELD_METADATA.put(3, UNQUALIFIED_LIST_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedStructField", 4); + THRIFT_NAMES_TO_IDS.put("unqualified_struct_field", 4); + FIELD_METADATA.put(4, UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalIntField", 5); + THRIFT_NAMES_TO_IDS.put("optional_int_field", 5); + FIELD_METADATA.put(5, OPTIONAL_INT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalBoolField", 6); + THRIFT_NAMES_TO_IDS.put("optional_bool_field", 6); + FIELD_METADATA.put(6, OPTIONAL_BOOL_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalListField", 7); + THRIFT_NAMES_TO_IDS.put("optional_list_field", 7); + FIELD_METADATA.put(7, OPTIONAL_LIST_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalStructField", 8); + THRIFT_NAMES_TO_IDS.put("optional_struct_field", 8); + FIELD_METADATA.put(8, OPTIONAL_STRUCT_FIELD_FIELD_DESC); + com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( + new com.facebook.thrift.type.UniversalName("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct"), + TestStruct.class, TestStruct::read0)); + } + + + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) + public int getUnqualifiedIntField() { return unqualifiedIntField; } + + + + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) + public boolean isUnqualifiedBoolField() { return unqualifiedBoolField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) + public List getUnqualifiedListField() { return unqualifiedListField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getUnqualifiedStructField() { return unqualifiedStructField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) + public Integer getOptionalIntField() { return optionalIntField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) + public Boolean isOptionalBoolField() { return optionalBoolField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) + public List getOptionalListField() { return optionalListField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getOptionalStructField() { return optionalStructField; } + + @java.lang.Override + public String toString() { + ToStringHelper helper = toStringHelper(this); + helper.add("unqualifiedIntField", unqualifiedIntField); + helper.add("unqualifiedBoolField", unqualifiedBoolField); + helper.add("unqualifiedListField", unqualifiedListField); + helper.add("unqualifiedStructField", unqualifiedStructField); + helper.add("optionalIntField", optionalIntField); + helper.add("optionalBoolField", optionalBoolField); + helper.add("optionalListField", optionalListField); + helper.add("optionalStructField", optionalStructField); + return helper.toString(); + } + + @java.lang.Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestStruct other = (TestStruct)o; + + return + Objects.equals(unqualifiedIntField, other.unqualifiedIntField) && + Objects.equals(unqualifiedBoolField, other.unqualifiedBoolField) && + Objects.equals(unqualifiedListField, other.unqualifiedListField) && + Objects.equals(unqualifiedStructField, other.unqualifiedStructField) && + Objects.equals(optionalIntField, other.optionalIntField) && + Objects.equals(optionalBoolField, other.optionalBoolField) && + Objects.equals(optionalListField, other.optionalListField) && + Objects.equals(optionalStructField, other.optionalStructField) && + true; + } + + @java.lang.Override + public int hashCode() { + return Arrays.deepHashCode(new java.lang.Object[] { + unqualifiedIntField, + unqualifiedBoolField, + unqualifiedListField, + unqualifiedStructField, + optionalIntField, + optionalBoolField, + optionalListField, + optionalStructField + }); + } + + + public static com.facebook.thrift.payload.Reader asReader() { + return TestStruct::read0; + } + + public static TestStruct read0(TProtocol oprot) throws TException { + TField __field; + oprot.readStructBegin(TestStruct.NAMES_TO_IDS, TestStruct.THRIFT_NAMES_TO_IDS, TestStruct.FIELD_METADATA); + TestStruct.Builder builder = new TestStruct.Builder(); + while (true) { + __field = oprot.readFieldBegin(); + if (__field.type == TType.STOP) { break; } + switch (__field.id) { + case _UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + int unqualifiedIntField = oprot.readI32(); + builder.setUnqualifiedIntField(unqualifiedIntField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + boolean unqualifiedBoolField = oprot.readBool(); + builder.setUnqualifiedBoolField(unqualifiedBoolField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + List unqualifiedListField; + { + TList _list = oprot.readListBegin(); + unqualifiedListField = new ArrayList(Math.max(0, _list.size)); + for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) { + + int _value1 = oprot.readI32(); + unqualifiedListField.add(_value1); + } + oprot.readListEnd(); + } + builder.setUnqualifiedListField(unqualifiedListField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField = com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.read0(oprot); + builder.setUnqualifiedStructField(unqualifiedStructField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + Integer optionalIntField = oprot.readI32(); + builder.setOptionalIntField(optionalIntField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + Boolean optionalBoolField = oprot.readBool(); + builder.setOptionalBoolField(optionalBoolField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + List optionalListField; + { + TList _list = oprot.readListBegin(); + optionalListField = new ArrayList(Math.max(0, _list.size)); + for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) { + + int _value1 = oprot.readI32(); + optionalListField.add(_value1); + } + oprot.readListEnd(); + } + builder.setOptionalListField(optionalListField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField = com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.read0(oprot); + builder.setOptionalStructField(optionalStructField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + default: + TProtocolUtil.skip(oprot, __field.type); + break; + } + oprot.readFieldEnd(); + } + oprot.readStructEnd(); + return builder.build(); + } + + public void write0(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualifiedIntField); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualifiedBoolField); + oprot.writeFieldEnd(); + if (unqualifiedListField != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + List _iter0 = unqualifiedListField; + oprot.writeListBegin(new TList(TType.I32, _iter0.size())); + for (int _iter1 : _iter0) { + oprot.writeI32(_iter1); + } + oprot.writeListEnd(); + oprot.writeFieldEnd(); + } + if (unqualifiedStructField != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualifiedStructField.write0(oprot); + oprot.writeFieldEnd(); + } + if (optionalIntField != null) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optionalIntField); + oprot.writeFieldEnd(); + } + if (optionalBoolField != null) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optionalBoolField); + oprot.writeFieldEnd(); + } + if (optionalListField != null) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + List _iter0 = optionalListField; + oprot.writeListBegin(new TList(TType.I32, _iter0.size())); + for (int _iter1 : _iter0) { + oprot.writeI32(_iter1); + } + oprot.writeListEnd(); + oprot.writeFieldEnd(); + } + if (optionalStructField != null) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optionalStructField.write0(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + private static class _TestStructLazy { + private static final TestStruct _DEFAULT = new TestStruct.Builder().build(); + } + + public static TestStruct defaultInstance() { + return _TestStructLazy._DEFAULT; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java new file mode 100644 index 00000000000000..8605ad3a92fca1 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java @@ -0,0 +1,35 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.thrift.type.TypeList; +import java.util.ArrayList; +import java.util.List; + +public class __fbthrift_TypeList_29830437 implements TypeList { + + private static List list = new ArrayList<>(); + + private static void add(String uri, String className) { + list.add(new TypeList.TypeMapping(uri, className)); + } + + private static void addToList0() { + add("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", "com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct"); + add("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", "com.facebook.thrift.compiler.test.fixtures.default_values_rectification.TestStruct"); + } + + static { + addToList0(); + } + + @java.lang.Override + public List getTypes() { + return list; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/EmptyStruct.java new file mode 100644 index 00000000000000..8c5446dc571cad --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/EmptyStruct.java @@ -0,0 +1,172 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 EmptyStruct implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(EmptyStruct.class, metaDataMap); + } + + public EmptyStruct() { + } + + public static class Builder { + + public Builder() { + } + + public EmptyStruct build() { + EmptyStruct result = new EmptyStruct(); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public EmptyStruct(EmptyStruct other) { + } + + public EmptyStruct deepCopy() { + return new EmptyStruct(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 EmptyStruct)) + return false; + EmptyStruct that = (EmptyStruct)_that; + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {}); + } + + @Override + public int compareTo(EmptyStruct 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("EmptyStruct"); + 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/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/TestStruct.java new file mode 100644 index 00000000000000..20b2ef595172bc --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/java_deprecated/gen-javadeprecated/TestStruct.java @@ -0,0 +1,926 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 TestStruct implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + + public int unqualified_int_field; + public boolean unqualified_bool_field; + public List unqualified_list_field; + public EmptyStruct unqualified_struct_field; + public int optional_int_field; + public boolean optional_bool_field; + public List optional_list_field; + public EmptyStruct optional_struct_field; + public static final int UNQUALIFIED_INT_FIELD = 1; + public static final int UNQUALIFIED_BOOL_FIELD = 2; + public static final int UNQUALIFIED_LIST_FIELD = 3; + public static final int UNQUALIFIED_STRUCT_FIELD = 4; + public static final int OPTIONAL_INT_FIELD = 5; + public static final int OPTIONAL_BOOL_FIELD = 6; + public static final int OPTIONAL_LIST_FIELD = 7; + public static final int OPTIONAL_STRUCT_FIELD = 8; + + // isset id assignments + private static final int __UNQUALIFIED_INT_FIELD_ISSET_ID = 0; + private static final int __UNQUALIFIED_BOOL_FIELD_ISSET_ID = 1; + private static final int __OPTIONAL_INT_FIELD_ISSET_ID = 2; + private static final int __OPTIONAL_BOOL_FIELD_ISSET_ID = 3; + private BitSet __isset_bit_vector = new BitSet(4); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + tmpMetaDataMap.put(UNQUALIFIED_INT_FIELD, new FieldMetaData("unqualified_int_field", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.I32))); + tmpMetaDataMap.put(UNQUALIFIED_BOOL_FIELD, new FieldMetaData("unqualified_bool_field", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.BOOL))); + tmpMetaDataMap.put(UNQUALIFIED_LIST_FIELD, new FieldMetaData("unqualified_list_field", TFieldRequirementType.DEFAULT, + new ListMetaData(TType.LIST, + new FieldValueMetaData(TType.I32)))); + tmpMetaDataMap.put(UNQUALIFIED_STRUCT_FIELD, new FieldMetaData("unqualified_struct_field", TFieldRequirementType.DEFAULT, + new StructMetaData(TType.STRUCT, EmptyStruct.class))); + tmpMetaDataMap.put(OPTIONAL_INT_FIELD, new FieldMetaData("optional_int_field", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.I32))); + tmpMetaDataMap.put(OPTIONAL_BOOL_FIELD, new FieldMetaData("optional_bool_field", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.BOOL))); + tmpMetaDataMap.put(OPTIONAL_LIST_FIELD, new FieldMetaData("optional_list_field", TFieldRequirementType.OPTIONAL, + new ListMetaData(TType.LIST, + new FieldValueMetaData(TType.I32)))); + tmpMetaDataMap.put(OPTIONAL_STRUCT_FIELD, new FieldMetaData("optional_struct_field", TFieldRequirementType.OPTIONAL, + new StructMetaData(TType.STRUCT, EmptyStruct.class))); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(TestStruct.class, metaDataMap); + } + + public TestStruct() { + } + + public TestStruct( + int unqualified_int_field, + boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field) { + this(); + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + } + + public TestStruct( + int unqualified_int_field, + boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field, + int optional_int_field, + boolean optional_bool_field, + List optional_list_field, + EmptyStruct optional_struct_field) { + this(); + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + this.optional_int_field = optional_int_field; + setOptional_int_fieldIsSet(true); + this.optional_bool_field = optional_bool_field; + setOptional_bool_fieldIsSet(true); + this.optional_list_field = optional_list_field; + this.optional_struct_field = optional_struct_field; + } + + public static class Builder { + private int unqualified_int_field; + private boolean unqualified_bool_field; + private List unqualified_list_field; + private EmptyStruct unqualified_struct_field; + private int optional_int_field; + private boolean optional_bool_field; + private List optional_list_field; + private EmptyStruct optional_struct_field; + + BitSet __optional_isset = new BitSet(4); + + public Builder() { + } + + public Builder setUnqualified_int_field(final int unqualified_int_field) { + this.unqualified_int_field = unqualified_int_field; + __optional_isset.set(__UNQUALIFIED_INT_FIELD_ISSET_ID, true); + return this; + } + + public Builder setUnqualified_bool_field(final boolean unqualified_bool_field) { + this.unqualified_bool_field = unqualified_bool_field; + __optional_isset.set(__UNQUALIFIED_BOOL_FIELD_ISSET_ID, true); + return this; + } + + public Builder setUnqualified_list_field(final List unqualified_list_field) { + this.unqualified_list_field = unqualified_list_field; + return this; + } + + public Builder setUnqualified_struct_field(final EmptyStruct unqualified_struct_field) { + this.unqualified_struct_field = unqualified_struct_field; + return this; + } + + public Builder setOptional_int_field(final int optional_int_field) { + this.optional_int_field = optional_int_field; + __optional_isset.set(__OPTIONAL_INT_FIELD_ISSET_ID, true); + return this; + } + + public Builder setOptional_bool_field(final boolean optional_bool_field) { + this.optional_bool_field = optional_bool_field; + __optional_isset.set(__OPTIONAL_BOOL_FIELD_ISSET_ID, true); + return this; + } + + public Builder setOptional_list_field(final List optional_list_field) { + this.optional_list_field = optional_list_field; + return this; + } + + public Builder setOptional_struct_field(final EmptyStruct optional_struct_field) { + this.optional_struct_field = optional_struct_field; + return this; + } + + public TestStruct build() { + TestStruct result = new TestStruct(); + if (__optional_isset.get(__UNQUALIFIED_INT_FIELD_ISSET_ID)) { + result.setUnqualified_int_field(this.unqualified_int_field); + } + if (__optional_isset.get(__UNQUALIFIED_BOOL_FIELD_ISSET_ID)) { + result.setUnqualified_bool_field(this.unqualified_bool_field); + } + result.setUnqualified_list_field(this.unqualified_list_field); + result.setUnqualified_struct_field(this.unqualified_struct_field); + if (__optional_isset.get(__OPTIONAL_INT_FIELD_ISSET_ID)) { + result.setOptional_int_field(this.optional_int_field); + } + if (__optional_isset.get(__OPTIONAL_BOOL_FIELD_ISSET_ID)) { + result.setOptional_bool_field(this.optional_bool_field); + } + result.setOptional_list_field(this.optional_list_field); + result.setOptional_struct_field(this.optional_struct_field); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public TestStruct(TestStruct other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + this.unqualified_int_field = TBaseHelper.deepCopy(other.unqualified_int_field); + this.unqualified_bool_field = TBaseHelper.deepCopy(other.unqualified_bool_field); + if (other.isSetUnqualified_list_field()) { + this.unqualified_list_field = TBaseHelper.deepCopy(other.unqualified_list_field); + } + if (other.isSetUnqualified_struct_field()) { + this.unqualified_struct_field = TBaseHelper.deepCopy(other.unqualified_struct_field); + } + this.optional_int_field = TBaseHelper.deepCopy(other.optional_int_field); + this.optional_bool_field = TBaseHelper.deepCopy(other.optional_bool_field); + if (other.isSetOptional_list_field()) { + this.optional_list_field = TBaseHelper.deepCopy(other.optional_list_field); + } + if (other.isSetOptional_struct_field()) { + this.optional_struct_field = TBaseHelper.deepCopy(other.optional_struct_field); + } + } + + public TestStruct deepCopy() { + return new TestStruct(this); + } + + public int getUnqualified_int_field() { + return this.unqualified_int_field; + } + + public TestStruct setUnqualified_int_field(int unqualified_int_field) { + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + return this; + } + + public void unsetUnqualified_int_field() { + __isset_bit_vector.clear(__UNQUALIFIED_INT_FIELD_ISSET_ID); + } + + // Returns true if field unqualified_int_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_int_field() { + return __isset_bit_vector.get(__UNQUALIFIED_INT_FIELD_ISSET_ID); + } + + public void setUnqualified_int_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__UNQUALIFIED_INT_FIELD_ISSET_ID, __value); + } + + public boolean isUnqualified_bool_field() { + return this.unqualified_bool_field; + } + + public TestStruct setUnqualified_bool_field(boolean unqualified_bool_field) { + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + return this; + } + + public void unsetUnqualified_bool_field() { + __isset_bit_vector.clear(__UNQUALIFIED_BOOL_FIELD_ISSET_ID); + } + + // Returns true if field unqualified_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_bool_field() { + return __isset_bit_vector.get(__UNQUALIFIED_BOOL_FIELD_ISSET_ID); + } + + public void setUnqualified_bool_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__UNQUALIFIED_BOOL_FIELD_ISSET_ID, __value); + } + + public List getUnqualified_list_field() { + return this.unqualified_list_field; + } + + public TestStruct setUnqualified_list_field(List unqualified_list_field) { + this.unqualified_list_field = unqualified_list_field; + return this; + } + + public void unsetUnqualified_list_field() { + this.unqualified_list_field = null; + } + + // Returns true if field unqualified_list_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_list_field() { + return this.unqualified_list_field != null; + } + + public void setUnqualified_list_fieldIsSet(boolean __value) { + if (!__value) { + this.unqualified_list_field = null; + } + } + + public EmptyStruct getUnqualified_struct_field() { + return this.unqualified_struct_field; + } + + public TestStruct setUnqualified_struct_field(EmptyStruct unqualified_struct_field) { + this.unqualified_struct_field = unqualified_struct_field; + return this; + } + + public void unsetUnqualified_struct_field() { + this.unqualified_struct_field = null; + } + + // Returns true if field unqualified_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_struct_field() { + return this.unqualified_struct_field != null; + } + + public void setUnqualified_struct_fieldIsSet(boolean __value) { + if (!__value) { + this.unqualified_struct_field = null; + } + } + + public int getOptional_int_field() { + return this.optional_int_field; + } + + public TestStruct setOptional_int_field(int optional_int_field) { + this.optional_int_field = optional_int_field; + setOptional_int_fieldIsSet(true); + return this; + } + + public void unsetOptional_int_field() { + __isset_bit_vector.clear(__OPTIONAL_INT_FIELD_ISSET_ID); + } + + // Returns true if field optional_int_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_int_field() { + return __isset_bit_vector.get(__OPTIONAL_INT_FIELD_ISSET_ID); + } + + public void setOptional_int_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__OPTIONAL_INT_FIELD_ISSET_ID, __value); + } + + public boolean isOptional_bool_field() { + return this.optional_bool_field; + } + + public TestStruct setOptional_bool_field(boolean optional_bool_field) { + this.optional_bool_field = optional_bool_field; + setOptional_bool_fieldIsSet(true); + return this; + } + + public void unsetOptional_bool_field() { + __isset_bit_vector.clear(__OPTIONAL_BOOL_FIELD_ISSET_ID); + } + + // Returns true if field optional_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_bool_field() { + return __isset_bit_vector.get(__OPTIONAL_BOOL_FIELD_ISSET_ID); + } + + public void setOptional_bool_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__OPTIONAL_BOOL_FIELD_ISSET_ID, __value); + } + + public List getOptional_list_field() { + return this.optional_list_field; + } + + public TestStruct setOptional_list_field(List optional_list_field) { + this.optional_list_field = optional_list_field; + return this; + } + + public void unsetOptional_list_field() { + this.optional_list_field = null; + } + + // Returns true if field optional_list_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_list_field() { + return this.optional_list_field != null; + } + + public void setOptional_list_fieldIsSet(boolean __value) { + if (!__value) { + this.optional_list_field = null; + } + } + + public EmptyStruct getOptional_struct_field() { + return this.optional_struct_field; + } + + public TestStruct setOptional_struct_field(EmptyStruct optional_struct_field) { + this.optional_struct_field = optional_struct_field; + return this; + } + + public void unsetOptional_struct_field() { + this.optional_struct_field = null; + } + + // Returns true if field optional_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_struct_field() { + return this.optional_struct_field != null; + } + + public void setOptional_struct_fieldIsSet(boolean __value) { + if (!__value) { + this.optional_struct_field = null; + } + } + + @SuppressWarnings("unchecked") + public void setFieldValue(int fieldID, Object __value) { + switch (fieldID) { + case UNQUALIFIED_INT_FIELD: + if (__value == null) { + unsetUnqualified_int_field(); + } else { + setUnqualified_int_field((Integer)__value); + } + break; + + case UNQUALIFIED_BOOL_FIELD: + if (__value == null) { + unsetUnqualified_bool_field(); + } else { + setUnqualified_bool_field((Boolean)__value); + } + break; + + case UNQUALIFIED_LIST_FIELD: + if (__value == null) { + unsetUnqualified_list_field(); + } else { + setUnqualified_list_field((List)__value); + } + break; + + case UNQUALIFIED_STRUCT_FIELD: + if (__value == null) { + unsetUnqualified_struct_field(); + } else { + setUnqualified_struct_field((EmptyStruct)__value); + } + break; + + case OPTIONAL_INT_FIELD: + if (__value == null) { + unsetOptional_int_field(); + } else { + setOptional_int_field((Integer)__value); + } + break; + + case OPTIONAL_BOOL_FIELD: + if (__value == null) { + unsetOptional_bool_field(); + } else { + setOptional_bool_field((Boolean)__value); + } + break; + + case OPTIONAL_LIST_FIELD: + if (__value == null) { + unsetOptional_list_field(); + } else { + setOptional_list_field((List)__value); + } + break; + + case OPTIONAL_STRUCT_FIELD: + if (__value == null) { + unsetOptional_struct_field(); + } else { + setOptional_struct_field((EmptyStruct)__value); + } + break; + + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + public Object getFieldValue(int fieldID) { + switch (fieldID) { + case UNQUALIFIED_INT_FIELD: + return new Integer(getUnqualified_int_field()); + + case UNQUALIFIED_BOOL_FIELD: + return new Boolean(isUnqualified_bool_field()); + + case UNQUALIFIED_LIST_FIELD: + return getUnqualified_list_field(); + + case UNQUALIFIED_STRUCT_FIELD: + return getUnqualified_struct_field(); + + case OPTIONAL_INT_FIELD: + return new Integer(getOptional_int_field()); + + case OPTIONAL_BOOL_FIELD: + return new Boolean(isOptional_bool_field()); + + case OPTIONAL_LIST_FIELD: + return getOptional_list_field(); + + case OPTIONAL_STRUCT_FIELD: + return getOptional_struct_field(); + + 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 TestStruct)) + return false; + TestStruct that = (TestStruct)_that; + + if (!TBaseHelper.equalsNobinary(this.unqualified_int_field, that.unqualified_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.unqualified_bool_field, that.unqualified_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_list_field(), that.isSetUnqualified_list_field(), this.unqualified_list_field, that.unqualified_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_struct_field(), that.isSetUnqualified_struct_field(), this.unqualified_struct_field, that.unqualified_struct_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_int_field(), that.isSetOptional_int_field(), this.optional_int_field, that.optional_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_bool_field(), that.isSetOptional_bool_field(), this.optional_bool_field, that.optional_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_list_field(), that.isSetOptional_list_field(), this.optional_list_field, that.optional_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_struct_field(), that.isSetOptional_struct_field(), this.optional_struct_field, that.optional_struct_field)) { return false; } + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {unqualified_int_field, unqualified_bool_field, unqualified_list_field, unqualified_struct_field, optional_int_field, optional_bool_field, optional_list_field, optional_struct_field}); + } + + @Override + public int compareTo(TestStruct other) { + if (other == null) { + // See java.lang.Comparable docs + throw new NullPointerException(); + } + + if (other == this) { + return 0; + } + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetUnqualified_int_field()).compareTo(other.isSetUnqualified_int_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_int_field, other.unqualified_int_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_bool_field()).compareTo(other.isSetUnqualified_bool_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_bool_field, other.unqualified_bool_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_list_field()).compareTo(other.isSetUnqualified_list_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_list_field, other.unqualified_list_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_struct_field()).compareTo(other.isSetUnqualified_struct_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_struct_field, other.unqualified_struct_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_int_field()).compareTo(other.isSetOptional_int_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_int_field, other.optional_int_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_bool_field()).compareTo(other.isSetOptional_bool_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_bool_field, other.optional_bool_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_list_field()).compareTo(other.isSetOptional_list_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_list_field, other.optional_list_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_struct_field()).compareTo(other.isSetOptional_struct_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_struct_field, other.optional_struct_field); + if (lastComparison != 0) { + return lastComparison; + } + 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) + { + case UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + this.unqualified_int_field = iprot.readI32(); + setUnqualified_int_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + this.unqualified_bool_field = iprot.readBool(); + setUnqualified_bool_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list0 = iprot.readListBegin(); + this.unqualified_list_field = new ArrayList(Math.max(0, _list0.size)); + for (int _i1 = 0; + (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); + ++_i1) + { + int _elem2; + _elem2 = iprot.readI32(); + this.unqualified_list_field.add(_elem2); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + this.unqualified_struct_field = new EmptyStruct(); + this.unqualified_struct_field.read(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + this.optional_int_field = iprot.readI32(); + setOptional_int_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + this.optional_bool_field = iprot.readBool(); + setOptional_bool_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list3 = iprot.readListBegin(); + this.optional_list_field = new ArrayList(Math.max(0, _list3.size)); + for (int _i4 = 0; + (_list3.size < 0) ? iprot.peekList() : (_i4 < _list3.size); + ++_i4) + { + int _elem5; + _elem5 = iprot.readI32(); + this.optional_list_field.add(_elem5); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + this.optional_struct_field = new EmptyStruct(); + this.optional_struct_field.read(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + 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.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualified_int_field); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualified_bool_field); + oprot.writeFieldEnd(); + if (this.unqualified_list_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.unqualified_list_field.size())); + for (int _iter6 : this.unqualified_list_field) { + oprot.writeI32(_iter6); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (this.unqualified_struct_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualified_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + if (isSetOptional_int_field()) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optional_int_field); + oprot.writeFieldEnd(); + } + if (isSetOptional_bool_field()) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optional_bool_field); + oprot.writeFieldEnd(); + } + if (this.optional_list_field != null) { + if (isSetOptional_list_field()) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.optional_list_field.size())); + for (int _iter7 : this.optional_list_field) { + oprot.writeI32(_iter7); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.optional_struct_field != null) { + if (isSetOptional_struct_field()) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optional_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + } + 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("TestStruct"); + sb.append(space); + sb.append("("); + sb.append(newLine); + boolean first = true; + + sb.append(indentStr); + sb.append("unqualified_int_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.getUnqualified_int_field(), indent + 1, prettyPrint)); + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_bool_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.isUnqualified_bool_field(), indent + 1, prettyPrint)); + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_list_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getUnqualified_list_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getUnqualified_list_field(), indent + 1, prettyPrint)); + } + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_struct_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getUnqualified_struct_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getUnqualified_struct_field(), indent + 1, prettyPrint)); + } + first = false; + if (isSetOptional_int_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_int_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.getOptional_int_field(), indent + 1, prettyPrint)); + first = false; + } + if (isSetOptional_bool_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_bool_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.isOptional_bool_field(), indent + 1, prettyPrint)); + first = false; + } + if (isSetOptional_list_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_list_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getOptional_list_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getOptional_list_field(), indent + 1, prettyPrint)); + } + first = false; + } + if (isSetOptional_struct_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_struct_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getOptional_struct_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getOptional_struct_field(), indent + 1, prettyPrint)); + } + first = false; + } + 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/default_values_rectification_after/out/json/gen-json/module.json b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/json/gen-json/module.json new file mode 100644 index 00000000000000..4a7f4a8ab07854 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/json/gen-json/module.json @@ -0,0 +1,161 @@ +{ + "__fbthrift": {"@generated": 0}, + "thrift_module" : "module", + "structs" : { + "EmptyStruct" : { + "lineno" : 19, + "is_exception" : false, + "is_union" : false, + "fields" : { + + }, + "source_range" : { + "begin" : { + "line" : 19, + "column" : 1 + }, + "end" : { + "line" : 19, + "column" : 22 + } + } + }, + "TestStruct" : { + "lineno" : 21, + "is_exception" : false, + "is_union" : false, + "fields" : { + "unqualified_int_field" : { + "type_enum" : "I32", + "spec_args" : null, + "required" : true, + "source_range" : { + "begin" : { + "line" : 22, + "column" : 3 + }, + "end" : { + "line" : 22, + "column" : 32 + } + } + }, + "unqualified_bool_field" : { + "type_enum" : "BOOL", + "spec_args" : null, + "required" : true, + "source_range" : { + "begin" : { + "line" : 24, + "column" : 3 + }, + "end" : { + "line" : 24, + "column" : 34 + } + } + }, + "unqualified_list_field" : { + "type_enum" : "LIST", + "spec_args" : { "type_enum" : "I32", "spec_args" : null} , + "required" : true, + "source_range" : { + "begin" : { + "line" : 26, + "column" : 3 + }, + "end" : { + "line" : 26, + "column" : 39 + } + } + }, + "unqualified_struct_field" : { + "type_enum" : "STRUCT", + "spec_args" : "EmptyStruct", + "required" : true, + "source_range" : { + "begin" : { + "line" : 28, + "column" : 3 + }, + "end" : { + "line" : 28, + "column" : 43 + } + } + }, + "optional_int_field" : { + "type_enum" : "I32", + "spec_args" : null, + "required" : false, + "source_range" : { + "begin" : { + "line" : 30, + "column" : 3 + }, + "end" : { + "line" : 30, + "column" : 38 + } + } + }, + "optional_bool_field" : { + "type_enum" : "BOOL", + "spec_args" : null, + "required" : false, + "source_range" : { + "begin" : { + "line" : 32, + "column" : 3 + }, + "end" : { + "line" : 32, + "column" : 40 + } + } + }, + "optional_list_field" : { + "type_enum" : "LIST", + "spec_args" : { "type_enum" : "I32", "spec_args" : null} , + "required" : false, + "source_range" : { + "begin" : { + "line" : 34, + "column" : 3 + }, + "end" : { + "line" : 34, + "column" : 45 + } + } + }, + "optional_struct_field" : { + "type_enum" : "STRUCT", + "spec_args" : "EmptyStruct", + "required" : false, + "source_range" : { + "begin" : { + "line" : 36, + "column" : 3 + }, + "end" : { + "line" : 36, + "column" : 49 + } + } + } + }, + "source_range" : { + "begin" : { + "line" : 21, + "column" : 1 + }, + "end" : { + "line" : 37, + "column" : 2 + } + } + } + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/json_experimental/gen-json_experimental/module.json b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/json_experimental/gen-json_experimental/module.json new file mode 100644 index 00000000000000..f0d561a99e7e9e --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/json_experimental/gen-json_experimental/module.json @@ -0,0 +1,97 @@ +{ + "__fbthrift": "@generated", + "thrift_module" : "module", + "package": { + "domain_prefix": "facebook", + "domain_suffix": "com", + "path": "thrift/compiler/test/fixtures/default_values_rectification", + "filename": "module" + }, + "structs" : + { + "EmptyStruct" : { + "name" : "EmptyStruct", + "is_exception" : false, + "is_union" : false, + "lineno" : 19 + }, + "TestStruct" : { + "name" : "TestStruct", + "fields" : { + "unqualified_int_field" : { + "name" : "unqualified_int_field", + "key" : 1, + "lineno" : 22, + "required" : "opt-in-req-out", + "type" : "i32" + }, + "unqualified_bool_field" : { + "name" : "unqualified_bool_field", + "key" : 2, + "lineno" : 24, + "required" : "opt-in-req-out", + "type" : "bool" + }, + "unqualified_list_field" : { + "name" : "unqualified_list_field", + "key" : 3, + "lineno" : 26, + "required" : "opt-in-req-out", + "type" : { + "type" : "list", + "inner_type" : "i32" + } + }, + "unqualified_struct_field" : { + "name" : "unqualified_struct_field", + "key" : 4, + "lineno" : 28, + "required" : "opt-in-req-out", + "type" : { + "type" : "struct", + "name" : "EmptyStruct" + } + }, + "optional_int_field" : { + "name" : "optional_int_field", + "key" : 5, + "lineno" : 30, + "required" : "optional", + "type" : "i32" + }, + "optional_bool_field" : { + "name" : "optional_bool_field", + "key" : 6, + "lineno" : 32, + "required" : "optional", + "type" : "bool" + }, + "optional_list_field" : { + "name" : "optional_list_field", + "key" : 7, + "lineno" : 34, + "required" : "optional", + "type" : { + "type" : "list", + "inner_type" : "i32" + } + }, + "optional_struct_field" : { + "name" : "optional_struct_field", + "key" : 8, + "lineno" : 36, + "required" : "optional", + "type" : { + "type" : "struct", + "name" : "EmptyStruct" + } + } + }, + "is_exception" : false, + "is_union" : false, + "lineno" : 21 + } + }, + "source_path" : "thrift/compiler/test/fixtures/default_values_rectification_after/src/module", + "py_namespace" : "" +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/__init__.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/__init__.py new file mode 100644 index 00000000000000..8bb216b5496dc9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/__init__.py @@ -0,0 +1,6 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/__init__.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/__init__.py new file mode 100644 index 00000000000000..451f5c6391ddaf --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/__init__.py @@ -0,0 +1,7 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# +__all__ = ['ttypes', 'constants'] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/constants.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/constants.py new file mode 100644 index 00000000000000..d447c44dca9113 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/constants.py @@ -0,0 +1,17 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# + +from __future__ import absolute_import +import sys +from thrift.util.Recursive import fix_spec +from thrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef +from thrift.protocol.TProtocol import TProtocolException + + + +from .ttypes import UTF8STRINGS, EmptyStruct, TestStruct + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/ttypes.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/ttypes.py new file mode 100644 index 00000000000000..23bc727cf0ac77 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py/gen-py/module/ttypes.py @@ -0,0 +1,414 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# + +from __future__ import absolute_import +import sys +from thrift.util.Recursive import fix_spec +from thrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef +from thrift.protocol.TProtocol import TProtocolException + + + +import pprint +import warnings +from thrift import Thrift +from thrift.transport import TTransport +from thrift.protocol import TBinaryProtocol +from thrift.protocol import TCompactProtocol +from thrift.protocol import THeaderProtocol +fastproto = None +try: + from thrift.protocol import fastproto +except ImportError: + pass + +def __EXPAND_THRIFT_SPEC(spec): + next_id = 0 + for item in spec: + item_id = item[0] + if next_id >= 0 and item_id < 0: + next_id = item_id + if item_id != next_id: + for _ in range(next_id, item_id): + yield None + yield item + next_id = item_id + 1 + +class ThriftEnumWrapper(int): + def __new__(cls, enum_class, value): + return super().__new__(cls, value) + def __init__(self, enum_class, value): self.enum_class = enum_class + def __repr__(self): + return self.enum_class.__name__ + '.' + self.enum_class._VALUES_TO_NAMES[self] + +all_structs = [] +UTF8STRINGS = bool(0) or sys.version_info.major >= 3 + +__all__ = ['UTF8STRINGS', 'EmptyStruct', 'TestStruct'] + +class EmptyStruct: + + 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('EmptyStruct') + 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.compiler.test.fixtures.default_values_rectification.module.thrift_types") + return thrift.python.converter.to_python_struct(python_types.EmptyStruct, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.EmptyStruct, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.types") + return thrift.py3.converter.to_py3_struct(py3_types.EmptyStruct, self) + + def _to_py_deprecated(self): + return self + +class TestStruct: + r""" + Attributes: + - unqualified_int_field + - unqualified_bool_field + - unqualified_list_field + - unqualified_struct_field + - optional_int_field + - optional_bool_field + - optional_list_field + - optional_struct_field + """ + + thrift_spec = None + thrift_field_annotations = None + thrift_struct_annotations = None + __init__ = 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 + if fid == 1: + if ftype == TType.I32: + self.unqualified_int_field = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.unqualified_bool_field = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.unqualified_list_field = [] + (_etype3, _size0) = iprot.readListBegin() + if _size0 >= 0: + for _i4 in range(_size0): + _elem5 = iprot.readI32() + self.unqualified_list_field.append(_elem5) + else: + while iprot.peekList(): + _elem6 = iprot.readI32() + self.unqualified_list_field.append(_elem6) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.unqualified_struct_field = EmptyStruct() + self.unqualified_struct_field.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I32: + self.optional_int_field = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.BOOL: + self.optional_bool_field = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 7: + if ftype == TType.LIST: + self.optional_list_field = [] + (_etype10, _size7) = iprot.readListBegin() + if _size7 >= 0: + for _i11 in range(_size7): + _elem12 = iprot.readI32() + self.optional_list_field.append(_elem12) + else: + while iprot.peekList(): + _elem13 = iprot.readI32() + self.optional_list_field.append(_elem13) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.STRUCT: + self.optional_struct_field = EmptyStruct() + self.optional_struct_field.read(iprot) + else: + iprot.skip(ftype) + 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('TestStruct') + if self.unqualified_int_field != None: + oprot.writeFieldBegin('unqualified_int_field', TType.I32, 1) + oprot.writeI32(self.unqualified_int_field) + oprot.writeFieldEnd() + if self.unqualified_bool_field != None: + oprot.writeFieldBegin('unqualified_bool_field', TType.BOOL, 2) + oprot.writeBool(self.unqualified_bool_field) + oprot.writeFieldEnd() + if self.unqualified_list_field != None: + oprot.writeFieldBegin('unqualified_list_field', TType.LIST, 3) + oprot.writeListBegin(TType.I32, len(self.unqualified_list_field)) + for iter14 in self.unqualified_list_field: + oprot.writeI32(iter14) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.unqualified_struct_field != None: + oprot.writeFieldBegin('unqualified_struct_field', TType.STRUCT, 4) + self.unqualified_struct_field.write(oprot) + oprot.writeFieldEnd() + if self.optional_int_field != None: + oprot.writeFieldBegin('optional_int_field', TType.I32, 5) + oprot.writeI32(self.optional_int_field) + oprot.writeFieldEnd() + if self.optional_bool_field != None: + oprot.writeFieldBegin('optional_bool_field', TType.BOOL, 6) + oprot.writeBool(self.optional_bool_field) + oprot.writeFieldEnd() + if self.optional_list_field != None: + oprot.writeFieldBegin('optional_list_field', TType.LIST, 7) + oprot.writeListBegin(TType.I32, len(self.optional_list_field)) + for iter15 in self.optional_list_field: + oprot.writeI32(iter15) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.optional_struct_field != None: + oprot.writeFieldBegin('optional_struct_field', TType.STRUCT, 8) + self.optional_struct_field.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def __repr__(self): + L = [] + padding = ' ' * 4 + if self.unqualified_int_field is not None: + value = pprint.pformat(self.unqualified_int_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_int_field=%s' % (value)) + if self.unqualified_bool_field is not None: + value = pprint.pformat(self.unqualified_bool_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_bool_field=%s' % (value)) + if self.unqualified_list_field is not None: + value = pprint.pformat(self.unqualified_list_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_list_field=%s' % (value)) + if self.unqualified_struct_field is not None: + value = pprint.pformat(self.unqualified_struct_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_struct_field=%s' % (value)) + if self.optional_int_field is not None: + value = pprint.pformat(self.optional_int_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_int_field=%s' % (value)) + if self.optional_bool_field is not None: + value = pprint.pformat(self.optional_bool_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_bool_field=%s' % (value)) + if self.optional_list_field is not None: + value = pprint.pformat(self.optional_list_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_list_field=%s' % (value)) + if self.optional_struct_field is not None: + value = pprint.pformat(self.optional_struct_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_struct_field=%s' % (value)) + 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 ( + 'unqualified_int_field', + 'unqualified_bool_field', + 'unqualified_list_field', + 'unqualified_struct_field', + 'optional_int_field', + 'optional_bool_field', + 'optional_list_field', + 'optional_struct_field', + ) + + __hash__ = object.__hash__ + + def _to_python(self): + import importlib + import thrift.python.converter + python_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_types") + return thrift.python.converter.to_python_struct(python_types.TestStruct, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.TestStruct, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.types") + return thrift.py3.converter.to_py3_struct(py3_types.TestStruct, self) + + def _to_py_deprecated(self): + return self + +all_structs.append(EmptyStruct) +EmptyStruct.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( +))) + +EmptyStruct.thrift_struct_annotations = { +} +EmptyStruct.thrift_field_annotations = { +} + +all_structs.append(TestStruct) +TestStruct.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( + (1, TType.I32, 'unqualified_int_field', None, None, 2, ), # 1 + (2, TType.BOOL, 'unqualified_bool_field', None, None, 2, ), # 2 + (3, TType.LIST, 'unqualified_list_field', (TType.I32,None), None, 2, ), # 3 + (4, TType.STRUCT, 'unqualified_struct_field', [EmptyStruct, EmptyStruct.thrift_spec, False], None, 2, ), # 4 + (5, TType.I32, 'optional_int_field', None, None, 1, ), # 5 + (6, TType.BOOL, 'optional_bool_field', None, None, 1, ), # 6 + (7, TType.LIST, 'optional_list_field', (TType.I32,None), None, 1, ), # 7 + (8, TType.STRUCT, 'optional_struct_field', [EmptyStruct, EmptyStruct.thrift_spec, False], None, 1, ), # 8 +))) + +TestStruct.thrift_struct_annotations = { +} +TestStruct.thrift_field_annotations = { +} + +def TestStruct__init__(self, unqualified_int_field=None, unqualified_bool_field=None, unqualified_list_field=None, unqualified_struct_field=None, optional_int_field=None, optional_bool_field=None, optional_list_field=None, optional_struct_field=None,): + self.unqualified_int_field = unqualified_int_field + self.unqualified_bool_field = unqualified_bool_field + self.unqualified_list_field = unqualified_list_field + self.unqualified_struct_field = unqualified_struct_field + self.optional_int_field = optional_int_field + self.optional_bool_field = optional_bool_field + self.optional_list_field = optional_list_field + self.optional_struct_field = optional_struct_field + +TestStruct.__init__ = TestStruct__init__ + +def TestStruct__setstate__(self, state): + state.setdefault('unqualified_int_field', None) + state.setdefault('unqualified_bool_field', None) + state.setdefault('unqualified_list_field', None) + state.setdefault('unqualified_struct_field', None) + state.setdefault('optional_int_field', None) + state.setdefault('optional_bool_field', None) + state.setdefault('optional_list_field', None) + state.setdefault('optional_struct_field', None) + self.__dict__ = state + +TestStruct.__getstate__ = lambda self: self.__dict__.copy() +TestStruct.__setstate__ = TestStruct__setstate__ + +fix_spec(all_structs) +del all_structs diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.cpp new file mode 100644 index 00000000000000..074ad5bb787734 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.cpp @@ -0,0 +1,28 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-py3/module/metadata.h" + +namespace facebook { +namespace thrift { +namespace compiler { +namespace test { +namespace fixtures { +namespace default_values_rectification { +::apache::thrift::metadata::ThriftMetadata module_getThriftModuleMetadata() { + ::apache::thrift::metadata::ThriftServiceMetadataResponse response; + ::apache::thrift::metadata::ThriftMetadata& metadata = *response.metadata_ref(); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); + return metadata; +} +} // namespace facebook +} // namespace thrift +} // namespace compiler +} // namespace test +} // namespace fixtures +} // namespace default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.h new file mode 100644 index 00000000000000..61277febc97ffd --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/metadata.h @@ -0,0 +1,26 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" + +namespace facebook { +namespace thrift { +namespace compiler { +namespace test { +namespace fixtures { +namespace default_values_rectification { +::apache::thrift::metadata::ThriftMetadata module_getThriftModuleMetadata(); +} // namespace facebook +} // namespace thrift +} // namespace compiler +} // namespace test +} // namespace fixtures +} // namespace default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/types.h new file mode 100644 index 00000000000000..fd5bdb2210f108 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/py3/gen-py3/module/types.h @@ -0,0 +1,79 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#pragma once + +#include +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_data.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_types.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_after/gen-cpp2/module_metadata.h" +namespace thrift { +namespace py3 { + + + +template<> +inline void reset_field<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>( + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& obj, uint16_t index) { + switch (index) { + } +} + +template<> +inline void reset_field<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>( + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct& obj, uint16_t index) { + switch (index) { + case 0: + obj.unqualified_int_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_int_field_ref()); + return; + case 1: + obj.unqualified_bool_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_bool_field_ref()); + return; + case 2: + obj.unqualified_list_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_list_field_ref()); + return; + case 3: + obj.unqualified_struct_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_struct_field_ref()); + return; + case 4: + obj.optional_int_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_int_field_ref()); + return; + case 5: + obj.optional_bool_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_bool_field_ref()); + return; + case 6: + obj.optional_list_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_list_field_ref()); + return; + case 7: + obj.optional_struct_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_struct_field_ref()); + return; + } +} + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} +} // namespace py3 +} // namespace thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/client.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/client.rs new file mode 100644 index 00000000000000..ff84b33d8feffc --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/client.rs @@ -0,0 +1,8 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies, unused_imports)] + +pub use :: as types; +pub(crate) use crate as client; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/consts.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/consts.rs new file mode 100644 index 00000000000000..f93d038b25b86e --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/consts.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift constant definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/errors.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/errors.rs new file mode 100644 index 00000000000000..94feb150167779 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/errors.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift error definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/mock.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/mock.rs new file mode 100644 index 00000000000000..9890b353bb144a --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/mock.rs @@ -0,0 +1,7 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies, unused_imports)] + +pub(crate) use :: as types; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-cpp2 b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-cpp2 new file mode 100644 index 00000000000000..ce5ed52fc7f197 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-cpp2 @@ -0,0 +1 @@ +::facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-rust b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-rust new file mode 100644 index 00000000000000..0cca093d7af2d9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/namespace-rust @@ -0,0 +1 @@ +module diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/server.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/server.rs new file mode 100644 index 00000000000000..36284361463836 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/server.rs @@ -0,0 +1,7 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies)] + +pub use :: as types; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/service-names b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/service-names new file mode 100644 index 00000000000000..8b137891791fe9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/service-names @@ -0,0 +1 @@ + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/services.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/services.rs new file mode 100644 index 00000000000000..ab5119d67c4394 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/services.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift service definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/types.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/types.rs new file mode 100644 index 00000000000000..4517d7d418df81 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/out/rust/gen-rust/types.rs @@ -0,0 +1,372 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift +// This file is probably not the place you want to edit! + + +#![recursion_limit = "100000000"] +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, clippy::redundant_closure, clippy::type_complexity)] + +#[allow(unused_imports)] +pub(crate) use crate as types; + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct EmptyStruct { + // This field forces `..Default::default()` when instantiating this + // struct, to make code future-proof against new fields added later to + // the definition in Thrift. If you don't want this, add the annotation + // `@rust.Exhaustive` to the Thrift struct to eliminate this field. + #[doc(hidden)] + pub _dot_dot_Default_default: self::dot_dot::OtherFields, +} + +#[derive(Clone, PartialEq)] +pub struct TestStruct { + pub unqualified_int_field: ::std::primitive::i32, + pub unqualified_bool_field: ::std::primitive::bool, + pub unqualified_list_field: ::std::vec::Vec<::std::primitive::i32>, + pub unqualified_struct_field: crate::types::EmptyStruct, + pub optional_int_field: ::std::option::Option<::std::primitive::i32>, + pub optional_bool_field: ::std::option::Option<::std::primitive::bool>, + pub optional_list_field: ::std::option::Option<::std::vec::Vec<::std::primitive::i32>>, + pub optional_struct_field: ::std::option::Option, + // This field forces `..Default::default()` when instantiating this + // struct, to make code future-proof against new fields added later to + // the definition in Thrift. If you don't want this, add the annotation + // `@rust.Exhaustive` to the Thrift struct to eliminate this field. + #[doc(hidden)] + pub _dot_dot_Default_default: self::dot_dot::OtherFields, +} + + + +#[allow(clippy::derivable_impls)] +impl ::std::default::Default for self::EmptyStruct { + fn default() -> Self { + Self { + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + } + } +} + +impl ::std::fmt::Debug for self::EmptyStruct { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + formatter + .debug_struct("EmptyStruct") + .finish() + } +} + +unsafe impl ::std::marker::Send for self::EmptyStruct {} +unsafe impl ::std::marker::Sync for self::EmptyStruct {} +impl ::std::marker::Unpin for self::EmptyStruct {} +impl ::std::panic::RefUnwindSafe for self::EmptyStruct {} +impl ::std::panic::UnwindSafe for self::EmptyStruct {} + +impl ::fbthrift::GetTType for self::EmptyStruct { + const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; +} + +impl ::fbthrift::GetUri for self::EmptyStruct { + fn uri() -> &'static ::std::primitive::str { + "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct" + } +} + +impl ::fbthrift::GetTypeNameType for self::EmptyStruct { + fn type_name_type() -> fbthrift::TypeNameType { + ::fbthrift::TypeNameType::StructType + } +} + +impl

::fbthrift::Serialize

for self::EmptyStruct +where + P: ::fbthrift::ProtocolWriter, +{ + #[inline] + fn write(&self, p: &mut P) { + p.write_struct_begin("EmptyStruct"); + p.write_field_stop(); + p.write_struct_end(); + } +} + +impl

::fbthrift::Deserialize

for self::EmptyStruct +where + P: ::fbthrift::ProtocolReader, +{ + #[inline] + fn read(p: &mut P) -> ::anyhow::Result { + static FIELDS: &[::fbthrift::Field] = &[ + ]; + #[allow(unused_mut)] + let mut fields = Self { + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + }; + let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a EmptyStruct")?; + loop { + let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; + match (fty, fid as ::std::primitive::i32) { + (::fbthrift::TType::Stop, _) => break, + (fty, _) => p.skip(fty)?, + } + p.read_field_end()?; + } + p.read_struct_end()?; + ::std::result::Result::Ok(fields) + } +} + + +impl ::fbthrift::metadata::ThriftAnnotations for EmptyStruct { + fn get_structured_annotation() -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + ::std::option::Option::None + } + + fn get_field_structured_annotation(field_id: ::std::primitive::i16) -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + #[allow(clippy::match_single_binding)] + match field_id { + _ => {} + } + + ::std::option::Option::None + } +} + + +#[allow(clippy::derivable_impls)] +impl ::std::default::Default for self::TestStruct { + fn default() -> Self { + Self { + unqualified_int_field: ::std::default::Default::default(), + unqualified_bool_field: ::std::default::Default::default(), + unqualified_list_field: ::std::default::Default::default(), + unqualified_struct_field: ::std::default::Default::default(), + optional_int_field: ::std::option::Option::None, + optional_bool_field: ::std::option::Option::None, + optional_list_field: ::std::option::Option::None, + optional_struct_field: ::std::option::Option::None, + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + } + } +} + +impl ::std::fmt::Debug for self::TestStruct { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + formatter + .debug_struct("TestStruct") + .field("unqualified_int_field", &self.unqualified_int_field) + .field("unqualified_bool_field", &self.unqualified_bool_field) + .field("unqualified_list_field", &self.unqualified_list_field) + .field("unqualified_struct_field", &self.unqualified_struct_field) + .field("optional_int_field", &self.optional_int_field) + .field("optional_bool_field", &self.optional_bool_field) + .field("optional_list_field", &self.optional_list_field) + .field("optional_struct_field", &self.optional_struct_field) + .finish() + } +} + +unsafe impl ::std::marker::Send for self::TestStruct {} +unsafe impl ::std::marker::Sync for self::TestStruct {} +impl ::std::marker::Unpin for self::TestStruct {} +impl ::std::panic::RefUnwindSafe for self::TestStruct {} +impl ::std::panic::UnwindSafe for self::TestStruct {} + +impl ::fbthrift::GetTType for self::TestStruct { + const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; +} + +impl ::fbthrift::GetUri for self::TestStruct { + fn uri() -> &'static ::std::primitive::str { + "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct" + } +} + +impl ::fbthrift::GetTypeNameType for self::TestStruct { + fn type_name_type() -> fbthrift::TypeNameType { + ::fbthrift::TypeNameType::StructType + } +} + +impl

::fbthrift::Serialize

for self::TestStruct +where + P: ::fbthrift::ProtocolWriter, +{ + #[inline] + fn write(&self, p: &mut P) { + p.write_struct_begin("TestStruct"); + p.write_field_begin("unqualified_int_field", ::fbthrift::TType::I32, 1); + ::fbthrift::Serialize::write(&self.unqualified_int_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_bool_field", ::fbthrift::TType::Bool, 2); + ::fbthrift::Serialize::write(&self.unqualified_bool_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_list_field", ::fbthrift::TType::List, 3); + ::fbthrift::Serialize::write(&self.unqualified_list_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_struct_field", ::fbthrift::TType::Struct, 4); + ::fbthrift::Serialize::write(&self.unqualified_struct_field, p); + p.write_field_end(); + if let ::std::option::Option::Some(some) = &self.optional_int_field { + p.write_field_begin("optional_int_field", ::fbthrift::TType::I32, 5); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_bool_field { + p.write_field_begin("optional_bool_field", ::fbthrift::TType::Bool, 6); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_list_field { + p.write_field_begin("optional_list_field", ::fbthrift::TType::List, 7); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_struct_field { + p.write_field_begin("optional_struct_field", ::fbthrift::TType::Struct, 8); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + p.write_field_stop(); + p.write_struct_end(); + } +} + +impl

::fbthrift::Deserialize

for self::TestStruct +where + P: ::fbthrift::ProtocolReader, +{ + #[inline] + fn read(p: &mut P) -> ::anyhow::Result { + static FIELDS: &[::fbthrift::Field] = &[ + ::fbthrift::Field::new("optional_bool_field", ::fbthrift::TType::Bool, 6), + ::fbthrift::Field::new("optional_int_field", ::fbthrift::TType::I32, 5), + ::fbthrift::Field::new("optional_list_field", ::fbthrift::TType::List, 7), + ::fbthrift::Field::new("optional_struct_field", ::fbthrift::TType::Struct, 8), + ::fbthrift::Field::new("unqualified_bool_field", ::fbthrift::TType::Bool, 2), + ::fbthrift::Field::new("unqualified_int_field", ::fbthrift::TType::I32, 1), + ::fbthrift::Field::new("unqualified_list_field", ::fbthrift::TType::List, 3), + ::fbthrift::Field::new("unqualified_struct_field", ::fbthrift::TType::Struct, 4), + ]; + let mut field_unqualified_int_field = ::std::option::Option::None; + let mut field_unqualified_bool_field = ::std::option::Option::None; + let mut field_unqualified_list_field = ::std::option::Option::None; + let mut field_unqualified_struct_field = ::std::option::Option::None; + let mut field_optional_int_field = ::std::option::Option::None; + let mut field_optional_bool_field = ::std::option::Option::None; + let mut field_optional_list_field = ::std::option::Option::None; + let mut field_optional_struct_field = ::std::option::Option::None; + let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a TestStruct")?; + loop { + let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; + match (fty, fid as ::std::primitive::i32) { + (::fbthrift::TType::Stop, _) => break, + (::fbthrift::TType::I32, 1) => field_unqualified_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Bool, 2) => field_unqualified_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::List, 3) => field_unqualified_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Struct, 4) => field_unqualified_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::I32, 5) => field_optional_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Bool, 6) => field_optional_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::List, 7) => field_optional_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Struct, 8) => field_optional_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (fty, _) => p.skip(fty)?, + } + p.read_field_end()?; + } + p.read_struct_end()?; + ::std::result::Result::Ok(Self { + unqualified_int_field: field_unqualified_int_field.unwrap_or_default(), + unqualified_bool_field: field_unqualified_bool_field.unwrap_or_default(), + unqualified_list_field: field_unqualified_list_field.unwrap_or_default(), + unqualified_struct_field: field_unqualified_struct_field.unwrap_or_default(), + optional_int_field: field_optional_int_field, + optional_bool_field: field_optional_bool_field, + optional_list_field: field_optional_list_field, + optional_struct_field: field_optional_struct_field, + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + }) + } +} + + +impl ::fbthrift::metadata::ThriftAnnotations for TestStruct { + fn get_structured_annotation() -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + ::std::option::Option::None + } + + fn get_field_structured_annotation(field_id: ::std::primitive::i16) -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + #[allow(clippy::match_single_binding)] + match field_id { + 1 => { + }, + 2 => { + }, + 3 => { + }, + 4 => { + }, + 5 => { + }, + 6 => { + }, + 7 => { + }, + 8 => { + }, + _ => {} + } + + ::std::option::Option::None + } +} + + + +mod dot_dot { + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct OtherFields(pub(crate) ()); + + #[allow(dead_code)] // if serde isn't being used + pub(super) fn default_for_serde_deserialize() -> OtherFields { + OtherFields(()) + } +} + +pub(crate) mod r#impl { + use ::ref_cast::RefCast; + + #[derive(RefCast)] + #[repr(transparent)] + pub(crate) struct LocalImpl(T); + + #[allow(unused)] + pub(crate) fn write(value: &T, p: &mut P) + where + LocalImpl: ::fbthrift::Serialize

, + P: ::fbthrift::ProtocolWriter, + { + ::fbthrift::Serialize::write(LocalImpl::ref_cast(value), p); + } + + #[allow(unused)] + pub(crate) fn read(p: &mut P) -> ::anyhow::Result + where + LocalImpl: ::fbthrift::Deserialize

, + P: ::fbthrift::ProtocolReader, + { + let value: LocalImpl = ::fbthrift::Deserialize::read(p)?; + ::std::result::Result::Ok(value.0) + } +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift new file mode 100644 index 00000000000000..a12daea032ec23 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_after/src/module.thrift @@ -0,0 +1,37 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package "facebook.com/thrift/compiler/test/fixtures/default_values_rectification" + +struct EmptyStruct {} + +struct TestStruct { + 1: i32 unqualified_int_field; + + 2: bool unqualified_bool_field; + + 3: list unqualified_list_field; + + 4: EmptyStruct unqualified_struct_field; + + 5: optional i32 optional_int_field; + + 6: optional bool optional_bool_field; + + 7: optional list optional_list_field; + + 8: optional EmptyStruct optional_struct_field; +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/cmd b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/cmd new file mode 100644 index 00000000000000..ea63038e2be698 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/cmd @@ -0,0 +1,13 @@ +android: android src/module.thrift +ast: thrift2ast-ast:protocol=debug,root_program_only,use_hash,no_backcompat src/module.thrift +cpp2: mstch_cpp2 src/module.thrift +go: mstch_go src/module.thrift +hack: hack:hack_collections=1 src/module.thrift +java: mstch_java src/module.thrift +java_deprecated: java_deprecated src/module.thrift +json: json src/module.thrift +json_experimental: json_experimental src/module.thrift +py3: mstch_py3 src/module.thrift +py: py src/module.thrift +python: mstch_python src/module.thrift +rust: mstch_rust src/module.thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/android/gen-android/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/android/gen-android/EmptyStruct.java new file mode 100644 index 00000000000000..017c2be236e9aa --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/android/gen-android/EmptyStruct.java @@ -0,0 +1,114 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 EmptyStruct implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); + + + public EmptyStruct() { + } + + /** + * Performs a deep copy on other. + */ + public EmptyStruct(EmptyStruct other) { + } + + public EmptyStruct deepCopy() { + return new EmptyStruct(this); + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof EmptyStruct)) + return false; + EmptyStruct that = (EmptyStruct)_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 EmptyStruct 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(); + + EmptyStruct _that; + _that = new EmptyStruct( + ); + _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/default_values_rectification_before/out/android/gen-android/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/android/gen-android/TestStruct.java new file mode 100644 index 00000000000000..d7392b979ae5e5 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/android/gen-android/TestStruct.java @@ -0,0 +1,438 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 TestStruct implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + + public final Integer unqualified_int_field; + public final Boolean unqualified_bool_field; + public final List unqualified_list_field; + public final EmptyStruct unqualified_struct_field; + public final Integer optional_int_field; + public final Boolean optional_bool_field; + public final List optional_list_field; + public final EmptyStruct optional_struct_field; + public static final int UNQUALIFIED_INT_FIELD = 1; + public static final int UNQUALIFIED_BOOL_FIELD = 2; + public static final int UNQUALIFIED_LIST_FIELD = 3; + public static final int UNQUALIFIED_STRUCT_FIELD = 4; + public static final int OPTIONAL_INT_FIELD = 5; + public static final int OPTIONAL_BOOL_FIELD = 6; + public static final int OPTIONAL_LIST_FIELD = 7; + public static final int OPTIONAL_STRUCT_FIELD = 8; + + public TestStruct( + Integer unqualified_int_field, + Boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field, + Integer optional_int_field, + Boolean optional_bool_field, + List optional_list_field, + EmptyStruct optional_struct_field) { + this.unqualified_int_field = unqualified_int_field; + this.unqualified_bool_field = unqualified_bool_field; + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + this.optional_int_field = optional_int_field; + this.optional_bool_field = optional_bool_field; + this.optional_list_field = optional_list_field; + this.optional_struct_field = optional_struct_field; + } + + /** + * Performs a deep copy on other. + */ + public TestStruct(TestStruct other) { + if (other.isSetUnqualified_int_field()) { + this.unqualified_int_field = TBaseHelper.deepCopy(other.unqualified_int_field); + } else { + this.unqualified_int_field = null; + } + if (other.isSetUnqualified_bool_field()) { + this.unqualified_bool_field = TBaseHelper.deepCopy(other.unqualified_bool_field); + } else { + this.unqualified_bool_field = null; + } + if (other.isSetUnqualified_list_field()) { + this.unqualified_list_field = TBaseHelper.deepCopy(other.unqualified_list_field); + } else { + this.unqualified_list_field = null; + } + if (other.isSetUnqualified_struct_field()) { + this.unqualified_struct_field = TBaseHelper.deepCopy(other.unqualified_struct_field); + } else { + this.unqualified_struct_field = null; + } + if (other.isSetOptional_int_field()) { + this.optional_int_field = TBaseHelper.deepCopy(other.optional_int_field); + } else { + this.optional_int_field = null; + } + if (other.isSetOptional_bool_field()) { + this.optional_bool_field = TBaseHelper.deepCopy(other.optional_bool_field); + } else { + this.optional_bool_field = null; + } + if (other.isSetOptional_list_field()) { + this.optional_list_field = TBaseHelper.deepCopy(other.optional_list_field); + } else { + this.optional_list_field = null; + } + if (other.isSetOptional_struct_field()) { + this.optional_struct_field = TBaseHelper.deepCopy(other.optional_struct_field); + } else { + this.optional_struct_field = null; + } + } + + public TestStruct deepCopy() { + return new TestStruct(this); + } + + public Integer getUnqualified_int_field() { + return this.unqualified_int_field; + } + + // Returns true if field unqualified_int_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_int_field() { + return this.unqualified_int_field != null; + } + + public Boolean isUnqualified_bool_field() { + return this.unqualified_bool_field; + } + + // Returns true if field unqualified_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_bool_field() { + return this.unqualified_bool_field != null; + } + + public List getUnqualified_list_field() { + return this.unqualified_list_field; + } + + // Returns true if field unqualified_list_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_list_field() { + return this.unqualified_list_field != null; + } + + public EmptyStruct getUnqualified_struct_field() { + return this.unqualified_struct_field; + } + + // Returns true if field unqualified_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_struct_field() { + return this.unqualified_struct_field != null; + } + + public Integer getOptional_int_field() { + return this.optional_int_field; + } + + // Returns true if field optional_int_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_int_field() { + return this.optional_int_field != null; + } + + public Boolean isOptional_bool_field() { + return this.optional_bool_field; + } + + // Returns true if field optional_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_bool_field() { + return this.optional_bool_field != null; + } + + public List getOptional_list_field() { + return this.optional_list_field; + } + + // Returns true if field optional_list_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_list_field() { + return this.optional_list_field != null; + } + + public EmptyStruct getOptional_struct_field() { + return this.optional_struct_field; + } + + // Returns true if field optional_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_struct_field() { + return this.optional_struct_field != null; + } + + @Override + public boolean equals(Object _that) { + if (_that == null) + return false; + if (this == _that) + return true; + if (!(_that instanceof TestStruct)) + return false; + TestStruct that = (TestStruct)_that; + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_int_field(), that.isSetUnqualified_int_field(), this.unqualified_int_field, that.unqualified_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_bool_field(), that.isSetUnqualified_bool_field(), this.unqualified_bool_field, that.unqualified_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_list_field(), that.isSetUnqualified_list_field(), this.unqualified_list_field, that.unqualified_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_struct_field(), that.isSetUnqualified_struct_field(), this.unqualified_struct_field, that.unqualified_struct_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_int_field(), that.isSetOptional_int_field(), this.optional_int_field, that.optional_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_bool_field(), that.isSetOptional_bool_field(), this.optional_bool_field, that.optional_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_list_field(), that.isSetOptional_list_field(), this.optional_list_field, that.optional_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_struct_field(), that.isSetOptional_struct_field(), this.optional_struct_field, that.optional_struct_field)) { return false; } + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {unqualified_int_field, unqualified_bool_field, unqualified_list_field, unqualified_struct_field, optional_int_field, optional_bool_field, optional_list_field, optional_struct_field}); + } + + // 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 TestStruct deserialize(TProtocol iprot) throws TException { + Integer tmp_unqualified_int_field = null; + Boolean tmp_unqualified_bool_field = null; + List tmp_unqualified_list_field = null; + EmptyStruct tmp_unqualified_struct_field = null; + Integer tmp_optional_int_field = null; + Boolean tmp_optional_bool_field = null; + List tmp_optional_list_field = null; + EmptyStruct tmp_optional_struct_field = null; + TField __field; + iprot.readStructBegin(); + while (true) + { + __field = iprot.readFieldBegin(); + if (__field.type == TType.STOP) { + break; + } + switch (__field.id) + { + case UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + tmp_unqualified_int_field = iprot.readI32(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + tmp_unqualified_bool_field = iprot.readBool(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list0 = iprot.readListBegin(); + tmp_unqualified_list_field = new ArrayList(Math.max(0, _list0.size)); + for (int _i1 = 0; + (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); + ++_i1) + { + Integer _elem2; + _elem2 = iprot.readI32(); + tmp_unqualified_list_field.add(_elem2); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + tmp_unqualified_struct_field = EmptyStruct.deserialize(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + tmp_optional_int_field = iprot.readI32(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + tmp_optional_bool_field = iprot.readBool(); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list3 = iprot.readListBegin(); + tmp_optional_list_field = new ArrayList(Math.max(0, _list3.size)); + for (int _i4 = 0; + (_list3.size < 0) ? iprot.peekList() : (_i4 < _list3.size); + ++_i4) + { + Integer _elem5; + _elem5 = iprot.readI32(); + tmp_optional_list_field.add(_elem5); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + tmp_optional_struct_field = EmptyStruct.deserialize(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + default: + TProtocolUtil.skip(iprot, __field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + TestStruct _that; + _that = new TestStruct( + tmp_unqualified_int_field + ,tmp_unqualified_bool_field + ,tmp_unqualified_list_field + ,tmp_unqualified_struct_field + ,tmp_optional_int_field + ,tmp_optional_bool_field + ,tmp_optional_list_field + ,tmp_optional_struct_field + ); + _that.validate(); + return _that; + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.unqualified_int_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualified_int_field); + oprot.writeFieldEnd(); + } + if (this.unqualified_bool_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualified_bool_field); + oprot.writeFieldEnd(); + } + if (this.unqualified_list_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.unqualified_list_field.size())); + for (Integer _iter6 : this.unqualified_list_field) { + oprot.writeI32(_iter6); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (this.unqualified_struct_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualified_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + if (this.optional_int_field != null) { + if (isSetOptional_int_field()) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optional_int_field); + oprot.writeFieldEnd(); + } + } + if (this.optional_bool_field != null) { + if (isSetOptional_bool_field()) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optional_bool_field); + oprot.writeFieldEnd(); + } + } + if (this.optional_list_field != null) { + if (isSetOptional_list_field()) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.optional_list_field.size())); + for (Integer _iter7 : this.optional_list_field) { + oprot.writeI32(_iter7); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.optional_struct_field != null) { + if (isSetOptional_struct_field()) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optional_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + } + 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/default_values_rectification_before/out/ast/gen-ast/module.ast b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/ast/gen-ast/module.ast new file mode 100644 index 00000000000000..87d204e82b16ac --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/ast/gen-ast/module.ast @@ -0,0 +1,275 @@ +Schema { + 1: programs (list) = list[1] { + [0] = Program { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "module", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification", + }, + 2: id (i64) = -6351212033995931189, + 8: definitionKeys (list) = list[2] { + [0] = "-`\213\210yF\377nh\343\367\371\213\013t\333", + [1] = "\235\347[]q\314\?\262\367{\351c\003\031v\346", + }, + 5: path (string) = "thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift", + }, + }, + 3: valuesMap (map) = map[7] { + -8442774064920780172 -> Value { + 1: boolValue (bool) = true, + }, + -7354011236927394272 -> Value { + 4: i32Value (i32) = 42, + }, + -6590636961672215483 -> Value { + 11: objectValue (struct) = Object { + 1: type (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", + 2: members (map) = map[0] { + }, + }, + }, + -3251352998482926443 -> Value { + 1: boolValue (bool) = false, + }, + 2649958233193026888 -> Value { + 14: listValue (list) = list[2] { + [0] = Value { + 4: i32Value (i32) = 1, + }, + [1] = Value { + 4: i32Value (i32) = 2, + }, + }, + }, + 5223775973731705452 -> Value { + 4: i32Value (i32) = 0, + }, + 8863055147593237692 -> Value { + 14: listValue (list) = list[0] { + }, + }, + }, + 8: definitionsMap (map) = map[2] { + "-`\213\210yF\377nh\343\367\371\213\013t\333" -> Definition { + 1: structDef (struct) = Struct { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "EmptyStruct", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 19, + 3: beginColumn (i32) = 1, + 4: endLine (i32) = 19, + 5: endColumn (i32) = 22, + }, + }, + }, + }, + "\235\347[]q\314\?\262\367{\351c\003\031v\346" -> Definition { + 1: structDef (struct) = Struct { + 1: attrs (struct) = DefinitionAttrs { + 1: name (string) = "TestStruct", + 2: uri (string) = "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 21, + 3: beginColumn (i32) = 1, + 4: endLine (i32) = 37, + 5: endColumn (i32) = 2, + }, + }, + 2: fields (list) = list[8] { + [0] = Field { + 1: id (i16) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_int_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 22, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 22, + 5: endColumn (i32) = 36, + }, + }, + 5: customDefault (i64) = 5223775973731705452, + }, + [1] = Field { + 1: id (i16) = 2, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 1: boolType (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_bool_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 24, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 24, + 5: endColumn (i32) = 42, + }, + }, + 5: customDefault (i64) = -3251352998482926443, + }, + [2] = Field { + 1: id (i16) = 3, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 14: listType (i32) = 0, + }, + 2: params (list) = list[1] { + [0] = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_list_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 26, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 26, + 5: endColumn (i32) = 44, + }, + }, + 5: customDefault (i64) = 8863055147593237692, + }, + [3] = Field { + 1: id (i16) = 4, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 11: structType (struct) = TypeUri { + 4: definitionKey (string) = "-`\213\210yF\377nh\343\367\371\213\013t\333", + }, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "unqualified_struct_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 28, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 28, + 5: endColumn (i32) = 48, + }, + }, + 5: customDefault (i64) = -6590636961672215483, + }, + [4] = Field { + 1: id (i16) = 5, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_int_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 30, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 30, + 5: endColumn (i32) = 43, + }, + }, + 5: customDefault (i64) = -7354011236927394272, + }, + [5] = Field { + 1: id (i16) = 6, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 1: boolType (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_bool_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 32, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 32, + 5: endColumn (i32) = 47, + }, + }, + 5: customDefault (i64) = -8442774064920780172, + }, + [6] = Field { + 1: id (i16) = 7, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 14: listType (i32) = 0, + }, + 2: params (list) = list[1] { + [0] = TypeStruct { + 1: name (struct) = TypeName { + 4: i32Type (i32) = 0, + }, + 2: params (list) = list[0] { + }, + }, + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_list_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 34, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 34, + 5: endColumn (i32) = 54, + }, + }, + 5: customDefault (i64) = 2649958233193026888, + }, + [7] = Field { + 1: id (i16) = 8, + 2: qualifier (i32) = 1, + 3: type (struct) = TypeStruct { + 1: name (struct) = TypeName { + 11: structType (struct) = TypeUri { + 4: definitionKey (string) = "-`\213\210yF\377nh\343\367\371\213\013t\333", + }, + }, + 2: params (list) = list[0] { + }, + }, + 4: attrs (struct) = DefinitionAttrs { + 1: name (string) = "optional_struct_field", + 7: sourceRange (struct) = SourceRange { + 1: programId (i64) = -6351212033995931189, + 2: beginLine (i32) = 36, + 3: beginColumn (i32) = 3, + 4: endLine (i32) = 36, + 5: endColumn (i32) = 54, + }, + }, + 5: customDefault (i64) = -6590636961672215483, + }, + }, + }, + }, + }, +} \ No newline at end of file diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_clients.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_clients.h new file mode 100644 index 00000000000000..63856004a06e3b --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_clients.h @@ -0,0 +1,8 @@ +/** + * Autogenerated by Thrift for + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.cpp new file mode 100644 index 00000000000000..dfc6b3974d6a41 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.cpp @@ -0,0 +1,25 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_constants.h" + +#include + + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +namespace module_constants { + + +::std::string_view _fbthrift_schema_a7dbf64e247c81cb() { + return ""; +} +::folly::Range _fbthrift_schema_a7dbf64e247c81cb_includes() { + return {}; +} + +} // namespace module_constants +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.h new file mode 100644 index 00000000000000..6bca124b2f71e9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_constants.h @@ -0,0 +1,21 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift"} */ +namespace module_constants { + + FOLLY_EXPORT ::std::string_view _fbthrift_schema_a7dbf64e247c81cb(); + FOLLY_EXPORT ::folly::Range _fbthrift_schema_a7dbf64e247c81cb_includes(); + +} // namespace module_constants +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.cpp new file mode 100644 index 00000000000000..a4356a009df650 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.cpp @@ -0,0 +1,101 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_data.h" + +#include + +FOLLY_CLANG_DISABLE_WARNING("-Wunused-macros") + +#if defined(__GNUC__) && defined(__linux__) && !FOLLY_MOBILE +// These attributes are applied to the static data members to ensure that they +// are not stripped from the compiled binary, in order to keep them available +// for use by debuggers at runtime. +// +// The "used" attribute is required to ensure the compiler always emits unused +// data. +// +// The "section" attribute is required to stop the linker from stripping used +// data. It works by forcing all of the data members (both used and unused ones) +// into the same section. As the linker strips data on a per-section basis, it +// is then unable to remove unused data without also removing used data. +// This has a similar effect to the "retain" attribute, but works with older +// toolchains. +#define THRIFT_DATA_MEMBER [[gnu::used]] [[gnu::section(".rodata.thrift.data")]] +#else +#define THRIFT_DATA_MEMBER +#endif + +namespace apache { +namespace thrift { + +THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::name = "EmptyStruct"; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_names = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_ids = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::fields_types = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::storage_names = { { +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::isset_indexes = { { +}}; + +THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::name = "TestStruct"; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_names = { { + "unqualified_int_field"sv, + "unqualified_bool_field"sv, + "unqualified_list_field"sv, + "unqualified_struct_field"sv, + "optional_int_field"sv, + "optional_bool_field"sv, + "optional_list_field"sv, + "optional_struct_field"sv, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_ids = { { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::fields_types = { { + TType::T_I32, + TType::T_BOOL, + TType::T_LIST, + TType::T_STRUCT, + TType::T_I32, + TType::T_BOOL, + TType::T_LIST, + TType::T_STRUCT, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::storage_names = { { + "__fbthrift_field_unqualified_int_field"sv, + "__fbthrift_field_unqualified_bool_field"sv, + "__fbthrift_field_unqualified_list_field"sv, + "__fbthrift_field_unqualified_struct_field"sv, + "__fbthrift_field_optional_int_field"sv, + "__fbthrift_field_optional_bool_field"sv, + "__fbthrift_field_optional_list_field"sv, + "__fbthrift_field_optional_struct_field"sv, +}}; +THRIFT_DATA_MEMBER const std::array TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::isset_indexes = { { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, +}}; + +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.h new file mode 100644 index 00000000000000..fcc80ce2c4fce2 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_data.h @@ -0,0 +1,47 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" + +namespace apache { namespace thrift { + +template <> struct TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + static constexpr const std::size_t fields_size = 0; + static const std::string_view name; + static const std::array fields_names; + static const std::array fields_ids; + static const std::array fields_types; + + private: + // The following fields describe internal storage metadata, and are private to + // prevent user logic from accessing them, but they can be inspected by + // debuggers. + static const std::array storage_names; + // -1 if the field has no isset. + static const std::array isset_indexes; +}; + +template <> struct TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + static constexpr const std::size_t fields_size = 8; + static const std::string_view name; + static const std::array fields_names; + static const std::array fields_ids; + static const std::array fields_types; + + private: + // The following fields describe internal storage metadata, and are private to + // prevent user logic from accessing them, but they can be inspected by + // debuggers. + static const std::array storage_names; + // -1 if the field has no isset. + static const std::array isset_indexes; +}; + +}} // apache::thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_for_each_field.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_for_each_field.h new file mode 100644 index 00000000000000..7b9cd990294c09 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_for_each_field.h @@ -0,0 +1,39 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" +#include + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct ForEachField<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + template + void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const { + } +}; + +template <> +struct ForEachField<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + template + void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const { + f(0, static_cast(t).unqualified_int_field_ref()...); + f(1, static_cast(t).unqualified_bool_field_ref()...); + f(2, static_cast(t).unqualified_list_field_ref()...); + f(3, static_cast(t).unqualified_struct_field_ref()...); + f(4, static_cast(t).optional_int_field_ref()...); + f(5, static_cast(t).optional_bool_field_ref()...); + f(6, static_cast(t).optional_list_field_ref()...); + f(7, static_cast(t).optional_struct_field_ref()...); + } +}; +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_handlers.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_handlers.h new file mode 100644 index 00000000000000..63856004a06e3b --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_handlers.h @@ -0,0 +1,8 @@ +/** + * Autogenerated by Thrift for + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.cpp new file mode 100644 index 00000000000000..28ea2630b7dfc5 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.cpp @@ -0,0 +1,67 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" + +// some of these functions can be so large that the compiler gives up optimizing +// them - and issues a warning which may be treated as an error! +// +// these functions are so rarely called that it is probably okay for them not to +// be optimized in practice +FOLLY_CLANG_DISABLE_WARNING("-Wignored-optimization-argument") + +namespace apache { +namespace thrift { +namespace detail { +namespace md { +using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata; +using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType; +using ThriftType = ::apache::thrift::metadata::ThriftType; +using ThriftService = ::apache::thrift::metadata::ThriftService; +using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext; +using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&); + + +const ::apache::thrift::metadata::ThriftStruct& +StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::gen(ThriftMetadata& metadata) { + auto res = metadata.structs()->emplace("module.EmptyStruct", ::apache::thrift::metadata::ThriftStruct{}); + if (!res.second) { + return res.first->second; + } + ::apache::thrift::metadata::ThriftStruct& module_EmptyStruct = res.first->second; + module_EmptyStruct.name() = "module.EmptyStruct"; + module_EmptyStruct.is_union() = false; + return res.first->second; +} +const ::apache::thrift::metadata::ThriftStruct& +StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::gen(ThriftMetadata& metadata) { + auto res = metadata.structs()->emplace("module.TestStruct", ::apache::thrift::metadata::ThriftStruct{}); + if (!res.second) { + return res.first->second; + } + ::apache::thrift::metadata::ThriftStruct& module_TestStruct = res.first->second; + module_TestStruct.name() = "module.TestStruct"; + module_TestStruct.is_union() = false; + static const auto* const + module_TestStruct_fields = new std::array{ { + { 1, "unqualified_int_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 2, "unqualified_bool_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 3, "unqualified_list_field", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 4, "unqualified_struct_field", false, std::make_unique>("module.EmptyStruct"), std::vector{ }}, { 5, "optional_int_field", true, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 6, "optional_bool_field", true, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, { 7, "optional_list_field", true, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector{ }}, { 8, "optional_struct_field", true, std::make_unique>("module.EmptyStruct"), std::vector{ }}, }}; + for (const auto& f : *module_TestStruct_fields) { + ::apache::thrift::metadata::ThriftField field; + field.id() = f.id; + field.name() = f.name; + field.is_optional() = f.is_optional; + f.metadata_type_interface->writeAndGenType(*field.type(), metadata); + field.structured_annotations() = f.structured_annotations; + module_TestStruct.fields()->push_back(std::move(field)); + } + return res.first->second; +} + +} // namespace md +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.h new file mode 100644 index 00000000000000..15f2829f02709f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_metadata.h @@ -0,0 +1,33 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" + + +namespace apache { +namespace thrift { +namespace detail { +namespace md { + +template <> +class StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + public: + static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata); +}; +template <> +class StructMetadata<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + public: + static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata); +}; +} // namespace md +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.cpp new file mode 100644 index 00000000000000..ea250678d02051 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.cpp @@ -0,0 +1,331 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.tcc" + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_data.h" +[[maybe_unused]] static constexpr std::string_view kModuleName = "module"; + + +namespace apache { +namespace thrift { +namespace detail { + +void TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept { + using data = apache::thrift::TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>; + static const st::translate_field_name_table table{ + data::fields_size, + data::fields_names.data(), + data::fields_ids.data(), + data::fields_types.data()}; + st::translate_field_name(_fname, fid, _ftype, table); +} + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +const char* EmptyStruct::__fbthrift_thrift_uri() { + return "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct"; +} + +std::string_view EmptyStruct::__fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord) { + if (ord == ::apache::thrift::FieldOrdinal{0}) { return {}; } + return apache::thrift::TStructDataStorage::fields_names[folly::to_underlying(ord) - 1]; +} +std::string_view EmptyStruct::__fbthrift_get_class_name() { + return apache::thrift::TStructDataStorage::name; +} + + +EmptyStruct::EmptyStruct(apache::thrift::FragileConstructor) {} + + +void EmptyStruct::__fbthrift_clear() { + // clear all fields +} + +void EmptyStruct::__fbthrift_clear_terse_fields() { +} + +bool EmptyStruct::__fbthrift_is_empty() const { + return true; +} + +bool EmptyStruct::operator==([[maybe_unused]] const EmptyStruct& rhs) const { + return ::apache::thrift::op::detail::StructEquality{}(*this, rhs); +} + +bool EmptyStruct::operator<([[maybe_unused]] const EmptyStruct& rhs) const { + return ::apache::thrift::op::detail::StructLessThan{}(*this, rhs); +} + + +void swap([[maybe_unused]] EmptyStruct& a, [[maybe_unused]] EmptyStruct& b) { + using ::std::swap; +} + +template void EmptyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +template uint32_t EmptyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +template uint32_t EmptyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +template void EmptyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +template uint32_t EmptyStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +template uint32_t EmptyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification + +namespace apache { +namespace thrift { +namespace detail { + +void TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept { + using data = apache::thrift::TStructDataStorage<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>; + static const st::translate_field_name_table table{ + data::fields_size, + data::fields_names.data(), + data::fields_ids.data(), + data::fields_types.data()}; + st::translate_field_name(_fname, fid, _ftype, table); +} + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +const char* TestStruct::__fbthrift_thrift_uri() { + return "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct"; +} + +std::string_view TestStruct::__fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord) { + if (ord == ::apache::thrift::FieldOrdinal{0}) { return {}; } + return apache::thrift::TStructDataStorage::fields_names[folly::to_underlying(ord) - 1]; +} +std::string_view TestStruct::__fbthrift_get_class_name() { + return apache::thrift::TStructDataStorage::name; +} + +TestStruct::TestStruct(const TestStruct&) = default; +TestStruct& TestStruct::operator=(const TestStruct&) = default; +TestStruct::TestStruct() : + __fbthrift_field_unqualified_int_field(static_cast<::std::int32_t>(0)), + __fbthrift_field_unqualified_bool_field(false), + __fbthrift_field_optional_int_field(static_cast<::std::int32_t>(42)), + __fbthrift_field_optional_bool_field(true), + __fbthrift_field_optional_list_field(std::initializer_list<::std::int32_t>{ static_cast<::std::int32_t>(1), + static_cast<::std::int32_t>(2) }) { +} + + +TestStruct::~TestStruct() {} + +TestStruct::TestStruct([[maybe_unused]] TestStruct&& other) noexcept : + __fbthrift_field_unqualified_int_field(std::move(other.__fbthrift_field_unqualified_int_field)), + __fbthrift_field_unqualified_bool_field(std::move(other.__fbthrift_field_unqualified_bool_field)), + __fbthrift_field_unqualified_list_field(std::move(other.__fbthrift_field_unqualified_list_field)), + __fbthrift_field_unqualified_struct_field(std::move(other.__fbthrift_field_unqualified_struct_field)), + __fbthrift_field_optional_int_field(std::move(other.__fbthrift_field_optional_int_field)), + __fbthrift_field_optional_bool_field(std::move(other.__fbthrift_field_optional_bool_field)), + __fbthrift_field_optional_list_field(std::move(other.__fbthrift_field_optional_list_field)), + __fbthrift_field_optional_struct_field(std::move(other.__fbthrift_field_optional_struct_field)), + __isset(other.__isset) { +} + +TestStruct& TestStruct::operator=([[maybe_unused]] TestStruct&& other) noexcept { + this->__fbthrift_field_unqualified_int_field = std::move(other.__fbthrift_field_unqualified_int_field); + this->__fbthrift_field_unqualified_bool_field = std::move(other.__fbthrift_field_unqualified_bool_field); + this->__fbthrift_field_unqualified_list_field = std::move(other.__fbthrift_field_unqualified_list_field); + this->__fbthrift_field_unqualified_struct_field = std::move(other.__fbthrift_field_unqualified_struct_field); + this->__fbthrift_field_optional_int_field = std::move(other.__fbthrift_field_optional_int_field); + this->__fbthrift_field_optional_bool_field = std::move(other.__fbthrift_field_optional_bool_field); + this->__fbthrift_field_optional_list_field = std::move(other.__fbthrift_field_optional_list_field); + this->__fbthrift_field_optional_struct_field = std::move(other.__fbthrift_field_optional_struct_field); + __isset = other.__isset; + return *this; +} + + +TestStruct::TestStruct(apache::thrift::FragileConstructor, ::std::int32_t unqualified_int_field__arg, bool unqualified_bool_field__arg, ::std::vector<::std::int32_t> unqualified_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct unqualified_struct_field__arg, ::std::int32_t optional_int_field__arg, bool optional_bool_field__arg, ::std::vector<::std::int32_t> optional_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct optional_struct_field__arg) : + __fbthrift_field_unqualified_int_field(std::move(unqualified_int_field__arg)), + __fbthrift_field_unqualified_bool_field(std::move(unqualified_bool_field__arg)), + __fbthrift_field_unqualified_list_field(std::move(unqualified_list_field__arg)), + __fbthrift_field_unqualified_struct_field(std::move(unqualified_struct_field__arg)), + __fbthrift_field_optional_int_field(std::move(optional_int_field__arg)), + __fbthrift_field_optional_bool_field(std::move(optional_bool_field__arg)), + __fbthrift_field_optional_list_field(std::move(optional_list_field__arg)), + __fbthrift_field_optional_struct_field(std::move(optional_struct_field__arg)) { + __isset.set(folly::index_constant<0>(), true); + __isset.set(folly::index_constant<1>(), true); + __isset.set(folly::index_constant<2>(), true); + __isset.set(folly::index_constant<3>(), true); + __isset.set(folly::index_constant<4>(), true); + __isset.set(folly::index_constant<5>(), true); + __isset.set(folly::index_constant<6>(), true); + __isset.set(folly::index_constant<7>(), true); +} + + +void TestStruct::__fbthrift_clear() { + // clear all fields + this->__fbthrift_field_unqualified_int_field = ::std::int32_t(); + this->__fbthrift_field_unqualified_bool_field = bool(); + this->__fbthrift_field_unqualified_list_field.clear(); + this->__fbthrift_field_optional_int_field = ::std::int32_t(); + this->__fbthrift_field_optional_bool_field = bool(); + this->__fbthrift_field_optional_list_field.clear(); + __isset = {}; +} + +void TestStruct::__fbthrift_clear_terse_fields() { +} + +bool TestStruct::__fbthrift_is_empty() const { + return false; +} + +bool TestStruct::operator==([[maybe_unused]] const TestStruct& rhs) const { + return ::apache::thrift::op::detail::StructEquality{}(*this, rhs); +} + +bool TestStruct::operator<([[maybe_unused]] const TestStruct& rhs) const { + return ::apache::thrift::op::detail::StructLessThan{}(*this, rhs); +} + + +::std::int32_t TestStruct::get_unqualified_int_field() const { + return __fbthrift_field_unqualified_int_field; +} + +::std::int32_t& TestStruct::set_unqualified_int_field(::std::int32_t unqualified_int_field_) { + unqualified_int_field_ref() = unqualified_int_field_; + return __fbthrift_field_unqualified_int_field; +} + +bool TestStruct::get_unqualified_bool_field() const { + return __fbthrift_field_unqualified_bool_field; +} + +bool& TestStruct::set_unqualified_bool_field(bool unqualified_bool_field_) { + unqualified_bool_field_ref() = unqualified_bool_field_; + return __fbthrift_field_unqualified_bool_field; +} + +const ::std::vector<::std::int32_t>& TestStruct::get_unqualified_list_field() const& { + return __fbthrift_field_unqualified_list_field; +} + +::std::vector<::std::int32_t> TestStruct::get_unqualified_list_field() && { + return static_cast<::std::vector<::std::int32_t>&&>(__fbthrift_field_unqualified_list_field); +} + +const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& TestStruct::get_unqualified_struct_field() const& { + return __fbthrift_field_unqualified_struct_field; +} + +::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct TestStruct::get_unqualified_struct_field() && { + return static_cast<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct&&>(__fbthrift_field_unqualified_struct_field); +} + +const ::std::int32_t* TestStruct::get_optional_int_field() const& { + return optional_int_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_int_field) : nullptr; +} + +::std::int32_t* TestStruct::get_optional_int_field() & { + return optional_int_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_int_field) : nullptr; +} + +::std::int32_t& TestStruct::set_optional_int_field(::std::int32_t optional_int_field_) { + optional_int_field_ref() = optional_int_field_; + return __fbthrift_field_optional_int_field; +} + +const bool* TestStruct::get_optional_bool_field() const& { + return optional_bool_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_bool_field) : nullptr; +} + +bool* TestStruct::get_optional_bool_field() & { + return optional_bool_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_bool_field) : nullptr; +} + +bool& TestStruct::set_optional_bool_field(bool optional_bool_field_) { + optional_bool_field_ref() = optional_bool_field_; + return __fbthrift_field_optional_bool_field; +} + +const ::std::vector<::std::int32_t>* TestStruct::get_optional_list_field() const& { + return optional_list_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_list_field) : nullptr; +} + +::std::vector<::std::int32_t>* TestStruct::get_optional_list_field() & { + return optional_list_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_list_field) : nullptr; +} + +const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* TestStruct::get_optional_struct_field() const& { + return optional_struct_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_struct_field) : nullptr; +} + +::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* TestStruct::get_optional_struct_field() & { + return optional_struct_field_ref().has_value() ? std::addressof(__fbthrift_field_optional_struct_field) : nullptr; +} + +void swap([[maybe_unused]] TestStruct& a, [[maybe_unused]] TestStruct& b) { + using ::std::swap; + swap(a.__fbthrift_field_unqualified_int_field, b.__fbthrift_field_unqualified_int_field); + swap(a.__fbthrift_field_unqualified_bool_field, b.__fbthrift_field_unqualified_bool_field); + swap(a.__fbthrift_field_unqualified_list_field, b.__fbthrift_field_unqualified_list_field); + swap(a.__fbthrift_field_unqualified_struct_field, b.__fbthrift_field_unqualified_struct_field); + swap(a.__fbthrift_field_optional_int_field, b.__fbthrift_field_optional_int_field); + swap(a.__fbthrift_field_optional_bool_field, b.__fbthrift_field_optional_bool_field); + swap(a.__fbthrift_field_optional_list_field, b.__fbthrift_field_optional_list_field); + swap(a.__fbthrift_field_optional_struct_field, b.__fbthrift_field_optional_struct_field); + swap(a.__isset, b.__isset); +} + +template void TestStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +template uint32_t TestStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +template uint32_t TestStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +template void TestStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +template uint32_t TestStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +template uint32_t TestStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + +static_assert( + ::apache::thrift::detail::st::gen_check_json< + TestStruct, + ::apache::thrift::type_class::structure, + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + "inconsistent use of json option"); +static_assert( + ::apache::thrift::detail::st::gen_check_json< + TestStruct, + ::apache::thrift::type_class::structure, + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + "inconsistent use of json option"); + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { namespace { +[[maybe_unused]] FOLLY_ERASE void validateAdapters() { +} +}} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +namespace apache::thrift::detail::annotation { +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.h new file mode 100644 index 00000000000000..8cfe029f1f2a3d --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.h @@ -0,0 +1,818 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include + + + +namespace apache { +namespace thrift { +namespace ident { +struct unqualified_int_field; +struct unqualified_bool_field; +struct unqualified_list_field; +struct unqualified_struct_field; +struct optional_int_field; +struct optional_bool_field; +struct optional_list_field; +struct optional_struct_field; +} // namespace ident +namespace detail { +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_int_field +#define APACHE_THRIFT_ACCESSOR_unqualified_int_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_int_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_bool_field +#define APACHE_THRIFT_ACCESSOR_unqualified_bool_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_bool_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_list_field +#define APACHE_THRIFT_ACCESSOR_unqualified_list_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_list_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_unqualified_struct_field +#define APACHE_THRIFT_ACCESSOR_unqualified_struct_field +APACHE_THRIFT_DEFINE_ACCESSOR(unqualified_struct_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_int_field +#define APACHE_THRIFT_ACCESSOR_optional_int_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_int_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_bool_field +#define APACHE_THRIFT_ACCESSOR_optional_bool_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_bool_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_list_field +#define APACHE_THRIFT_ACCESSOR_optional_list_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_list_field); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_optional_struct_field +#define APACHE_THRIFT_ACCESSOR_optional_struct_field +APACHE_THRIFT_DEFINE_ACCESSOR(optional_struct_field); +#endif +} // namespace detail +} // namespace thrift +} // namespace apache + +// BEGIN declare_enums + +// END declare_enums +// BEGIN forward_declare +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +class EmptyStruct; +class TestStruct; +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +// END forward_declare +namespace apache::thrift::detail::annotation { +} // namespace apache::thrift::detail::annotation + +namespace apache::thrift::detail::qualifier { +} // namespace apache::thrift::detail::qualifier + +// BEGIN hash_and_equal_to +// END hash_and_equal_to +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +using ::apache::thrift::detail::operator!=; +using ::apache::thrift::detail::operator>; +using ::apache::thrift::detail::operator<=; +using ::apache::thrift::detail::operator>=; + + +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift", "name": "EmptyStruct", "kind": "struct" } */ +class EmptyStruct final { + private: + friend struct ::apache::thrift::detail::st::struct_private_access; + template friend struct ::apache::thrift::detail::invoke_reffer; + + // used by a static_assert in the corresponding source + static constexpr bool __fbthrift_cpp2_gen_json = false; + static constexpr bool __fbthrift_cpp2_is_runtime_annotation = false; + static const char* __fbthrift_thrift_uri(); + static std::string_view __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord); + static std::string_view __fbthrift_get_class_name(); + template + FOLLY_ERASE static constexpr std::string_view __fbthrift_get_module_name() noexcept { + return "module"; + } + using __fbthrift_reflection_ident_list = folly::tag_t< + >; + + static constexpr std::int16_t __fbthrift_reflection_field_id_list[] = {0}; + using __fbthrift_reflection_type_tags = folly::tag_t< + >; + + static constexpr std::size_t __fbthrift_field_size_v = 0; + + template + using __fbthrift_id = ::apache::thrift::type::field_id<__fbthrift_reflection_field_id_list[folly::to_underlying(T::value)]>; + + template + using __fbthrift_type_tag = ::apache::thrift::detail::at<__fbthrift_reflection_type_tags, T::value>; + + template + using __fbthrift_ident = ::apache::thrift::detail::at<__fbthrift_reflection_ident_list, T::value>; + + template using __fbthrift_ordinal = ::apache::thrift::type::ordinal_tag< + ::apache::thrift::detail::getFieldOrdinal( + __fbthrift_reflection_field_id_list + ) + >; + void __fbthrift_clear(); + void __fbthrift_clear_terse_fields(); + bool __fbthrift_is_empty() const; + + public: + using __fbthrift_cpp2_type = EmptyStruct; + static constexpr bool __fbthrift_cpp2_is_union = + false; + static constexpr bool __fbthrift_cpp2_uses_op_encode = + false; + + + public: + + EmptyStruct() { + } + // FragileConstructor for use in initialization lists only. + [[deprecated("This constructor is deprecated")]] + EmptyStruct(apache::thrift::FragileConstructor); + + EmptyStruct(EmptyStruct&&) = default; + + EmptyStruct(const EmptyStruct&) = default; + + + EmptyStruct& operator=(EmptyStruct&&) = default; + + EmptyStruct& operator=(const EmptyStruct&) = default; + + public: + + bool operator==(const EmptyStruct&) const; + bool operator<(const EmptyStruct&) const; + + template + unsigned long read(Protocol_* iprot); + template + uint32_t serializedSize(Protocol_ const* prot_) const; + template + uint32_t serializedSizeZC(Protocol_ const* prot_) const; + template + uint32_t write(Protocol_* prot_) const; + + private: + template + void readNoXfer(Protocol_* iprot); + + friend class ::apache::thrift::Cpp2Ops; + friend void swap(EmptyStruct& a, EmptyStruct& b); +}; + +template +unsigned long EmptyStruct::read(Protocol_* iprot) { + auto _xferStart = iprot->getCursorPosition(); + readNoXfer(iprot); + return iprot->getCursorPosition() - _xferStart; +} + + +/** Glean {"file": "thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift", "name": "TestStruct", "kind": "struct" } */ +class TestStruct final { + private: + friend struct ::apache::thrift::detail::st::struct_private_access; + template friend struct ::apache::thrift::detail::invoke_reffer; + + // used by a static_assert in the corresponding source + static constexpr bool __fbthrift_cpp2_gen_json = false; + static constexpr bool __fbthrift_cpp2_is_runtime_annotation = false; + static const char* __fbthrift_thrift_uri(); + static std::string_view __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord); + static std::string_view __fbthrift_get_class_name(); + template + FOLLY_ERASE static constexpr std::string_view __fbthrift_get_module_name() noexcept { + return "module"; + } + using __fbthrift_reflection_ident_list = folly::tag_t< + ::apache::thrift::ident::unqualified_int_field, + ::apache::thrift::ident::unqualified_bool_field, + ::apache::thrift::ident::unqualified_list_field, + ::apache::thrift::ident::unqualified_struct_field, + ::apache::thrift::ident::optional_int_field, + ::apache::thrift::ident::optional_bool_field, + ::apache::thrift::ident::optional_list_field, + ::apache::thrift::ident::optional_struct_field + >; + + static constexpr std::int16_t __fbthrift_reflection_field_id_list[] = {0,1,2,3,4,5,6,7,8}; + using __fbthrift_reflection_type_tags = folly::tag_t< + ::apache::thrift::type::i32_t, + ::apache::thrift::type::bool_t, + ::apache::thrift::type::list<::apache::thrift::type::i32_t>, + ::apache::thrift::type::struct_t<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>, + ::apache::thrift::type::i32_t, + ::apache::thrift::type::bool_t, + ::apache::thrift::type::list<::apache::thrift::type::i32_t>, + ::apache::thrift::type::struct_t<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> + >; + + static constexpr std::size_t __fbthrift_field_size_v = 8; + + template + using __fbthrift_id = ::apache::thrift::type::field_id<__fbthrift_reflection_field_id_list[folly::to_underlying(T::value)]>; + + template + using __fbthrift_type_tag = ::apache::thrift::detail::at<__fbthrift_reflection_type_tags, T::value>; + + template + using __fbthrift_ident = ::apache::thrift::detail::at<__fbthrift_reflection_ident_list, T::value>; + + template using __fbthrift_ordinal = ::apache::thrift::type::ordinal_tag< + ::apache::thrift::detail::getFieldOrdinal( + __fbthrift_reflection_field_id_list + ) + >; + void __fbthrift_clear(); + void __fbthrift_clear_terse_fields(); + bool __fbthrift_is_empty() const; + + public: + using __fbthrift_cpp2_type = TestStruct; + static constexpr bool __fbthrift_cpp2_is_union = + false; + static constexpr bool __fbthrift_cpp2_uses_op_encode = + false; + + + public: + + TestStruct(); + + // FragileConstructor for use in initialization lists only. + [[deprecated("This constructor is deprecated")]] + TestStruct(apache::thrift::FragileConstructor, ::std::int32_t unqualified_int_field__arg, bool unqualified_bool_field__arg, ::std::vector<::std::int32_t> unqualified_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct unqualified_struct_field__arg, ::std::int32_t optional_int_field__arg, bool optional_bool_field__arg, ::std::vector<::std::int32_t> optional_list_field__arg, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct optional_struct_field__arg); + + TestStruct(TestStruct&&) noexcept; + + TestStruct(const TestStruct& src); + + + TestStruct& operator=(TestStruct&&) noexcept; + TestStruct& operator=(const TestStruct& src); + + ~TestStruct(); + + private: + ::std::int32_t __fbthrift_field_unqualified_int_field; + private: + bool __fbthrift_field_unqualified_bool_field; + private: + ::std::vector<::std::int32_t> __fbthrift_field_unqualified_list_field; + private: + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct __fbthrift_field_unqualified_struct_field; + private: + ::std::int32_t __fbthrift_field_optional_int_field; + private: + bool __fbthrift_field_optional_bool_field; + private: + ::std::vector<::std::int32_t> __fbthrift_field_optional_list_field; + private: + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct __fbthrift_field_optional_struct_field; + private: + apache::thrift::detail::isset_bitset<8, apache::thrift::detail::IssetBitsetOption::Unpacked> __isset; + + public: + + bool operator==(const TestStruct&) const; + bool operator<(const TestStruct&) const; + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() const& { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() & { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() const& { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() & { + return {this->__fbthrift_field_unqualified_int_field, __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_int_field() && { + return {static_cast(this->__fbthrift_field_unqualified_int_field), __isset.at(0), __isset.bit(0)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() const& { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() & { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() const& { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() & { + return {this->__fbthrift_field_unqualified_bool_field, __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_bool_field() && { + return {static_cast(this->__fbthrift_field_unqualified_bool_field), __isset.at(1), __isset.bit(1)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() const& { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() & { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() const& { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() & { + return {this->__fbthrift_field_unqualified_list_field, __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::field_ref unqualified_list_field() && { + return {static_cast(this->__fbthrift_field_unqualified_list_field), __isset.at(2), __isset.bit(2)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() const& { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() const&& { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() & { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field_ref() && { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() const& { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() const&& { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() & { + return {this->__fbthrift_field_unqualified_struct_field, __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "unqualified_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::field_ref unqualified_struct_field() && { + return {static_cast(this->__fbthrift_field_unqualified_struct_field), __isset.at(3), __isset.bit(3)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() const& { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() & { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() const& { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() const&& { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() & { + return {this->__fbthrift_field_optional_int_field, __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_int_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_int_field() && { + return {static_cast(this->__fbthrift_field_optional_int_field), __isset.at(4), __isset.bit(4)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() const& { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() & { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() const& { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() const&& { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() & { + return {this->__fbthrift_field_optional_bool_field, __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_bool_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_bool_field() && { + return {static_cast(this->__fbthrift_field_optional_bool_field), __isset.at(5), __isset.bit(5)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() const& { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() & { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() const& { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() const&& { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() & { + return {this->__fbthrift_field_optional_list_field, __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_list_field" } */ + template > + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_list_field() && { + return {static_cast(this->__fbthrift_field_optional_list_field), __isset.at(6), __isset.bit(6)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() const& { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() const&& { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() & { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field_ref() && { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() const& { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() const&& { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() & { + return {this->__fbthrift_field_optional_struct_field, __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "optional_struct_field" } */ + template + FOLLY_ERASE ::apache::thrift::optional_field_ref optional_struct_field() && { + return {static_cast(this->__fbthrift_field_optional_struct_field), __isset.at(7), __isset.bit(7)}; + } + + /** Glean { "field": "unqualified_int_field" } */ + [[deprecated("Use `FOO.unqualified_int_field().value();` instead of `FOO.get_unqualified_int_field();`")]] + ::std::int32_t get_unqualified_int_field() const; + + /** Glean { "field": "unqualified_int_field" } */ + [[deprecated("Use `FOO.unqualified_int_field() = BAR;` instead of `FOO.set_unqualified_int_field(BAR);`")]] + ::std::int32_t& set_unqualified_int_field(::std::int32_t unqualified_int_field_); + + /** Glean { "field": "unqualified_bool_field" } */ + [[deprecated("Use `FOO.unqualified_bool_field().value();` instead of `FOO.get_unqualified_bool_field();`")]] + bool get_unqualified_bool_field() const; + + /** Glean { "field": "unqualified_bool_field" } */ + [[deprecated("Use `FOO.unqualified_bool_field() = BAR;` instead of `FOO.set_unqualified_bool_field(BAR);`")]] + bool& set_unqualified_bool_field(bool unqualified_bool_field_); + + /** Glean { "field": "unqualified_list_field" } */ + [[deprecated("Use `FOO.unqualified_list_field().value();` instead of `FOO.get_unqualified_list_field();`")]] + const ::std::vector<::std::int32_t>& get_unqualified_list_field() const&; + + /** Glean { "field": "unqualified_list_field" } */ + [[deprecated("Use `FOO.unqualified_list_field().value();` instead of `FOO.get_unqualified_list_field();`")]] + ::std::vector<::std::int32_t> get_unqualified_list_field() &&; + + /** Glean { "field": "unqualified_list_field" } */ + template > + [[deprecated("Use `FOO.unqualified_list_field() = BAR;` instead of `FOO.set_unqualified_list_field(BAR);`")]] + ::std::vector<::std::int32_t>& set_unqualified_list_field(T_TestStruct_unqualified_list_field_struct_setter&& unqualified_list_field_) { + unqualified_list_field_ref() = std::forward(unqualified_list_field_); + return __fbthrift_field_unqualified_list_field; + } + + /** Glean { "field": "unqualified_struct_field" } */ + [[deprecated("Use `FOO.unqualified_struct_field().value();` instead of `FOO.get_unqualified_struct_field();`")]] + const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& get_unqualified_struct_field() const&; + + /** Glean { "field": "unqualified_struct_field" } */ + [[deprecated("Use `FOO.unqualified_struct_field().value();` instead of `FOO.get_unqualified_struct_field();`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct get_unqualified_struct_field() &&; + + /** Glean { "field": "unqualified_struct_field" } */ + template + [[deprecated("Use `FOO.unqualified_struct_field() = BAR;` instead of `FOO.set_unqualified_struct_field(BAR);`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& set_unqualified_struct_field(T_TestStruct_unqualified_struct_field_struct_setter&& unqualified_struct_field_) { + unqualified_struct_field_ref() = std::forward(unqualified_struct_field_); + return __fbthrift_field_unqualified_struct_field; + } + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field().value();` instead of `FOO.get_optional_int_field();`")]] + const ::std::int32_t* get_optional_int_field() const&; + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field().value();` instead of `FOO.get_optional_int_field();`")]] + ::std::int32_t* get_optional_int_field() &; + + ::std::int32_t* get_optional_int_field() && = delete; + + /** Glean { "field": "optional_int_field" } */ + [[deprecated("Use `FOO.optional_int_field() = BAR;` instead of `FOO.set_optional_int_field(BAR);`")]] + ::std::int32_t& set_optional_int_field(::std::int32_t optional_int_field_); + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field().value();` instead of `FOO.get_optional_bool_field();`")]] + const bool* get_optional_bool_field() const&; + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field().value();` instead of `FOO.get_optional_bool_field();`")]] + bool* get_optional_bool_field() &; + + bool* get_optional_bool_field() && = delete; + + /** Glean { "field": "optional_bool_field" } */ + [[deprecated("Use `FOO.optional_bool_field() = BAR;` instead of `FOO.set_optional_bool_field(BAR);`")]] + bool& set_optional_bool_field(bool optional_bool_field_); + + /** Glean { "field": "optional_list_field" } */ + [[deprecated("Use `FOO.optional_list_field().value();` instead of `FOO.get_optional_list_field();`")]] + const ::std::vector<::std::int32_t>* get_optional_list_field() const&; + + /** Glean { "field": "optional_list_field" } */ + [[deprecated("Use `FOO.optional_list_field().value();` instead of `FOO.get_optional_list_field();`")]] + ::std::vector<::std::int32_t>* get_optional_list_field() &; + + ::std::vector<::std::int32_t>* get_optional_list_field() && = delete; + + /** Glean { "field": "optional_list_field" } */ + template > + [[deprecated("Use `FOO.optional_list_field() = BAR;` instead of `FOO.set_optional_list_field(BAR);`")]] + ::std::vector<::std::int32_t>& set_optional_list_field(T_TestStruct_optional_list_field_struct_setter&& optional_list_field_) { + optional_list_field_ref() = std::forward(optional_list_field_); + return __fbthrift_field_optional_list_field; + } + + /** Glean { "field": "optional_struct_field" } */ + [[deprecated("Use `FOO.optional_struct_field().value();` instead of `FOO.get_optional_struct_field();`")]] + const ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() const&; + + /** Glean { "field": "optional_struct_field" } */ + [[deprecated("Use `FOO.optional_struct_field().value();` instead of `FOO.get_optional_struct_field();`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() &; + + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct* get_optional_struct_field() && = delete; + + /** Glean { "field": "optional_struct_field" } */ + template + [[deprecated("Use `FOO.optional_struct_field() = BAR;` instead of `FOO.set_optional_struct_field(BAR);`")]] + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& set_optional_struct_field(T_TestStruct_optional_struct_field_struct_setter&& optional_struct_field_) { + optional_struct_field_ref() = std::forward(optional_struct_field_); + return __fbthrift_field_optional_struct_field; + } + + template + unsigned long read(Protocol_* iprot); + template + uint32_t serializedSize(Protocol_ const* prot_) const; + template + uint32_t serializedSizeZC(Protocol_ const* prot_) const; + template + uint32_t write(Protocol_* prot_) const; + + private: + template + void readNoXfer(Protocol_* iprot); + + friend class ::apache::thrift::Cpp2Ops; + friend void swap(TestStruct& a, TestStruct& b); +}; + +template +unsigned long TestStruct::read(Protocol_* iprot) { + auto _xferStart = iprot->getCursorPosition(); + readNoXfer(iprot); + return iprot->getCursorPosition() - _xferStart; +} + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.tcc b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.tcc new file mode 100644 index 00000000000000..56fe81a1a1e6eb --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types.tcc @@ -0,0 +1,509 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" + +#include + + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + static void translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept; +}; +template <> +struct TccStructTraits<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + static void translateFieldName( + std::string_view _fname, + int16_t& fid, + apache::thrift::protocol::TType& _ftype) noexcept; +}; + +} // namespace detail +} // namespace thrift +} // namespace apache + +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { + +template +void EmptyStruct::readNoXfer(Protocol_* iprot) { + __fbthrift_clear_terse_fields(); + + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(iprot); + + using apache::thrift::TProtocolException; + + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 0, + 0, + apache::thrift::protocol::T_STOP))) { + goto _loop; + } + +_end: + _readState.readStructEnd(iprot); + + return; + + goto _advance_failure; // Avoid compiler warnings about unused labels. + _advance_failure: + _readState.afterAdvanceFailure(iprot); +_loop: + if (_readState.atStop()) { + goto _end; + } + if (iprot->kUsesFieldNames()) { + _readState.template fillFieldTraitsFromName>(); + } + + switch (_readState.fieldId) { + default: + { + _readState.skip(iprot); + _readState.readFieldEnd(iprot); + _readState.readFieldBeginNoInline(iprot); + goto _loop; + } + } +} + +template +uint32_t EmptyStruct::serializedSize(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("EmptyStruct"); + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t EmptyStruct::serializedSizeZC(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("EmptyStruct"); + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t EmptyStruct::write(Protocol_* prot_) const { + uint32_t xfer = 0; + xfer += prot_->writeStructBegin("EmptyStruct"); + xfer += prot_->writeFieldStop(); + xfer += prot_->writeStructEnd(); + return xfer; +} + +extern template void EmptyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +extern template uint32_t EmptyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +extern template uint32_t EmptyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template void EmptyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +extern template uint32_t EmptyStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +extern template uint32_t EmptyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +extern template uint32_t EmptyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +template +void TestStruct::readNoXfer(Protocol_* iprot) { + __fbthrift_clear_terse_fields(); + + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(iprot); + + using apache::thrift::TProtocolException; + + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 0, + 1, + apache::thrift::protocol::T_I32))) { + goto _advance_failure; + } +_readField_unqualified_int_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::readWithContext(*iprot, this->__fbthrift_field_unqualified_int_field, _readState); + } + this->__isset.set(0, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 1, + 2, + apache::thrift::protocol::T_BOOL))) { + goto _advance_failure; + } +_readField_unqualified_bool_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->__fbthrift_field_unqualified_bool_field, _readState); + } + this->__isset.set(1, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 2, + 3, + apache::thrift::protocol::T_LIST))) { + goto _advance_failure; + } +_readField_unqualified_list_field: + { + _readState.beforeSubobject(iprot); + this->__fbthrift_field_unqualified_list_field = ::std::vector<::std::int32_t>(); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::readWithContext(*iprot, this->__fbthrift_field_unqualified_list_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(2, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 3, + 4, + apache::thrift::protocol::T_STRUCT))) { + goto _advance_failure; + } +_readField_unqualified_struct_field: + { + _readState.beforeSubobject(iprot); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::readWithContext(*iprot, this->__fbthrift_field_unqualified_struct_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(3, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 4, + 5, + apache::thrift::protocol::T_I32))) { + goto _advance_failure; + } +_readField_optional_int_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::readWithContext(*iprot, this->__fbthrift_field_optional_int_field, _readState); + } + this->__isset.set(4, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 5, + 6, + apache::thrift::protocol::T_BOOL))) { + goto _advance_failure; + } +_readField_optional_bool_field: + { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->__fbthrift_field_optional_bool_field, _readState); + } + this->__isset.set(5, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 6, + 7, + apache::thrift::protocol::T_LIST))) { + goto _advance_failure; + } +_readField_optional_list_field: + { + _readState.beforeSubobject(iprot); + this->__fbthrift_field_optional_list_field = ::std::vector<::std::int32_t>(); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::readWithContext(*iprot, this->__fbthrift_field_optional_list_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(6, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 7, + 8, + apache::thrift::protocol::T_STRUCT))) { + goto _advance_failure; + } +_readField_optional_struct_field: + { + _readState.beforeSubobject(iprot); + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::readWithContext(*iprot, this->__fbthrift_field_optional_struct_field, _readState); + _readState.afterSubobject(iprot); + } + this->__isset.set(7, true); + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 8, + 0, + apache::thrift::protocol::T_STOP))) { + goto _advance_failure; + } + +_end: + _readState.readStructEnd(iprot); + + return; + + goto _advance_failure; // Avoid compiler warnings about unused labels. + _advance_failure: + _readState.afterAdvanceFailure(iprot); +_loop: + if (_readState.atStop()) { + goto _end; + } + if (iprot->kUsesFieldNames()) { + _readState.template fillFieldTraitsFromName>(); + } + + switch (_readState.fieldId) { + case 1: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_I32))) { + goto _readField_unqualified_int_field; + } else { + goto _skip; + } + } + case 2: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_unqualified_bool_field; + } else { + goto _skip; + } + } + case 3: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_LIST))) { + goto _readField_unqualified_list_field; + } else { + goto _skip; + } + } + case 4: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRUCT))) { + goto _readField_unqualified_struct_field; + } else { + goto _skip; + } + } + case 5: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_I32))) { + goto _readField_optional_int_field; + } else { + goto _skip; + } + } + case 6: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_optional_bool_field; + } else { + goto _skip; + } + } + case 7: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_LIST))) { + goto _readField_optional_list_field; + } else { + goto _skip; + } + } + case 8: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRUCT))) { + goto _readField_optional_struct_field; + } else { + goto _skip; + } + } + default: + { +_skip: + _readState.skip(iprot); + _readState.readFieldEnd(iprot); + _readState.readFieldBeginNoInline(iprot); + goto _loop; + } + } +} + +template +uint32_t TestStruct::serializedSize(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("TestStruct"); + { + xfer += prot_->serializedFieldSize("unqualified_int_field", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_unqualified_int_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_bool_field", apache::thrift::protocol::T_BOOL, 2); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_unqualified_bool_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_list_field", apache::thrift::protocol::T_LIST, 3); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_unqualified_list_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_struct_field", apache::thrift::protocol::T_STRUCT, 4); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_unqualified_struct_field); + } + if (this->__isset.get(4)) { + xfer += prot_->serializedFieldSize("optional_int_field", apache::thrift::protocol::T_I32, 5); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_optional_int_field); + } + if (this->__isset.get(5)) { + xfer += prot_->serializedFieldSize("optional_bool_field", apache::thrift::protocol::T_BOOL, 6); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_optional_bool_field); + } + if (this->__isset.get(6)) { + xfer += prot_->serializedFieldSize("optional_list_field", apache::thrift::protocol::T_LIST, 7); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_optional_list_field); + } + if (this->__isset.get(7)) { + xfer += prot_->serializedFieldSize("optional_struct_field", apache::thrift::protocol::T_STRUCT, 8); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_optional_struct_field); + } + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t TestStruct::serializedSizeZC(Protocol_ const* prot_) const { + uint32_t xfer = 0; + xfer += prot_->serializedStructSize("TestStruct"); + { + xfer += prot_->serializedFieldSize("unqualified_int_field", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_unqualified_int_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_bool_field", apache::thrift::protocol::T_BOOL, 2); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_unqualified_bool_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_list_field", apache::thrift::protocol::T_LIST, 3); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_unqualified_list_field); + } + { + xfer += prot_->serializedFieldSize("unqualified_struct_field", apache::thrift::protocol::T_STRUCT, 4); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_unqualified_struct_field); + } + if (this->__isset.get(4)) { + xfer += prot_->serializedFieldSize("optional_int_field", apache::thrift::protocol::T_I32, 5); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::serializedSize(*prot_, this->__fbthrift_field_optional_int_field); + } + if (this->__isset.get(5)) { + xfer += prot_->serializedFieldSize("optional_bool_field", apache::thrift::protocol::T_BOOL, 6); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->__fbthrift_field_optional_bool_field); + } + if (this->__isset.get(6)) { + xfer += prot_->serializedFieldSize("optional_list_field", apache::thrift::protocol::T_LIST, 7); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::serializedSize(*prot_, this->__fbthrift_field_optional_list_field); + } + if (this->__isset.get(7)) { + xfer += prot_->serializedFieldSize("optional_struct_field", apache::thrift::protocol::T_STRUCT, 8); + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::serializedSize(*prot_, this->__fbthrift_field_optional_struct_field); + } + xfer += prot_->serializedSizeStop(); + return xfer; +} + +template +uint32_t TestStruct::write(Protocol_* prot_) const { + uint32_t xfer = 0; + xfer += prot_->writeStructBegin("TestStruct"); + bool previousFieldHasValue = true; + { + constexpr int16_t kPrevFieldId = 0; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_int_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::write(*prot_, this->__fbthrift_field_unqualified_int_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 1; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_bool_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::write(*prot_, this->__fbthrift_field_unqualified_bool_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 2; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_list_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::write(*prot_, this->__fbthrift_field_unqualified_list_field); + xfer += prot_->writeFieldEnd(); + } + { + constexpr int16_t kPrevFieldId = 3; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "unqualified_struct_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::write(*prot_, this->__fbthrift_field_unqualified_struct_field); + xfer += prot_->writeFieldEnd(); + } + if (this->__isset.get(4)) { + constexpr int16_t kPrevFieldId = 4; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_int_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, ::std::int32_t>::write(*prot_, this->__fbthrift_field_optional_int_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(5)) { + constexpr int16_t kPrevFieldId = 5; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_bool_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::integral, bool>::write(*prot_, this->__fbthrift_field_optional_bool_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(6)) { + constexpr int16_t kPrevFieldId = 6; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_list_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::list<::apache::thrift::type_class::integral>, ::std::vector<::std::int32_t>>::write(*prot_, this->__fbthrift_field_optional_list_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + if (this->__isset.get(7)) { + constexpr int16_t kPrevFieldId = 7; + xfer += ::apache::thrift::detail::writeFieldBegin(*prot_, "optional_struct_field", previousFieldHasValue); + previousFieldHasValue = true; + xfer += ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::structure, ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::write(*prot_, this->__fbthrift_field_optional_struct_field); + xfer += prot_->writeFieldEnd(); + } else { + previousFieldHasValue = false; + } + xfer += prot_->writeFieldStop(); + xfer += prot_->writeStructEnd(); + return xfer; +} + +extern template void TestStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); +extern template uint32_t TestStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; +extern template uint32_t TestStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; +extern template void TestStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); +extern template uint32_t TestStruct::write<>(apache::thrift::CompactProtocolWriter*) const; +extern template uint32_t TestStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; +extern template uint32_t TestStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; + + +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_custom_protocol.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_custom_protocol.h new file mode 100644 index 00000000000000..93e203c1c3b721 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_custom_protocol.h @@ -0,0 +1,18 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + + +/** + * This header file includes the tcc files of the corresponding header file + * and the header files of its dependent types. Include this header file + * only when you need to use custom protocols (e.g. DebugProtocol, + * VirtualProtocol) to read/write thrift structs. + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.tcc" + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_fwd.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_fwd.h new file mode 100644 index 00000000000000..8f347e08483620 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_types_fwd.h @@ -0,0 +1,14 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +// BEGIN forward_declare +namespace facebook::thrift::compiler::test::fixtures::default_values_rectification { +class EmptyStruct; +class TestStruct; +} // namespace facebook::thrift::compiler::test::fixtures::default_values_rectification +// END forward_declare diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h new file mode 100644 index 00000000000000..adeea70d0bc736 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_by_thrift_field_metadata.h @@ -0,0 +1,55 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" + +namespace apache { +namespace thrift { +namespace detail { + +template <> +struct VisitByFieldId<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct> { + template + void operator()([[maybe_unused]] F&& f, int32_t fieldId, [[maybe_unused]] T&& t) const { + switch (fieldId) { + default: + throwInvalidThriftId(fieldId, "::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct"); + } + } +}; + +template <> +struct VisitByFieldId<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct> { + template + void operator()([[maybe_unused]] F&& f, int32_t fieldId, [[maybe_unused]] T&& t) const { + switch (fieldId) { + case 1: + return f(0, static_cast(t).unqualified_int_field_ref()); + case 2: + return f(1, static_cast(t).unqualified_bool_field_ref()); + case 3: + return f(2, static_cast(t).unqualified_list_field_ref()); + case 4: + return f(3, static_cast(t).unqualified_struct_field_ref()); + case 5: + return f(4, static_cast(t).optional_int_field_ref()); + case 6: + return f(5, static_cast(t).optional_bool_field_ref()); + case 7: + return f(6, static_cast(t).optional_list_field_ref()); + case 8: + return f(7, static_cast(t).optional_struct_field_ref()); + default: + throwInvalidThriftId(fieldId, "::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct"); + } + } +}; +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_union.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_union.h new file mode 100644 index 00000000000000..0013e6236c4ace --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visit_union.h @@ -0,0 +1,18 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" +#include + +namespace apache { +namespace thrift { +namespace detail { + +} // namespace detail +} // namespace thrift +} // namespace apache diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visitation.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visitation.h new file mode 100644 index 00000000000000..1c71b31d0051e2 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/cpp2/gen-cpp2/module_visitation.h @@ -0,0 +1,10 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated @nocommit + */ +#pragma once +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_for_each_field.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_visit_union.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_visit_by_thrift_field_metadata.h" diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/codec.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/codec.go new file mode 100644 index 00000000000000..12932495e9fd54 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/codec.go @@ -0,0 +1,203 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + + +import ( + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO + +// Premade codec specs +var ( + premadeCodecTypeSpec_module_EmptyStruct = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "module.EmptyStruct", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "module.EmptyStruct", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewEmptyStruct() }, +}, + + } + }() + premadeCodecTypeSpec_i32 = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "i32", + CodecPrimitiveSpec: &thrift.CodecPrimitiveSpec{ + PrimitiveType: thrift.CODEC_PRIMITIVE_TYPE_I32, +}, + + } + }() + premadeCodecTypeSpec_bool = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "bool", + CodecPrimitiveSpec: &thrift.CodecPrimitiveSpec{ + PrimitiveType: thrift.CODEC_PRIMITIVE_TYPE_BOOL, +}, + + } + }() + premadeCodecTypeSpec_list_i32 = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "list", + CodecListSpec: &thrift.CodecListSpec{ + ElementWireType: thrift.I32, + ElementTypeSpec: premadeCodecTypeSpec_i32, +}, + + } + }() + premadeCodecTypeSpec_module_TestStruct = func() *thrift.TypeSpec { + return &thrift.TypeSpec{ + FullName: "module.TestStruct", + CodecStructSpec: &thrift.CodecStructSpec{ + ScopedName: "module.TestStruct", + IsUnion: false, + NewFunc: func() thrift.Struct { return NewTestStruct() }, +}, + + } + }() +) + +// Premade struct specs +var ( + premadeStructSpec_EmptyStruct = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "EmptyStruct", + ScopedName: "module.EmptyStruct", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + }, + FieldSpecIDToIndex: map[int16]int{ + }, + FieldSpecNameToIndex: map[string]int{ + }, +} + }() + premadeStructSpec_TestStruct = func() *thrift.StructSpec { + return &thrift.StructSpec{ + Name: "TestStruct", + ScopedName: "module.TestStruct", + IsUnion: false, + IsException: false, + FieldSpecs: []thrift.FieldSpec{ + { + ID: 1, + WireType: thrift.I32, + Name: "unqualified_int_field", + ReflectIndex: 0, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_i32, + MustBeSetToSerialize: false, + }, { + ID: 2, + WireType: thrift.BOOL, + Name: "unqualified_bool_field", + ReflectIndex: 1, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_bool, + MustBeSetToSerialize: false, + }, { + ID: 3, + WireType: thrift.LIST, + Name: "unqualified_list_field", + ReflectIndex: 2, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_list_i32, + MustBeSetToSerialize: false, + }, { + ID: 4, + WireType: thrift.STRUCT, + Name: "unqualified_struct_field", + ReflectIndex: 3, + IsOptional: false, + ValueTypeSpec: premadeCodecTypeSpec_module_EmptyStruct, + MustBeSetToSerialize: true, + }, { + ID: 5, + WireType: thrift.I32, + Name: "optional_int_field", + ReflectIndex: 4, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_i32, + MustBeSetToSerialize: true, + }, { + ID: 6, + WireType: thrift.BOOL, + Name: "optional_bool_field", + ReflectIndex: 5, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_bool, + MustBeSetToSerialize: true, + }, { + ID: 7, + WireType: thrift.LIST, + Name: "optional_list_field", + ReflectIndex: 6, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_list_i32, + MustBeSetToSerialize: true, + }, { + ID: 8, + WireType: thrift.STRUCT, + Name: "optional_struct_field", + ReflectIndex: 7, + IsOptional: true, + ValueTypeSpec: premadeCodecTypeSpec_module_EmptyStruct, + MustBeSetToSerialize: true, + }, }, + FieldSpecIDToIndex: map[int16]int{ + 1: 0, + 2: 1, + 3: 2, + 4: 3, + 5: 4, + 6: 5, + 7: 6, + 8: 7, + }, + FieldSpecNameToIndex: map[string]int{ + "unqualified_int_field": 0, + "unqualified_bool_field": 1, + "unqualified_list_field": 2, + "unqualified_struct_field": 3, + "optional_int_field": 4, + "optional_bool_field": 5, + "optional_list_field": 6, + "optional_struct_field": 7, + }, +} + }() +) + +// Premade slice of all struct specs +var premadeStructSpecs = func() []*thrift.StructSpec { + fbthriftResults := make([]*thrift.StructSpec, 0) + fbthriftResults = append(fbthriftResults, premadeStructSpec_EmptyStruct) + fbthriftResults = append(fbthriftResults, premadeStructSpec_TestStruct) + return fbthriftResults +}() + +var premadeCodecSpecsMap = func() map[string]*thrift.TypeSpec { + fbthriftTypeSpecsMap := make(map[string]*thrift.TypeSpec) + fbthriftTypeSpecsMap[premadeCodecTypeSpec_module_EmptyStruct.FullName] = premadeCodecTypeSpec_module_EmptyStruct + fbthriftTypeSpecsMap[premadeCodecTypeSpec_i32.FullName] = premadeCodecTypeSpec_i32 + fbthriftTypeSpecsMap[premadeCodecTypeSpec_bool.FullName] = premadeCodecTypeSpec_bool + fbthriftTypeSpecsMap[premadeCodecTypeSpec_module_TestStruct.FullName] = premadeCodecTypeSpec_module_TestStruct + return fbthriftTypeSpecsMap +}() + +// GetMetadataThriftType (INTERNAL USE ONLY). +// Returns metadata TypeSpec for a given full type name. +func GetCodecTypeSpec(fullName string) *thrift.TypeSpec { + return premadeCodecSpecsMap[fullName] +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/const.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/const.go new file mode 100644 index 00000000000000..37f02e130edbe7 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/const.go @@ -0,0 +1,16 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO + +var GoUnusedProtection__ int + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/metadata.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/metadata.go new file mode 100644 index 00000000000000..589e3ba51f5315 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/metadata.go @@ -0,0 +1,293 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + "maps" + + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" + metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata" +) + +// (needed to ensure safety because of naive import list construction) +var _ = thrift.ZERO +var _ = maps.Copy[map[int]int, map[int]int] +var _ = metadata.GoUnusedProtection__ + +// Premade Thrift types +var ( + premadeThriftType_module_EmptyStruct = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("module.EmptyStruct"), + ) + }() + premadeThriftType_i32 = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTPrimitive( + metadata.ThriftPrimitiveType_THRIFT_I32_TYPE.Ptr(), + ) + }() + premadeThriftType_bool = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTPrimitive( + metadata.ThriftPrimitiveType_THRIFT_BOOL_TYPE.Ptr(), + ) + }() + premadeThriftType_list_i32 = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTList( + metadata.NewThriftListType(). + SetValueType(premadeThriftType_i32), + ) + }() + premadeThriftType_module_TestStruct = func() *metadata.ThriftType { + return metadata.NewThriftType().SetTStruct( + metadata.NewThriftStructType(). + SetName("module.TestStruct"), + ) + }() +) + +// Helper type to allow us to store Thrift types in a slice at compile time, +// and put them in a map at runtime. See comment at the top of template +// about a compilation limitation that affects map literals. +type thriftTypeWithFullName struct { + fullName string + thriftType *metadata.ThriftType +} + +var premadeThriftTypesMap = func() map[string]*metadata.ThriftType { + thriftTypesWithFullName := make([]thriftTypeWithFullName, 0) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "module.EmptyStruct", premadeThriftType_module_EmptyStruct }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "i32", premadeThriftType_i32 }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "bool", premadeThriftType_bool }) + thriftTypesWithFullName = append(thriftTypesWithFullName, thriftTypeWithFullName{ "module.TestStruct", premadeThriftType_module_TestStruct }) + + fbthriftThriftTypesMap := make(map[string]*metadata.ThriftType, len(thriftTypesWithFullName)) + for _, value := range thriftTypesWithFullName { + fbthriftThriftTypesMap[value.fullName] = value.thriftType + } + return fbthriftThriftTypesMap +}() + +var structMetadatas = func() []*metadata.ThriftStruct { + fbthriftResults := make([]*metadata.ThriftStruct, 0) + for _, fbthriftStructSpec := range premadeStructSpecs { + if !fbthriftStructSpec.IsException { + fbthriftResults = append(fbthriftResults, getMetadataThriftStruct(fbthriftStructSpec)) + } + } + return fbthriftResults +}() + +var exceptionMetadatas = func() []*metadata.ThriftException { + fbthriftResults := make([]*metadata.ThriftException, 0) + for _, fbthriftStructSpec := range premadeStructSpecs { + if fbthriftStructSpec.IsException { + fbthriftResults = append(fbthriftResults, getMetadataThriftException(fbthriftStructSpec)) + } + } + return fbthriftResults +}() + +var enumMetadatas = func() []*metadata.ThriftEnum { + fbthriftResults := make([]*metadata.ThriftEnum, 0) + return fbthriftResults +}() + +var serviceMetadatas = func() []*metadata.ThriftService { + fbthriftResults := make([]*metadata.ThriftService, 0) + return fbthriftResults +}() + +// GetMetadataThriftType (INTERNAL USE ONLY). +// Returns metadata ThriftType for a given full type name. +func GetMetadataThriftType(fullName string) *metadata.ThriftType { + return premadeThriftTypesMap[fullName] +} + +// GetThriftMetadata returns complete Thrift metadata for current and imported packages. +func GetThriftMetadata() *metadata.ThriftMetadata { + allEnumsMap := make(map[string]*metadata.ThriftEnum) + allStructsMap := make(map[string]*metadata.ThriftStruct) + allExceptionsMap := make(map[string]*metadata.ThriftException) + allServicesMap := make(map[string]*metadata.ThriftService) + + // Add enum metadatas from the current program... + for _, enumMetadata := range enumMetadatas { + allEnumsMap[enumMetadata.GetName()] = enumMetadata + } + // Add struct metadatas from the current program... + for _, structMetadata := range structMetadatas { + allStructsMap[structMetadata.GetName()] = structMetadata + } + // Add exception metadatas from the current program... + for _, exceptionMetadata := range exceptionMetadatas { + allExceptionsMap[exceptionMetadata.GetName()] = exceptionMetadata + } + // Add service metadatas from the current program... + for _, serviceMetadata := range serviceMetadatas { + allServicesMap[serviceMetadata.GetName()] = serviceMetadata + } + + // Obtain Thrift metadatas from recursively included programs... + var recursiveThriftMetadatas []*metadata.ThriftMetadata + + // ...now merge metadatas from recursively included programs. + for _, thriftMetadata := range recursiveThriftMetadatas { + maps.Copy(allEnumsMap, thriftMetadata.GetEnums()) + maps.Copy(allStructsMap, thriftMetadata.GetStructs()) + maps.Copy(allExceptionsMap, thriftMetadata.GetExceptions()) + maps.Copy(allServicesMap, thriftMetadata.GetServices()) + } + + return metadata.NewThriftMetadata(). + SetEnums(allEnumsMap). + SetStructs(allStructsMap). + SetExceptions(allExceptionsMap). + SetServices(allServicesMap) +} + +// GetThriftMetadataForService returns Thrift metadata for the given service. +func GetThriftMetadataForService(scopedServiceName string) *metadata.ThriftMetadata { + thriftMetadata := GetThriftMetadata() + + allServicesMap := thriftMetadata.GetServices() + relevantServicesMap := make(map[string]*metadata.ThriftService) + + serviceMetadata := allServicesMap[scopedServiceName] + // Visit and record all recursive parents of the target service. + for serviceMetadata != nil { + relevantServicesMap[serviceMetadata.GetName()] = serviceMetadata + if serviceMetadata.IsSetParent() { + serviceMetadata = allServicesMap[serviceMetadata.GetParent()] + } else { + serviceMetadata = nil + } + } + + thriftMetadata.SetServices(relevantServicesMap) + + return thriftMetadata +} + +func getMetadataThriftPrimitiveType(s *thrift.CodecPrimitiveSpec) *metadata.ThriftPrimitiveType { + var value metadata.ThriftPrimitiveType + + switch s.PrimitiveType { + case thrift.CODEC_PRIMITIVE_TYPE_BYTE: + value = metadata.ThriftPrimitiveType_THRIFT_BYTE_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_BOOL: + value = metadata.ThriftPrimitiveType_THRIFT_BOOL_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I16: + value = metadata.ThriftPrimitiveType_THRIFT_I16_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I32: + value = metadata.ThriftPrimitiveType_THRIFT_I32_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_I64: + value = metadata.ThriftPrimitiveType_THRIFT_I64_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_FLOAT: + value = metadata.ThriftPrimitiveType_THRIFT_FLOAT_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_DOUBLE: + value = metadata.ThriftPrimitiveType_THRIFT_DOUBLE_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_BINARY: + value = metadata.ThriftPrimitiveType_THRIFT_BINARY_TYPE + case thrift.CODEC_PRIMITIVE_TYPE_STRING: + value = metadata.ThriftPrimitiveType_THRIFT_STRING_TYPE + } + + return value.Ptr() +} + +func getMetadataThriftEnumType(s *thrift.CodecEnumSpec) *metadata.ThriftEnumType { + return metadata.NewThriftEnumType(). + SetName(s.ScopedName) +} + +func getMetadataThriftSetType(s *thrift.CodecSetSpec) *metadata.ThriftSetType { + return metadata.NewThriftSetType(). + SetValueType(getMetadataThriftType(s.ElementTypeSpec)) +} + +func getMetadataThriftListType(s *thrift.CodecListSpec) *metadata.ThriftListType { + return metadata.NewThriftListType(). + SetValueType(getMetadataThriftType(s.ElementTypeSpec)) +} + +func getMetadataThriftMapType(s *thrift.CodecMapSpec) *metadata.ThriftMapType { + return metadata.NewThriftMapType(). + SetKeyType(getMetadataThriftType(s.KeyTypeSpec)). + SetValueType(getMetadataThriftType(s.ValueTypeSpec)) +} + +func getMetadataThriftTypedefType(s *thrift.CodecTypedefSpec) *metadata.ThriftTypedefType { + return metadata.NewThriftTypedefType(). + SetName(s.ScopedName). + SetUnderlyingType(getMetadataThriftType(s.UnderlyingTypeSpec)) +} + +func getMetadataThriftStructType(s *thrift.CodecStructSpec) *metadata.ThriftStructType { + return metadata.NewThriftStructType(). + SetName(s.ScopedName) +} + +func getMetadataThriftUnionType(s *thrift.CodecStructSpec) *metadata.ThriftUnionType { + return metadata.NewThriftUnionType(). + SetName(s.ScopedName) +} + +func getMetadataThriftType(s *thrift.TypeSpec) *metadata.ThriftType { + thriftType := metadata.NewThriftType() + switch { + case s.CodecPrimitiveSpec != nil: + thriftType.SetTPrimitive(getMetadataThriftPrimitiveType(s.CodecPrimitiveSpec)) + case s.CodecEnumSpec != nil: + thriftType.SetTEnum(getMetadataThriftEnumType(s.CodecEnumSpec)) + case s.CodecSetSpec != nil: + thriftType.SetTSet(getMetadataThriftSetType(s.CodecSetSpec)) + case s.CodecListSpec != nil: + thriftType.SetTList(getMetadataThriftListType(s.CodecListSpec)) + case s.CodecMapSpec != nil: + thriftType.SetTMap(getMetadataThriftMapType(s.CodecMapSpec)) + case s.CodecTypedefSpec != nil: + thriftType.SetTTypedef(getMetadataThriftTypedefType(s.CodecTypedefSpec)) + case s.CodecStructSpec != nil: + if s.CodecStructSpec.IsUnion { + thriftType.SetTUnion(getMetadataThriftUnionType(s.CodecStructSpec)) + } else { + thriftType.SetTStruct(getMetadataThriftStructType(s.CodecStructSpec)) + } + } + return thriftType +} + +func getMetadataThriftField(s *thrift.FieldSpec) *metadata.ThriftField { + return metadata.NewThriftField(). + SetId(int32(s.ID)). + SetName(s.Name). + SetIsOptional(s.IsOptional). + SetType(getMetadataThriftType(s.ValueTypeSpec)) +} + +func getMetadataThriftStruct(s *thrift.StructSpec) *metadata.ThriftStruct { + metadataThriftFields := make([]*metadata.ThriftField, len(s.FieldSpecs), len(s.FieldSpecs)) + for i, fieldSpec := range s.FieldSpecs { + metadataThriftFields[i] = getMetadataThriftField(&fieldSpec) + } + + return metadata.NewThriftStruct(). + SetName(s.ScopedName). + SetIsUnion(s.IsUnion). + SetFields(metadataThriftFields) +} + +func getMetadataThriftException(s *thrift.StructSpec) *metadata.ThriftException { + metadataThriftFields := make([]*metadata.ThriftField, len(s.FieldSpecs), len(s.FieldSpecs)) + for i, fieldSpec := range s.FieldSpecs { + metadataThriftFields[i] = getMetadataThriftField(&fieldSpec) + } + + return metadata.NewThriftException(). + SetName(s.ScopedName). + SetFields(metadataThriftFields) +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/svcs.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/svcs.go new file mode 100644 index 00000000000000..bb888e2d6045a5 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/svcs.go @@ -0,0 +1,7 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/types.go b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/types.go new file mode 100644 index 00000000000000..496000aaa856d6 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/go/gen-go/module/types.go @@ -0,0 +1,705 @@ +// Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// @generated + +package module + +import ( + "fmt" + "reflect" + + thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift/types" +) + +// (needed to ensure safety because of naive import list construction) +var _ = fmt.Printf +var _ = reflect.Ptr +var _ = thrift.ZERO + +type EmptyStruct struct { +} +// Compile time interface enforcer +var _ thrift.Struct = (*EmptyStruct)(nil) + +func NewEmptyStruct() *EmptyStruct { + return (&EmptyStruct{}).setDefaults() +} + + + +func (x *EmptyStruct) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("EmptyStruct"); 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 *EmptyStruct) 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 *EmptyStruct) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *EmptyStruct) setDefaults() *EmptyStruct { + return x +} + +type TestStruct struct { + UnqualifiedIntField int32 `thrift:"unqualified_int_field,1" json:"unqualified_int_field" db:"unqualified_int_field"` + UnqualifiedBoolField bool `thrift:"unqualified_bool_field,2" json:"unqualified_bool_field" db:"unqualified_bool_field"` + UnqualifiedListField []int32 `thrift:"unqualified_list_field,3" json:"unqualified_list_field" db:"unqualified_list_field"` + UnqualifiedStructField *EmptyStruct `thrift:"unqualified_struct_field,4" json:"unqualified_struct_field" db:"unqualified_struct_field"` + OptionalIntField *int32 `thrift:"optional_int_field,5,optional" json:"optional_int_field,omitempty" db:"optional_int_field"` + OptionalBoolField *bool `thrift:"optional_bool_field,6,optional" json:"optional_bool_field,omitempty" db:"optional_bool_field"` + OptionalListField []int32 `thrift:"optional_list_field,7,optional" json:"optional_list_field,omitempty" db:"optional_list_field"` + OptionalStructField *EmptyStruct `thrift:"optional_struct_field,8,optional" json:"optional_struct_field,omitempty" db:"optional_struct_field"` +} +// Compile time interface enforcer +var _ thrift.Struct = (*TestStruct)(nil) + +func NewTestStruct() *TestStruct { + return (&TestStruct{}).setDefaults() +} + +func (x *TestStruct) GetUnqualifiedIntField() int32 { + return x.UnqualifiedIntField +} + +func (x *TestStruct) GetUnqualifiedBoolField() bool { + return x.UnqualifiedBoolField +} + +func (x *TestStruct) GetUnqualifiedListField() []int32 { + if !x.IsSetUnqualifiedListField() { + return []int32{ +} + } + return x.UnqualifiedListField +} + +func (x *TestStruct) GetUnqualifiedStructField() *EmptyStruct { + if !x.IsSetUnqualifiedStructField() { + return nil + } + return x.UnqualifiedStructField +} + +func (x *TestStruct) GetOptionalIntField() int32 { + if !x.IsSetOptionalIntField() { + return 42 + } + return *x.OptionalIntField +} + +func (x *TestStruct) GetOptionalBoolField() bool { + if !x.IsSetOptionalBoolField() { + return true + } + return *x.OptionalBoolField +} + +func (x *TestStruct) GetOptionalListField() []int32 { + if !x.IsSetOptionalListField() { + return []int32{ + 1, + 2, +} + } + return x.OptionalListField +} + +func (x *TestStruct) GetOptionalStructField() *EmptyStruct { + if !x.IsSetOptionalStructField() { + return nil + } + return x.OptionalStructField +} + +func (x *TestStruct) SetUnqualifiedIntFieldNonCompat(value int32) *TestStruct { + x.UnqualifiedIntField = value + return x +} + +func (x *TestStruct) SetUnqualifiedIntField(value int32) *TestStruct { + x.UnqualifiedIntField = value + return x +} + +func (x *TestStruct) SetUnqualifiedBoolFieldNonCompat(value bool) *TestStruct { + x.UnqualifiedBoolField = value + return x +} + +func (x *TestStruct) SetUnqualifiedBoolField(value bool) *TestStruct { + x.UnqualifiedBoolField = value + return x +} + +func (x *TestStruct) SetUnqualifiedListFieldNonCompat(value []int32) *TestStruct { + x.UnqualifiedListField = value + return x +} + +func (x *TestStruct) SetUnqualifiedListField(value []int32) *TestStruct { + x.UnqualifiedListField = value + return x +} + +func (x *TestStruct) SetUnqualifiedStructFieldNonCompat(value *EmptyStruct) *TestStruct { + x.UnqualifiedStructField = value + return x +} + +func (x *TestStruct) SetUnqualifiedStructField(value *EmptyStruct) *TestStruct { + x.UnqualifiedStructField = value + return x +} + +func (x *TestStruct) SetOptionalIntFieldNonCompat(value int32) *TestStruct { + x.OptionalIntField = &value + return x +} + +func (x *TestStruct) SetOptionalIntField(value int32) *TestStruct { + x.OptionalIntField = &value + return x +} + +func (x *TestStruct) SetOptionalBoolFieldNonCompat(value bool) *TestStruct { + x.OptionalBoolField = &value + return x +} + +func (x *TestStruct) SetOptionalBoolField(value bool) *TestStruct { + x.OptionalBoolField = &value + return x +} + +func (x *TestStruct) SetOptionalListFieldNonCompat(value []int32) *TestStruct { + x.OptionalListField = value + return x +} + +func (x *TestStruct) SetOptionalListField(value []int32) *TestStruct { + x.OptionalListField = value + return x +} + +func (x *TestStruct) SetOptionalStructFieldNonCompat(value *EmptyStruct) *TestStruct { + x.OptionalStructField = value + return x +} + +func (x *TestStruct) SetOptionalStructField(value EmptyStruct) *TestStruct { + x.OptionalStructField = &value + return x +} + +func (x *TestStruct) IsSetUnqualifiedListField() bool { + return x != nil && x.UnqualifiedListField != nil +} + +func (x *TestStruct) IsSetUnqualifiedStructField() bool { + return x != nil && x.UnqualifiedStructField != nil +} + +func (x *TestStruct) IsSetOptionalIntField() bool { + return x != nil && x.OptionalIntField != nil +} + +func (x *TestStruct) IsSetOptionalBoolField() bool { + return x != nil && x.OptionalBoolField != nil +} + +func (x *TestStruct) IsSetOptionalListField() bool { + return x != nil && x.OptionalListField != nil +} + +func (x *TestStruct) IsSetOptionalStructField() bool { + return x != nil && x.OptionalStructField != nil +} + +func (x *TestStruct) writeField1(p thrift.Encoder) error { // UnqualifiedIntField + if err := p.WriteFieldBegin("unqualified_int_field", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedIntField + if err := p.WriteI32(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField2(p thrift.Encoder) error { // UnqualifiedBoolField + if err := p.WriteFieldBegin("unqualified_bool_field", thrift.BOOL, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedBoolField + if err := p.WriteBool(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField3(p thrift.Encoder) error { // UnqualifiedListField + if err := p.WriteFieldBegin("unqualified_list_field", thrift.LIST, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedListField + if err := p.WriteListBegin(thrift.I32, len(item)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range item { + { + item := v + if err := p.WriteI32(item); err != nil { + return err + } + } + } + if err := p.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField4(p thrift.Encoder) error { // UnqualifiedStructField + if !x.IsSetUnqualifiedStructField() { + return nil + } + + if err := p.WriteFieldBegin("unqualified_struct_field", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.UnqualifiedStructField + if err := item.Write(p); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField5(p thrift.Encoder) error { // OptionalIntField + if !x.IsSetOptionalIntField() { + return nil + } + + if err := p.WriteFieldBegin("optional_int_field", thrift.I32, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := *x.OptionalIntField + if err := p.WriteI32(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField6(p thrift.Encoder) error { // OptionalBoolField + if !x.IsSetOptionalBoolField() { + return nil + } + + if err := p.WriteFieldBegin("optional_bool_field", thrift.BOOL, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := *x.OptionalBoolField + if err := p.WriteBool(item); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField7(p thrift.Encoder) error { // OptionalListField + if !x.IsSetOptionalListField() { + return nil + } + + if err := p.WriteFieldBegin("optional_list_field", thrift.LIST, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.OptionalListField + if err := p.WriteListBegin(thrift.I32, len(item)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range item { + { + item := v + if err := p.WriteI32(item); err != nil { + return err + } + } + } + if err := p.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) writeField8(p thrift.Encoder) error { // OptionalStructField + if !x.IsSetOptionalStructField() { + return nil + } + + if err := p.WriteFieldBegin("optional_struct_field", thrift.STRUCT, 8); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) + } + + item := x.OptionalStructField + if err := item.Write(p); err != nil { + return err + } + + if err := p.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) + } + return nil +} + +func (x *TestStruct) readField1(p thrift.Decoder) error { // UnqualifiedIntField + result, err := p.ReadI32() + if err != nil { + return err + } + + x.UnqualifiedIntField = result + return nil +} + +func (x *TestStruct) readField2(p thrift.Decoder) error { // UnqualifiedBoolField + result, err := p.ReadBool() + if err != nil { + return err + } + + x.UnqualifiedBoolField = result + return nil +} + +func (x *TestStruct) readField3(p thrift.Decoder) error { // UnqualifiedListField + _ /* elemType */, size, err := p.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + + listResult := make([]int32, 0, size) + for i := 0; i < size; i++ { + var elem int32 + { + result, err := p.ReadI32() + if err != nil { + return err + } + elem = result + } + listResult = append(listResult, elem) + } + + if err := p.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + result := listResult + + x.UnqualifiedListField = result + return nil +} + +func (x *TestStruct) readField4(p thrift.Decoder) error { // UnqualifiedStructField + result := NewEmptyStruct() + err := result.Read(p) + if err != nil { + return err + } + + x.UnqualifiedStructField = result + return nil +} + +func (x *TestStruct) readField5(p thrift.Decoder) error { // OptionalIntField + result, err := p.ReadI32() + if err != nil { + return err + } + + x.OptionalIntField = &result + return nil +} + +func (x *TestStruct) readField6(p thrift.Decoder) error { // OptionalBoolField + result, err := p.ReadBool() + if err != nil { + return err + } + + x.OptionalBoolField = &result + return nil +} + +func (x *TestStruct) readField7(p thrift.Decoder) error { // OptionalListField + _ /* elemType */, size, err := p.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + + listResult := make([]int32, 0, size) + for i := 0; i < size; i++ { + var elem int32 + { + result, err := p.ReadI32() + if err != nil { + return err + } + elem = result + } + listResult = append(listResult, elem) + } + + if err := p.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + result := listResult + + x.OptionalListField = result + return nil +} + +func (x *TestStruct) readField8(p thrift.Decoder) error { // OptionalStructField + result := NewEmptyStruct() + err := result.Read(p) + if err != nil { + return err + } + + x.OptionalStructField = result + return nil +} + +// Deprecated: Use NewTestStruct().GetUnqualifiedStructField() instead. +func (x *TestStruct) DefaultGetUnqualifiedStructField() *EmptyStruct { + if !x.IsSetUnqualifiedStructField() { + return NewEmptyStruct() + } + return x.UnqualifiedStructField +} + + + +// Deprecated: Use NewTestStruct().GetOptionalStructField() instead. +func (x *TestStruct) DefaultGetOptionalStructField() *EmptyStruct { + if !x.IsSetOptionalStructField() { + return NewEmptyStruct() + } + return x.OptionalStructField +} + + + +func (x *TestStruct) Write(p thrift.Encoder) error { + if err := p.WriteStructBegin("TestStruct"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err) + } + + if err := x.writeField1(p); err != nil { + return err + } + if err := x.writeField2(p); err != nil { + return err + } + if err := x.writeField3(p); err != nil { + return err + } + if err := x.writeField4(p); err != nil { + return err + } + if err := x.writeField5(p); err != nil { + return err + } + if err := x.writeField6(p); err != nil { + return err + } + if err := x.writeField7(p); err != nil { + return err + } + if err := x.writeField8(p); err != nil { + return 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 *TestStruct) 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 { + case ((id == 1 && wireType == thrift.I32) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_int_field")): // unqualified_int_field + fieldReadErr = x.readField1(p) + case ((id == 2 && wireType == thrift.BOOL) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_bool_field")): // unqualified_bool_field + fieldReadErr = x.readField2(p) + case ((id == 3 && wireType == thrift.LIST) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_list_field")): // unqualified_list_field + fieldReadErr = x.readField3(p) + case ((id == 4 && wireType == thrift.STRUCT) || (id == thrift.NO_FIELD_ID && fieldName == "unqualified_struct_field")): // unqualified_struct_field + fieldReadErr = x.readField4(p) + case ((id == 5 && wireType == thrift.I32) || (id == thrift.NO_FIELD_ID && fieldName == "optional_int_field")): // optional_int_field + fieldReadErr = x.readField5(p) + case ((id == 6 && wireType == thrift.BOOL) || (id == thrift.NO_FIELD_ID && fieldName == "optional_bool_field")): // optional_bool_field + fieldReadErr = x.readField6(p) + case ((id == 7 && wireType == thrift.LIST) || (id == thrift.NO_FIELD_ID && fieldName == "optional_list_field")): // optional_list_field + fieldReadErr = x.readField7(p) + case ((id == 8 && wireType == thrift.STRUCT) || (id == thrift.NO_FIELD_ID && fieldName == "optional_struct_field")): // optional_struct_field + fieldReadErr = x.readField8(p) + 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 *TestStruct) String() string { + return thrift.StructToString(reflect.ValueOf(x)) +} + +func (x *TestStruct) setDefaults() *TestStruct { + return x. + SetUnqualifiedIntFieldNonCompat(0). + SetUnqualifiedBoolFieldNonCompat(false). + SetUnqualifiedListFieldNonCompat( + []int32{ +}, + ). + SetUnqualifiedStructFieldNonCompat( + NewEmptyStruct(), + ). + SetOptionalIntFieldNonCompat(42). + SetOptionalBoolFieldNonCompat(true). + SetOptionalListFieldNonCompat( + []int32{ + 1, + 2, +}, + ). + SetOptionalStructFieldNonCompat( + NewEmptyStruct(), + ) +} + + + +// RegisterTypes registers types found in this file that have a thrift_uri with the passed in registry. +func RegisterTypes(registry interface { + RegisterType(name string, initializer func() any) +}) { + registry.RegisterType("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", func() any { return NewEmptyStruct() }) + registry.RegisterType("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", func() any { return NewTestStruct() }) + +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/hack/gen-hack/module_types.php b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/hack/gen-hack/module_types.php new file mode 100644 index 00000000000000..7e7f46f5c137eb --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/hack/gen-hack/module_types.php @@ -0,0 +1,362 @@ + 'facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct'))>> +class EmptyStruct 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 'EmptyStruct'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "module.EmptyStruct", + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + +/** + * Original thrift struct:- + * TestStruct + */ +<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct'))>> +class TestStruct implements \IThriftSyncStruct, \IThriftStructMetadata { + use \ThriftSerializationTrait; + + const \ThriftStructTypes::TSpec SPEC = dict[ + 1 => shape( + 'var' => 'unqualified_int_field', + 'type' => \TType::I32, + ), + 2 => shape( + 'var' => 'unqualified_bool_field', + 'type' => \TType::BOOL, + ), + 3 => shape( + 'var' => 'unqualified_list_field', + 'type' => \TType::LST, + 'etype' => \TType::I32, + 'elem' => shape( + 'type' => \TType::I32, + ), + 'format' => 'collection', + ), + 4 => shape( + 'var' => 'unqualified_struct_field', + 'type' => \TType::STRUCT, + 'class' => \facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct::class, + ), + 5 => shape( + 'var' => 'optional_int_field', + 'type' => \TType::I32, + ), + 6 => shape( + 'var' => 'optional_bool_field', + 'type' => \TType::BOOL, + ), + 7 => shape( + 'var' => 'optional_list_field', + 'type' => \TType::LST, + 'etype' => \TType::I32, + 'elem' => shape( + 'type' => \TType::I32, + ), + 'format' => 'collection', + ), + 8 => shape( + 'var' => 'optional_struct_field', + 'type' => \TType::STRUCT, + 'class' => \facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct::class, + ), + ]; + const dict FIELDMAP = dict[ + 'unqualified_int_field' => 1, + 'unqualified_bool_field' => 2, + 'unqualified_list_field' => 3, + 'unqualified_struct_field' => 4, + 'optional_int_field' => 5, + 'optional_bool_field' => 6, + 'optional_list_field' => 7, + 'optional_struct_field' => 8, + ]; + + const type TConstructorShape = shape( + ?'unqualified_int_field' => ?int, + ?'unqualified_bool_field' => ?bool, + ?'unqualified_list_field' => ?Vector, + ?'unqualified_struct_field' => ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct, + ?'optional_int_field' => ?int, + ?'optional_bool_field' => ?bool, + ?'optional_list_field' => ?Vector, + ?'optional_struct_field' => ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct, + ); + + const int STRUCTURAL_ID = 7991153564712628734; + /** + * Original thrift field:- + * 1: i32 unqualified_int_field + */ + public int $unqualified_int_field; + /** + * Original thrift field:- + * 2: bool unqualified_bool_field + */ + public bool $unqualified_bool_field; + /** + * Original thrift field:- + * 3: list unqualified_list_field + */ + public Vector $unqualified_list_field; + /** + * Original thrift field:- + * 4: module.EmptyStruct unqualified_struct_field + */ + public ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $unqualified_struct_field; + /** + * Original thrift field:- + * 5: i32 optional_int_field + */ + public int $optional_int_field; + /** + * Original thrift field:- + * 6: bool optional_bool_field + */ + public bool $optional_bool_field; + /** + * Original thrift field:- + * 7: list optional_list_field + */ + public Vector $optional_list_field; + /** + * Original thrift field:- + * 8: module.EmptyStruct optional_struct_field + */ + public ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $optional_struct_field; + + public function __construct(?int $unqualified_int_field = null, ?bool $unqualified_bool_field = null, ?Vector $unqualified_list_field = null, ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $unqualified_struct_field = null, ?int $optional_int_field = null, ?bool $optional_bool_field = null, ?Vector $optional_list_field = null, ?\facebook\thrift\compiler\test\fixtures\default_values_rectification\EmptyStruct $optional_struct_field = null)[] { + $this->unqualified_int_field = $unqualified_int_field ?? 0; + $this->unqualified_bool_field = $unqualified_bool_field ?? false; + $this->unqualified_list_field = $unqualified_list_field ?? Vector { + }; + $this->unqualified_struct_field = $unqualified_struct_field; + $this->optional_int_field = $optional_int_field ?? 42; + $this->optional_bool_field = $optional_bool_field ?? true; + $this->optional_list_field = $optional_list_field ?? Vector { + 1, + 2, + }; + $this->optional_struct_field = $optional_struct_field; + } + + public static function withDefaultValues()[]: this { + return new static(); + } + + public static function fromShape(self::TConstructorShape $shape)[]: this { + return new static( + Shapes::idx($shape, 'unqualified_int_field'), + Shapes::idx($shape, 'unqualified_bool_field'), + Shapes::idx($shape, 'unqualified_list_field'), + Shapes::idx($shape, 'unqualified_struct_field'), + Shapes::idx($shape, 'optional_int_field'), + Shapes::idx($shape, 'optional_bool_field'), + Shapes::idx($shape, 'optional_list_field'), + Shapes::idx($shape, 'optional_struct_field'), + ); + } + + public function getName()[]: string { + return 'TestStruct'; + } + + public static function getStructMetadata()[]: \tmeta_ThriftStruct { + return \tmeta_ThriftStruct::fromShape( + shape( + "name" => "module.TestStruct", + "fields" => vec[ + \tmeta_ThriftField::fromShape( + shape( + "id" => 1, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + "name" => "unqualified_int_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 2, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE, + ) + ), + "name" => "unqualified_bool_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 3, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_list" => \tmeta_ThriftListType::fromShape( + shape( + "valueType" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + ) + ), + ) + ), + "name" => "unqualified_list_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 4, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_struct" => \tmeta_ThriftStructType::fromShape( + shape( + "name" => "module.EmptyStruct", + ) + ), + ) + ), + "name" => "unqualified_struct_field", + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 5, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + "name" => "optional_int_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 6, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE, + ) + ), + "name" => "optional_bool_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 7, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_list" => \tmeta_ThriftListType::fromShape( + shape( + "valueType" => \tmeta_ThriftType::fromShape( + shape( + "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE, + ) + ), + ) + ), + ) + ), + "name" => "optional_list_field", + "is_optional" => true, + ) + ), + \tmeta_ThriftField::fromShape( + shape( + "id" => 8, + "type" => \tmeta_ThriftType::fromShape( + shape( + "t_struct" => \tmeta_ThriftStructType::fromShape( + shape( + "name" => "module.EmptyStruct", + ) + ), + ) + ), + "name" => "optional_struct_field", + "is_optional" => true, + ) + ), + ], + "is_union" => false, + ) + ); + } + + public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { + return shape( + 'struct' => dict[], + 'fields' => dict[ + ], + ); + } + + public function getInstanceKey()[write_props]: string { + return \TCompactSerializer::serialize($this); + } + +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module new file mode 100644 index 00000000000000..8b137891791fe9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/.generated_module @@ -0,0 +1 @@ + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java new file mode 100644 index 00000000000000..651a87db2d2785 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct.java @@ -0,0 +1,126 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.swift.codec.*; +import com.facebook.swift.codec.ThriftField.Requiredness; +import com.facebook.swift.codec.ThriftField.Recursiveness; +import com.google.common.collect.*; +import java.util.*; +import javax.annotation.Nullable; +import org.apache.thrift.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.protocol.*; +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.MoreObjects.ToStringHelper; + +@SwiftGenerated +@com.facebook.swift.codec.ThriftStruct(value="EmptyStruct", builder=EmptyStruct.Builder.class) +public final class EmptyStruct implements com.facebook.thrift.payload.ThriftSerializable { + @ThriftConstructor + public EmptyStruct( + ) { + } + + + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(EmptyStruct other) { + return new Builder(other); + } + + public static class Builder { + + public Builder() { } + public Builder(EmptyStruct other) { + } + + @ThriftConstructor + public EmptyStruct build() { + EmptyStruct result = new EmptyStruct ( + ); + return result; + } + } + + public static final Map NAMES_TO_IDS = new HashMap<>(); + public static final Map THRIFT_NAMES_TO_IDS = new HashMap<>(); + public static final Map FIELD_METADATA = new HashMap<>(); + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); +static { + com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( + new com.facebook.thrift.type.UniversalName("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct"), + EmptyStruct.class, EmptyStruct::read0)); + } + @java.lang.Override + public String toString() { + ToStringHelper helper = toStringHelper(this); + return helper.toString(); + } + + @java.lang.Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + EmptyStruct other = (EmptyStruct)o; + + return + true; + } + + @java.lang.Override + public int hashCode() { + return Arrays.deepHashCode(new java.lang.Object[] { + }); + } + + + public static com.facebook.thrift.payload.Reader asReader() { + return EmptyStruct::read0; + } + + public static EmptyStruct read0(TProtocol oprot) throws TException { + TField __field; + oprot.readStructBegin(EmptyStruct.NAMES_TO_IDS, EmptyStruct.THRIFT_NAMES_TO_IDS, EmptyStruct.FIELD_METADATA); + EmptyStruct.Builder builder = new EmptyStruct.Builder(); + while (true) { + __field = oprot.readFieldBegin(); + if (__field.type == TType.STOP) { break; } + switch (__field.id) { + default: + TProtocolUtil.skip(oprot, __field.type); + break; + } + oprot.readFieldEnd(); + } + oprot.readStructEnd(); + return builder.build(); + } + + public void write0(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + private static class _EmptyStructLazy { + private static final EmptyStruct _DEFAULT = new EmptyStruct.Builder().build(); + } + + public static EmptyStruct defaultInstance() { + return _EmptyStructLazy._DEFAULT; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java new file mode 100644 index 00000000000000..2b699a7343c6b3 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/TestStruct.java @@ -0,0 +1,476 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.swift.codec.*; +import com.facebook.swift.codec.ThriftField.Requiredness; +import com.facebook.swift.codec.ThriftField.Recursiveness; +import com.google.common.collect.*; +import java.util.*; +import javax.annotation.Nullable; +import org.apache.thrift.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.protocol.*; +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.MoreObjects.ToStringHelper; + +@SwiftGenerated +@com.facebook.swift.codec.ThriftStruct(value="TestStruct", builder=TestStruct.Builder.class) +public final class TestStruct implements com.facebook.thrift.payload.ThriftSerializable { + @ThriftConstructor + public TestStruct( + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) final int unqualifiedIntField, + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) final boolean unqualifiedBoolField, + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) final List unqualifiedListField, + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField, + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) final Integer optionalIntField, + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) final Boolean optionalBoolField, + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) final List optionalListField, + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField + ) { + this.unqualifiedIntField = unqualifiedIntField; + this.unqualifiedBoolField = unqualifiedBoolField; + this.unqualifiedListField = unqualifiedListField; + this.unqualifiedStructField = unqualifiedStructField; + this.optionalIntField = optionalIntField; + this.optionalBoolField = optionalBoolField; + this.optionalListField = optionalListField; + this.optionalStructField = optionalStructField; + } + + @ThriftConstructor + protected TestStruct() { + this.unqualifiedIntField = 0; + this.unqualifiedBoolField = false; + this.unqualifiedListField = ImmutableList.builder() + .build(); + this.unqualifiedStructField = new com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.Builder().build(); + this.optionalIntField = null; + this.optionalBoolField = null; + this.optionalListField = null; + this.optionalStructField = null; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(TestStruct other) { + return new Builder(other); + } + + public static class Builder { + private int unqualifiedIntField = 0; + private boolean unqualifiedBoolField = false; + private List unqualifiedListField = ImmutableList.builder() + .build(); + private com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField = new com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.Builder().build(); + private Integer optionalIntField = null; + private Boolean optionalBoolField = null; + private List optionalListField = null; + private com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField = null; + + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedIntField(int unqualifiedIntField) { + this.unqualifiedIntField = unqualifiedIntField; + return this; + } + + public int getUnqualifiedIntField() { return unqualifiedIntField; } + + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedBoolField(boolean unqualifiedBoolField) { + this.unqualifiedBoolField = unqualifiedBoolField; + return this; + } + + public boolean isUnqualifiedBoolField() { return unqualifiedBoolField; } + + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedListField(List unqualifiedListField) { + this.unqualifiedListField = unqualifiedListField; + return this; + } + + public List getUnqualifiedListField() { return unqualifiedListField; } + + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) public Builder setUnqualifiedStructField(com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField) { + this.unqualifiedStructField = unqualifiedStructField; + return this; + } + + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getUnqualifiedStructField() { return unqualifiedStructField; } + + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalIntField(Integer optionalIntField) { + this.optionalIntField = optionalIntField; + return this; + } + + public Integer getOptionalIntField() { return optionalIntField; } + + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalBoolField(Boolean optionalBoolField) { + this.optionalBoolField = optionalBoolField; + return this; + } + + public Boolean isOptionalBoolField() { return optionalBoolField; } + + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalListField(List optionalListField) { + this.optionalListField = optionalListField; + return this; + } + + public List getOptionalListField() { return optionalListField; } + + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) public Builder setOptionalStructField(com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField) { + this.optionalStructField = optionalStructField; + return this; + } + + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getOptionalStructField() { return optionalStructField; } + + public Builder() { } + public Builder(TestStruct other) { + this.unqualifiedIntField = other.unqualifiedIntField; + this.unqualifiedBoolField = other.unqualifiedBoolField; + this.unqualifiedListField = other.unqualifiedListField; + this.unqualifiedStructField = other.unqualifiedStructField; + this.optionalIntField = other.optionalIntField; + this.optionalBoolField = other.optionalBoolField; + this.optionalListField = other.optionalListField; + this.optionalStructField = other.optionalStructField; + } + + @ThriftConstructor + public TestStruct build() { + TestStruct result = new TestStruct ( + this.unqualifiedIntField, + this.unqualifiedBoolField, + this.unqualifiedListField, + this.unqualifiedStructField, + this.optionalIntField, + this.optionalBoolField, + this.optionalListField, + this.optionalStructField + ); + return result; + } + } + + public static final Map NAMES_TO_IDS = new HashMap<>(); + public static final Map THRIFT_NAMES_TO_IDS = new HashMap<>(); + public static final Map FIELD_METADATA = new HashMap<>(); + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private final int unqualifiedIntField; + public static final int _UNQUALIFIED_INT_FIELD = 1; + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private final boolean unqualifiedBoolField; + public static final int _UNQUALIFIED_BOOL_FIELD = 2; + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private final List unqualifiedListField; + public static final int _UNQUALIFIED_LIST_FIELD = 3; + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField; + public static final int _UNQUALIFIED_STRUCT_FIELD = 4; + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private final Integer optionalIntField; + public static final int _OPTIONAL_INT_FIELD = 5; + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private final Boolean optionalBoolField; + public static final int _OPTIONAL_BOOL_FIELD = 6; + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private final List optionalListField; + public static final int _OPTIONAL_LIST_FIELD = 7; + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private final com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField; + public static final int _OPTIONAL_STRUCT_FIELD = 8; + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + static { + NAMES_TO_IDS.put("unqualifiedIntField", 1); + THRIFT_NAMES_TO_IDS.put("unqualified_int_field", 1); + FIELD_METADATA.put(1, UNQUALIFIED_INT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedBoolField", 2); + THRIFT_NAMES_TO_IDS.put("unqualified_bool_field", 2); + FIELD_METADATA.put(2, UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedListField", 3); + THRIFT_NAMES_TO_IDS.put("unqualified_list_field", 3); + FIELD_METADATA.put(3, UNQUALIFIED_LIST_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("unqualifiedStructField", 4); + THRIFT_NAMES_TO_IDS.put("unqualified_struct_field", 4); + FIELD_METADATA.put(4, UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalIntField", 5); + THRIFT_NAMES_TO_IDS.put("optional_int_field", 5); + FIELD_METADATA.put(5, OPTIONAL_INT_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalBoolField", 6); + THRIFT_NAMES_TO_IDS.put("optional_bool_field", 6); + FIELD_METADATA.put(6, OPTIONAL_BOOL_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalListField", 7); + THRIFT_NAMES_TO_IDS.put("optional_list_field", 7); + FIELD_METADATA.put(7, OPTIONAL_LIST_FIELD_FIELD_DESC); + NAMES_TO_IDS.put("optionalStructField", 8); + THRIFT_NAMES_TO_IDS.put("optional_struct_field", 8); + FIELD_METADATA.put(8, OPTIONAL_STRUCT_FIELD_FIELD_DESC); + com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( + new com.facebook.thrift.type.UniversalName("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct"), + TestStruct.class, TestStruct::read0)); + } + + + @com.facebook.swift.codec.ThriftField(value=1, name="unqualified_int_field", requiredness=Requiredness.NONE) + public int getUnqualifiedIntField() { return unqualifiedIntField; } + + + + @com.facebook.swift.codec.ThriftField(value=2, name="unqualified_bool_field", requiredness=Requiredness.NONE) + public boolean isUnqualifiedBoolField() { return unqualifiedBoolField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=3, name="unqualified_list_field", requiredness=Requiredness.NONE) + public List getUnqualifiedListField() { return unqualifiedListField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=4, name="unqualified_struct_field", requiredness=Requiredness.NONE) + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getUnqualifiedStructField() { return unqualifiedStructField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=5, name="optional_int_field", requiredness=Requiredness.OPTIONAL) + public Integer getOptionalIntField() { return optionalIntField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=6, name="optional_bool_field", requiredness=Requiredness.OPTIONAL) + public Boolean isOptionalBoolField() { return optionalBoolField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=7, name="optional_list_field", requiredness=Requiredness.OPTIONAL) + public List getOptionalListField() { return optionalListField; } + + + @Nullable + @com.facebook.swift.codec.ThriftField(value=8, name="optional_struct_field", requiredness=Requiredness.OPTIONAL) + public com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct getOptionalStructField() { return optionalStructField; } + + @java.lang.Override + public String toString() { + ToStringHelper helper = toStringHelper(this); + helper.add("unqualifiedIntField", unqualifiedIntField); + helper.add("unqualifiedBoolField", unqualifiedBoolField); + helper.add("unqualifiedListField", unqualifiedListField); + helper.add("unqualifiedStructField", unqualifiedStructField); + helper.add("optionalIntField", optionalIntField); + helper.add("optionalBoolField", optionalBoolField); + helper.add("optionalListField", optionalListField); + helper.add("optionalStructField", optionalStructField); + return helper.toString(); + } + + @java.lang.Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestStruct other = (TestStruct)o; + + return + Objects.equals(unqualifiedIntField, other.unqualifiedIntField) && + Objects.equals(unqualifiedBoolField, other.unqualifiedBoolField) && + Objects.equals(unqualifiedListField, other.unqualifiedListField) && + Objects.equals(unqualifiedStructField, other.unqualifiedStructField) && + Objects.equals(optionalIntField, other.optionalIntField) && + Objects.equals(optionalBoolField, other.optionalBoolField) && + Objects.equals(optionalListField, other.optionalListField) && + Objects.equals(optionalStructField, other.optionalStructField) && + true; + } + + @java.lang.Override + public int hashCode() { + return Arrays.deepHashCode(new java.lang.Object[] { + unqualifiedIntField, + unqualifiedBoolField, + unqualifiedListField, + unqualifiedStructField, + optionalIntField, + optionalBoolField, + optionalListField, + optionalStructField + }); + } + + + public static com.facebook.thrift.payload.Reader asReader() { + return TestStruct::read0; + } + + public static TestStruct read0(TProtocol oprot) throws TException { + TField __field; + oprot.readStructBegin(TestStruct.NAMES_TO_IDS, TestStruct.THRIFT_NAMES_TO_IDS, TestStruct.FIELD_METADATA); + TestStruct.Builder builder = new TestStruct.Builder(); + while (true) { + __field = oprot.readFieldBegin(); + if (__field.type == TType.STOP) { break; } + switch (__field.id) { + case _UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + int unqualifiedIntField = oprot.readI32(); + builder.setUnqualifiedIntField(unqualifiedIntField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + boolean unqualifiedBoolField = oprot.readBool(); + builder.setUnqualifiedBoolField(unqualifiedBoolField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + List unqualifiedListField; + { + TList _list = oprot.readListBegin(); + unqualifiedListField = new ArrayList(Math.max(0, _list.size)); + for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) { + + int _value1 = oprot.readI32(); + unqualifiedListField.add(_value1); + } + oprot.readListEnd(); + } + builder.setUnqualifiedListField(unqualifiedListField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct unqualifiedStructField = com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.read0(oprot); + builder.setUnqualifiedStructField(unqualifiedStructField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + Integer optionalIntField = oprot.readI32(); + builder.setOptionalIntField(optionalIntField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + Boolean optionalBoolField = oprot.readBool(); + builder.setOptionalBoolField(optionalBoolField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + List optionalListField; + { + TList _list = oprot.readListBegin(); + optionalListField = new ArrayList(Math.max(0, _list.size)); + for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) { + + int _value1 = oprot.readI32(); + optionalListField.add(_value1); + } + oprot.readListEnd(); + } + builder.setOptionalListField(optionalListField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + case _OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct optionalStructField = com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct.read0(oprot); + builder.setOptionalStructField(optionalStructField); + } else { + TProtocolUtil.skip(oprot, __field.type); + } + break; + default: + TProtocolUtil.skip(oprot, __field.type); + break; + } + oprot.readFieldEnd(); + } + oprot.readStructEnd(); + return builder.build(); + } + + public void write0(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualifiedIntField); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualifiedBoolField); + oprot.writeFieldEnd(); + if (unqualifiedListField != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + List _iter0 = unqualifiedListField; + oprot.writeListBegin(new TList(TType.I32, _iter0.size())); + for (int _iter1 : _iter0) { + oprot.writeI32(_iter1); + } + oprot.writeListEnd(); + oprot.writeFieldEnd(); + } + if (unqualifiedStructField != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualifiedStructField.write0(oprot); + oprot.writeFieldEnd(); + } + if (optionalIntField != null) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optionalIntField); + oprot.writeFieldEnd(); + } + if (optionalBoolField != null) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optionalBoolField); + oprot.writeFieldEnd(); + } + if (optionalListField != null) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + List _iter0 = optionalListField; + oprot.writeListBegin(new TList(TType.I32, _iter0.size())); + for (int _iter1 : _iter0) { + oprot.writeI32(_iter1); + } + oprot.writeListEnd(); + oprot.writeFieldEnd(); + } + if (optionalStructField != null) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optionalStructField.write0(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + private static class _TestStructLazy { + private static final TestStruct _DEFAULT = new TestStruct.Builder().build(); + } + + public static TestStruct defaultInstance() { + return _TestStructLazy._DEFAULT; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java new file mode 100644 index 00000000000000..8605ad3a92fca1 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java/gen-java/com/facebook/thrift/compiler/test/fixtures/default_values_rectification/__fbthrift_TypeList_29830437.java @@ -0,0 +1,35 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +package com.facebook.thrift.compiler.test.fixtures.default_values_rectification; + +import com.facebook.thrift.type.TypeList; +import java.util.ArrayList; +import java.util.List; + +public class __fbthrift_TypeList_29830437 implements TypeList { + + private static List list = new ArrayList<>(); + + private static void add(String uri, String className) { + list.add(new TypeList.TypeMapping(uri, className)); + } + + private static void addToList0() { + add("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct", "com.facebook.thrift.compiler.test.fixtures.default_values_rectification.EmptyStruct"); + add("facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct", "com.facebook.thrift.compiler.test.fixtures.default_values_rectification.TestStruct"); + } + + static { + addToList0(); + } + + @java.lang.Override + public List getTypes() { + return list; + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/EmptyStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/EmptyStruct.java new file mode 100644 index 00000000000000..8c5446dc571cad --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/EmptyStruct.java @@ -0,0 +1,172 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 EmptyStruct implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("EmptyStruct"); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(EmptyStruct.class, metaDataMap); + } + + public EmptyStruct() { + } + + public static class Builder { + + public Builder() { + } + + public EmptyStruct build() { + EmptyStruct result = new EmptyStruct(); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public EmptyStruct(EmptyStruct other) { + } + + public EmptyStruct deepCopy() { + return new EmptyStruct(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 EmptyStruct)) + return false; + EmptyStruct that = (EmptyStruct)_that; + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {}); + } + + @Override + public int compareTo(EmptyStruct 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("EmptyStruct"); + 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/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/TestStruct.java b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/TestStruct.java new file mode 100644 index 00000000000000..938380dfdcc0a9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/java_deprecated/gen-javadeprecated/TestStruct.java @@ -0,0 +1,944 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +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 TestStruct implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("TestStruct"); + private static final TField UNQUALIFIED_INT_FIELD_FIELD_DESC = new TField("unqualified_int_field", TType.I32, (short)1); + private static final TField UNQUALIFIED_BOOL_FIELD_FIELD_DESC = new TField("unqualified_bool_field", TType.BOOL, (short)2); + private static final TField UNQUALIFIED_LIST_FIELD_FIELD_DESC = new TField("unqualified_list_field", TType.LIST, (short)3); + private static final TField UNQUALIFIED_STRUCT_FIELD_FIELD_DESC = new TField("unqualified_struct_field", TType.STRUCT, (short)4); + private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optional_int_field", TType.I32, (short)5); + private static final TField OPTIONAL_BOOL_FIELD_FIELD_DESC = new TField("optional_bool_field", TType.BOOL, (short)6); + private static final TField OPTIONAL_LIST_FIELD_FIELD_DESC = new TField("optional_list_field", TType.LIST, (short)7); + private static final TField OPTIONAL_STRUCT_FIELD_FIELD_DESC = new TField("optional_struct_field", TType.STRUCT, (short)8); + + public int unqualified_int_field; + public boolean unqualified_bool_field; + public List unqualified_list_field; + public EmptyStruct unqualified_struct_field; + public int optional_int_field; + public boolean optional_bool_field; + public List optional_list_field; + public EmptyStruct optional_struct_field; + public static final int UNQUALIFIED_INT_FIELD = 1; + public static final int UNQUALIFIED_BOOL_FIELD = 2; + public static final int UNQUALIFIED_LIST_FIELD = 3; + public static final int UNQUALIFIED_STRUCT_FIELD = 4; + public static final int OPTIONAL_INT_FIELD = 5; + public static final int OPTIONAL_BOOL_FIELD = 6; + public static final int OPTIONAL_LIST_FIELD = 7; + public static final int OPTIONAL_STRUCT_FIELD = 8; + + // isset id assignments + private static final int __UNQUALIFIED_INT_FIELD_ISSET_ID = 0; + private static final int __UNQUALIFIED_BOOL_FIELD_ISSET_ID = 1; + private static final int __OPTIONAL_INT_FIELD_ISSET_ID = 2; + private static final int __OPTIONAL_BOOL_FIELD_ISSET_ID = 3; + private BitSet __isset_bit_vector = new BitSet(4); + + public static final Map metaDataMap; + + static { + Map tmpMetaDataMap = new HashMap(); + tmpMetaDataMap.put(UNQUALIFIED_INT_FIELD, new FieldMetaData("unqualified_int_field", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.I32))); + tmpMetaDataMap.put(UNQUALIFIED_BOOL_FIELD, new FieldMetaData("unqualified_bool_field", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.BOOL))); + tmpMetaDataMap.put(UNQUALIFIED_LIST_FIELD, new FieldMetaData("unqualified_list_field", TFieldRequirementType.DEFAULT, + new ListMetaData(TType.LIST, + new FieldValueMetaData(TType.I32)))); + tmpMetaDataMap.put(UNQUALIFIED_STRUCT_FIELD, new FieldMetaData("unqualified_struct_field", TFieldRequirementType.DEFAULT, + new StructMetaData(TType.STRUCT, EmptyStruct.class))); + tmpMetaDataMap.put(OPTIONAL_INT_FIELD, new FieldMetaData("optional_int_field", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.I32))); + tmpMetaDataMap.put(OPTIONAL_BOOL_FIELD, new FieldMetaData("optional_bool_field", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.BOOL))); + tmpMetaDataMap.put(OPTIONAL_LIST_FIELD, new FieldMetaData("optional_list_field", TFieldRequirementType.OPTIONAL, + new ListMetaData(TType.LIST, + new FieldValueMetaData(TType.I32)))); + tmpMetaDataMap.put(OPTIONAL_STRUCT_FIELD, new FieldMetaData("optional_struct_field", TFieldRequirementType.OPTIONAL, + new StructMetaData(TType.STRUCT, EmptyStruct.class))); + metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap); + } + + static { + FieldMetaData.addStructMetaDataMap(TestStruct.class, metaDataMap); + } + + public TestStruct() { + this.unqualified_int_field = 0; + + this.unqualified_bool_field = false; + + this.unqualified_list_field = new ArrayList(); + + this.unqualified_struct_field = new EmptyStruct(); + + this.optional_int_field = 42; + + this.optional_bool_field = true; + + this.optional_list_field = new ArrayList(); + this.optional_list_field.add(1); + this.optional_list_field.add(2); + + this.optional_struct_field = new EmptyStruct(); + + } + + public TestStruct( + int unqualified_int_field, + boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field) { + this(); + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + } + + public TestStruct( + int unqualified_int_field, + boolean unqualified_bool_field, + List unqualified_list_field, + EmptyStruct unqualified_struct_field, + int optional_int_field, + boolean optional_bool_field, + List optional_list_field, + EmptyStruct optional_struct_field) { + this(); + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + this.unqualified_list_field = unqualified_list_field; + this.unqualified_struct_field = unqualified_struct_field; + this.optional_int_field = optional_int_field; + setOptional_int_fieldIsSet(true); + this.optional_bool_field = optional_bool_field; + setOptional_bool_fieldIsSet(true); + this.optional_list_field = optional_list_field; + this.optional_struct_field = optional_struct_field; + } + + public static class Builder { + private int unqualified_int_field; + private boolean unqualified_bool_field; + private List unqualified_list_field; + private EmptyStruct unqualified_struct_field; + private int optional_int_field; + private boolean optional_bool_field; + private List optional_list_field; + private EmptyStruct optional_struct_field; + + BitSet __optional_isset = new BitSet(4); + + public Builder() { + } + + public Builder setUnqualified_int_field(final int unqualified_int_field) { + this.unqualified_int_field = unqualified_int_field; + __optional_isset.set(__UNQUALIFIED_INT_FIELD_ISSET_ID, true); + return this; + } + + public Builder setUnqualified_bool_field(final boolean unqualified_bool_field) { + this.unqualified_bool_field = unqualified_bool_field; + __optional_isset.set(__UNQUALIFIED_BOOL_FIELD_ISSET_ID, true); + return this; + } + + public Builder setUnqualified_list_field(final List unqualified_list_field) { + this.unqualified_list_field = unqualified_list_field; + return this; + } + + public Builder setUnqualified_struct_field(final EmptyStruct unqualified_struct_field) { + this.unqualified_struct_field = unqualified_struct_field; + return this; + } + + public Builder setOptional_int_field(final int optional_int_field) { + this.optional_int_field = optional_int_field; + __optional_isset.set(__OPTIONAL_INT_FIELD_ISSET_ID, true); + return this; + } + + public Builder setOptional_bool_field(final boolean optional_bool_field) { + this.optional_bool_field = optional_bool_field; + __optional_isset.set(__OPTIONAL_BOOL_FIELD_ISSET_ID, true); + return this; + } + + public Builder setOptional_list_field(final List optional_list_field) { + this.optional_list_field = optional_list_field; + return this; + } + + public Builder setOptional_struct_field(final EmptyStruct optional_struct_field) { + this.optional_struct_field = optional_struct_field; + return this; + } + + public TestStruct build() { + TestStruct result = new TestStruct(); + if (__optional_isset.get(__UNQUALIFIED_INT_FIELD_ISSET_ID)) { + result.setUnqualified_int_field(this.unqualified_int_field); + } + if (__optional_isset.get(__UNQUALIFIED_BOOL_FIELD_ISSET_ID)) { + result.setUnqualified_bool_field(this.unqualified_bool_field); + } + result.setUnqualified_list_field(this.unqualified_list_field); + result.setUnqualified_struct_field(this.unqualified_struct_field); + if (__optional_isset.get(__OPTIONAL_INT_FIELD_ISSET_ID)) { + result.setOptional_int_field(this.optional_int_field); + } + if (__optional_isset.get(__OPTIONAL_BOOL_FIELD_ISSET_ID)) { + result.setOptional_bool_field(this.optional_bool_field); + } + result.setOptional_list_field(this.optional_list_field); + result.setOptional_struct_field(this.optional_struct_field); + return result; + } + } + + public static Builder builder() { + return new Builder(); + } + + /** + * Performs a deep copy on other. + */ + public TestStruct(TestStruct other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + this.unqualified_int_field = TBaseHelper.deepCopy(other.unqualified_int_field); + this.unqualified_bool_field = TBaseHelper.deepCopy(other.unqualified_bool_field); + if (other.isSetUnqualified_list_field()) { + this.unqualified_list_field = TBaseHelper.deepCopy(other.unqualified_list_field); + } + if (other.isSetUnqualified_struct_field()) { + this.unqualified_struct_field = TBaseHelper.deepCopy(other.unqualified_struct_field); + } + this.optional_int_field = TBaseHelper.deepCopy(other.optional_int_field); + this.optional_bool_field = TBaseHelper.deepCopy(other.optional_bool_field); + if (other.isSetOptional_list_field()) { + this.optional_list_field = TBaseHelper.deepCopy(other.optional_list_field); + } + if (other.isSetOptional_struct_field()) { + this.optional_struct_field = TBaseHelper.deepCopy(other.optional_struct_field); + } + } + + public TestStruct deepCopy() { + return new TestStruct(this); + } + + public int getUnqualified_int_field() { + return this.unqualified_int_field; + } + + public TestStruct setUnqualified_int_field(int unqualified_int_field) { + this.unqualified_int_field = unqualified_int_field; + setUnqualified_int_fieldIsSet(true); + return this; + } + + public void unsetUnqualified_int_field() { + __isset_bit_vector.clear(__UNQUALIFIED_INT_FIELD_ISSET_ID); + } + + // Returns true if field unqualified_int_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_int_field() { + return __isset_bit_vector.get(__UNQUALIFIED_INT_FIELD_ISSET_ID); + } + + public void setUnqualified_int_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__UNQUALIFIED_INT_FIELD_ISSET_ID, __value); + } + + public boolean isUnqualified_bool_field() { + return this.unqualified_bool_field; + } + + public TestStruct setUnqualified_bool_field(boolean unqualified_bool_field) { + this.unqualified_bool_field = unqualified_bool_field; + setUnqualified_bool_fieldIsSet(true); + return this; + } + + public void unsetUnqualified_bool_field() { + __isset_bit_vector.clear(__UNQUALIFIED_BOOL_FIELD_ISSET_ID); + } + + // Returns true if field unqualified_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_bool_field() { + return __isset_bit_vector.get(__UNQUALIFIED_BOOL_FIELD_ISSET_ID); + } + + public void setUnqualified_bool_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__UNQUALIFIED_BOOL_FIELD_ISSET_ID, __value); + } + + public List getUnqualified_list_field() { + return this.unqualified_list_field; + } + + public TestStruct setUnqualified_list_field(List unqualified_list_field) { + this.unqualified_list_field = unqualified_list_field; + return this; + } + + public void unsetUnqualified_list_field() { + this.unqualified_list_field = null; + } + + // Returns true if field unqualified_list_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_list_field() { + return this.unqualified_list_field != null; + } + + public void setUnqualified_list_fieldIsSet(boolean __value) { + if (!__value) { + this.unqualified_list_field = null; + } + } + + public EmptyStruct getUnqualified_struct_field() { + return this.unqualified_struct_field; + } + + public TestStruct setUnqualified_struct_field(EmptyStruct unqualified_struct_field) { + this.unqualified_struct_field = unqualified_struct_field; + return this; + } + + public void unsetUnqualified_struct_field() { + this.unqualified_struct_field = null; + } + + // Returns true if field unqualified_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetUnqualified_struct_field() { + return this.unqualified_struct_field != null; + } + + public void setUnqualified_struct_fieldIsSet(boolean __value) { + if (!__value) { + this.unqualified_struct_field = null; + } + } + + public int getOptional_int_field() { + return this.optional_int_field; + } + + public TestStruct setOptional_int_field(int optional_int_field) { + this.optional_int_field = optional_int_field; + setOptional_int_fieldIsSet(true); + return this; + } + + public void unsetOptional_int_field() { + __isset_bit_vector.clear(__OPTIONAL_INT_FIELD_ISSET_ID); + } + + // Returns true if field optional_int_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_int_field() { + return __isset_bit_vector.get(__OPTIONAL_INT_FIELD_ISSET_ID); + } + + public void setOptional_int_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__OPTIONAL_INT_FIELD_ISSET_ID, __value); + } + + public boolean isOptional_bool_field() { + return this.optional_bool_field; + } + + public TestStruct setOptional_bool_field(boolean optional_bool_field) { + this.optional_bool_field = optional_bool_field; + setOptional_bool_fieldIsSet(true); + return this; + } + + public void unsetOptional_bool_field() { + __isset_bit_vector.clear(__OPTIONAL_BOOL_FIELD_ISSET_ID); + } + + // Returns true if field optional_bool_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_bool_field() { + return __isset_bit_vector.get(__OPTIONAL_BOOL_FIELD_ISSET_ID); + } + + public void setOptional_bool_fieldIsSet(boolean __value) { + __isset_bit_vector.set(__OPTIONAL_BOOL_FIELD_ISSET_ID, __value); + } + + public List getOptional_list_field() { + return this.optional_list_field; + } + + public TestStruct setOptional_list_field(List optional_list_field) { + this.optional_list_field = optional_list_field; + return this; + } + + public void unsetOptional_list_field() { + this.optional_list_field = null; + } + + // Returns true if field optional_list_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_list_field() { + return this.optional_list_field != null; + } + + public void setOptional_list_fieldIsSet(boolean __value) { + if (!__value) { + this.optional_list_field = null; + } + } + + public EmptyStruct getOptional_struct_field() { + return this.optional_struct_field; + } + + public TestStruct setOptional_struct_field(EmptyStruct optional_struct_field) { + this.optional_struct_field = optional_struct_field; + return this; + } + + public void unsetOptional_struct_field() { + this.optional_struct_field = null; + } + + // Returns true if field optional_struct_field is set (has been assigned a value) and false otherwise + public boolean isSetOptional_struct_field() { + return this.optional_struct_field != null; + } + + public void setOptional_struct_fieldIsSet(boolean __value) { + if (!__value) { + this.optional_struct_field = null; + } + } + + @SuppressWarnings("unchecked") + public void setFieldValue(int fieldID, Object __value) { + switch (fieldID) { + case UNQUALIFIED_INT_FIELD: + if (__value == null) { + unsetUnqualified_int_field(); + } else { + setUnqualified_int_field((Integer)__value); + } + break; + + case UNQUALIFIED_BOOL_FIELD: + if (__value == null) { + unsetUnqualified_bool_field(); + } else { + setUnqualified_bool_field((Boolean)__value); + } + break; + + case UNQUALIFIED_LIST_FIELD: + if (__value == null) { + unsetUnqualified_list_field(); + } else { + setUnqualified_list_field((List)__value); + } + break; + + case UNQUALIFIED_STRUCT_FIELD: + if (__value == null) { + unsetUnqualified_struct_field(); + } else { + setUnqualified_struct_field((EmptyStruct)__value); + } + break; + + case OPTIONAL_INT_FIELD: + if (__value == null) { + unsetOptional_int_field(); + } else { + setOptional_int_field((Integer)__value); + } + break; + + case OPTIONAL_BOOL_FIELD: + if (__value == null) { + unsetOptional_bool_field(); + } else { + setOptional_bool_field((Boolean)__value); + } + break; + + case OPTIONAL_LIST_FIELD: + if (__value == null) { + unsetOptional_list_field(); + } else { + setOptional_list_field((List)__value); + } + break; + + case OPTIONAL_STRUCT_FIELD: + if (__value == null) { + unsetOptional_struct_field(); + } else { + setOptional_struct_field((EmptyStruct)__value); + } + break; + + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + public Object getFieldValue(int fieldID) { + switch (fieldID) { + case UNQUALIFIED_INT_FIELD: + return new Integer(getUnqualified_int_field()); + + case UNQUALIFIED_BOOL_FIELD: + return new Boolean(isUnqualified_bool_field()); + + case UNQUALIFIED_LIST_FIELD: + return getUnqualified_list_field(); + + case UNQUALIFIED_STRUCT_FIELD: + return getUnqualified_struct_field(); + + case OPTIONAL_INT_FIELD: + return new Integer(getOptional_int_field()); + + case OPTIONAL_BOOL_FIELD: + return new Boolean(isOptional_bool_field()); + + case OPTIONAL_LIST_FIELD: + return getOptional_list_field(); + + case OPTIONAL_STRUCT_FIELD: + return getOptional_struct_field(); + + 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 TestStruct)) + return false; + TestStruct that = (TestStruct)_that; + + if (!TBaseHelper.equalsNobinary(this.unqualified_int_field, that.unqualified_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.unqualified_bool_field, that.unqualified_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_list_field(), that.isSetUnqualified_list_field(), this.unqualified_list_field, that.unqualified_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetUnqualified_struct_field(), that.isSetUnqualified_struct_field(), this.unqualified_struct_field, that.unqualified_struct_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_int_field(), that.isSetOptional_int_field(), this.optional_int_field, that.optional_int_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_bool_field(), that.isSetOptional_bool_field(), this.optional_bool_field, that.optional_bool_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_list_field(), that.isSetOptional_list_field(), this.optional_list_field, that.optional_list_field)) { return false; } + + if (!TBaseHelper.equalsNobinary(this.isSetOptional_struct_field(), that.isSetOptional_struct_field(), this.optional_struct_field, that.optional_struct_field)) { return false; } + + return true; + } + + @Override + public int hashCode() { + return Arrays.deepHashCode(new Object[] {unqualified_int_field, unqualified_bool_field, unqualified_list_field, unqualified_struct_field, optional_int_field, optional_bool_field, optional_list_field, optional_struct_field}); + } + + @Override + public int compareTo(TestStruct other) { + if (other == null) { + // See java.lang.Comparable docs + throw new NullPointerException(); + } + + if (other == this) { + return 0; + } + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetUnqualified_int_field()).compareTo(other.isSetUnqualified_int_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_int_field, other.unqualified_int_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_bool_field()).compareTo(other.isSetUnqualified_bool_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_bool_field, other.unqualified_bool_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_list_field()).compareTo(other.isSetUnqualified_list_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_list_field, other.unqualified_list_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetUnqualified_struct_field()).compareTo(other.isSetUnqualified_struct_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(unqualified_struct_field, other.unqualified_struct_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_int_field()).compareTo(other.isSetOptional_int_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_int_field, other.optional_int_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_bool_field()).compareTo(other.isSetOptional_bool_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_bool_field, other.optional_bool_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_list_field()).compareTo(other.isSetOptional_list_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_list_field, other.optional_list_field); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetOptional_struct_field()).compareTo(other.isSetOptional_struct_field()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(optional_struct_field, other.optional_struct_field); + if (lastComparison != 0) { + return lastComparison; + } + 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) + { + case UNQUALIFIED_INT_FIELD: + if (__field.type == TType.I32) { + this.unqualified_int_field = iprot.readI32(); + setUnqualified_int_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_BOOL_FIELD: + if (__field.type == TType.BOOL) { + this.unqualified_bool_field = iprot.readBool(); + setUnqualified_bool_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list0 = iprot.readListBegin(); + this.unqualified_list_field = new ArrayList(Math.max(0, _list0.size)); + for (int _i1 = 0; + (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); + ++_i1) + { + int _elem2; + _elem2 = iprot.readI32(); + this.unqualified_list_field.add(_elem2); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case UNQUALIFIED_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + this.unqualified_struct_field = new EmptyStruct(); + this.unqualified_struct_field.read(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_INT_FIELD: + if (__field.type == TType.I32) { + this.optional_int_field = iprot.readI32(); + setOptional_int_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_BOOL_FIELD: + if (__field.type == TType.BOOL) { + this.optional_bool_field = iprot.readBool(); + setOptional_bool_fieldIsSet(true); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_LIST_FIELD: + if (__field.type == TType.LIST) { + { + TList _list3 = iprot.readListBegin(); + this.optional_list_field = new ArrayList(Math.max(0, _list3.size)); + for (int _i4 = 0; + (_list3.size < 0) ? iprot.peekList() : (_i4 < _list3.size); + ++_i4) + { + int _elem5; + _elem5 = iprot.readI32(); + this.optional_list_field.add(_elem5); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + case OPTIONAL_STRUCT_FIELD: + if (__field.type == TType.STRUCT) { + this.optional_struct_field = new EmptyStruct(); + this.optional_struct_field.read(iprot); + } else { + TProtocolUtil.skip(iprot, __field.type); + } + break; + 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.writeFieldBegin(UNQUALIFIED_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.unqualified_int_field); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(UNQUALIFIED_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.unqualified_bool_field); + oprot.writeFieldEnd(); + if (this.unqualified_list_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.unqualified_list_field.size())); + for (int _iter6 : this.unqualified_list_field) { + oprot.writeI32(_iter6); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (this.unqualified_struct_field != null) { + oprot.writeFieldBegin(UNQUALIFIED_STRUCT_FIELD_FIELD_DESC); + this.unqualified_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + if (isSetOptional_int_field()) { + oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC); + oprot.writeI32(this.optional_int_field); + oprot.writeFieldEnd(); + } + if (isSetOptional_bool_field()) { + oprot.writeFieldBegin(OPTIONAL_BOOL_FIELD_FIELD_DESC); + oprot.writeBool(this.optional_bool_field); + oprot.writeFieldEnd(); + } + if (this.optional_list_field != null) { + if (isSetOptional_list_field()) { + oprot.writeFieldBegin(OPTIONAL_LIST_FIELD_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.I32, this.optional_list_field.size())); + for (int _iter7 : this.optional_list_field) { + oprot.writeI32(_iter7); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (this.optional_struct_field != null) { + if (isSetOptional_struct_field()) { + oprot.writeFieldBegin(OPTIONAL_STRUCT_FIELD_FIELD_DESC); + this.optional_struct_field.write(oprot); + oprot.writeFieldEnd(); + } + } + 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("TestStruct"); + sb.append(space); + sb.append("("); + sb.append(newLine); + boolean first = true; + + sb.append(indentStr); + sb.append("unqualified_int_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.getUnqualified_int_field(), indent + 1, prettyPrint)); + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_bool_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.isUnqualified_bool_field(), indent + 1, prettyPrint)); + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_list_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getUnqualified_list_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getUnqualified_list_field(), indent + 1, prettyPrint)); + } + first = false; + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("unqualified_struct_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getUnqualified_struct_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getUnqualified_struct_field(), indent + 1, prettyPrint)); + } + first = false; + if (isSetOptional_int_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_int_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.getOptional_int_field(), indent + 1, prettyPrint)); + first = false; + } + if (isSetOptional_bool_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_bool_field"); + sb.append(space); + sb.append(":").append(space); + sb.append(TBaseHelper.toString(this.isOptional_bool_field(), indent + 1, prettyPrint)); + first = false; + } + if (isSetOptional_list_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_list_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getOptional_list_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getOptional_list_field(), indent + 1, prettyPrint)); + } + first = false; + } + if (isSetOptional_struct_field()) + { + if (!first) sb.append("," + newLine); + sb.append(indentStr); + sb.append("optional_struct_field"); + sb.append(space); + sb.append(":").append(space); + if (this.getOptional_struct_field() == null) { + sb.append("null"); + } else { + sb.append(TBaseHelper.toString(this.getOptional_struct_field(), indent + 1, prettyPrint)); + } + first = false; + } + 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/default_values_rectification_before/out/json/gen-json/module.json b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/json/gen-json/module.json new file mode 100644 index 00000000000000..1ace542807bf1f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/json/gen-json/module.json @@ -0,0 +1,169 @@ +{ + "__fbthrift": {"@generated": 0}, + "thrift_module" : "module", + "structs" : { + "EmptyStruct" : { + "lineno" : 19, + "is_exception" : false, + "is_union" : false, + "fields" : { + + }, + "source_range" : { + "begin" : { + "line" : 19, + "column" : 1 + }, + "end" : { + "line" : 19, + "column" : 22 + } + } + }, + "TestStruct" : { + "lineno" : 21, + "is_exception" : false, + "is_union" : false, + "fields" : { + "unqualified_int_field" : { + "type_enum" : "I32", + "spec_args" : null, + "required" : true, + "default_value" : 0, + "source_range" : { + "begin" : { + "line" : 22, + "column" : 3 + }, + "end" : { + "line" : 22, + "column" : 36 + } + } + }, + "unqualified_bool_field" : { + "type_enum" : "BOOL", + "spec_args" : null, + "required" : true, + "default_value" : false, + "source_range" : { + "begin" : { + "line" : 24, + "column" : 3 + }, + "end" : { + "line" : 24, + "column" : 42 + } + } + }, + "unqualified_list_field" : { + "type_enum" : "LIST", + "spec_args" : { "type_enum" : "I32", "spec_args" : null} , + "required" : true, + "default_value" : [ ], + "source_range" : { + "begin" : { + "line" : 26, + "column" : 3 + }, + "end" : { + "line" : 26, + "column" : 44 + } + } + }, + "unqualified_struct_field" : { + "type_enum" : "STRUCT", + "spec_args" : "EmptyStruct", + "required" : true, + "default_value" : { }, + "source_range" : { + "begin" : { + "line" : 28, + "column" : 3 + }, + "end" : { + "line" : 28, + "column" : 48 + } + } + }, + "optional_int_field" : { + "type_enum" : "I32", + "spec_args" : null, + "required" : false, + "default_value" : 42, + "source_range" : { + "begin" : { + "line" : 30, + "column" : 3 + }, + "end" : { + "line" : 30, + "column" : 43 + } + } + }, + "optional_bool_field" : { + "type_enum" : "BOOL", + "spec_args" : null, + "required" : false, + "default_value" : true, + "source_range" : { + "begin" : { + "line" : 32, + "column" : 3 + }, + "end" : { + "line" : 32, + "column" : 47 + } + } + }, + "optional_list_field" : { + "type_enum" : "LIST", + "spec_args" : { "type_enum" : "I32", "spec_args" : null} , + "required" : false, + "default_value" : [ 1, 2 ], + "source_range" : { + "begin" : { + "line" : 34, + "column" : 3 + }, + "end" : { + "line" : 34, + "column" : 54 + } + } + }, + "optional_struct_field" : { + "type_enum" : "STRUCT", + "spec_args" : "EmptyStruct", + "required" : false, + "default_value" : { }, + "source_range" : { + "begin" : { + "line" : 36, + "column" : 3 + }, + "end" : { + "line" : 36, + "column" : 54 + } + } + } + }, + "source_range" : { + "begin" : { + "line" : 21, + "column" : 1 + }, + "end" : { + "line" : 37, + "column" : 2 + } + } + } + } +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/json_experimental/gen-json_experimental/module.json b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/json_experimental/gen-json_experimental/module.json new file mode 100644 index 00000000000000..abb75fc375a89f --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/json_experimental/gen-json_experimental/module.json @@ -0,0 +1,105 @@ +{ + "__fbthrift": "@generated", + "thrift_module" : "module", + "package": { + "domain_prefix": "facebook", + "domain_suffix": "com", + "path": "thrift/compiler/test/fixtures/default_values_rectification", + "filename": "module" + }, + "structs" : + { + "EmptyStruct" : { + "name" : "EmptyStruct", + "is_exception" : false, + "is_union" : false, + "lineno" : 19 + }, + "TestStruct" : { + "name" : "TestStruct", + "fields" : { + "unqualified_int_field" : { + "name" : "unqualified_int_field", + "default_value" : 0, + "key" : 1, + "lineno" : 22, + "required" : "opt-in-req-out", + "type" : "i32" + }, + "unqualified_bool_field" : { + "name" : "unqualified_bool_field", + "default_value" : 0, + "key" : 2, + "lineno" : 24, + "required" : "opt-in-req-out", + "type" : "bool" + }, + "unqualified_list_field" : { + "name" : "unqualified_list_field", + "default_value" : [], + "key" : 3, + "lineno" : 26, + "required" : "opt-in-req-out", + "type" : { + "type" : "list", + "inner_type" : "i32" + } + }, + "unqualified_struct_field" : { + "name" : "unqualified_struct_field", + "default_value" : {}, + "key" : 4, + "lineno" : 28, + "required" : "opt-in-req-out", + "type" : { + "type" : "struct", + "name" : "EmptyStruct" + } + }, + "optional_int_field" : { + "name" : "optional_int_field", + "default_value" : 42, + "key" : 5, + "lineno" : 30, + "required" : "optional", + "type" : "i32" + }, + "optional_bool_field" : { + "name" : "optional_bool_field", + "default_value" : 1, + "key" : 6, + "lineno" : 32, + "required" : "optional", + "type" : "bool" + }, + "optional_list_field" : { + "name" : "optional_list_field", + "default_value" : [1,2], + "key" : 7, + "lineno" : 34, + "required" : "optional", + "type" : { + "type" : "list", + "inner_type" : "i32" + } + }, + "optional_struct_field" : { + "name" : "optional_struct_field", + "default_value" : {}, + "key" : 8, + "lineno" : 36, + "required" : "optional", + "type" : { + "type" : "struct", + "name" : "EmptyStruct" + } + } + }, + "is_exception" : false, + "is_union" : false, + "lineno" : 21 + } + }, + "source_path" : "thrift/compiler/test/fixtures/default_values_rectification_before/src/module", + "py_namespace" : "" +} diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/__init__.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/__init__.py new file mode 100644 index 00000000000000..8bb216b5496dc9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/__init__.py @@ -0,0 +1,6 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/__init__.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/__init__.py new file mode 100644 index 00000000000000..451f5c6391ddaf --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/__init__.py @@ -0,0 +1,7 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# +__all__ = ['ttypes', 'constants'] diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/constants.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/constants.py new file mode 100644 index 00000000000000..d447c44dca9113 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/constants.py @@ -0,0 +1,17 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# + +from __future__ import absolute_import +import sys +from thrift.util.Recursive import fix_spec +from thrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef +from thrift.protocol.TProtocol import TProtocolException + + + +from .ttypes import UTF8STRINGS, EmptyStruct, TestStruct + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/ttypes.py b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/ttypes.py new file mode 100644 index 00000000000000..02412c0a455c99 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py/gen-py/module/ttypes.py @@ -0,0 +1,440 @@ +# +# Autogenerated by Thrift +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# @generated +# + +from __future__ import absolute_import +import sys +from thrift.util.Recursive import fix_spec +from thrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef +from thrift.protocol.TProtocol import TProtocolException + + + +import pprint +import warnings +from thrift import Thrift +from thrift.transport import TTransport +from thrift.protocol import TBinaryProtocol +from thrift.protocol import TCompactProtocol +from thrift.protocol import THeaderProtocol +fastproto = None +try: + from thrift.protocol import fastproto +except ImportError: + pass + +def __EXPAND_THRIFT_SPEC(spec): + next_id = 0 + for item in spec: + item_id = item[0] + if next_id >= 0 and item_id < 0: + next_id = item_id + if item_id != next_id: + for _ in range(next_id, item_id): + yield None + yield item + next_id = item_id + 1 + +class ThriftEnumWrapper(int): + def __new__(cls, enum_class, value): + return super().__new__(cls, value) + def __init__(self, enum_class, value): self.enum_class = enum_class + def __repr__(self): + return self.enum_class.__name__ + '.' + self.enum_class._VALUES_TO_NAMES[self] + +all_structs = [] +UTF8STRINGS = bool(0) or sys.version_info.major >= 3 + +__all__ = ['UTF8STRINGS', 'EmptyStruct', 'TestStruct'] + +class EmptyStruct: + + 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('EmptyStruct') + 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.compiler.test.fixtures.default_values_rectification.module.thrift_types") + return thrift.python.converter.to_python_struct(python_types.EmptyStruct, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.EmptyStruct, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.types") + return thrift.py3.converter.to_py3_struct(py3_types.EmptyStruct, self) + + def _to_py_deprecated(self): + return self + +class TestStruct: + r""" + Attributes: + - unqualified_int_field + - unqualified_bool_field + - unqualified_list_field + - unqualified_struct_field + - optional_int_field + - optional_bool_field + - optional_list_field + - optional_struct_field + """ + + thrift_spec = None + thrift_field_annotations = None + thrift_struct_annotations = None + __init__ = 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 + if fid == 1: + if ftype == TType.I32: + self.unqualified_int_field = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.unqualified_bool_field = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.unqualified_list_field = [] + (_etype3, _size0) = iprot.readListBegin() + if _size0 >= 0: + for _i4 in range(_size0): + _elem5 = iprot.readI32() + self.unqualified_list_field.append(_elem5) + else: + while iprot.peekList(): + _elem6 = iprot.readI32() + self.unqualified_list_field.append(_elem6) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.unqualified_struct_field = EmptyStruct() + self.unqualified_struct_field.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I32: + self.optional_int_field = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.BOOL: + self.optional_bool_field = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 7: + if ftype == TType.LIST: + self.optional_list_field = [] + (_etype10, _size7) = iprot.readListBegin() + if _size7 >= 0: + for _i11 in range(_size7): + _elem12 = iprot.readI32() + self.optional_list_field.append(_elem12) + else: + while iprot.peekList(): + _elem13 = iprot.readI32() + self.optional_list_field.append(_elem13) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.STRUCT: + self.optional_struct_field = EmptyStruct() + self.optional_struct_field.read(iprot) + else: + iprot.skip(ftype) + 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('TestStruct') + if self.unqualified_int_field != None: + oprot.writeFieldBegin('unqualified_int_field', TType.I32, 1) + oprot.writeI32(self.unqualified_int_field) + oprot.writeFieldEnd() + if self.unqualified_bool_field != None: + oprot.writeFieldBegin('unqualified_bool_field', TType.BOOL, 2) + oprot.writeBool(self.unqualified_bool_field) + oprot.writeFieldEnd() + if self.unqualified_list_field != None: + oprot.writeFieldBegin('unqualified_list_field', TType.LIST, 3) + oprot.writeListBegin(TType.I32, len(self.unqualified_list_field)) + for iter14 in self.unqualified_list_field: + oprot.writeI32(iter14) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.unqualified_struct_field != None: + oprot.writeFieldBegin('unqualified_struct_field', TType.STRUCT, 4) + self.unqualified_struct_field.write(oprot) + oprot.writeFieldEnd() + if self.optional_int_field != None and self.optional_int_field != self.thrift_spec[5][4]: + oprot.writeFieldBegin('optional_int_field', TType.I32, 5) + oprot.writeI32(self.optional_int_field) + oprot.writeFieldEnd() + if self.optional_bool_field != None and self.optional_bool_field != self.thrift_spec[6][4]: + oprot.writeFieldBegin('optional_bool_field', TType.BOOL, 6) + oprot.writeBool(self.optional_bool_field) + oprot.writeFieldEnd() + if self.optional_list_field != None and self.optional_list_field != self.thrift_spec[7][4]: + oprot.writeFieldBegin('optional_list_field', TType.LIST, 7) + oprot.writeListBegin(TType.I32, len(self.optional_list_field)) + for iter15 in self.optional_list_field: + oprot.writeI32(iter15) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.optional_struct_field != None and self.optional_struct_field != self.thrift_spec[8][4]: + oprot.writeFieldBegin('optional_struct_field', TType.STRUCT, 8) + self.optional_struct_field.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def __repr__(self): + L = [] + padding = ' ' * 4 + if self.unqualified_int_field is not None: + value = pprint.pformat(self.unqualified_int_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_int_field=%s' % (value)) + if self.unqualified_bool_field is not None: + value = pprint.pformat(self.unqualified_bool_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_bool_field=%s' % (value)) + if self.unqualified_list_field is not None: + value = pprint.pformat(self.unqualified_list_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_list_field=%s' % (value)) + if self.unqualified_struct_field is not None: + value = pprint.pformat(self.unqualified_struct_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' unqualified_struct_field=%s' % (value)) + if self.optional_int_field is not None: + value = pprint.pformat(self.optional_int_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_int_field=%s' % (value)) + if self.optional_bool_field is not None: + value = pprint.pformat(self.optional_bool_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_bool_field=%s' % (value)) + if self.optional_list_field is not None: + value = pprint.pformat(self.optional_list_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_list_field=%s' % (value)) + if self.optional_struct_field is not None: + value = pprint.pformat(self.optional_struct_field, indent=0) + value = padding.join(value.splitlines(True)) + L.append(' optional_struct_field=%s' % (value)) + 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 ( + 'unqualified_int_field', + 'unqualified_bool_field', + 'unqualified_list_field', + 'unqualified_struct_field', + 'optional_int_field', + 'optional_bool_field', + 'optional_list_field', + 'optional_struct_field', + ) + + __hash__ = object.__hash__ + + def _to_python(self): + import importlib + import thrift.python.converter + python_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_types") + return thrift.python.converter.to_python_struct(python_types.TestStruct, self) + + def _to_mutable_python(self): + import importlib + import thrift.python.mutable_converter + python_mutable_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.thrift_mutable_types") + return thrift.python.mutable_converter.to_mutable_python_struct_or_union(python_mutable_types.TestStruct, self) + + def _to_py3(self): + import importlib + import thrift.py3.converter + py3_types = importlib.import_module("facebook.thrift.compiler.test.fixtures.default_values_rectification.module.types") + return thrift.py3.converter.to_py3_struct(py3_types.TestStruct, self) + + def _to_py_deprecated(self): + return self + +all_structs.append(EmptyStruct) +EmptyStruct.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( +))) + +EmptyStruct.thrift_struct_annotations = { +} +EmptyStruct.thrift_field_annotations = { +} + +all_structs.append(TestStruct) +TestStruct.thrift_spec = tuple(__EXPAND_THRIFT_SPEC(( + (1, TType.I32, 'unqualified_int_field', None, 0, 2, ), # 1 + (2, TType.BOOL, 'unqualified_bool_field', None, False, 2, ), # 2 + (3, TType.LIST, 'unqualified_list_field', (TType.I32,None), [ + ], 2, ), # 3 + (4, TType.STRUCT, 'unqualified_struct_field', [EmptyStruct, EmptyStruct.thrift_spec, False], EmptyStruct(**{ + }), 2, ), # 4 + (5, TType.I32, 'optional_int_field', None, 42, 1, ), # 5 + (6, TType.BOOL, 'optional_bool_field', None, True, 1, ), # 6 + (7, TType.LIST, 'optional_list_field', (TType.I32,None), [ + 1, + 2, + ], 1, ), # 7 + (8, TType.STRUCT, 'optional_struct_field', [EmptyStruct, EmptyStruct.thrift_spec, False], EmptyStruct(**{ + }), 1, ), # 8 +))) + +TestStruct.thrift_struct_annotations = { +} +TestStruct.thrift_field_annotations = { +} + +def TestStruct__init__(self, unqualified_int_field=TestStruct.thrift_spec[1][4], unqualified_bool_field=TestStruct.thrift_spec[2][4], unqualified_list_field=TestStruct.thrift_spec[3][4], unqualified_struct_field=TestStruct.thrift_spec[4][4], optional_int_field=TestStruct.thrift_spec[5][4], optional_bool_field=TestStruct.thrift_spec[6][4], optional_list_field=TestStruct.thrift_spec[7][4], optional_struct_field=TestStruct.thrift_spec[8][4],): + self.unqualified_int_field = unqualified_int_field + self.unqualified_bool_field = unqualified_bool_field + if unqualified_list_field is self.thrift_spec[3][4]: + unqualified_list_field = [ + ] + self.unqualified_list_field = unqualified_list_field + if unqualified_struct_field is self.thrift_spec[4][4]: + unqualified_struct_field = EmptyStruct(**{ + }) + self.unqualified_struct_field = unqualified_struct_field + self.optional_int_field = optional_int_field + self.optional_bool_field = optional_bool_field + if optional_list_field is self.thrift_spec[7][4]: + optional_list_field = [ + 1, + 2, + ] + self.optional_list_field = optional_list_field + if optional_struct_field is self.thrift_spec[8][4]: + optional_struct_field = EmptyStruct(**{ + }) + self.optional_struct_field = optional_struct_field + +TestStruct.__init__ = TestStruct__init__ + +def TestStruct__setstate__(self, state): + state.setdefault('unqualified_int_field', 0) + state.setdefault('unqualified_bool_field', False) + state.setdefault('unqualified_list_field', [ + ]) + state.setdefault('unqualified_struct_field', EmptyStruct(**{ + })) + state.setdefault('optional_int_field', 42) + state.setdefault('optional_bool_field', True) + state.setdefault('optional_list_field', [ + 1, + 2, + ]) + state.setdefault('optional_struct_field', EmptyStruct(**{ + })) + self.__dict__ = state + +TestStruct.__getstate__ = lambda self: self.__dict__.copy() +TestStruct.__setstate__ = TestStruct__setstate__ + +fix_spec(all_structs) +del all_structs diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.cpp b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.cpp new file mode 100644 index 00000000000000..bc0b12b2ecd94d --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.cpp @@ -0,0 +1,28 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-py3/module/metadata.h" + +namespace facebook { +namespace thrift { +namespace compiler { +namespace test { +namespace fixtures { +namespace default_values_rectification { +::apache::thrift::metadata::ThriftMetadata module_getThriftModuleMetadata() { + ::apache::thrift::metadata::ThriftServiceMetadataResponse response; + ::apache::thrift::metadata::ThriftMetadata& metadata = *response.metadata_ref(); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); + ::apache::thrift::detail::md::StructMetadata::gen(metadata); + return metadata; +} +} // namespace facebook +} // namespace thrift +} // namespace compiler +} // namespace test +} // namespace fixtures +} // namespace default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.h new file mode 100644 index 00000000000000..f7cf3b8ae33a30 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/metadata.h @@ -0,0 +1,26 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#pragma once + +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" + +namespace facebook { +namespace thrift { +namespace compiler { +namespace test { +namespace fixtures { +namespace default_values_rectification { +::apache::thrift::metadata::ThriftMetadata module_getThriftModuleMetadata(); +} // namespace facebook +} // namespace thrift +} // namespace compiler +} // namespace test +} // namespace fixtures +} // namespace default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/types.h b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/types.h new file mode 100644 index 00000000000000..9842711f6134de --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/py3/gen-py3/module/types.h @@ -0,0 +1,79 @@ +/** + * Autogenerated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ + +#pragma once + +#include +#include + +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_data.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_types.h" +#include "thrift/compiler/test/fixtures/default_values_rectification_before/gen-cpp2/module_metadata.h" +namespace thrift { +namespace py3 { + + + +template<> +inline void reset_field<::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>( + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct& obj, uint16_t index) { + switch (index) { + } +} + +template<> +inline void reset_field<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>( + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct& obj, uint16_t index) { + switch (index) { + case 0: + obj.unqualified_int_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_int_field_ref()); + return; + case 1: + obj.unqualified_bool_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_bool_field_ref()); + return; + case 2: + obj.unqualified_list_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_list_field_ref()); + return; + case 3: + obj.unqualified_struct_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().unqualified_struct_field_ref()); + return; + case 4: + obj.optional_int_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_int_field_ref()); + return; + case 5: + obj.optional_bool_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_bool_field_ref()); + return; + case 6: + obj.optional_list_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_list_field_ref()); + return; + case 7: + obj.optional_struct_field_ref().copy_from(default_inst<::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>().optional_struct_field_ref()); + return; + } +} + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::EmptyStruct>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} + +template<> +inline const std::unordered_map& PyStructTraits< + ::facebook::thrift::compiler::test::fixtures::default_values_rectification::TestStruct>::namesmap() { + static const folly::Indestructible map { + { + } + }; + return *map; +} +} // namespace py3 +} // namespace thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/client.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/client.rs new file mode 100644 index 00000000000000..05e24c4183a898 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/client.rs @@ -0,0 +1,8 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies, unused_imports)] + +pub use :: as types; +pub(crate) use crate as client; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/consts.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/consts.rs new file mode 100644 index 00000000000000..503b4c31fdd10d --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/consts.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift constant definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/errors.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/errors.rs new file mode 100644 index 00000000000000..dc7c2b934f4894 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/errors.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift error definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/mock.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/mock.rs new file mode 100644 index 00000000000000..1be98e1127d89e --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/mock.rs @@ -0,0 +1,7 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies, unused_imports)] + +pub(crate) use :: as types; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-cpp2 b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-cpp2 new file mode 100644 index 00000000000000..ce5ed52fc7f197 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-cpp2 @@ -0,0 +1 @@ +::facebook::thrift::compiler::test::fixtures::default_values_rectification diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-rust b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-rust new file mode 100644 index 00000000000000..0cca093d7af2d9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/namespace-rust @@ -0,0 +1 @@ +module diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/server.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/server.rs new file mode 100644 index 00000000000000..d0376d19eefa82 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/server.rs @@ -0,0 +1,7 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +#![doc(hidden)] +#![allow(non_snake_case, unused_crate_dependencies)] + +pub use :: as types; diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/service-names b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/service-names new file mode 100644 index 00000000000000..8b137891791fe9 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/service-names @@ -0,0 +1 @@ + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/services.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/services.rs new file mode 100644 index 00000000000000..cc76fc4cf2b9d1 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/services.rs @@ -0,0 +1,5 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + +//! Thrift service definitions for `module`. + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/types.rs b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/types.rs new file mode 100644 index 00000000000000..07bd3d20c16fad --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/out/rust/gen-rust/types.rs @@ -0,0 +1,376 @@ +// @generated by Thrift for thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift +// This file is probably not the place you want to edit! + + +#![recursion_limit = "100000000"] +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, clippy::redundant_closure, clippy::type_complexity)] + +#[allow(unused_imports)] +pub(crate) use crate as types; + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct EmptyStruct { + // This field forces `..Default::default()` when instantiating this + // struct, to make code future-proof against new fields added later to + // the definition in Thrift. If you don't want this, add the annotation + // `@rust.Exhaustive` to the Thrift struct to eliminate this field. + #[doc(hidden)] + pub _dot_dot_Default_default: self::dot_dot::OtherFields, +} + +#[derive(Clone, PartialEq)] +pub struct TestStruct { + pub unqualified_int_field: ::std::primitive::i32, + pub unqualified_bool_field: ::std::primitive::bool, + pub unqualified_list_field: ::std::vec::Vec<::std::primitive::i32>, + pub unqualified_struct_field: crate::types::EmptyStruct, + pub optional_int_field: ::std::option::Option<::std::primitive::i32>, + pub optional_bool_field: ::std::option::Option<::std::primitive::bool>, + pub optional_list_field: ::std::option::Option<::std::vec::Vec<::std::primitive::i32>>, + pub optional_struct_field: ::std::option::Option, + // This field forces `..Default::default()` when instantiating this + // struct, to make code future-proof against new fields added later to + // the definition in Thrift. If you don't want this, add the annotation + // `@rust.Exhaustive` to the Thrift struct to eliminate this field. + #[doc(hidden)] + pub _dot_dot_Default_default: self::dot_dot::OtherFields, +} + + + +#[allow(clippy::derivable_impls)] +impl ::std::default::Default for self::EmptyStruct { + fn default() -> Self { + Self { + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + } + } +} + +impl ::std::fmt::Debug for self::EmptyStruct { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + formatter + .debug_struct("EmptyStruct") + .finish() + } +} + +unsafe impl ::std::marker::Send for self::EmptyStruct {} +unsafe impl ::std::marker::Sync for self::EmptyStruct {} +impl ::std::marker::Unpin for self::EmptyStruct {} +impl ::std::panic::RefUnwindSafe for self::EmptyStruct {} +impl ::std::panic::UnwindSafe for self::EmptyStruct {} + +impl ::fbthrift::GetTType for self::EmptyStruct { + const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; +} + +impl ::fbthrift::GetUri for self::EmptyStruct { + fn uri() -> &'static ::std::primitive::str { + "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/EmptyStruct" + } +} + +impl ::fbthrift::GetTypeNameType for self::EmptyStruct { + fn type_name_type() -> fbthrift::TypeNameType { + ::fbthrift::TypeNameType::StructType + } +} + +impl

::fbthrift::Serialize

for self::EmptyStruct +where + P: ::fbthrift::ProtocolWriter, +{ + #[inline] + fn write(&self, p: &mut P) { + p.write_struct_begin("EmptyStruct"); + p.write_field_stop(); + p.write_struct_end(); + } +} + +impl

::fbthrift::Deserialize

for self::EmptyStruct +where + P: ::fbthrift::ProtocolReader, +{ + #[inline] + fn read(p: &mut P) -> ::anyhow::Result { + static FIELDS: &[::fbthrift::Field] = &[ + ]; + #[allow(unused_mut)] + let mut fields = Self { + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + }; + let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a EmptyStruct")?; + loop { + let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; + match (fty, fid as ::std::primitive::i32) { + (::fbthrift::TType::Stop, _) => break, + (fty, _) => p.skip(fty)?, + } + p.read_field_end()?; + } + p.read_struct_end()?; + ::std::result::Result::Ok(fields) + } +} + + +impl ::fbthrift::metadata::ThriftAnnotations for EmptyStruct { + fn get_structured_annotation() -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + ::std::option::Option::None + } + + fn get_field_structured_annotation(field_id: ::std::primitive::i16) -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + #[allow(clippy::match_single_binding)] + match field_id { + _ => {} + } + + ::std::option::Option::None + } +} + + +#[allow(clippy::derivable_impls)] +impl ::std::default::Default for self::TestStruct { + fn default() -> Self { + Self { + unqualified_int_field: 0, + unqualified_bool_field: false, + unqualified_list_field: ::std::vec::Vec::new(), + unqualified_struct_field: crate::types::EmptyStruct { + ..::std::default::Default::default() + }, + optional_int_field: ::std::option::Option::None, + optional_bool_field: ::std::option::Option::None, + optional_list_field: ::std::option::Option::None, + optional_struct_field: ::std::option::Option::None, + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + } + } +} + +impl ::std::fmt::Debug for self::TestStruct { + fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + formatter + .debug_struct("TestStruct") + .field("unqualified_int_field", &self.unqualified_int_field) + .field("unqualified_bool_field", &self.unqualified_bool_field) + .field("unqualified_list_field", &self.unqualified_list_field) + .field("unqualified_struct_field", &self.unqualified_struct_field) + .field("optional_int_field", &self.optional_int_field) + .field("optional_bool_field", &self.optional_bool_field) + .field("optional_list_field", &self.optional_list_field) + .field("optional_struct_field", &self.optional_struct_field) + .finish() + } +} + +unsafe impl ::std::marker::Send for self::TestStruct {} +unsafe impl ::std::marker::Sync for self::TestStruct {} +impl ::std::marker::Unpin for self::TestStruct {} +impl ::std::panic::RefUnwindSafe for self::TestStruct {} +impl ::std::panic::UnwindSafe for self::TestStruct {} + +impl ::fbthrift::GetTType for self::TestStruct { + const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; +} + +impl ::fbthrift::GetUri for self::TestStruct { + fn uri() -> &'static ::std::primitive::str { + "facebook.com/thrift/compiler/test/fixtures/default_values_rectification/TestStruct" + } +} + +impl ::fbthrift::GetTypeNameType for self::TestStruct { + fn type_name_type() -> fbthrift::TypeNameType { + ::fbthrift::TypeNameType::StructType + } +} + +impl

::fbthrift::Serialize

for self::TestStruct +where + P: ::fbthrift::ProtocolWriter, +{ + #[inline] + fn write(&self, p: &mut P) { + p.write_struct_begin("TestStruct"); + p.write_field_begin("unqualified_int_field", ::fbthrift::TType::I32, 1); + ::fbthrift::Serialize::write(&self.unqualified_int_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_bool_field", ::fbthrift::TType::Bool, 2); + ::fbthrift::Serialize::write(&self.unqualified_bool_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_list_field", ::fbthrift::TType::List, 3); + ::fbthrift::Serialize::write(&self.unqualified_list_field, p); + p.write_field_end(); + p.write_field_begin("unqualified_struct_field", ::fbthrift::TType::Struct, 4); + ::fbthrift::Serialize::write(&self.unqualified_struct_field, p); + p.write_field_end(); + if let ::std::option::Option::Some(some) = &self.optional_int_field { + p.write_field_begin("optional_int_field", ::fbthrift::TType::I32, 5); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_bool_field { + p.write_field_begin("optional_bool_field", ::fbthrift::TType::Bool, 6); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_list_field { + p.write_field_begin("optional_list_field", ::fbthrift::TType::List, 7); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + if let ::std::option::Option::Some(some) = &self.optional_struct_field { + p.write_field_begin("optional_struct_field", ::fbthrift::TType::Struct, 8); + ::fbthrift::Serialize::write(some, p); + p.write_field_end(); + } + p.write_field_stop(); + p.write_struct_end(); + } +} + +impl

::fbthrift::Deserialize

for self::TestStruct +where + P: ::fbthrift::ProtocolReader, +{ + #[inline] + fn read(p: &mut P) -> ::anyhow::Result { + static FIELDS: &[::fbthrift::Field] = &[ + ::fbthrift::Field::new("optional_bool_field", ::fbthrift::TType::Bool, 6), + ::fbthrift::Field::new("optional_int_field", ::fbthrift::TType::I32, 5), + ::fbthrift::Field::new("optional_list_field", ::fbthrift::TType::List, 7), + ::fbthrift::Field::new("optional_struct_field", ::fbthrift::TType::Struct, 8), + ::fbthrift::Field::new("unqualified_bool_field", ::fbthrift::TType::Bool, 2), + ::fbthrift::Field::new("unqualified_int_field", ::fbthrift::TType::I32, 1), + ::fbthrift::Field::new("unqualified_list_field", ::fbthrift::TType::List, 3), + ::fbthrift::Field::new("unqualified_struct_field", ::fbthrift::TType::Struct, 4), + ]; + let mut field_unqualified_int_field = ::std::option::Option::None; + let mut field_unqualified_bool_field = ::std::option::Option::None; + let mut field_unqualified_list_field = ::std::option::Option::None; + let mut field_unqualified_struct_field = ::std::option::Option::None; + let mut field_optional_int_field = ::std::option::Option::None; + let mut field_optional_bool_field = ::std::option::Option::None; + let mut field_optional_list_field = ::std::option::Option::None; + let mut field_optional_struct_field = ::std::option::Option::None; + let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a TestStruct")?; + loop { + let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; + match (fty, fid as ::std::primitive::i32) { + (::fbthrift::TType::Stop, _) => break, + (::fbthrift::TType::I32, 1) => field_unqualified_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Bool, 2) => field_unqualified_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::List, 3) => field_unqualified_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Struct, 4) => field_unqualified_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::I32, 5) => field_optional_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Bool, 6) => field_optional_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::List, 7) => field_optional_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (::fbthrift::TType::Struct, 8) => field_optional_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), + (fty, _) => p.skip(fty)?, + } + p.read_field_end()?; + } + p.read_struct_end()?; + ::std::result::Result::Ok(Self { + unqualified_int_field: field_unqualified_int_field.unwrap_or(0), + unqualified_bool_field: field_unqualified_bool_field.unwrap_or(false), + unqualified_list_field: field_unqualified_list_field.unwrap_or_else(|| ::std::vec::Vec::new()), + unqualified_struct_field: field_unqualified_struct_field.unwrap_or_else(|| crate::types::EmptyStruct { + ..::std::default::Default::default() + }), + optional_int_field: field_optional_int_field, + optional_bool_field: field_optional_bool_field, + optional_list_field: field_optional_list_field, + optional_struct_field: field_optional_struct_field, + _dot_dot_Default_default: self::dot_dot::OtherFields(()), + }) + } +} + + +impl ::fbthrift::metadata::ThriftAnnotations for TestStruct { + fn get_structured_annotation() -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + ::std::option::Option::None + } + + fn get_field_structured_annotation(field_id: ::std::primitive::i16) -> ::std::option::Option { + #[allow(unused_variables)] + let type_id = ::std::any::TypeId::of::(); + + #[allow(clippy::match_single_binding)] + match field_id { + 1 => { + }, + 2 => { + }, + 3 => { + }, + 4 => { + }, + 5 => { + }, + 6 => { + }, + 7 => { + }, + 8 => { + }, + _ => {} + } + + ::std::option::Option::None + } +} + + + +mod dot_dot { + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct OtherFields(pub(crate) ()); + + #[allow(dead_code)] // if serde isn't being used + pub(super) fn default_for_serde_deserialize() -> OtherFields { + OtherFields(()) + } +} + +pub(crate) mod r#impl { + use ::ref_cast::RefCast; + + #[derive(RefCast)] + #[repr(transparent)] + pub(crate) struct LocalImpl(T); + + #[allow(unused)] + pub(crate) fn write(value: &T, p: &mut P) + where + LocalImpl: ::fbthrift::Serialize

, + P: ::fbthrift::ProtocolWriter, + { + ::fbthrift::Serialize::write(LocalImpl::ref_cast(value), p); + } + + #[allow(unused)] + pub(crate) fn read(p: &mut P) -> ::anyhow::Result + where + LocalImpl: ::fbthrift::Deserialize

, + P: ::fbthrift::ProtocolReader, + { + let value: LocalImpl = ::fbthrift::Deserialize::read(p)?; + ::std::result::Result::Ok(value.0) + } +} + diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift new file mode 100644 index 00000000000000..d8e191101077c8 --- /dev/null +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/default_values_rectification_before/src/module.thrift @@ -0,0 +1,37 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package "facebook.com/thrift/compiler/test/fixtures/default_values_rectification" + +struct EmptyStruct {} + +struct TestStruct { + 1: i32 unqualified_int_field = 0; + + 2: bool unqualified_bool_field = false; + + 3: list unqualified_list_field = []; + + 4: EmptyStruct unqualified_struct_field = {}; + + 5: optional i32 optional_int_field = 42; + + 6: optional bool optional_bool_field = true; + + 7: optional list optional_list_field = [1, 2]; + + 8: optional EmptyStruct optional_struct_field = {}; +}