From 2adfd14c02383c006f4e1cf64ab3e22b61fb5bf7 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 1 Apr 2024 22:44:14 +0200 Subject: [PATCH] THRIFT-5750 Remove "ansistr_binary_" option Client: delphi Patch: Jens Geyer --- .../src/thrift/generate/t_delphi_generator.cc | 33 +++---------------- lib/delphi/src/Thrift.Protocol.pas | 28 ++++++++++++---- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index c91ff332eab..c5998365664 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -68,7 +68,6 @@ class t_delphi_generator : public t_oop_generator { has_const = false; std::map::const_iterator iter; - ansistr_binary_ = false; register_types_ = false; constprefix_ = false; old_names_ = false; @@ -78,10 +77,7 @@ class t_delphi_generator : public t_oop_generator { com_types_ = false; rtti_ = false; for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { - if( iter->first.compare("ansistr_binary") == 0) { - ansistr_binary_ = true; - pwarning(0, "The 'ansistr_binary' option is deprecated."); - } else if( iter->first.compare("register_types") == 0) { + if( iter->first.compare("register_types") == 0) { register_types_ = true; } else if( iter->first.compare("old_names") == 0) { old_names_ = true; @@ -102,10 +98,6 @@ class t_delphi_generator : public t_oop_generator { } } - if(com_types_ && ansistr_binary_) { - throw "com_types and ansistr_binary are mutually exclusive"; - } - out_dir_base_ = "gen-delphi"; escape_.clear(); escape_['\''] = "''"; @@ -468,7 +460,6 @@ class t_delphi_generator : public t_oop_generator { void init_known_types_list(); bool is_void(t_type* type); int indent_impl_; - bool ansistr_binary_; bool register_types_; bool constprefix_; bool old_names_; @@ -760,7 +751,6 @@ void t_delphi_generator::close_generator() { f_all << "const" << endl; indent_up(); - indent(f_all) << "c" << tmp_unit << "_Option_AnsiStr_Binary = " << (ansistr_binary_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << endl; @@ -2634,11 +2624,7 @@ void t_delphi_generator::generate_deserialize_field(ostream& out, break; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - out << "ReadAnsiString();"; - } else { - out << (com_types_ ? "ReadBinaryCOM();" : "ReadBinary();"); - } + out << (com_types_ ? "ReadBinaryCOM();" : "ReadBinary();"); } else { out << "ReadString();"; } @@ -2837,11 +2823,7 @@ void t_delphi_generator::generate_serialize_field(ostream& out, break; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - out << "WriteAnsiString("; - } else { - out << "WriteBinary("; - } + out << "WriteBinary("; } else { out << "WriteString("; } @@ -3180,8 +3162,6 @@ string t_delphi_generator::base_type_name(t_base_type* tbase) { return ""; case t_base_type::TYPE_STRING: if (tbase->is_binary()) { - if (ansistr_binary_) - return "System.AnsiString"; if( com_types_) return "IThriftBytes"; if( rtti_) @@ -3400,11 +3380,7 @@ string t_delphi_generator::empty_value(t_type* type) { return "0"; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - return "''"; - } else { - return "nil"; - } + return "nil"; } else { return "''"; } @@ -4072,7 +4048,6 @@ std::string t_delphi_generator::display_name() const { THRIFT_REGISTER_GENERATOR( delphi, "Delphi", - " ansistr_binary: Use AnsiString for binary datatype (default is TBytes).\n" " register_types: Enable TypeRegistry, allows for creation of struct, union\n" " and container instances by interface or TypeInfo()\n" " constprefix: Name TConstants classes after IDL to reduce ambiguities\n" diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index fd92da9b73b..7cfc2ae651b 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -232,7 +232,7 @@ TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRe procedure WriteI64( const i64: Int64); procedure WriteDouble( const d: Double); procedure WriteString( const s: string ); - procedure WriteAnsiString( const s: AnsiString); + procedure WriteAnsiString( const s: AnsiString); deprecated 'AnsiString routines are deprecated, see THRIFT-5750'; procedure WriteBinary( const b: TBytes); overload; procedure WriteBinary( const b: IThriftBytes); overload; procedure WriteUuid( const uuid: TGuid); @@ -259,7 +259,7 @@ TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRe function ReadBinaryCOM : IThriftBytes; function ReadUuid: TGuid; function ReadString: string; - function ReadAnsiString: AnsiString; + function ReadAnsiString: AnsiString; deprecated 'AnsiString routines are deprecated, see THRIFT-5750'; function NextRecursionLevel : IProtocolRecursionTracker; procedure IncrementRecursionDepth; @@ -311,7 +311,6 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) procedure WriteI64( const i64: Int64); virtual; abstract; procedure WriteDouble( const d: Double); virtual; abstract; procedure WriteString( const s: string ); virtual; - procedure WriteAnsiString( const s: AnsiString); virtual; procedure WriteBinary( const b: TBytes); overload; virtual; abstract; procedure WriteUuid( const b: TGuid); virtual; abstract; @@ -336,7 +335,6 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) function ReadBinary: TBytes; virtual; abstract; function ReadUuid: TGuid; virtual; abstract; function ReadString: string; virtual; - function ReadAnsiString: AnsiString; virtual; // provide generic implementation for all derived classes procedure WriteBinary( const bytes : IThriftBytes); overload; virtual; @@ -344,6 +342,13 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) property Transport: ITransport read GetTransport; + private + // THRIFT-5750 unit visible, but no longer protected - awaiting final removal + // - Note that you can implement whavetever you want in your derived class, but no longer inherit + // - The function can still be called via IProtocol until final removal + function ReadAnsiString: AnsiString; virtual; //deprecated; + procedure WriteAnsiString( const s: AnsiString); virtual; //deprecated; + public constructor Create( const aTransport : ITransport); virtual; end; @@ -508,7 +513,6 @@ TProtocolDecorator = class( TProtocolImpl) procedure WriteI64( const i64: Int64); override; procedure WriteDouble( const d: Double); override; procedure WriteString( const s: string ); override; - procedure WriteAnsiString( const s: AnsiString); override; procedure WriteBinary( const b: TBytes); override; procedure WriteBinary( const bytes : IThriftBytes); overload; override; procedure WriteUuid( const uuid: TGuid); override; @@ -534,7 +538,15 @@ TProtocolDecorator = class( TProtocolImpl) function ReadBinary: TBytes; override; function ReadUuid: TGuid; override; function ReadString: string; override; - function ReadAnsiString: AnsiString; override; + + private + // THRIFT-5750 unit visible, but no longer protected - awaiting final removal + // - Note that you can implement whavetever you want in your derived class, but no longer inherit + // - The function can still be called via IProtocol until final removal + {$WARN SYMBOL_DEPRECATED OFF} + function ReadAnsiString: AnsiString; override; deprecated; + procedure WriteAnsiString( const s: AnsiString); override; deprecated; + {$WARN SYMBOL_DEPRECATED DEFAULT} end; @@ -1520,7 +1532,9 @@ procedure TProtocolDecorator.WriteString( const s: string ); procedure TProtocolDecorator.WriteAnsiString( const s: AnsiString); begin + {$WARN SYMBOL_DEPRECATED OFF} FWrappedProtocol.WriteAnsiString( s); + {$WARN SYMBOL_DEPRECATED DEFAULT} end; @@ -1670,7 +1684,9 @@ function TProtocolDecorator.ReadString: string; function TProtocolDecorator.ReadAnsiString: AnsiString; begin + {$WARN SYMBOL_DEPRECATED OFF} result := FWrappedProtocol.ReadAnsiString; + {$WARN SYMBOL_DEPRECATED DEFAULT} end;