THRIFT-1485 Performance: pass large and/or refcounted arguments as "const"
Patch: Jens Geyer

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1228965 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas
index abc401f..66ff1c0 100644
--- a/lib/delphi/src/Thrift.Collections.pas
+++ b/lib/delphi/src/Thrift.Collections.pas
@@ -195,11 +195,11 @@
     function GetCount: Integer;

     property Count: Integer read GetCount;

     property IsReadOnly: Boolean read GetIsReadOnly;

-    procedure Add( item: TValue);

+    procedure Add( const item: TValue);

     procedure Clear;

-    function Contains( item: TValue): Boolean;

+    function Contains( const item: TValue): Boolean;

     procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);

-    function Remove( item: TValue ): Boolean;

+    function Remove( const item: TValue ): Boolean;

   end;

 

   THashSetImpl<TValue> = class( TInterfacedObject, IHashSet<TValue>)

@@ -212,11 +212,11 @@
     function GetCount: Integer;

     property Count: Integer read GetCount;

     property IsReadOnly: Boolean read FIsReadOnly;

-    procedure Add( item: TValue);

+    procedure Add( const item: TValue);

     procedure Clear;

-    function Contains( item: TValue): Boolean;

+    function Contains( const item: TValue): Boolean;

     procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);

-    function Remove( item: TValue ): Boolean;

+    function Remove( const item: TValue ): Boolean;

   public

     constructor Create;

   end;

@@ -225,7 +225,7 @@
 

 { THashSetImpl<TValue> }

 

-procedure THashSetImpl<TValue>.Add(item: TValue);

+procedure THashSetImpl<TValue>.Add( const item: TValue);

 begin

   if not FDictionary.ContainsKey(item) then

   begin

@@ -238,7 +238,7 @@
   FDictionary.Clear;

 end;

 

-function THashSetImpl<TValue>.Contains(item: TValue): Boolean;

+function THashSetImpl<TValue>.Contains( const item: TValue): Boolean;

 begin

   Result := FDictionary.ContainsKey(item);

 end;

@@ -277,7 +277,7 @@
   Result := FIsReadOnly;

 end;

 

-function THashSetImpl<TValue>.Remove(item: TValue): Boolean;

+function THashSetImpl<TValue>.Remove( const item: TValue): Boolean;

 begin

   Result := False;

   if FDictionary.ContainsKey( item ) then

@@ -330,8 +330,7 @@
 end;

 

 {$IF CompilerVersion >= 21.0}

-function TThriftDictionaryImpl<TKey, TValue>.ExtractPair(

-  const Key: TKey): TPair<TKey, TValue>;

+function TThriftDictionaryImpl<TKey, TValue>.ExtractPair( const Key: TKey): TPair<TKey, TValue>;

 begin

   Result := FDictionaly.ExtractPair( Key);

 end;

diff --git a/lib/delphi/src/Thrift.Protocol.JSON.pas b/lib/delphi/src/Thrift.Protocol.JSON.pas
index dfab86b..3c54386 100644
--- a/lib/delphi/src/Thrift.Protocol.JSON.pas
+++ b/lib/delphi/src/Thrift.Protocol.JSON.pas
@@ -48,7 +48,7 @@
     type
       TFactory = class( TInterfacedObject, IProtocolFactory)
       public
-        function GetProtocol( trans: ITransport): IProtocol;
+        function GetProtocol( const trans: ITransport): IProtocol;
       end;
 
   private
@@ -126,12 +126,12 @@
 
     // 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 @@
 
     // 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 @@
 
   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 @@
 //--- 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 @@
 end;
 
 
-constructor TJSONProtocolImpl.Create( aTrans : ITransport);
+constructor TJSONProtocolImpl.Create( const aTrans : ITransport);
 begin
   inherited Create( aTrans);
 
@@ -487,7 +487,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.PushContext( aCtx : TJSONBaseContext);
+procedure TJSONProtocolImpl.PushContext( const aCtx : TJSONBaseContext);
 begin
   FContextStack.Push( FContext);
   FContext := aCtx;
@@ -528,7 +528,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteJSONString( str : string);
+procedure TJSONProtocolImpl.WriteJSONString( const str : string);
 begin
   WriteJSONString( SysUtils.TEncoding.UTF8.GetBytes( str));
 end;
@@ -575,7 +575,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteJSONInteger( num : Int64);
+procedure TJSONProtocolImpl.WriteJSONInteger( const num : Int64);
 var str : String;
     escapeNum : Boolean;
 begin
@@ -676,7 +676,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteMessageBegin( aMsg : IMessage);
+procedure TJSONProtocolImpl.WriteMessageBegin( const aMsg : IMessage);
 begin
   ResetContextStack;  // THRIFT-1473
 
@@ -695,7 +695,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteStructBegin( struc: IStruct);
+procedure TJSONProtocolImpl.WriteStructBegin( const struc: IStruct);
 begin
   WriteJSONObjectStart;
 end;
@@ -707,7 +707,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteFieldBegin( field : IField);
+procedure TJSONProtocolImpl.WriteFieldBegin( const field : IField);
 begin
   WriteJSONInteger(field.ID);
   WriteJSONObjectStart;
@@ -726,7 +726,7 @@
   // 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 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteListBegin( list: IList);
+procedure TJSONProtocolImpl.WriteListBegin( const list: IList);
 begin
   WriteJSONArrayStart;
   WriteJSONString( GetTypeNameForTypeID( list.ElementType));
@@ -757,7 +757,7 @@
 end;
 
 
-procedure TJSONProtocolImpl.WriteSetBegin( set_: ISet);
+procedure TJSONProtocolImpl.WriteSetBegin( const set_: ISet);
 begin
   WriteJSONArrayStart;
   WriteJSONString( GetTypeNameForTypeID( set_.ElementType));
@@ -792,12 +792,12 @@
   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;
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 8fa6008..82c58b1 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -61,7 +61,7 @@
 

   IProtocolFactory = interface

     ['{7CD64A10-4E9F-4E99-93BF-708A31F4A67B}']

-    function GetProtocol( trans: ITransport): IProtocol;

+    function GetProtocol( const trans: ITransport): IProtocol;

   end;

 

   TThriftStringBuilder = class( TStringBuilder)

@@ -236,25 +236,25 @@
   IProtocol = interface

     ['{FD95C151-1527-4C96-8134-B902BFC4B4FC}']

     function GetTransport: ITransport;

-    procedure WriteMessageBegin( message: IMessage);

+    procedure WriteMessageBegin( const msg: IMessage);

     procedure WriteMessageEnd;

-    procedure WriteStructBegin(struc: IStruct);

+    procedure WriteStructBegin( const struc: IStruct);

     procedure WriteStructEnd;

-    procedure WriteFieldBegin(field: IField);

+    procedure WriteFieldBegin( const field: IField);

     procedure WriteFieldEnd;

     procedure WriteFieldStop;

-    procedure WriteMapBegin(map: IMap);

+    procedure WriteMapBegin( const map: IMap);

     procedure WriteMapEnd;

-    procedure WriteListBegin( list: IList);

+    procedure WriteListBegin( const list: IList);

     procedure WriteListEnd();

-    procedure WriteSetBegin( set_: ISet );

+    procedure WriteSetBegin( const set_: ISet );

     procedure WriteSetEnd();

     procedure WriteBool( b: Boolean);

     procedure WriteByte( b: ShortInt);

     procedure WriteI16( i16: SmallInt);

     procedure WriteI32( i32: Integer);

-    procedure WriteI64( i64: Int64);

-    procedure WriteDouble( d: Double);

+    procedure WriteI64( const i64: Int64);

+    procedure WriteDouble( const d: Double);

     procedure WriteString( const s: string );

     procedure WriteAnsiString( const s: AnsiString);

     procedure WriteBinary( const b: TBytes);

@@ -288,25 +288,25 @@
     FTrans : ITransport;

     function GetTransport: ITransport;

   public

-    procedure WriteMessageBegin( message: IMessage); virtual; abstract;

+    procedure WriteMessageBegin( const msg: IMessage); virtual; abstract;

     procedure WriteMessageEnd; virtual; abstract;

-    procedure WriteStructBegin(struc: IStruct); virtual; abstract;

+    procedure WriteStructBegin( const struc: IStruct); virtual; abstract;

     procedure WriteStructEnd; virtual; abstract;

-    procedure WriteFieldBegin(field: IField); virtual; abstract;

+    procedure WriteFieldBegin( const field: IField); virtual; abstract;

     procedure WriteFieldEnd; virtual; abstract;

     procedure WriteFieldStop; virtual; abstract;

-    procedure WriteMapBegin(map: IMap); virtual; abstract;

+    procedure WriteMapBegin( const map: IMap); virtual; abstract;

     procedure WriteMapEnd; virtual; abstract;

-    procedure WriteListBegin( list: IList); virtual; abstract;

+    procedure WriteListBegin( const list: IList); virtual; abstract;

     procedure WriteListEnd(); virtual; abstract;

-    procedure WriteSetBegin( set_: ISet ); virtual; abstract;

+    procedure WriteSetBegin( const set_: ISet ); virtual; abstract;

     procedure WriteSetEnd(); virtual; abstract;

     procedure WriteBool( b: Boolean); virtual; abstract;

     procedure WriteByte( b: ShortInt); virtual; abstract;

     procedure WriteI16( i16: SmallInt); virtual; abstract;

     procedure WriteI32( i32: Integer); virtual; abstract;

-    procedure WriteI64( i64: Int64); virtual; abstract;

-    procedure WriteDouble( d: Double); virtual; abstract;

+    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); virtual; abstract;

@@ -341,8 +341,8 @@
   IBase = interface

     ['{08D9BAA8-5EAA-410F-B50B-AC2E6E5E4155}']

     function ToString: string;

-    procedure Read( iprot: IProtocol);

-    procedure Write( iprot: IProtocol);

+    procedure Read( const iprot: IProtocol);

+    procedure Write( const iprot: IProtocol);

   end;

 

   IStruct = interface

@@ -385,33 +385,33 @@
         FStrictRead : Boolean;

         FStrictWrite : Boolean;

       public

-        function GetProtocol(trans: ITransport): IProtocol;

+        function GetProtocol( const trans: ITransport): IProtocol;

         constructor Create( AStrictRead, AStrictWrite: Boolean ); overload;

         constructor Create; overload;

       end;

 

-    constructor Create( trans: ITransport); overload;

-    constructor Create( trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;

+    constructor Create( const trans: ITransport); overload;

+    constructor Create( const trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;

 

-    procedure WriteMessageBegin( message: IMessage); override;

+    procedure WriteMessageBegin( const msg: 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 WriteBinary( const b: TBytes); override;

 

     function ReadMessageBegin: IMessage; override;

@@ -439,13 +439,13 @@
 

 implementation

 

-function ConvertInt64ToDouble( n: Int64): Double;

+function ConvertInt64ToDouble( const n: Int64): Double;

 begin

   ASSERT( SizeOf(n) = SizeOf(Result));

   System.Move( n, Result, SizeOf(Result));

 end;

 

-function ConvertDoubleToInt64( d: Double): Int64;

+function ConvertDoubleToInt64( const d: Double): Int64;

 begin

   ASSERT( SizeOf(d) = SizeOf(Result));

   System.Move( d, Result, SizeOf(Result));

@@ -739,7 +739,7 @@
 

 { TBinaryProtocolImpl }

 

-constructor TBinaryProtocolImpl.Create( trans: ITransport);

+constructor TBinaryProtocolImpl.Create( const trans: ITransport);

 begin

   Create( trans, False, True);

 end;

@@ -756,7 +756,7 @@
   end;

 end;

 

-constructor TBinaryProtocolImpl.Create(trans: ITransport; strictRead,

+constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead,

   strictWrite: Boolean);

 begin

   inherited Create( trans );

@@ -997,12 +997,12 @@
   FTrans.Write( a, 0, 1 );

 end;

 

-procedure TBinaryProtocolImpl.WriteDouble(d: Double);

+procedure TBinaryProtocolImpl.WriteDouble( const d: Double);

 begin

   WriteI64(ConvertDoubleToInt64(d));

 end;

 

-procedure TBinaryProtocolImpl.WriteFieldBegin(field: IField);

+procedure TBinaryProtocolImpl.WriteFieldBegin( const field: IField);

 begin

   WriteByte(ShortInt(field.Type_));

   WriteI16(field.ID);

@@ -1040,7 +1040,7 @@
   FTrans.Write( i32out, 0, 4);

 end;

 

-procedure TBinaryProtocolImpl.WriteI64(i64: Int64);

+procedure TBinaryProtocolImpl.WriteI64( const i64: Int64);

 var

   i64out : TBytes;

 begin

@@ -1056,7 +1056,7 @@
   FTrans.Write( i64out, 0, 8);

 end;

 

-procedure TBinaryProtocolImpl.WriteListBegin(list: IList);

+procedure TBinaryProtocolImpl.WriteListBegin( const list: IList);

 begin

   WriteByte(ShortInt(list.ElementType));

   WriteI32(list.Count);

@@ -1067,7 +1067,7 @@
 

 end;

 

-procedure TBinaryProtocolImpl.WriteMapBegin(map: IMap);

+procedure TBinaryProtocolImpl.WriteMapBegin( const map: IMap);

 begin

   WriteByte(ShortInt(map.KeyType));

   WriteByte(ShortInt(map.ValueType));

@@ -1079,21 +1079,21 @@
 

 end;

 

-procedure TBinaryProtocolImpl.WriteMessageBegin( message: IMessage);

+procedure TBinaryProtocolImpl.WriteMessageBegin( const msg: IMessage);

 var

   version : Cardinal;

 begin

   if FStrictWrite then

   begin

-    version := VERSION_1 or Cardinal( message.Type_);

+    version := VERSION_1 or Cardinal( msg.Type_);

     WriteI32( Integer( version) );

-    WriteString( message.Name);

-  	WriteI32(message.SeqID);

+    WriteString( msg.Name);

+  	WriteI32( msg.SeqID);

   end else

   begin

-    WriteString(message.Name);

-    WriteByte(ShortInt(message.Type_));

-    WriteI32(message.SeqID);

+    WriteString( msg.Name);

+    WriteByte(ShortInt( msg.Type_));

+    WriteI32( msg.SeqID);

   end;

 end;

 

@@ -1102,7 +1102,7 @@
 

 end;

 

-procedure TBinaryProtocolImpl.WriteSetBegin(set_: ISet);

+procedure TBinaryProtocolImpl.WriteSetBegin( const set_: ISet);

 begin

   WriteByte(ShortInt(set_.ElementType));

   WriteI32(set_.Count);

@@ -1113,7 +1113,7 @@
 

 end;

 

-procedure TBinaryProtocolImpl.WriteStructBegin(struc: IStruct);

+procedure TBinaryProtocolImpl.WriteStructBegin( const struc: IStruct);

 begin

 

 end;

@@ -1169,7 +1169,7 @@
   Create( False, True )

 end;

 

-function TBinaryProtocolImpl.TFactory.GetProtocol(trans: ITransport): IProtocol;

+function TBinaryProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;

 begin

   Result := TBinaryProtocolImpl.Create( trans );

 end;

diff --git a/lib/delphi/src/Thrift.Server.pas b/lib/delphi/src/Thrift.Server.pas
index 2d35c19..d437527 100644
--- a/lib/delphi/src/Thrift.Server.pas
+++ b/lib/delphi/src/Thrift.Server.pas
@@ -37,7 +37,7 @@
   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 @@
     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 @@
   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 @@
 
 { 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 @@
   );
 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 @@
   );
 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 @@
     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 @@
   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 @@
 
 { 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 @@
     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 @@
     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);
diff --git a/lib/delphi/src/Thrift.Stream.pas b/lib/delphi/src/Thrift.Stream.pas
index a02677e..81d5d2a 100644
--- a/lib/delphi/src/Thrift.Stream.pas
+++ b/lib/delphi/src/Thrift.Stream.pas
@@ -68,7 +68,7 @@
     function IsOpen: Boolean; override;

     function ToArray: TBytes; override;

   public

-    constructor Create( AStream: TStream; AOwnsStream : Boolean);

+    constructor Create( const AStream: TStream; AOwnsStream : Boolean);

     destructor Destroy; override;

   end;

 

@@ -84,7 +84,7 @@
     function IsOpen: Boolean; override;

     function ToArray: TBytes; override;

   public

-    constructor Create( AStream: IStream);

+    constructor Create( const AStream: IStream);

   end;

 

 implementation

@@ -96,7 +96,7 @@
   FStream := nil;

 end;

 

-constructor TThriftStreamAdapterCOM.Create(AStream: IStream);

+constructor TThriftStreamAdapterCOM.Create( const AStream: IStream);

 begin

   FStream := AStream;

 end;

@@ -219,7 +219,7 @@
   FOwnsStream := False;

 end;

 

-constructor TThriftStreamAdapterDelphi.Create(AStream: TStream; AOwnsStream: Boolean);

+constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean);

 begin

   FStream := AStream;

   FOwnsStream := AOwnsStream;

diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas
index a460819..f5ccf6e 100644
--- a/lib/delphi/src/Thrift.Transport.pas
+++ b/lib/delphi/src/Thrift.Transport.pas
@@ -145,11 +145,11 @@
 

   ITransportFactory = interface

     ['{DD809446-000F-49E1-9BFF-E0D0DC76A9D7}']

-    function GetTransport( ATrans: ITransport): ITransport;

+    function GetTransport( const ATrans: ITransport): ITransport;

   end;

 

   TTransportFactoryImpl = class( TInterfacedObject, ITransportFactory)

-    function GetTransport( ATrans: ITransport): ITransport; virtual;

+    function GetTransport( const ATrans: ITransport): ITransport; virtual;

   end;

 

   TTcpSocketStreamImpl = class( TThriftStreamImpl )

@@ -165,7 +165,7 @@
     function IsOpen: Boolean; override;

     function ToArray: TBytes; override;

   public

-    constructor Create( ATcpClient: TCustomIpClient);

+    constructor Create( const ATcpClient: TCustomIpClient);

   end;

 

   IStreamTransport = interface( ITransport )

@@ -194,7 +194,7 @@
     procedure Flush; override;

     function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;

     procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    constructor Create( AInputStream : IThriftStream; AOutputStream : IThriftStream);

+    constructor Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);

     destructor Destroy; override;

   end;

 

@@ -212,7 +212,7 @@
     function IsOpen: Boolean; override;

     function ToArray: TBytes; override;

   public

-    constructor Create( AStream: IThriftStream; ABufSize: Integer);

+    constructor Create( const AStream: IThriftStream; ABufSize: Integer);

     destructor Destroy; override;

   end;

 

@@ -226,8 +226,8 @@
   protected

     function AcceptImpl: ITransport; override;

   public

-    constructor Create( AServer: TTcpServer ); overload;

-    constructor Create( AServer: TTcpServer; AClientTimeout: Integer); overload;

+    constructor Create( const AServer: TTcpServer ); overload;

+    constructor Create( const AServer: TTcpServer; AClientTimeout: Integer); overload;

     constructor Create( APort: Integer); overload;

     constructor Create( APort: Integer; AClientTimeout: Integer); overload;

     constructor Create( APort: Integer; AClientTimeout: Integer;

@@ -254,8 +254,8 @@
     procedure Close(); override;

     function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;

     procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    constructor Create( ATransport : IStreamTransport ); overload;

-    constructor Create( ATransport : IStreamTransport; ABufSize: Integer); overload;

+    constructor Create( const ATransport : IStreamTransport ); overload;

+    constructor Create( const ATransport : IStreamTransport; ABufSize: Integer); overload;

     property UnderlyingTransport: ITransport read GetUnderlyingTransport;

     property IsOpen: Boolean read GetIsOpen;

   end;

@@ -273,7 +273,7 @@
     function GetIsOpen: Boolean; override;

   public

     procedure Open; override;

-    constructor Create( AClient : TCustomIpClient); overload;

+    constructor Create( const AClient : TCustomIpClient); overload;

     constructor Create( const AHost: string; APort: Integer); overload;

     constructor Create( const AHost: string; APort: Integer; ATimeout: Integer); overload;

     destructor Destroy; override;

@@ -299,14 +299,14 @@
     type

       TFactory = class( TTransportFactoryImpl )

       public

-        function GetTransport( ATrans: ITransport): ITransport; override;

+        function GetTransport( const ATrans: ITransport): ITransport; override;

       end;

 

 {$IF CompilerVersion >= 21.0}

     class constructor Create;

 {$IFEND}

     constructor Create; overload;

-    constructor Create( ATrans: ITransport); overload;

+    constructor Create( const ATrans: ITransport); overload;

     destructor Destroy; override;

 

     procedure Open(); override;

@@ -528,20 +528,20 @@
 

 { TTransportFactoryImpl }

 

-function TTransportFactoryImpl.GetTransport(ATrans: ITransport): ITransport;

+function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;

 begin

   Result := ATrans;

 end;

 

 { TServerSocket }

 

-constructor TServerSocketImpl.Create(AServer: TTcpServer; AClientTimeout: Integer);

+constructor TServerSocketImpl.Create( const AServer: TTcpServer; AClientTimeout: Integer);

 begin

   FServer := AServer;

   FClientTimeout := AClientTimeout;

 end;

 

-constructor TServerSocketImpl.Create(AServer: TTcpServer);

+constructor TServerSocketImpl.Create( const AServer: TTcpServer);

 begin

   Create( AServer, 0 );

 end;

@@ -658,7 +658,7 @@
 

 { TSocket }

 

-constructor TSocketImpl.Create(AClient : TCustomIpClient);

+constructor TSocketImpl.Create( const AClient : TCustomIpClient);

 var

   stream : IThriftStream;

 begin

@@ -773,7 +773,7 @@
   FBuffer := nil;

 end;

 

-constructor TBufferedStreamImpl.Create(AStream: IThriftStream; ABufSize: Integer);

+constructor TBufferedStreamImpl.Create( const AStream: IThriftStream; ABufSize: Integer);

 begin

   FStream := AStream;

   FBufSize := ABufSize;

@@ -903,7 +903,7 @@
   end;

 end;

 

-constructor TStreamTransportImpl.Create( AInputStream : IThriftStream; AOutputStream : IThriftStream);

+constructor TStreamTransportImpl.Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);

 begin

   FInputStream := AInputStream;

   FOutputStream := AOutputStream;

@@ -967,7 +967,7 @@
 

 { TBufferedTransportImpl }

 

-constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport);

+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport);

 begin

   Create( ATransport, 1024 );

 end;

@@ -977,7 +977,7 @@
   FTransport.Close;

 end;

 

-constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport;

+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport;

   ABufSize: Integer);

 begin

   FTransport := ATransport;

@@ -1064,7 +1064,7 @@
   FTransport.Close;

 end;

 

-constructor TFramedTransportImpl.Create(ATrans: ITransport);

+constructor TFramedTransportImpl.Create( const ATrans: ITransport);

 begin

   InitWriteBuffer;

   FTransport := ATrans;

@@ -1176,7 +1176,7 @@
 

 { TFramedTransport.TFactory }

 

-function TFramedTransportImpl.TFactory.GetTransport(ATrans: ITransport): ITransport;

+function TFramedTransportImpl.TFactory.GetTransport( const ATrans: ITransport): ITransport;

 begin

   Result := TFramedTransportImpl.Create( ATrans );

 end;

@@ -1188,7 +1188,7 @@
   FTcpClient.Close;

 end;

 

-constructor TTcpSocketStreamImpl.Create(ATcpClient: TCustomIpClient);

+constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient);

 begin

   FTcpClient := ATcpClient;

 end;

diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas
index aa69f93..8b13406 100644
--- a/lib/delphi/src/Thrift.pas
+++ b/lib/delphi/src/Thrift.pas
@@ -30,7 +30,7 @@
 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 @@
     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 @@
   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 @@
   Result := TApplicationException.Create( typ, msg );
 end;
 
-procedure TApplicationException.Write(oprot: IProtocol);
+procedure TApplicationException.Write( const oprot: IProtocol);
 var
   struc : IStruct;
   field : IField;
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index e547413..0155c9a 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -65,7 +65,7 @@
   protected

     procedure Execute; override;

   public

-    constructor Create(ATransport: ITransport; AProtocol : IProtocol; ANumIteration: Integer);

+    constructor Create( const ATransport: ITransport; const AProtocol : IProtocol; ANumIteration: Integer);

     destructor Destroy; override;

   end;

 

@@ -880,7 +880,7 @@
 end;

 

 

-constructor TClientThread.Create(ATransport: ITransport; AProtocol : IProtocol; ANumIteration: Integer);

+constructor TClientThread.Create( const ATransport: ITransport; const AProtocol : IProtocol; ANumIteration: Integer);

 begin

   inherited Create( True );

   FNumIteration := ANumIteration;

diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas
index 8f890da..b8b4d72 100644
--- a/lib/delphi/test/TestServer.pas
+++ b/lib/delphi/test/TestServer.pas
@@ -42,7 +42,7 @@
     type
 
       ITestHandler = interface( TThriftTest.Iface )
-        procedure SetServer( AServer : IServer );
+        procedure SetServer( const AServer : IServer );
       end;
 
       TTestHandlerImpl = class( TInterfacedObject, ITestHandler )
@@ -50,39 +50,39 @@
         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 @@
   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 @@
   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 @@
   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 @@
 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 @@
 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 @@
 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 @@
   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 @@
   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 @@
 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 @@
   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 @@
   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 @@
 
 { TTestServer }
 
-class procedure TTestServer.Execute(args: array of string);
+class procedure TTestServer.Execute( const args: array of string);
 var
   UseBufferedSockets : Boolean;
   UseFramed : Boolean;