Thrift-1408: Delphi Test Server: Exception test case fails due to naming conflict...
authorJake Farrell <jfarrell@apache.org>
Mon, 31 Oct 2011 14:07:14 +0000 (14:07 +0000)
committerJake Farrell <jfarrell@apache.org>
Mon, 31 Oct 2011 14:07:14 +0000 (14:07 +0000)
Client: delphi
Patch: jens Geyer

Fix name comflict with e.message

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1195461 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_delphi_generator.cc
lib/delphi/src/Thrift.pas
lib/delphi/test/TestServer.pas

index fc684df..569afe3 100644 (file)
@@ -981,7 +981,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   }
   out << "class(";
   if ( is_exception && (! is_x_factory)) {
-    out << "Exception";
+    out << "TException";
   } else {
     out << "TInterfacedObject, IBase, " << struct_intf_name;
   }
index 6f352b1..48c3d47 100644 (file)
@@ -54,8 +54,22 @@ type
     procedure Write( oprot: IProtocol );\r
   end;\r
 \r
+  // base class for IDL-generated exceptions\r
+  TException = class( SysUtils.Exception)\r
+  public\r
+    procedure Message;  // hide inherited property to prevent accidental read/write\r
+  end;\r
+\r
 implementation\r
 \r
+{ TException }\r
+\r
+procedure TException.Message;\r
+// hide inherited property to prevent accidental read/write\r
+begin\r
+  ASSERT( FALSE, 'Unexpected call to '+ClassName+'.message. Forgot the underscore?');\r
+end;\r
+\r
 { TApplicationException }\r
 \r
 constructor TApplicationException.Create;\r
index c120712..67cce77 100644 (file)
@@ -276,7 +276,7 @@ begin
   begin\r
     x := TXception.Create;\r
     x.ErrorCode := 1001;\r
-    x.Message := 'This is an Xception';\r
+    x.Message_ := 'This is an Xception';\r
     raise x;\r
   end else\r
   if ( arg0 = 'Xception2') then\r