THRIFT-1485 Performance: pass large and/or refcounted arguments as "const"
authorRoger Meier <roger@apache.org>
Sun, 8 Jan 2012 21:51:08 +0000 (21:51 +0000)
committerRoger Meier <roger@apache.org>
Sun, 8 Jan 2012 21:51:08 +0000 (21:51 +0000)
Patch: Jens Geyer

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

compiler/cpp/src/generate/t_delphi_generator.cc
lib/delphi/src/Thrift.Collections.pas
lib/delphi/src/Thrift.Protocol.JSON.pas
lib/delphi/src/Thrift.Protocol.pas
lib/delphi/src/Thrift.Server.pas
lib/delphi/src/Thrift.Stream.pas
lib/delphi/src/Thrift.Transport.pas
lib/delphi/src/Thrift.pas
lib/delphi/test/TestClient.pas
lib/delphi/test/TestServer.pas

index bb00ea7..6aaaf52 100644 (file)
@@ -131,10 +131,11 @@ class t_delphi_generator : public t_oop_generator
 
     std::string type_name( t_type* ttype, bool b_cls=false, bool b_no_postfix=false, bool b_exception_factory=false, bool b_full_exception_factory = false);
     std::string normalize_clsnm(std::string name, std::string prefix, bool b_no_check_keyword = false);
-
+    std::string input_arg_prefix( t_type* ttype);
+  
     std::string base_type_name(t_base_type* tbase);
     std::string declare_field(t_field* tfield, bool init=false, std::string prefix="", bool is_xception_class = false);
-    std::string function_signature(t_function* tfunction, std::string full_cls="", bool is_xception = false);
+    std::string function_signature(t_function* tfunction, std::string full_cls="", bool is_xception = false);  
     std::string argument_list(t_struct* tstruct);
     std::string constructor_argument_list(t_struct* tstruct, std::string current_indent);
     std::string type_to_enum(t_type* ttype);
@@ -1072,8 +1073,8 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   if ((! is_exception) || is_x_factory) {
     out  << endl;
     indent(out) << "// IBase" << endl;
-    indent(out) << "procedure Read( iprot: IProtocol);" << endl;
-    indent(out) << "procedure Write( oprot: IProtocol);" << endl;
+    indent(out) << "procedure Read( const iprot: IProtocol);" << endl;
+    indent(out) << "procedure Write( const oprot: IProtocol);" << endl;
   }
 
   if (is_exception && is_x_factory) {
@@ -1193,9 +1194,11 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
   indent_down_impl();
   indent_impl(s_service_impl) <<  "end;" << endl << endl;
 
-  indent(s_service) << "constructor Create( iprot: IProtocol; oprot: IProtocol); overload;" << endl;
+  indent(s_service) << "constructor Create( const iprot: IProtocol; const oprot: IProtocol); overload;" << endl;
 
-  indent_impl(s_service_impl) <<  "constructor " << normalize_clsnm( service_name_, "T") << ".TClient.Create( iprot: IProtocol; oprot: IProtocol);" << endl;
+  indent_impl(s_service_impl) <<  
+    "constructor " << normalize_clsnm( service_name_, "T") << 
+    ".TClient.Create( const iprot: IProtocol; const oprot: IProtocol);" << endl;
   indent_impl(s_service_impl) <<  "begin" << endl;
   indent_up_impl();
   indent_impl(s_service_impl) << "iprot_ := iprot;" << endl;    
@@ -1446,7 +1449,7 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
   indent_up();
   indent(s_service) << "type" << endl;
   indent_up();
-  indent(s_service) << "TProcessFunction = reference to procedure( seqid: Integer; iprot: IProtocol; oprot: IProtocol);" << endl;
+  indent(s_service) << "TProcessFunction = reference to procedure( seqid: Integer; const iprot: IProtocol; const oprot: IProtocol);" << endl;
   indent_down();
   indent_down();
 
@@ -1461,12 +1464,12 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
   indent(s_service) << "public" << endl;
   indent_up();
   if (extends.empty()) {
-    indent(s_service) << "function Process( iprot: IProtocol; oprot: IProtocol): Boolean;" << endl;
+    indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol): Boolean;" << endl;
   } else {
-    indent(s_service) << "function Process( iprot: IProtocol; oprot: IProtocol): Boolean; reintroduce;" << endl;
+    indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol): Boolean; reintroduce;" << endl;
   }
 
-  indent_impl(s_service_impl) << "function " << full_cls << ".Process( iprot: IProtocol; oprot: IProtocol): Boolean;" << endl;;
+  indent_impl(s_service_impl) << "function " << full_cls << ".Process( const iprot: IProtocol; const oprot: IProtocol): Boolean;" << endl;;
   indent_impl(s_service_impl) << "var" << endl;
   indent_up_impl();
   indent_impl(s_service_impl) << "msg : IMessage;" << endl;
@@ -1552,7 +1555,7 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
   string result_intfnm = normalize_clsnm(org_resultname, "I");
 
   indent(s_service) <<
-    "procedure " << funcname << "_Process( seqid: Integer; iprot: IProtocol; oprot: IProtocol);" << endl;
+    "procedure " << funcname << "_Process( seqid: Integer; const iprot: IProtocol; const oprot: IProtocol);" << endl;
 
   if (tfunction->is_oneway()) {
     indent_impl(s_service_impl) << "// one way processor" << endl;
@@ -1561,7 +1564,7 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
   }
 
   indent_impl(s_service_impl) <<
-    "procedure " << full_cls << "." << funcname << "_Process( seqid: Integer; iprot: IProtocol; oprot: IProtocol);" << endl;
+    "procedure " << full_cls << "." << funcname << "_Process( seqid: Integer; const iprot: IProtocol; const oprot: IProtocol);" << endl;
   indent_impl(s_service_impl) << "var" << endl;
   indent_up_impl();
   indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << endl;
@@ -2104,6 +2107,52 @@ string t_delphi_generator::type_name( t_type* ttype, bool b_cls, bool b_no_postf
   return nm;
 }
 
+// returns "const " for some argument types
+string t_delphi_generator::input_arg_prefix( t_type* ttype) {
+
+  // base types
+  if (ttype->is_base_type()) {
+    switch (((t_base_type*)ttype)->get_base()) {
+  
+      // these should be const'ed for optimal performamce
+      case t_base_type::TYPE_STRING:  // refcounted pointer
+      case t_base_type::TYPE_I64:   // larger than 32 bit
+      case t_base_type::TYPE_DOUBLE:   // larger than 32 bit
+        return "const ";
+  
+      // all others don't need to be
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+      case t_base_type::TYPE_BOOL:
+      case t_base_type::TYPE_VOID:
+        return "";
+      
+      // we better always report any unknown types
+      default:
+        throw "compiler error: no input_arg_prefix() for base type " + (((t_base_type*)ttype)->get_base());
+    }
+  
+  // enums
+  } else if (ttype->is_enum()) {
+    return "";   // usually <= 32 bit
+  
+  // containers
+  } else if (ttype->is_map()) {
+    return "const ";  // refcounted pointer
+
+  } else if (ttype->is_set()) {
+    return "const ";  // refcounted pointer
+
+  } else if (ttype->is_list()) {
+    return "const ";  // refcounted pointer
+
+  }
+  
+  // any other type, either TSomething or ISomething
+  return "const ";  // possibly refcounted pointer
+}
+
 string t_delphi_generator::base_type_name(t_base_type* tbase) {
   switch (tbase->get_base()) {
     case t_base_type::TYPE_VOID:
@@ -2176,7 +2225,8 @@ string t_delphi_generator::argument_list(t_struct* tstruct) {
     }
 
     tt = (*f_iter)->get_type();
-    result += normalize_name((*f_iter)->get_name()) + ": " + type_name( tt, false, true, tt->is_xception(), true);
+  result += input_arg_prefix(tt);  // const?
+  result += normalize_name((*f_iter)->get_name()) + ": " + type_name( tt, false, true, tt->is_xception(), true);
   }
   return result;
 }
@@ -2211,6 +2261,7 @@ string t_delphi_generator::constructor_argument_list(t_struct* tstruct, string c
     }
 
     tt = (*f_iter)->get_type();
+    line += input_arg_prefix(tt);  // const?
     line += constructor_param_name((*f_iter)->get_name()) + ": " + type_name( tt, false, true, tt->is_xception(), true);
   }
 
@@ -2514,7 +2565,7 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out, string
 
   cls_nm = type_name(tstruct,true,false,is_exception,is_exception);
 
-  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Read( iprot: IProtocol);" << endl;
+  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Read( const iprot: IProtocol);" << endl;
   indent_impl(out) << "var" << endl;
   indent_up_impl();
   indent_impl(out) << "field_ : IField;" << endl;
@@ -2582,7 +2633,7 @@ void t_delphi_generator::generate_delphi_struct_result_writer_impl(ostream& out,
 
   cls_nm = type_name(tstruct,true,false,is_exception,is_exception);
 
-  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( oprot: IProtocol);" << endl;
+  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);" << endl;
   indent_impl(out) << "var" << endl;
   indent_up_impl();
   indent_impl(out) << "struc : IStruct;" << endl;
@@ -2654,7 +2705,7 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out, string
 
   cls_nm = type_name(tstruct,true,false,is_exception,is_exception);
 
-  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( oprot: IProtocol);" << endl;
+  indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);" << endl;
   indent_impl(out) << "var" << endl;
   indent_up_impl();
   indent_impl(out) << "struc : IStruct;" << endl;
index abc401f..66ff1c0 100644 (file)
@@ -195,11 +195,11 @@ type
     function GetCount: Integer;\r
     property Count: Integer read GetCount;\r
     property IsReadOnly: Boolean read GetIsReadOnly;\r
-    procedure Add( item: TValue);\r
+    procedure Add( const item: TValue);\r
     procedure Clear;\r
-    function Contains( item: TValue): Boolean;\r
+    function Contains( const item: TValue): Boolean;\r
     procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);\r
-    function Remove( item: TValue ): Boolean;\r
+    function Remove( const item: TValue ): Boolean;\r
   end;\r
 \r
   THashSetImpl<TValue> = class( TInterfacedObject, IHashSet<TValue>)\r
@@ -212,11 +212,11 @@ type
     function GetCount: Integer;\r
     property Count: Integer read GetCount;\r
     property IsReadOnly: Boolean read FIsReadOnly;\r
-    procedure Add( item: TValue);\r
+    procedure Add( const item: TValue);\r
     procedure Clear;\r
-    function Contains( item: TValue): Boolean;\r
+    function Contains( const item: TValue): Boolean;\r
     procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);\r
-    function Remove( item: TValue ): Boolean;\r
+    function Remove( const item: TValue ): Boolean;\r
   public\r
     constructor Create;\r
   end;\r
@@ -225,7 +225,7 @@ implementation
 \r
 { THashSetImpl<TValue> }\r
 \r
-procedure THashSetImpl<TValue>.Add(item: TValue);\r
+procedure THashSetImpl<TValue>.Add( const item: TValue);\r
 begin\r
   if not FDictionary.ContainsKey(item) then\r
   begin\r
@@ -238,7 +238,7 @@ begin
   FDictionary.Clear;\r
 end;\r
 \r
-function THashSetImpl<TValue>.Contains(item: TValue): Boolean;\r
+function THashSetImpl<TValue>.Contains( const item: TValue): Boolean;\r
 begin\r
   Result := FDictionary.ContainsKey(item);\r
 end;\r
@@ -277,7 +277,7 @@ begin
   Result := FIsReadOnly;\r
 end;\r
 \r
-function THashSetImpl<TValue>.Remove(item: TValue): Boolean;\r
+function THashSetImpl<TValue>.Remove( const item: TValue): Boolean;\r
 begin\r
   Result := False;\r
   if FDictionary.ContainsKey( item ) then\r
@@ -330,8 +330,7 @@ begin
 end;\r
 \r
 {$IF CompilerVersion >= 21.0}\r
-function TThriftDictionaryImpl<TKey, TValue>.ExtractPair(\r
-  const Key: TKey): TPair<TKey, TValue>;\r
+function TThriftDictionaryImpl<TKey, TValue>.ExtractPair( const Key: TKey): TPair<TKey, TValue>;\r
 begin\r
   Result := FDictionaly.ExtractPair( Key);\r
 end;\r
index dfab86b..3c54386 100644 (file)
@@ -48,7 +48,7 @@ type
     type
       TFactory = class( TInterfacedObject, IProtocolFactory)
       public
-        function GetProtocol( trans: ITransport): IProtocol;
+        function GetProtocol( const trans: ITransport): IProtocol;
       end;
 
   private
@@ -126,12 +126,12 @@ type
 
     // Push/pop a new JSON context onto/from the stack.
     procedure ResetContextStack;
-    procedure PushContext( aCtx : TJSONBaseContext);
+    procedure PushContext( const aCtx : TJSONBaseContext);
     procedure PopContext;
 
   public
     // TJSONProtocolImpl Constructor
-    constructor Create( aTrans : ITransport);
+    constructor Create( const aTrans : ITransport);
     destructor Destroy;   override;
 
   protected
@@ -148,11 +148,11 @@ type
 
     // Write the bytes in array buf as a JSON characters, escaping as needed
     procedure WriteJSONString( const b : TBytes);  overload;
-    procedure WriteJSONString( str : string);  overload;
+    procedure WriteJSONString( const str : string);  overload;
 
     // Write out number as a JSON value. If the context dictates so, it will be
     // wrapped in quotes to output as a JSON string.
-    procedure WriteJSONInteger( num : Int64);
+    procedure WriteJSONInteger( const num : Int64);
 
     // Write out a double as a JSON value. If it is NaN or infinity or if the
     // context dictates escaping, Write out as JSON string.
@@ -168,25 +168,25 @@ type
 
   public
     // IProtocol
-    procedure WriteMessageBegin( aMsg : IMessage); override;
+    procedure WriteMessageBegin( const aMsg : IMessage); override;
     procedure WriteMessageEnd; override;
-    procedure WriteStructBegin(struc: IStruct); override;
+    procedure WriteStructBegin( const struc: IStruct); override;
     procedure WriteStructEnd; override;
-    procedure WriteFieldBegin(field: IField); override;
+    procedure WriteFieldBegin( const field: IField); override;
     procedure WriteFieldEnd; override;
     procedure WriteFieldStop; override;
-    procedure WriteMapBegin(map: IMap); override;
+    procedure WriteMapBegin( const map: IMap); override;
     procedure WriteMapEnd; override;
-    procedure WriteListBegin( list: IList); override;
+    procedure WriteListBegin( const list: IList); override;
     procedure WriteListEnd(); override;
-    procedure WriteSetBegin( set_: ISet ); override;
+    procedure WriteSetBegin( const set_: ISet ); override;
     procedure WriteSetEnd(); override;
     procedure WriteBool( b: Boolean); override;
     procedure WriteByte( b: ShortInt); override;
     procedure WriteI16( i16: SmallInt); override;
     procedure WriteI32( i32: Integer); override;
-    procedure WriteI64( i64: Int64); override;
-    procedure WriteDouble( d: Double); override;
+    procedure WriteI64( const i64: Int64); override;
+    procedure WriteDouble( const d: Double); override;
     procedure WriteString( const s: string );   override;
     procedure WriteBinary( const b: TBytes); override;
     //
@@ -290,7 +290,7 @@ const
 //--- TJSONProtocolImpl ----------------------
 
 
-function TJSONProtocolImpl.TFactory.GetProtocol( trans: ITransport): IProtocol;
+function TJSONProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;
 begin
   result := TJSONProtocolImpl.Create(trans);
 end;
@@ -455,7 +455,7 @@ begin
 end;
 
 
-constructor TJSONProtocolImpl.Create( aTrans : ITransport);
+constructor TJSONProtocolImpl.Create( const aTrans : ITransport);
 begin
   inherited Create( aTrans);
 
@@ -487,7 +487,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.PushContext( aCtx : TJSONBaseContext);
+procedure TJSONProtocolImpl.PushContext( const aCtx : TJSONBaseContext);
 begin
   FContextStack.Push( FContext);
   FContext := aCtx;
@@ -528,7 +528,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteJSONString( str : string);
+procedure TJSONProtocolImpl.WriteJSONString( const str : string);
 begin
   WriteJSONString( SysUtils.TEncoding.UTF8.GetBytes( str));
 end;
@@ -575,7 +575,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteJSONInteger( num : Int64);
+procedure TJSONProtocolImpl.WriteJSONInteger( const num : Int64);
 var str : String;
     escapeNum : Boolean;
 begin
@@ -676,7 +676,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteMessageBegin( aMsg : IMessage);
+procedure TJSONProtocolImpl.WriteMessageBegin( const aMsg : IMessage);
 begin
   ResetContextStack;  // THRIFT-1473
 
@@ -695,7 +695,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteStructBegin( struc: IStruct);
+procedure TJSONProtocolImpl.WriteStructBegin( const struc: IStruct);
 begin
   WriteJSONObjectStart;
 end;
@@ -707,7 +707,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteFieldBegin( field : IField);
+procedure TJSONProtocolImpl.WriteFieldBegin( const field : IField);
 begin
   WriteJSONInteger(field.ID);
   WriteJSONObjectStart;
@@ -726,7 +726,7 @@ begin
   // nothing to do
 end;
 
-procedure TJSONProtocolImpl.WriteMapBegin( map: IMap);
+procedure TJSONProtocolImpl.WriteMapBegin( const map: IMap);
 begin
   WriteJSONArrayStart;
   WriteJSONString( GetTypeNameForTypeID( map.KeyType));
@@ -743,7 +743,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteListBegin( list: IList);
+procedure TJSONProtocolImpl.WriteListBegin( const list: IList);
 begin
   WriteJSONArrayStart;
   WriteJSONString( GetTypeNameForTypeID( list.ElementType));
@@ -757,7 +757,7 @@ begin
 end;
 
 
-procedure TJSONProtocolImpl.WriteSetBegin( set_: ISet);
+procedure TJSONProtocolImpl.WriteSetBegin( const set_: ISet);
 begin
   WriteJSONArrayStart;
   WriteJSONString( GetTypeNameForTypeID( set_.ElementType));
@@ -792,12 +792,12 @@ begin
   WriteJSONInteger( i32);
 end;
 
-procedure TJSONProtocolImpl.WriteI64( i64: Int64);
+procedure TJSONProtocolImpl.WriteI64( const i64: Int64);
 begin
   WriteJSONInteger(i64);
 end;
 
-procedure TJSONProtocolImpl.WriteDouble( d: Double);
+procedure TJSONProtocolImpl.WriteDouble( const d: Double);
 begin
   WriteJSONDouble( d);
 end;
index 8fa6008..82c58b1 100644 (file)
@@ -61,7 +61,7 @@ type
 \r
   IProtocolFactory = interface\r
     ['{7CD64A10-4E9F-4E99-93BF-708A31F4A67B}']\r
-    function GetProtocol( trans: ITransport): IProtocol;\r
+    function GetProtocol( const trans: ITransport): IProtocol;\r
   end;\r
 \r
   TThriftStringBuilder = class( TStringBuilder)\r
@@ -236,25 +236,25 @@ type
   IProtocol = interface\r
     ['{FD95C151-1527-4C96-8134-B902BFC4B4FC}']\r
     function GetTransport: ITransport;\r
-    procedure WriteMessageBegin( message: IMessage);\r
+    procedure WriteMessageBegin( const msg: IMessage);\r
     procedure WriteMessageEnd;\r
-    procedure WriteStructBegin(struc: IStruct);\r
+    procedure WriteStructBegin( const struc: IStruct);\r
     procedure WriteStructEnd;\r
-    procedure WriteFieldBegin(field: IField);\r
+    procedure WriteFieldBegin( const field: IField);\r
     procedure WriteFieldEnd;\r
     procedure WriteFieldStop;\r
-    procedure WriteMapBegin(map: IMap);\r
+    procedure WriteMapBegin( const map: IMap);\r
     procedure WriteMapEnd;\r
-    procedure WriteListBegin( list: IList);\r
+    procedure WriteListBegin( const list: IList);\r
     procedure WriteListEnd();\r
-    procedure WriteSetBegin( set_: ISet );\r
+    procedure WriteSetBegin( const set_: ISet );\r
     procedure WriteSetEnd();\r
     procedure WriteBool( b: Boolean);\r
     procedure WriteByte( b: ShortInt);\r
     procedure WriteI16( i16: SmallInt);\r
     procedure WriteI32( i32: Integer);\r
-    procedure WriteI64( i64: Int64);\r
-    procedure WriteDouble( d: Double);\r
+    procedure WriteI64( const i64: Int64);\r
+    procedure WriteDouble( const d: Double);\r
     procedure WriteString( const s: string );\r
     procedure WriteAnsiString( const s: AnsiString);\r
     procedure WriteBinary( const b: TBytes);\r
@@ -288,25 +288,25 @@ type
     FTrans : ITransport;\r
     function GetTransport: ITransport;\r
   public\r
-    procedure WriteMessageBegin( message: IMessage); virtual; abstract;\r
+    procedure WriteMessageBegin( const msg: IMessage); virtual; abstract;\r
     procedure WriteMessageEnd; virtual; abstract;\r
-    procedure WriteStructBegin(struc: IStruct); virtual; abstract;\r
+    procedure WriteStructBegin( const struc: IStruct); virtual; abstract;\r
     procedure WriteStructEnd; virtual; abstract;\r
-    procedure WriteFieldBegin(field: IField); virtual; abstract;\r
+    procedure WriteFieldBegin( const field: IField); virtual; abstract;\r
     procedure WriteFieldEnd; virtual; abstract;\r
     procedure WriteFieldStop; virtual; abstract;\r
-    procedure WriteMapBegin(map: IMap); virtual; abstract;\r
+    procedure WriteMapBegin( const map: IMap); virtual; abstract;\r
     procedure WriteMapEnd; virtual; abstract;\r
-    procedure WriteListBegin( list: IList); virtual; abstract;\r
+    procedure WriteListBegin( const list: IList); virtual; abstract;\r
     procedure WriteListEnd(); virtual; abstract;\r
-    procedure WriteSetBegin( set_: ISet ); virtual; abstract;\r
+    procedure WriteSetBegin( const set_: ISet ); virtual; abstract;\r
     procedure WriteSetEnd(); virtual; abstract;\r
     procedure WriteBool( b: Boolean); virtual; abstract;\r
     procedure WriteByte( b: ShortInt); virtual; abstract;\r
     procedure WriteI16( i16: SmallInt); virtual; abstract;\r
     procedure WriteI32( i32: Integer); virtual; abstract;\r
-    procedure WriteI64( i64: Int64); virtual; abstract;\r
-    procedure WriteDouble( d: Double); virtual; abstract;\r
+    procedure WriteI64( const i64: Int64); virtual; abstract;\r
+    procedure WriteDouble( const d: Double); virtual; abstract;\r
     procedure WriteString( const s: string ); virtual;\r
     procedure WriteAnsiString( const s: AnsiString); virtual;\r
     procedure WriteBinary( const b: TBytes); virtual; abstract;\r
@@ -341,8 +341,8 @@ type
   IBase = interface\r
     ['{08D9BAA8-5EAA-410F-B50B-AC2E6E5E4155}']\r
     function ToString: string;\r
-    procedure Read( iprot: IProtocol);\r
-    procedure Write( iprot: IProtocol);\r
+    procedure Read( const iprot: IProtocol);\r
+    procedure Write( const iprot: IProtocol);\r
   end;\r
 \r
   IStruct = interface\r
@@ -385,33 +385,33 @@ type
         FStrictRead : Boolean;\r
         FStrictWrite : Boolean;\r
       public\r
-        function GetProtocol(trans: ITransport): IProtocol;\r
+        function GetProtocol( const trans: ITransport): IProtocol;\r
         constructor Create( AStrictRead, AStrictWrite: Boolean ); overload;\r
         constructor Create; overload;\r
       end;\r
 \r
-    constructor Create( trans: ITransport); overload;\r
-    constructor Create( trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;\r
+    constructor Create( const trans: ITransport); overload;\r
+    constructor Create( const trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;\r
 \r
-    procedure WriteMessageBegin( message: IMessage); override;\r
+    procedure WriteMessageBegin( const msg: IMessage); override;\r
     procedure WriteMessageEnd; override;\r
-    procedure WriteStructBegin(struc: IStruct); override;\r
+    procedure WriteStructBegin( const struc: IStruct); override;\r
     procedure WriteStructEnd; override;\r
-    procedure WriteFieldBegin(field: IField); override;\r
+    procedure WriteFieldBegin( const field: IField); override;\r
     procedure WriteFieldEnd; override;\r
     procedure WriteFieldStop; override;\r
-    procedure WriteMapBegin(map: IMap); override;\r
+    procedure WriteMapBegin( const map: IMap); override;\r
     procedure WriteMapEnd; override;\r
-    procedure WriteListBegin( list: IList); override;\r
+    procedure WriteListBegin( const list: IList); override;\r
     procedure WriteListEnd(); override;\r
-    procedure WriteSetBegin( set_: ISet ); override;\r
+    procedure WriteSetBegin( const set_: ISet ); override;\r
     procedure WriteSetEnd(); override;\r
     procedure WriteBool( b: Boolean); override;\r
     procedure WriteByte( b: ShortInt); override;\r
     procedure WriteI16( i16: SmallInt); override;\r
     procedure WriteI32( i32: Integer); override;\r
-    procedure WriteI64( i64: Int64); override;\r
-    procedure WriteDouble( d: Double); override;\r
+    procedure WriteI64( const i64: Int64); override;\r
+    procedure WriteDouble( const d: Double); override;\r
     procedure WriteBinary( const b: TBytes); override;\r
 \r
     function ReadMessageBegin: IMessage; override;\r
@@ -439,13 +439,13 @@ type
 \r
 implementation\r
 \r
-function ConvertInt64ToDouble( n: Int64): Double;\r
+function ConvertInt64ToDouble( const n: Int64): Double;\r
 begin\r
   ASSERT( SizeOf(n) = SizeOf(Result));\r
   System.Move( n, Result, SizeOf(Result));\r
 end;\r
 \r
-function ConvertDoubleToInt64( d: Double): Int64;\r
+function ConvertDoubleToInt64( const d: Double): Int64;\r
 begin\r
   ASSERT( SizeOf(d) = SizeOf(Result));\r
   System.Move( d, Result, SizeOf(Result));\r
@@ -739,7 +739,7 @@ end;
 \r
 { TBinaryProtocolImpl }\r
 \r
-constructor TBinaryProtocolImpl.Create( trans: ITransport);\r
+constructor TBinaryProtocolImpl.Create( const trans: ITransport);\r
 begin\r
   Create( trans, False, True);\r
 end;\r
@@ -756,7 +756,7 @@ begin
   end;\r
 end;\r
 \r
-constructor TBinaryProtocolImpl.Create(trans: ITransport; strictRead,\r
+constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead,\r
   strictWrite: Boolean);\r
 begin\r
   inherited Create( trans );\r
@@ -997,12 +997,12 @@ begin
   FTrans.Write( a, 0, 1 );\r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteDouble(d: Double);\r
+procedure TBinaryProtocolImpl.WriteDouble( const d: Double);\r
 begin\r
   WriteI64(ConvertDoubleToInt64(d));\r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteFieldBegin(field: IField);\r
+procedure TBinaryProtocolImpl.WriteFieldBegin( const field: IField);\r
 begin\r
   WriteByte(ShortInt(field.Type_));\r
   WriteI16(field.ID);\r
@@ -1040,7 +1040,7 @@ begin
   FTrans.Write( i32out, 0, 4);\r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteI64(i64: Int64);\r
+procedure TBinaryProtocolImpl.WriteI64( const i64: Int64);\r
 var\r
   i64out : TBytes;\r
 begin\r
@@ -1056,7 +1056,7 @@ begin
   FTrans.Write( i64out, 0, 8);\r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteListBegin(list: IList);\r
+procedure TBinaryProtocolImpl.WriteListBegin( const list: IList);\r
 begin\r
   WriteByte(ShortInt(list.ElementType));\r
   WriteI32(list.Count);\r
@@ -1067,7 +1067,7 @@ begin
 \r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteMapBegin(map: IMap);\r
+procedure TBinaryProtocolImpl.WriteMapBegin( const map: IMap);\r
 begin\r
   WriteByte(ShortInt(map.KeyType));\r
   WriteByte(ShortInt(map.ValueType));\r
@@ -1079,21 +1079,21 @@ begin
 \r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteMessageBegin( message: IMessage);\r
+procedure TBinaryProtocolImpl.WriteMessageBegin( const msg: IMessage);\r
 var\r
   version : Cardinal;\r
 begin\r
   if FStrictWrite then\r
   begin\r
-    version := VERSION_1 or Cardinal( message.Type_);\r
+    version := VERSION_1 or Cardinal( msg.Type_);\r
     WriteI32( Integer( version) );\r
-    WriteString( message.Name);\r
-       WriteI32(message.SeqID);\r
+    WriteString( msg.Name);\r
+       WriteI32( msg.SeqID);\r
   end else\r
   begin\r
-    WriteString(message.Name);\r
-    WriteByte(ShortInt(message.Type_));\r
-    WriteI32(message.SeqID);\r
+    WriteString( msg.Name);\r
+    WriteByte(ShortInt( msg.Type_));\r
+    WriteI32( msg.SeqID);\r
   end;\r
 end;\r
 \r
@@ -1102,7 +1102,7 @@ begin
 \r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteSetBegin(set_: ISet);\r
+procedure TBinaryProtocolImpl.WriteSetBegin( const set_: ISet);\r
 begin\r
   WriteByte(ShortInt(set_.ElementType));\r
   WriteI32(set_.Count);\r
@@ -1113,7 +1113,7 @@ begin
 \r
 end;\r
 \r
-procedure TBinaryProtocolImpl.WriteStructBegin(struc: IStruct);\r
+procedure TBinaryProtocolImpl.WriteStructBegin( const struc: IStruct);\r
 begin\r
 \r
 end;\r
@@ -1169,7 +1169,7 @@ begin
   Create( False, True )\r
 end;\r
 \r
-function TBinaryProtocolImpl.TFactory.GetProtocol(trans: ITransport): IProtocol;\r
+function TBinaryProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;\r
 begin\r
   Result := TBinaryProtocolImpl.Create( trans );\r
 end;\r
index 2d35c19..d437527 100644 (file)
@@ -37,7 +37,7 @@ type
   TServerImpl = class abstract( TInterfacedObject, IServer )
   public
     type
-      TLogDelegate = reference to procedure( str: string);
+      TLogDelegate = reference to procedure( const str: string);
   protected
     FProcessor : IProcessor;
     FServerTransport : IServerTransport;
@@ -47,41 +47,43 @@ type
     FOutputProtocolFactory : IProtocolFactory;
     FLogDelegate : TLogDelegate;
 
-    class procedure DefaultLogDelegate( str: string);
+    class procedure DefaultLogDelegate( const str: string);
 
     procedure Serve; virtual; abstract;
     procedure Stop; virtual; abstract;
   public
     constructor Create(
-      AProcessor :IProcessor;
-      AServerTransport: IServerTransport;
-      AInputTransportFactory : ITransportFactory;
-      AOutputTransportFactory : ITransportFactory;
-      AInputProtocolFactory : IProtocolFactory;
-      AOutputProtocolFactory : IProtocolFactory;
-      ALogDelegate : TLogDelegate
+      const AProcessor :IProcessor;
+      const AServerTransport: IServerTransport;
+      const AInputTransportFactory : ITransportFactory;
+      const AOutputTransportFactory : ITransportFactory;
+      const AInputProtocolFactory : IProtocolFactory;
+      const AOutputProtocolFactory : IProtocolFactory;
+      const ALogDelegate : TLogDelegate
       ); overload;
 
-    constructor Create( AProcessor :IProcessor;
-      AServerTransport: IServerTransport); overload;
+    constructor Create( 
+      const AProcessor :IProcessor;
+      const AServerTransport: IServerTransport
+         ); overload;
 
     constructor Create(
-      AProcessor :IProcessor;
-      AServerTransport: IServerTransport;
-      ALogDelegate: TLogDelegate
+      const AProcessor :IProcessor;
+      const AServerTransport: IServerTransport;
+      const ALogDelegate: TLogDelegate
       ); overload;
 
     constructor Create(
-      AProcessor :IProcessor;
-      AServerTransport: IServerTransport;
-      ATransportFactory : ITransportFactory
+      const AProcessor :IProcessor;
+      const AServerTransport: IServerTransport;
+      const ATransportFactory : ITransportFactory
       ); overload;
 
     constructor Create(
-      AProcessor :IProcessor;
-      AServerTransport: IServerTransport;
-      ATransportFactory : ITransportFactory;
-      AProtocolFactory : IProtocolFactory
+      const AProcessor :IProcessor;
+      const AServerTransport: IServerTransport;
+      const ATransportFactory : ITransportFactory;
+      const AProtocolFactory : IProtocolFactory
       ); overload;
   end;
 
@@ -89,13 +91,13 @@ type
   private
     FStop : Boolean;
   public
-    constructor Create( AProcessor: IProcessor; AServerTransport: IServerTransport); overload;
-    constructor Create( AProcessor: IProcessor; AServerTransport: IServerTransport;
+    constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport); overload;
+    constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport;
       ALogDel: TServerImpl.TLogDelegate); overload;
-    constructor Create( AProcessor: IProcessor; AServerTransport: IServerTransport;
-      ATransportFactory: ITransportFactory); overload;
-    constructor Create( AProcessor: IProcessor; AServerTransport: IServerTransport;
-      ATransportFactory: ITransportFactory; AProtocolFactory: IProtocolFactory); overload;
+    constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport;
+      const ATransportFactory: ITransportFactory); overload;
+    constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport;
+      const ATransportFactory: ITransportFactory; const AProtocolFactory: IProtocolFactory); overload;
 
     procedure Serve; override;
     procedure Stop; override;
@@ -106,8 +108,8 @@ implementation
 
 { TServerImpl }
 
-constructor TServerImpl.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ALogDelegate: TLogDelegate);
+constructor TServerImpl.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; const ALogDelegate: TLogDelegate);
 var
   InputFactory, OutputFactory : IProtocolFactory;
   InputTransFactory, OutputTransFactory : ITransportFactory;
@@ -129,8 +131,8 @@ begin
   );
 end;
 
-constructor TServerImpl.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport);
+constructor TServerImpl.Create(const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport);
 var
   InputFactory, OutputFactory : IProtocolFactory;
   InputTransFactory, OutputTransFactory : ITransportFactory;
@@ -152,8 +154,8 @@ begin
   );
 end;
 
-constructor TServerImpl.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ATransportFactory: ITransportFactory);
+constructor TServerImpl.Create(const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory);
 var
   InputProtocolFactory : IProtocolFactory;
   OutputProtocolFactory : IProtocolFactory;
@@ -165,11 +167,11 @@ begin
     InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate);
 end;
 
-constructor TServerImpl.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; AInputTransportFactory,
-  AOutputTransportFactory: ITransportFactory; AInputProtocolFactory,
-  AOutputProtocolFactory: IProtocolFactory;
-  ALogDelegate : TLogDelegate);
+constructor TServerImpl.Create(const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport;
+  const AInputTransportFactory, AOutputTransportFactory: ITransportFactory;
+  const AInputProtocolFactory, AOutputProtocolFactory: IProtocolFactory;
+  const ALogDelegate : TLogDelegate);
 begin
   FProcessor := AProcessor;
   FServerTransport := AServerTransport;
@@ -180,14 +182,14 @@ begin
   FLogDelegate := ALogDelegate;
 end;
 
-class procedure TServerImpl.DefaultLogDelegate( str: string);
+class procedure TServerImpl.DefaultLogDelegate( const str: string);
 begin
   Writeln( str );
 end;
 
-constructor TServerImpl.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ATransportFactory: ITransportFactory;
-  AProtocolFactory: IProtocolFactory);
+constructor TServerImpl.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory;
+  const AProtocolFactory: IProtocolFactory);
 begin
   Create( AProcessor, AServerTransport,
           ATransportFactory, ATransportFactory,
@@ -197,8 +199,8 @@ end;
 
 { TSimpleServer }
 
-constructor TSimpleServer.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport);
+constructor TSimpleServer.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport);
 var
   InputProtocolFactory : IProtocolFactory;
   OutputProtocolFactory : IProtocolFactory;
@@ -214,8 +216,8 @@ begin
     OutputTransportFactory, InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate);
 end;
 
-constructor TSimpleServer.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ALogDel: TServerImpl.TLogDelegate);
+constructor TSimpleServer.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; ALogDel: TServerImpl.TLogDelegate);
 var
   InputProtocolFactory : IProtocolFactory;
   OutputProtocolFactory : IProtocolFactory;
@@ -231,16 +233,16 @@ begin
     OutputTransportFactory, InputProtocolFactory, OutputProtocolFactory, ALogDel);
 end;
 
-constructor TSimpleServer.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ATransportFactory: ITransportFactory);
+constructor TSimpleServer.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory);
 begin
   inherited Create( AProcessor, AServerTransport, ATransportFactory,
     ATransportFactory, TBinaryProtocolImpl.TFactory.Create, TBinaryProtocolImpl.TFactory.Create, DefaultLogDelegate);
 end;
 
-constructor TSimpleServer.Create(AProcessor: IProcessor;
-  AServerTransport: IServerTransport; ATransportFactory: ITransportFactory;
-  AProtocolFactory: IProtocolFactory);
+constructor TSimpleServer.Create( const AProcessor: IProcessor;
+  const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory;
+  const AProtocolFactory: IProtocolFactory);
 begin
   inherited Create( AProcessor, AServerTransport, ATransportFactory,
     ATransportFactory, AProtocolFactory, AProtocolFactory, DefaultLogDelegate);
index a02677e..81d5d2a 100644 (file)
@@ -68,7 +68,7 @@ type
     function IsOpen: Boolean; override;\r
     function ToArray: TBytes; override;\r
   public\r
-    constructor Create( AStream: TStream; AOwnsStream : Boolean);\r
+    constructor Create( const AStream: TStream; AOwnsStream : Boolean);\r
     destructor Destroy; override;\r
   end;\r
 \r
@@ -84,7 +84,7 @@ type
     function IsOpen: Boolean; override;\r
     function ToArray: TBytes; override;\r
   public\r
-    constructor Create( AStream: IStream);\r
+    constructor Create( const AStream: IStream);\r
   end;\r
 \r
 implementation\r
@@ -96,7 +96,7 @@ begin
   FStream := nil;\r
 end;\r
 \r
-constructor TThriftStreamAdapterCOM.Create(AStream: IStream);\r
+constructor TThriftStreamAdapterCOM.Create( const AStream: IStream);\r
 begin\r
   FStream := AStream;\r
 end;\r
@@ -219,7 +219,7 @@ begin
   FOwnsStream := False;\r
 end;\r
 \r
-constructor TThriftStreamAdapterDelphi.Create(AStream: TStream; AOwnsStream: Boolean);\r
+constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean);\r
 begin\r
   FStream := AStream;\r
   FOwnsStream := AOwnsStream;\r
index a460819..f5ccf6e 100644 (file)
@@ -145,11 +145,11 @@ type
 \r
   ITransportFactory = interface\r
     ['{DD809446-000F-49E1-9BFF-E0D0DC76A9D7}']\r
-    function GetTransport( ATrans: ITransport): ITransport;\r
+    function GetTransport( const ATrans: ITransport): ITransport;\r
   end;\r
 \r
   TTransportFactoryImpl = class( TInterfacedObject, ITransportFactory)\r
-    function GetTransport( ATrans: ITransport): ITransport; virtual;\r
+    function GetTransport( const ATrans: ITransport): ITransport; virtual;\r
   end;\r
 \r
   TTcpSocketStreamImpl = class( TThriftStreamImpl )\r
@@ -165,7 +165,7 @@ type
     function IsOpen: Boolean; override;\r
     function ToArray: TBytes; override;\r
   public\r
-    constructor Create( ATcpClient: TCustomIpClient);\r
+    constructor Create( const ATcpClient: TCustomIpClient);\r
   end;\r
 \r
   IStreamTransport = interface( ITransport )\r
@@ -194,7 +194,7 @@ type
     procedure Flush; override;\r
     function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;\r
     procedure Write( const buf: TBytes; off: Integer; len: Integer); override;\r
-    constructor Create( AInputStream : IThriftStream; AOutputStream : IThriftStream);\r
+    constructor Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);\r
     destructor Destroy; override;\r
   end;\r
 \r
@@ -212,7 +212,7 @@ type
     function IsOpen: Boolean; override;\r
     function ToArray: TBytes; override;\r
   public\r
-    constructor Create( AStream: IThriftStream; ABufSize: Integer);\r
+    constructor Create( const AStream: IThriftStream; ABufSize: Integer);\r
     destructor Destroy; override;\r
   end;\r
 \r
@@ -226,8 +226,8 @@ type
   protected\r
     function AcceptImpl: ITransport; override;\r
   public\r
-    constructor Create( AServer: TTcpServer ); overload;\r
-    constructor Create( AServer: TTcpServer; AClientTimeout: Integer); overload;\r
+    constructor Create( const AServer: TTcpServer ); overload;\r
+    constructor Create( const AServer: TTcpServer; AClientTimeout: Integer); overload;\r
     constructor Create( APort: Integer); overload;\r
     constructor Create( APort: Integer; AClientTimeout: Integer); overload;\r
     constructor Create( APort: Integer; AClientTimeout: Integer;\r
@@ -254,8 +254,8 @@ type
     procedure Close(); override;\r
     function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;\r
     procedure Write( const buf: TBytes; off: Integer; len: Integer); override;\r
-    constructor Create( ATransport : IStreamTransport ); overload;\r
-    constructor Create( ATransport : IStreamTransport; ABufSize: Integer); overload;\r
+    constructor Create( const ATransport : IStreamTransport ); overload;\r
+    constructor Create( const ATransport : IStreamTransport; ABufSize: Integer); overload;\r
     property UnderlyingTransport: ITransport read GetUnderlyingTransport;\r
     property IsOpen: Boolean read GetIsOpen;\r
   end;\r
@@ -273,7 +273,7 @@ type
     function GetIsOpen: Boolean; override;\r
   public\r
     procedure Open; override;\r
-    constructor Create( AClient : TCustomIpClient); overload;\r
+    constructor Create( const AClient : TCustomIpClient); overload;\r
     constructor Create( const AHost: string; APort: Integer); overload;\r
     constructor Create( const AHost: string; APort: Integer; ATimeout: Integer); overload;\r
     destructor Destroy; override;\r
@@ -299,14 +299,14 @@ type
     type\r
       TFactory = class( TTransportFactoryImpl )\r
       public\r
-        function GetTransport( ATrans: ITransport): ITransport; override;\r
+        function GetTransport( const ATrans: ITransport): ITransport; override;\r
       end;\r
 \r
 {$IF CompilerVersion >= 21.0}\r
     class constructor Create;\r
 {$IFEND}\r
     constructor Create; overload;\r
-    constructor Create( ATrans: ITransport); overload;\r
+    constructor Create( const ATrans: ITransport); overload;\r
     destructor Destroy; override;\r
 \r
     procedure Open(); override;\r
@@ -528,20 +528,20 @@ end;
 \r
 { TTransportFactoryImpl }\r
 \r
-function TTransportFactoryImpl.GetTransport(ATrans: ITransport): ITransport;\r
+function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;\r
 begin\r
   Result := ATrans;\r
 end;\r
 \r
 { TServerSocket }\r
 \r
-constructor TServerSocketImpl.Create(AServer: TTcpServer; AClientTimeout: Integer);\r
+constructor TServerSocketImpl.Create( const AServer: TTcpServer; AClientTimeout: Integer);\r
 begin\r
   FServer := AServer;\r
   FClientTimeout := AClientTimeout;\r
 end;\r
 \r
-constructor TServerSocketImpl.Create(AServer: TTcpServer);\r
+constructor TServerSocketImpl.Create( const AServer: TTcpServer);\r
 begin\r
   Create( AServer, 0 );\r
 end;\r
@@ -658,7 +658,7 @@ end;
 \r
 { TSocket }\r
 \r
-constructor TSocketImpl.Create(AClient : TCustomIpClient);\r
+constructor TSocketImpl.Create( const AClient : TCustomIpClient);\r
 var\r
   stream : IThriftStream;\r
 begin\r
@@ -773,7 +773,7 @@ begin
   FBuffer := nil;\r
 end;\r
 \r
-constructor TBufferedStreamImpl.Create(AStream: IThriftStream; ABufSize: Integer);\r
+constructor TBufferedStreamImpl.Create( const AStream: IThriftStream; ABufSize: Integer);\r
 begin\r
   FStream := AStream;\r
   FBufSize := ABufSize;\r
@@ -903,7 +903,7 @@ begin
   end;\r
 end;\r
 \r
-constructor TStreamTransportImpl.Create( AInputStream : IThriftStream; AOutputStream : IThriftStream);\r
+constructor TStreamTransportImpl.Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);\r
 begin\r
   FInputStream := AInputStream;\r
   FOutputStream := AOutputStream;\r
@@ -967,7 +967,7 @@ end;
 \r
 { TBufferedTransportImpl }\r
 \r
-constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport);\r
+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport);\r
 begin\r
   Create( ATransport, 1024 );\r
 end;\r
@@ -977,7 +977,7 @@ begin
   FTransport.Close;\r
 end;\r
 \r
-constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport;\r
+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport;\r
   ABufSize: Integer);\r
 begin\r
   FTransport := ATransport;\r
@@ -1064,7 +1064,7 @@ begin
   FTransport.Close;\r
 end;\r
 \r
-constructor TFramedTransportImpl.Create(ATrans: ITransport);\r
+constructor TFramedTransportImpl.Create( const ATrans: ITransport);\r
 begin\r
   InitWriteBuffer;\r
   FTransport := ATrans;\r
@@ -1176,7 +1176,7 @@ end;
 \r
 { TFramedTransport.TFactory }\r
 \r
-function TFramedTransportImpl.TFactory.GetTransport(ATrans: ITransport): ITransport;\r
+function TFramedTransportImpl.TFactory.GetTransport( const ATrans: ITransport): ITransport;\r
 begin\r
   Result := TFramedTransportImpl.Create( ATrans );\r
 end;\r
@@ -1188,7 +1188,7 @@ begin
   FTcpClient.Close;\r
 end;\r
 \r
-constructor TTcpSocketStreamImpl.Create(ATcpClient: TCustomIpClient);\r
+constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient);\r
 begin\r
   FTcpClient := ATcpClient;\r
 end;\r
index aa69f93..8b13406 100644 (file)
@@ -30,7 +30,7 @@ const
 type
   IProcessor = interface
     ['{B1538A07-6CAC-4406-8A4C-AFED07C70A89}']
-    function Process( iprot :IProtocol; oprot: IProtocol): Boolean;
+    function Process( const iprot :IProtocol; const oprot: IProtocol): Boolean;
   end;
 
   TApplicationException = class( SysUtils.Exception )
@@ -53,8 +53,8 @@ type
     constructor Create( AType: TExceptionType); overload;
     constructor Create( AType: TExceptionType; const msg: string); overload;
 
-    class function Read( iprot: IProtocol): TApplicationException;
-    procedure Write( oprot: IProtocol );
+    class function Read( const iprot: IProtocol): TApplicationException;
+    procedure Write( const oprot: IProtocol );
   end;
 
   // base class for IDL-generated exceptions
@@ -102,8 +102,7 @@ begin
   FType := AType;
 end;
 
-class function TApplicationException.Read(
-  iprot: IProtocol): TApplicationException;
+class function TApplicationException.Read( const iprot: IProtocol): TApplicationException;
 var
   field : IField;
   msg : string;
@@ -149,7 +148,7 @@ begin
   Result := TApplicationException.Create( typ, msg );
 end;
 
-procedure TApplicationException.Write(oprot: IProtocol);
+procedure TApplicationException.Write( const oprot: IProtocol);
 var
   struc : IStruct;
   field : IField;
index e547413..0155c9a 100644 (file)
@@ -65,7 +65,7 @@ type
   protected\r
     procedure Execute; override;\r
   public\r
-    constructor Create(ATransport: ITransport; AProtocol : IProtocol; ANumIteration: Integer);\r
+    constructor Create( const ATransport: ITransport; const AProtocol : IProtocol; ANumIteration: Integer);\r
     destructor Destroy; override;\r
   end;\r
 \r
@@ -880,7 +880,7 @@ begin
 end;\r
 \r
 \r
-constructor TClientThread.Create(ATransport: ITransport; AProtocol : IProtocol; ANumIteration: Integer);\r
+constructor TClientThread.Create( const ATransport: ITransport; const AProtocol : IProtocol; ANumIteration: Integer);\r
 begin\r
   inherited Create( True );\r
   FNumIteration := ANumIteration;\r
index 8f890da..b8b4d72 100644 (file)
@@ -42,7 +42,7 @@ type
     type
 
       ITestHandler = interface( TThriftTest.Iface )
-        procedure SetServer( AServer : IServer );
+        procedure SetServer( const AServer : IServer );
       end;
 
       TTestHandlerImpl = class( TInterfacedObject, ITestHandler )
@@ -50,39 +50,39 @@ type
         FServer : IServer;
       protected
         procedure testVoid();
-        function testString(thing: string): string;
+        function testString(const thing: string): string;
         function testByte(thing: ShortInt): ShortInt;
         function testI32(thing: Integer): Integer;
-        function testI64(thing: Int64): Int64;
-        function testDouble(thing: Double): Double;
-        function testStruct(thing: IXtruct): IXtruct;
-        function testNest(thing: IXtruct2): IXtruct2;
-        function testMap(thing: IThriftDictionary<Integer, Integer>): IThriftDictionary<Integer, Integer>;
-        function testStringMap(thing: IThriftDictionary<string, string>): IThriftDictionary<string, string>;
-        function testSet(thing: IHashSet<Integer>): IHashSet<Integer>;
-        function testList(thing: IThriftList<Integer>): IThriftList<Integer>;
+        function testI64(const thing: Int64): Int64;
+        function testDouble(const thing: Double): Double;
+        function testStruct(const thing: IXtruct): IXtruct;
+        function testNest(const thing: IXtruct2): IXtruct2;
+        function testMap(const thing: IThriftDictionary<Integer, Integer>): IThriftDictionary<Integer, Integer>;
+        function testStringMap(const thing: IThriftDictionary<string, string>): IThriftDictionary<string, string>;
+        function testSet(const thing: IHashSet<Integer>): IHashSet<Integer>;
+        function testList(const thing: IThriftList<Integer>): IThriftList<Integer>;
         function testEnum(thing: TNumberz): TNumberz;
-        function testTypedef(thing: Int64): Int64;
+        function testTypedef(const thing: Int64): Int64;
         function testMapMap(hello: Integer): IThriftDictionary<Integer, IThriftDictionary<Integer, Integer>>;
-        function testInsanity(argument: IInsanity): IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>;
-        function testMulti(arg0: ShortInt; arg1: Integer; arg2: Int64; arg3: IThriftDictionary<SmallInt, string>; arg4: TNumberz; arg5: Int64): IXtruct;
-        procedure testException(arg: string);
-        function testMultiException(arg0: string; arg1: string): IXtruct;
+        function testInsanity(const argument: IInsanity): IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>;
+        function testMulti(arg0: ShortInt; arg1: Integer; const arg2: Int64; const arg3: IThriftDictionary<SmallInt, string>; arg4: TNumberz; const arg5: Int64): IXtruct;
+        procedure testException(const arg: string);
+        function testMultiException(const arg0: string; const arg1: string): IXtruct;
         procedure testOneway(secondsToSleep: Integer);
 
          procedure testStop;
 
-        procedure SetServer( AServer : IServer );
+        procedure SetServer( const AServer : IServer );
       end;
 
-      class procedure Execute( args: array of string);
+      class procedure Execute( const args: array of string);
   end;
 
 implementation
 
 { TTestServer.TTestHandlerImpl }
 
-procedure TTestServer.TTestHandlerImpl.SetServer(AServer: IServer);
+procedure TTestServer.TTestHandlerImpl.SetServer( const AServer: IServer);
 begin
   FServer := AServer;
 end;
@@ -93,7 +93,7 @@ begin
   Result := thing;
 end;
 
-function TTestServer.TTestHandlerImpl.testDouble(thing: Double): Double;
+function TTestServer.TTestHandlerImpl.testDouble( const thing: Double): Double;
 begin
   Console.WriteLine('testDouble("' + FloatToStr( thing ) + '")');
   Result := thing;
@@ -105,7 +105,7 @@ begin
   Result := thing;
 end;
 
-procedure TTestServer.TTestHandlerImpl.testException(arg: string);
+procedure TTestServer.TTestHandlerImpl.testException(const arg: string);
 begin
   Console.WriteLine('testException(' + arg + ')');
   if ( arg = 'Xception') then
@@ -120,14 +120,14 @@ begin
   Result := thing;
 end;
 
-function TTestServer.TTestHandlerImpl.testI64(thing: Int64): Int64;
+function TTestServer.TTestHandlerImpl.testI64( const thing: Int64): Int64;
 begin
   Console.WriteLine('testI64("' + IntToStr( thing) + '")');
   Result := thing;
 end;
 
 function TTestServer.TTestHandlerImpl.testInsanity(
-  argument: IInsanity): IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>;
+  const argument: IInsanity): IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>;
 var
   hello, goodbye : IXtruct;
   crazy : IInsanity;
@@ -178,7 +178,7 @@ begin
 end;
 
 function TTestServer.TTestHandlerImpl.testList(
-  thing: IThriftList<Integer>): IThriftList<Integer>;
+  const thing: IThriftList<Integer>): IThriftList<Integer>;
 var
   first : Boolean;
   elem : Integer;
@@ -201,7 +201,7 @@ begin
 end;
 
 function TTestServer.TTestHandlerImpl.testMap(
-  thing: IThriftDictionary<Integer, Integer>): IThriftDictionary<Integer, Integer>;
+  const thing: IThriftDictionary<Integer, Integer>): IThriftDictionary<Integer, Integer>;
 var
   first : Boolean;
   key : Integer;
@@ -249,8 +249,8 @@ begin
 end;
 
 function TTestServer.TTestHandlerImpl.testMulti(arg0: ShortInt; arg1: Integer;
-  arg2: Int64; arg3: IThriftDictionary<SmallInt, string>; arg4: TNumberz;
-  arg5: Int64): IXtruct;
+  const arg2: Int64; const arg3: IThriftDictionary<SmallInt, string>;
+  arg4: TNumberz; const arg5: Int64): IXtruct;
 var
   hello : IXtruct;
 begin
@@ -263,8 +263,7 @@ begin
   Result := hello;
 end;
 
-function TTestServer.TTestHandlerImpl.testMultiException(arg0,
-  arg1: string): IXtruct;
+function TTestServer.TTestHandlerImpl.testMultiException( const arg0, arg1: string): IXtruct;
 var
   x2 : TXception2;
 begin
@@ -287,7 +286,7 @@ begin
   Result.String_thing := arg1;
 end;
 
-function TTestServer.TTestHandlerImpl.testNest(thing: IXtruct2): IXtruct2;
+function TTestServer.TTestHandlerImpl.testNest( const thing: IXtruct2): IXtruct2;
 var
   temp : IXtruct;
 begin
@@ -310,7 +309,7 @@ begin
 end;
 
 function TTestServer.TTestHandlerImpl.testSet(
-  thing: IHashSet<Integer>):IHashSet<Integer>;
+  const thing: IHashSet<Integer>):IHashSet<Integer>;
 var
   first : Boolean;
   elem : Integer;
@@ -341,19 +340,19 @@ begin
   end;
 end;
 
-function TTestServer.TTestHandlerImpl.testString(thing: string): string;
+function TTestServer.TTestHandlerImpl.testString( const thing: string): string;
 begin
   Console.WriteLine('teststring("' + thing + '")');
   Result := thing;
 end;
 
 function TTestServer.TTestHandlerImpl.testStringMap(
-  thing: IThriftDictionary<string, string>): IThriftDictionary<string, string>;
+  const thing: IThriftDictionary<string, string>): IThriftDictionary<string, string>;
 begin
 
 end;
 
-function TTestServer.TTestHandlerImpl.testTypedef(thing: Int64): Int64;
+function TTestServer.TTestHandlerImpl.testTypedef( const thing: Int64): Int64;
 begin
   Console.WriteLine('testTypedef(' + IntToStr( thing) + ')');
   Result := thing;
@@ -364,7 +363,7 @@ begin
   Console.WriteLine('testVoid()');
 end;
 
-function TTestServer.TTestHandlerImpl.testStruct(thing: IXtruct): IXtruct;
+function TTestServer.TTestHandlerImpl.testStruct( const thing: IXtruct): IXtruct;
 begin
   Console.WriteLine('testStruct({' +
     '"' + thing.String_thing + '", ' +
@@ -376,7 +375,7 @@ end;
 
 { TTestServer }
 
-class procedure TTestServer.Execute(args: array of string);
+class procedure TTestServer.Execute( const args: array of string);
 var
   UseBufferedSockets : Boolean;
   UseFramed : Boolean;