This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 85431d9  THRIFT-4862 better ToString() support for enums and container 
types Client: Delphi Patch: Jens Geyer
85431d9 is described below

commit 85431d9c6a4695c5fbdeccc34e60de6c6ecf7225
Author: Jens Geyer <[email protected]>
AuthorDate: Fri May 10 21:17:00 2019 +0200

    THRIFT-4862 better ToString() support for enums and container types
    Client: Delphi
    Patch: Jens Geyer
---
 compiler/cpp/src/thrift/generate/t_delphi_generator.cc | 2 +-
 lib/delphi/src/Thrift.Utils.pas                        | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc 
b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
index 11501bf..4a2ebda 100644
--- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
@@ -3950,7 +3950,7 @@ void 
t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out,
                        << prop_name((*f_iter), is_exception) << 
".ToString());" << endl;
     } else if (ttype->is_enum()) {
       indent_impl(out) << tmp_sb << ".Append(EnumUtils<" 
-                       << type_name(ttype, false, true, is_exception, true) 
+                       << type_name(ttype, false, true, false, false) 
                        << ">.ToString( System.Ord( Self." 
                        << prop_name((*f_iter), is_exception) << ")));" << endl;
     } else {
diff --git a/lib/delphi/src/Thrift.Utils.pas b/lib/delphi/src/Thrift.Utils.pas
index 46e238c..11c4f3e 100644
--- a/lib/delphi/src/Thrift.Utils.pas
+++ b/lib/delphi/src/Thrift.Utils.pas
@@ -295,15 +295,18 @@ end;
 { StringUtils<T> }
 
 class function StringUtils<T>.ToString(const value : T) : string;
+type PInterface = ^IInterface;
 var pType : PTypeInfo;
-    base  : ISupportsToString;
+    stos  : ISupportsToString;
+    pIntf : PInterface;  // Workaround: Rio does not allow the direct typecast
 begin
   pType := PTypeInfo(TypeInfo(T));
   if Assigned(pType) then begin
     case pType^.Kind of
       tkInterface : begin
-        if Supports(IInterface(value), ISupportsToString, base) then begin
-          result := base.toString;
+        pIntf := PInterface(@value);
+        if Supports( pIntf^, ISupportsToString, stos) then begin
+          result := stos.toString;
           Exit;
         end;
       end;

Reply via email to