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
This commit is contained in:
Roger Meier 2012-01-08 21:51:08 +00:00
parent 77e1e62913
commit 333bbf3d88
10 changed files with 273 additions and 223 deletions

View 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;

View File

@ -195,11 +195,11 @@ type
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 @@ type
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 @@ implementation
{ 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 @@ begin
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 @@ begin
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 @@ begin
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;

View 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;

View File

@ -61,7 +61,7 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ end;
{ TBinaryProtocolImpl }
constructor TBinaryProtocolImpl.Create( trans: ITransport);
constructor TBinaryProtocolImpl.Create( const trans: ITransport);
begin
Create( trans, False, True);
end;
@ -756,7 +756,7 @@ begin
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 @@ begin
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 @@ begin
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 @@ begin
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 @@ begin
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 @@ begin
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 @@ begin
end;
procedure TBinaryProtocolImpl.WriteSetBegin(set_: ISet);
procedure TBinaryProtocolImpl.WriteSetBegin( const set_: ISet);
begin
WriteByte(ShortInt(set_.ElementType));
WriteI32(set_.Count);
@ -1113,7 +1113,7 @@ begin
end;
procedure TBinaryProtocolImpl.WriteStructBegin(struc: IStruct);
procedure TBinaryProtocolImpl.WriteStructBegin( const struc: IStruct);
begin
end;
@ -1169,7 +1169,7 @@ begin
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;

View 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);

View File

@ -68,7 +68,7 @@ type
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 @@ type
function IsOpen: Boolean; override;
function ToArray: TBytes; override;
public
constructor Create( AStream: IStream);
constructor Create( const AStream: IStream);
end;
implementation
@ -96,7 +96,7 @@ begin
FStream := nil;
end;
constructor TThriftStreamAdapterCOM.Create(AStream: IStream);
constructor TThriftStreamAdapterCOM.Create( const AStream: IStream);
begin
FStream := AStream;
end;
@ -219,7 +219,7 @@ begin
FOwnsStream := False;
end;
constructor TThriftStreamAdapterDelphi.Create(AStream: TStream; AOwnsStream: Boolean);
constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean);
begin
FStream := AStream;
FOwnsStream := AOwnsStream;

View File

@ -145,11 +145,11 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ type
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 @@ type
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
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 @@ end;
{ 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 @@ end;
{ TSocket }
constructor TSocketImpl.Create(AClient : TCustomIpClient);
constructor TSocketImpl.Create( const AClient : TCustomIpClient);
var
stream : IThriftStream;
begin
@ -773,7 +773,7 @@ begin
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 @@ begin
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 @@ end;
{ TBufferedTransportImpl }
constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport);
constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport);
begin
Create( ATransport, 1024 );
end;
@ -977,7 +977,7 @@ begin
FTransport.Close;
end;
constructor TBufferedTransportImpl.Create(ATransport: IStreamTransport;
constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport;
ABufSize: Integer);
begin
FTransport := ATransport;
@ -1064,7 +1064,7 @@ begin
FTransport.Close;
end;
constructor TFramedTransportImpl.Create(ATrans: ITransport);
constructor TFramedTransportImpl.Create( const ATrans: ITransport);
begin
InitWriteBuffer;
FTransport := ATrans;
@ -1176,7 +1176,7 @@ end;
{ 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 @@ begin
FTcpClient.Close;
end;
constructor TTcpSocketStreamImpl.Create(ATcpClient: TCustomIpClient);
constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient);
begin
FTcpClient := ATcpClient;
end;

View 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;

View File

@ -65,7 +65,7 @@ type
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 @@ begin
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;

View 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;