From: Jake Farrell Date: Tue, 6 Dec 2011 00:59:30 +0000 (+0000) Subject: Thrift-1446:Compile error with Delphi 2009 in constant initializer X-Git-Tag: 0.9.1~517 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=6fa2b30940188fef9f1eaba539dedfa4ddc0946f;p=common%2Fthrift.git Thrift-1446:Compile error with Delphi 2009 in constant initializer Client: delphi Patch: Kenjiro Fukumitsu Generated code cannot be compiled with Delphi 2009 due to the bug in constant initializer. git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1210728 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc index a238f688..4b602e50 100644 --- a/compiler/cpp/src/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/generate/t_delphi_generator.cc @@ -91,7 +91,7 @@ class t_delphi_generator : public t_oop_generator void print_const_prop(std::ostream& out, string name, t_type* type, t_const_value* value); void print_private_field(std::ostream& out, string name, t_type* type, t_const_value* value); void print_const_value ( std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value); - void initialize_field(std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value, std::string cls_nm = ""); + void initialize_field(std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value); void finalize_field(std::ostream& out, std::string name, t_type* type, t_const_value* value, std::string cls_nm = ""); std::string render_const_value( std::ostream& local_vars, std::ostream& out, std::string name, t_type* type, t_const_value* value); void print_const_def_value( std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value, std::string cls_nm = ""); @@ -609,8 +609,8 @@ void t_delphi_generator::generate_consts(std::vector consts) { indent_up_impl(); for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { - initialize_field( vars, code, "F" + prop_name( (*c_iter)->get_name()), - (*c_iter)->get_type(), (*c_iter)->get_value(), "TConstants" ); + initialize_field( vars, code, "TConstants.F" + prop_name( (*c_iter)->get_name()), + (*c_iter)->get_type(), (*c_iter)->get_value()); } indent_down_impl(); @@ -723,8 +723,7 @@ void t_delphi_generator::print_const_value( std::ostream& vars, std::ostream& ou } -void t_delphi_generator::initialize_field(std::ostream& vars, std::ostream& out, string name, t_type* type, t_const_value* value, string cls_nm) { - (void) cls_nm; +void t_delphi_generator::initialize_field(std::ostream& vars, std::ostream& out, string name, t_type* type, t_const_value* value) { print_const_value( vars, out, name, type, value ); } diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas index 9ca90d90..e5474132 100644 --- a/lib/delphi/test/TestClient.pas +++ b/lib/delphi/test/TestClient.pas @@ -85,12 +85,14 @@ function BoolToString( b : Boolean) : string; begin if b then result := 'true' - else result := 'false'; -end; - - -{ TTestClient } - + else result := 'false'; +end; + +// not available in all versions, so make sure we have this one imported +function IsDebuggerPresent: BOOL; stdcall; external KERNEL32 name 'IsDebuggerPresent'; + +{ TTestClient } + class procedure TTestClient.Execute(const args: array of string); var i : Integer;