summaryrefslogtreecommitdiff
path: root/lib/delphi
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2019-11-09 23:24:52 +0100
committerJens Geyer <jensg@apache.org>2019-11-13 09:34:58 +0100
commitfad7fd3e5a850c0f4bf57e7370fad359d575fdc6 (patch)
treec92cb9fb6ad206d1a00a64236c331b80e812f06b /lib/delphi
parent9f11c1e545a9aa0db076e9b5be9b7e397e594f4a (diff)
downloadthrift-fad7fd3e5a850c0f4bf57e7370fad359d575fdc6.tar.gz
THRIFT-5005 Refactoring of the Delphi libs [ci skip]
Client: Delphi Patch: Jens Geyer
Diffstat (limited to 'lib/delphi')
-rw-r--r--lib/delphi/src/Thrift.Collections.pas12
-rw-r--r--lib/delphi/src/Thrift.Processor.Multiplex.pas18
-rw-r--r--lib/delphi/src/Thrift.Protocol.Compact.pas16
-rw-r--r--lib/delphi/src/Thrift.Protocol.JSON.pas24
-rw-r--r--lib/delphi/src/Thrift.Protocol.Multiplex.pas2
-rw-r--r--lib/delphi/src/Thrift.Protocol.pas85
-rw-r--r--lib/delphi/src/Thrift.Serializer.pas4
-rw-r--r--lib/delphi/src/Thrift.Server.pas162
-rw-r--r--lib/delphi/src/Thrift.Socket.pas6
-rw-r--r--lib/delphi/src/Thrift.Stream.pas13
-rw-r--r--lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas4
-rw-r--r--lib/delphi/src/Thrift.Transport.Pipes.pas2
-rw-r--r--lib/delphi/src/Thrift.Transport.WinHTTP.pas10
-rw-r--r--lib/delphi/src/Thrift.Transport.pas54
-rw-r--r--lib/delphi/src/Thrift.TypeRegistry.pas2
-rw-r--r--lib/delphi/src/Thrift.pas24
-rw-r--r--lib/delphi/test/serializer/TestSerializer.dpr7
17 files changed, 221 insertions, 224 deletions
diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas
index 3b56fe205..ad852acca 100644
--- a/lib/delphi/src/Thrift.Collections.pas
+++ b/lib/delphi/src/Thrift.Collections.pas
@@ -65,9 +65,9 @@ type
end;
TThriftDictionaryImpl<TKey,TValue> = class( TInterfacedObject, IThriftDictionary<TKey,TValue>, IThriftContainer, ISupportsToString)
- private
+ strict private
FDictionaly : TDictionary<TKey,TValue>;
- protected
+ strict protected
function GetEnumerator: TEnumerator<TPair<TKey,TValue>>;
function GetKeys: TDictionary<TKey,TValue>.TKeyCollection;
@@ -142,9 +142,9 @@ type
end;
TThriftListImpl<T> = class( TInterfacedObject, IThriftList<T>, IThriftContainer, ISupportsToString)
- private
+ strict private
FList : TList<T>;
- protected
+ strict protected
function GetEnumerator: TEnumerator<T>;
function GetCapacity: Integer;
procedure SetCapacity(Value: Integer);
@@ -205,10 +205,10 @@ type
end;
THashSetImpl<TValue> = class( TInterfacedObject, IHashSet<TValue>, IThriftContainer, ISupportsToString)
- private
+ strict private
FDictionary : IThriftDictionary<TValue,Integer>;
FIsReadOnly: Boolean;
- protected
+ strict protected
function GetEnumerator: TEnumerator<TValue>;
function GetIsReadOnly: Boolean;
function GetCount: Integer;
diff --git a/lib/delphi/src/Thrift.Processor.Multiplex.pas b/lib/delphi/src/Thrift.Processor.Multiplex.pas
index 8cf23db07..622f730f2 100644
--- a/lib/delphi/src/Thrift.Processor.Multiplex.pas
+++ b/lib/delphi/src/Thrift.Processor.Multiplex.pas
@@ -62,19 +62,19 @@ type
TMultiplexedProcessorImpl = class( TInterfacedObject, IMultiplexedProcessor, IProcessor)
- private type
+ strict private type
// Our goal was to work with any protocol. In order to do that, we needed
// to allow them to call readMessageBegin() and get a TMessage in exactly
// the standard format, without the service name prepended to TMessage.name.
TStoredMessageProtocol = class( TProtocolDecorator)
- private
+ strict private
FMessageBegin : TThriftMessage;
public
constructor Create( const protocol : IProtocol; const aMsgBegin : TThriftMessage);
function ReadMessageBegin: TThriftMessage; override;
end;
- private
+ strict private
FServiceProcessorMap : TDictionary<String, IProcessor>;
FDefaultProcessor : IProcessor;
@@ -113,12 +113,6 @@ begin
end;
-function TMultiplexedProcessorImpl.TStoredMessageProtocol.ReadMessageBegin: TThriftMessage;
-begin
- result := FMessageBegin;
-end;
-
-
constructor TMultiplexedProcessorImpl.Create;
begin
inherited Create;
@@ -136,6 +130,12 @@ begin
end;
+function TMultiplexedProcessorImpl.TStoredMessageProtocol.ReadMessageBegin: TThriftMessage;
+begin
+ result := FMessageBegin;
+end;
+
+
procedure TMultiplexedProcessorImpl.RegisterProcessor( const serviceName : String; const processor : IProcessor; const asDefault : Boolean);
begin
FServiceProcessorMap.Add( serviceName, processor);
diff --git a/lib/delphi/src/Thrift.Protocol.Compact.pas b/lib/delphi/src/Thrift.Protocol.Compact.pas
index 07cab9a05..866bd26e3 100644
--- a/lib/delphi/src/Thrift.Protocol.Compact.pas
+++ b/lib/delphi/src/Thrift.Protocol.Compact.pas
@@ -47,7 +47,7 @@ type
function GetProtocol( const trans: ITransport): IProtocol;
end;
- private const
+ strict private const
{ TODO
static TStruct ANONYMOUS_STRUCT = new TStruct("");
@@ -61,7 +61,7 @@ type
TYPE_BITS = Byte( $07); // 0000 0111
TYPE_SHIFT_AMOUNT = Byte( 5);
- private type
+ strict private type
// All of the on-wire type codes.
Types = (
STOP = $00,
@@ -79,7 +79,7 @@ type
STRUCT = $0C
);
- private const
+ strict private const
ttypeToCompactType : array[TType] of Types = (
Types.STOP, // Stop = 0,
Types(-1), // Void = 1,
@@ -115,7 +115,7 @@ type
TType.Struct // STRUCT
);
- private
+ strict private
// Used to keep track of the last field for the current and previous structs,
// so we can do the delta stuff.
lastField_ : TStack<Integer>;
@@ -123,11 +123,11 @@ type
// If we encounter a boolean field begin, save the TField here so it can
// have the value incorporated.
- private booleanField_ : TThriftField;
+ strict private booleanField_ : TThriftField;
// If we Read a field header, and it's a boolean field, save the boolean
// value here so that ReadBool can use it.
- private boolValue_ : ( unused, bool_true, bool_false);
+ strict private boolValue_ : ( unused, bool_true, bool_false);
public
constructor Create(const trans : ITransport);
@@ -135,7 +135,7 @@ type
procedure Reset;
- private
+ strict private
procedure WriteByteDirect( const b : Byte); overload;
// Writes a byte without any possibility of all that field header nonsense.
@@ -145,7 +145,7 @@ type
// TODO: make a permanent buffer like WriteVarint64?
procedure WriteVarint32( n : Cardinal);
- private
+ strict private
// The workhorse of WriteFieldBegin. It has the option of doing a 'type override'
// of the type header. This is used specifically in the boolean field case.
procedure WriteFieldBeginInternal( const field : TThriftField; typeOverride : Byte);
diff --git a/lib/delphi/src/Thrift.Protocol.JSON.pas b/lib/delphi/src/Thrift.Protocol.JSON.pas
index 30600aa80..85cb973f9 100644
--- a/lib/delphi/src/Thrift.Protocol.JSON.pas
+++ b/lib/delphi/src/Thrift.Protocol.JSON.pas
@@ -52,17 +52,17 @@ type
function GetProtocol( const trans: ITransport): IProtocol;
end;
- private
+ strict private
class function GetTypeNameForTypeID(typeID : TType) : string;
class function GetTypeIDForTypeName( const name : string) : TType;
- protected
+ strict protected
type
// Base class for tracking JSON contexts that may require
// inserting/Reading additional JSON syntax characters.
// This base context does nothing.
TJSONBaseContext = class
- protected
+ strict protected
FProto : Pointer; // weak IJSONProtocol;
public
constructor Create( const aProto : IJSONProtocol);
@@ -74,7 +74,7 @@ type
// Context for JSON lists.
// Will insert/Read commas before each item except for the first one.
TJSONListContext = class( TJSONBaseContext)
- private
+ strict private
FFirst : Boolean;
public
constructor Create( const aProto : IJSONProtocol);
@@ -86,7 +86,7 @@ type
// pair, and commas before each key except the first. In addition, will indicate that numbers
// in the key position need to be escaped in quotes (since JSON keys must be strings).
TJSONPairContext = class( TJSONBaseContext)
- private
+ strict private
FFirst, FColon : Boolean;
public
constructor Create( const aProto : IJSONProtocol);
@@ -97,11 +97,13 @@ type
// Holds up to one byte from the transport
TLookaheadReader = class
- protected
+ strict protected
FProto : Pointer; // weak IJSONProtocol;
+
+ protected
constructor Create( const aProto : IJSONProtocol);
- private
+ strict private
FHasData : Boolean;
FData : Byte;
@@ -115,7 +117,7 @@ type
function Peek : Byte;
end;
- protected
+ strict protected
// Stack of nested contexts that we may be in
FContextStack : TStack<TJSONBaseContext>;
@@ -135,12 +137,12 @@ type
constructor Create( const aTrans : ITransport);
destructor Destroy; override;
- protected
+ strict protected
// IJSONProtocol
// Read a byte that must match b; otherwise an exception is thrown.
procedure ReadJSONSyntaxChar( b : Byte);
- private
+ strict private
// Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its corresponding hex value
class function HexVal( ch : Byte) : Byte;
@@ -213,7 +215,7 @@ type
function ReadBinary: TBytes; override;
- private
+ strict private
// Reading methods.
// Read in a JSON string, unescaping as appropriate.
diff --git a/lib/delphi/src/Thrift.Protocol.Multiplex.pas b/lib/delphi/src/Thrift.Protocol.Multiplex.pas
index 93a38380d..e5e0cd9fe 100644
--- a/lib/delphi/src/Thrift.Protocol.Multiplex.pas
+++ b/lib/delphi/src/Thrift.Protocol.Multiplex.pas
@@ -54,7 +54,7 @@ type
{ Used to delimit the service name from the function name }
SEPARATOR = ':';
- private
+ strict private
FServiceName : String;
public
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 47e88fe67..7c802214d 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -106,7 +106,6 @@ type
end;
-
IProtocolFactory = interface
['{7CD64A10-4E9F-4E99-93BF-708A31F4A67B}']
function GetProtocol( const trans: ITransport): IProtocol;
@@ -123,7 +122,7 @@ type
NOT_IMPLEMENTED = 5,
DEPTH_LIMIT = 6
);
- protected
+ strict protected
constructor HiddenCreate(const Msg: string);
class function GetType: TExceptionType; virtual; abstract;
public
@@ -142,37 +141,37 @@ type
end;
TProtocolExceptionUnknown = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionInvalidData = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionNegativeSize = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionSizeLimit = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionBadVersion = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionNotImplemented = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
TProtocolExceptionDepthLimit = class (TProtocolExceptionSpecialized)
- protected
+ strict protected
class function GetType: TProtocolException.TExceptionType; override;
end;
@@ -189,7 +188,7 @@ type
end;
TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRecursionTracker)
- protected
+ strict protected
FProtocol : IProtocol;
public
constructor Create( prot : IProtocol);
@@ -255,7 +254,7 @@ type
end;
TProtocolImpl = class abstract( TInterfacedObject, IProtocol)
- protected
+ strict protected
FTrans : ITransport;
FRecursionLimit : Integer;
FRecursionDepth : Integer;
@@ -326,33 +325,30 @@ type
TBinaryProtocolImpl = class( TProtocolImpl )
- protected
+ strict protected
const
VERSION_MASK : Cardinal = $ffff0000;
VERSION_1 : Cardinal = $80010000;
- protected
+ strict protected
FStrictRead : Boolean;
FStrictWrite : Boolean;
- private
+ strict private
function ReadAll( const pBuf : Pointer; const buflen : Integer; off: Integer; len: Integer ): Integer; inline;
function ReadStringBody( size: Integer): string;
public
-
type
TFactory = class( TInterfacedObject, IProtocolFactory)
- protected
+ strict protected
FStrictRead : Boolean;
FStrictWrite : Boolean;
- public
function GetProtocol( const trans: ITransport): IProtocol;
- constructor Create( AStrictRead, AStrictWrite: Boolean ); overload;
- constructor Create; overload;
+ public
+ constructor Create( const aStrictRead : Boolean = FALSE; const aStrictWrite: Boolean = TRUE); reintroduce;
end;
- constructor Create( const trans: ITransport); overload;
- constructor Create( const trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;
+ constructor Create( const trans: ITransport; strictRead: Boolean = FALSE; strictWrite: Boolean = TRUE); reintroduce;
procedure WriteMessageBegin( const msg: TThriftMessage); override;
procedure WriteMessageEnd; override;
@@ -405,7 +401,7 @@ type
See p.175 of Design Patterns (by Gamma et al.)
}
TProtocolDecorator = class( TProtocolImpl)
- private
+ strict private
FWrappedProtocol : IProtocol;
public
@@ -507,13 +503,13 @@ procedure Init( var rec : TThriftList; const AElementType: TType = Low(TType)
implementation
-function ConvertInt64ToDouble( const n: Int64): Double;
+function ConvertInt64ToDouble( const n: Int64): Double; inline;
begin
ASSERT( SizeOf(n) = SizeOf(Result));
System.Move( n, Result, SizeOf(Result));
end;
-function ConvertDoubleToInt64( const d: Double): Int64;
+function ConvertDoubleToInt64( const d: Double): Int64; inline;
begin
ASSERT( SizeOf(d) = SizeOf(Result));
System.Move( d, Result, SizeOf(Result));
@@ -595,8 +591,7 @@ begin
Result := '';
b := ReadBinary;
len := Length( b );
- if len > 0 then
- begin
+ if len > 0 then begin
SetLength( Result, len);
System.Move( b[0], Pointer(Result)^, len );
end;
@@ -614,8 +609,7 @@ var
begin
len := Length(s);
SetLength( b, len);
- if len > 0 then
- begin
+ if len > 0 then begin
System.Move( Pointer(s)^, b[0], len );
end;
WriteBinary( b );
@@ -693,16 +687,9 @@ end;
{ TBinaryProtocolImpl }
-constructor TBinaryProtocolImpl.Create( const trans: ITransport);
-begin
- //no inherited
- Create( trans, False, True);
-end;
-
-constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead,
- strictWrite: Boolean);
+constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead, strictWrite: Boolean);
begin
- inherited Create( trans );
+ inherited Create( trans);
FStrictRead := strictRead;
FStrictWrite := strictWrite;
end;
@@ -718,7 +705,7 @@ var
buf : TBytes;
begin
size := ReadI32;
- SetLength( buf, size );
+ SetLength( buf, size);
FTrans.ReadAll( buf, 0, size);
Result := buf;
end;
@@ -853,10 +840,9 @@ begin
end;
function TBinaryProtocolImpl.ReadStringBody( size: Integer): string;
-var
- buf : TBytes;
+var buf : TBytes;
begin
- SetLength( buf, size );
+ SetLength( buf, size);
FTrans.ReadAll( buf, 0, size );
Result := TEncoding.UTF8.GetString( buf);
end;
@@ -971,17 +957,14 @@ begin
end;
procedure TBinaryProtocolImpl.WriteMessageBegin( const msg: TThriftMessage);
-var
- version : Cardinal;
+var version : Cardinal;
begin
- if FStrictWrite then
- begin
+ if FStrictWrite then begin
version := VERSION_1 or Cardinal( msg.Type_);
WriteI32( Integer( version) );
WriteString( msg.Name);
WriteI32( msg.SeqID);
- end else
- begin
+ end else begin
WriteString( msg.Name);
WriteByte(ShortInt( msg.Type_));
WriteI32( msg.SeqID);
@@ -1099,19 +1082,13 @@ end;
{ TBinaryProtocolImpl.TFactory }
-constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean);
+constructor TBinaryProtocolImpl.TFactory.Create( const aStrictRead, aStrictWrite: Boolean);
begin
inherited Create;
FStrictRead := AStrictRead;
FStrictWrite := AStrictWrite;
end;
-constructor TBinaryProtocolImpl.TFactory.Create;
-begin
- //no inherited;
- Create( False, True )
-end;
-
function TBinaryProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;
begin
Result := TBinaryProtocolImpl.Create( trans, FStrictRead, FStrictWrite);
diff --git a/lib/delphi/src/Thrift.Serializer.pas b/lib/delphi/src/Thrift.Serializer.pas
index 5f2905a97..71b695cde 100644
--- a/lib/delphi/src/Thrift.Serializer.pas
+++ b/lib/delphi/src/Thrift.Serializer.pas
@@ -36,7 +36,7 @@ uses
type
// Generic utility for easily serializing objects into a byte array or Stream.
TSerializer = class
- private
+ strict private
FStream : TMemoryStream;
FTransport : ITransport;
FProtocol : IProtocol;
@@ -60,7 +60,7 @@ type
// Generic utility for easily deserializing objects from byte array or Stream.
TDeserializer = class
- private
+ strict private
FStream : TMemoryStream;
FTransport : ITransport;
FProtocol : IProtocol;
diff --git a/lib/delphi/src/Thrift.Server.pas b/lib/delphi/src/Thrift.Server.pas
index 13c5762cf..c7cce7375 100644
--- a/lib/delphi/src/Thrift.Server.pas
+++ b/lib/delphi/src/Thrift.Server.pas
@@ -61,7 +61,7 @@ type
public
type
TLogDelegate = reference to procedure( const str: string);
- protected
+ strict protected
FProcessor : IProcessor;
FServerTransport : IServerTransport;
FInputTransportFactory : ITransportFactory;
@@ -80,51 +80,68 @@ type
procedure Stop; virtual; abstract;
public
constructor Create(
- const AProcessor :IProcessor;
- const AServerTransport: IServerTransport;
- const AInputTransportFactory : ITransportFactory;
- const AOutputTransportFactory : ITransportFactory;
- const AInputProtocolFactory : IProtocolFactory;
- const AOutputProtocolFactory : IProtocolFactory;
- const 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(
- const AProcessor :IProcessor;
- const AServerTransport: IServerTransport
+ const aProcessor :IProcessor;
+ const aServerTransport: IServerTransport
); overload;
constructor Create(
- const AProcessor :IProcessor;
- const AServerTransport: IServerTransport;
- const ALogDelegate: TLogDelegate
+ const aProcessor :IProcessor;
+ const aServerTransport: IServerTransport;
+ const aLogDelegate: TLogDelegate
); overload;
constructor Create(
- const AProcessor :IProcessor;
- const AServerTransport: IServerTransport;
- const ATransportFactory : ITransportFactory
+ const aProcessor :IProcessor;
+ const aServerTransport: IServerTransport;
+ const aTransportFactory : ITransportFactory
); overload;
constructor Create(
- const AProcessor :IProcessor;
- const AServerTransport: IServerTransport;
- const ATransportFactory : ITransportFactory;
- const AProtocolFactory : IProtocolFactory
+ const aProcessor :IProcessor;
+ const aServerTransport: IServerTransport;
+ const aTransportFactory : ITransportFactory;
+ const aProtocolFactory : IProtocolFactory
); overload;
end;
+
TSimpleServer = class( TServerImpl)
- private
+ strict private
FStop : Boolean;
public
- constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport); overload;
- constructor Create( const AProcessor: IProcessor; const AServerTransport: IServerTransport;
- ALogDel: TServerImpl.TLogDelegate); 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;
+ constructor Create(
+ const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport
+ ); overload;
+
+ constructor Create(
+ const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport;
+ const ALogDel: TServerImpl.TLogDelegate
+ ); 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;
@@ -135,8 +152,9 @@ implementation
{ TServerImpl }
-constructor TServerImpl.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; const ALogDelegate: TLogDelegate);
+constructor TServerImpl.Create( const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport;
+ const aLogDelegate: TLogDelegate);
var
InputFactory, OutputFactory : IProtocolFactory;
InputTransFactory, OutputTransFactory : ITransportFactory;
@@ -149,8 +167,8 @@ begin
//no inherited;
Create(
- AProcessor,
- AServerTransport,
+ aProcessor,
+ aServerTransport,
InputTransFactory,
OutputTransFactory,
InputFactory,
@@ -159,8 +177,8 @@ begin
);
end;
-constructor TServerImpl.Create(const AProcessor: IProcessor;
- const AServerTransport: IServerTransport);
+constructor TServerImpl.Create(const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport);
var
InputFactory, OutputFactory : IProtocolFactory;
InputTransFactory, OutputTransFactory : ITransportFactory;
@@ -173,8 +191,8 @@ begin
//no inherited;
Create(
- AProcessor,
- AServerTransport,
+ aProcessor,
+ aServerTransport,
InputTransFactory,
OutputTransFactory,
InputFactory,
@@ -183,8 +201,8 @@ begin
);
end;
-constructor TServerImpl.Create(const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory);
+constructor TServerImpl.Create(const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport; const aTransportFactory: ITransportFactory);
var
InputProtocolFactory : IProtocolFactory;
OutputProtocolFactory : IProtocolFactory;
@@ -193,24 +211,24 @@ begin
OutputProtocolFactory := TBinaryProtocolImpl.TFactory.Create;
//no inherited;
- Create( AProcessor, AServerTransport, ATransportFactory, ATransportFactory,
+ Create( aProcessor, aServerTransport, aTransportFactory, aTransportFactory,
InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate);
end;
-constructor TServerImpl.Create(const AProcessor: IProcessor;
- const AServerTransport: IServerTransport;
- const AInputTransportFactory, AOutputTransportFactory: ITransportFactory;
- const AInputProtocolFactory, AOutputProtocolFactory: IProtocolFactory;
- const ALogDelegate : TLogDelegate);
+constructor TServerImpl.Create(const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport;
+ const aInputTransportFactory, aOutputTransportFactory: ITransportFactory;
+ const aInputProtocolFactory, aOutputProtocolFactory: IProtocolFactory;
+ const aLogDelegate : TLogDelegate);
begin
inherited Create;
- FProcessor := AProcessor;
- FServerTransport := AServerTransport;
- FInputTransportFactory := AInputTransportFactory;
- FOutputTransportFactory := AOutputTransportFactory;
- FInputProtocolFactory := AInputProtocolFactory;
- FOutputProtocolFactory := AOutputProtocolFactory;
- FLogDelegate := ALogDelegate;
+ FProcessor := aProcessor;
+ FServerTransport := aServerTransport;
+ FInputTransportFactory := aInputTransportFactory;
+ FOutputTransportFactory := aOutputTransportFactory;
+ FInputProtocolFactory := aInputProtocolFactory;
+ FOutputProtocolFactory := aOutputProtocolFactory;
+ FLogDelegate := aLogDelegate;
end;
class procedure TServerImpl.DefaultLogDelegate( const str: string);
@@ -223,14 +241,14 @@ begin
end;
end;
-constructor TServerImpl.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory;
- const AProtocolFactory: IProtocolFactory);
+constructor TServerImpl.Create( const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport; const aTransportFactory: ITransportFactory;
+ const aProtocolFactory: IProtocolFactory);
begin
//no inherited;
- Create( AProcessor, AServerTransport,
- ATransportFactory, ATransportFactory,
- AProtocolFactory, AProtocolFactory,
+ Create( aProcessor, aServerTransport,
+ aTransportFactory, aTransportFactory,
+ aProtocolFactory, aProtocolFactory,
DefaultLogDelegate);
end;
@@ -250,8 +268,8 @@ end;
{ TSimpleServer }
-constructor TSimpleServer.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport);
+constructor TSimpleServer.Create( const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport);
var
InputProtocolFactory : IProtocolFactory;
OutputProtocolFactory : IProtocolFactory;
@@ -263,12 +281,12 @@ begin
InputTransportFactory := TTransportFactoryImpl.Create;
OutputTransportFactory := TTransportFactoryImpl.Create;
- inherited Create( AProcessor, AServerTransport, InputTransportFactory,
+ inherited Create( aProcessor, aServerTransport, InputTransportFactory,
OutputTransportFactory, InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate);
end;
-constructor TSimpleServer.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; ALogDel: TServerImpl.TLogDelegate);
+constructor TSimpleServer.Create( const aProcessor: IProcessor;
+ const aServerTransport: IServerTransport; const ALogDel: TServerImpl.TLogDelegate);
var
InputProtocolFactory : IProtocolFactory;
OutputProtocolFactory : IProtocolFactory;
@@ -280,23 +298,23 @@ begin
InputTransportFactory := TTransportFactoryImpl.Create;
OutputTransportFactory := TTransportFactoryImpl.Create;
- inherited Create( AProcessor, AServerTransport, InputTransportFactory,
+ inherited Create( aProcessor, aServerTransport, InputTransportFactory,
OutputTransportFactory, InputProtocolFactory, OutputProtocolFactory, ALogDel);
end;
-constructor TSimpleServer.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; const 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);
+ inherited Create( aProcessor, aServerTransport, aTransportFactory,
+ aTransportFactory, TBinaryProtocolImpl.TFactory.Create, TBinaryProtocolImpl.TFactory.Create, DefaultLogDelegate);
end;
-constructor TSimpleServer.Create( const AProcessor: IProcessor;
- const AServerTransport: IServerTransport; const ATransportFactory: ITransportFactory;
- const 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);
+ inherited Create( aProcessor, aServerTransport, aTransportFactory,
+ aTransportFactory, aProtocolFactory, aProtocolFactory, DefaultLogDelegate);
end;
procedure TSimpleServer.Serve;
diff --git a/lib/delphi/src/Thrift.Socket.pas b/lib/delphi/src/Thrift.Socket.pas
index f0cab79db..b33f20276 100644
--- a/lib/delphi/src/Thrift.Socket.pas
+++ b/lib/delphi/src/Thrift.Socket.pas
@@ -81,7 +81,7 @@ type
TScopeId = record
public
Value: ULONG;
- private
+ strict private
function GetBitField(Loc: Integer): Integer; inline;
procedure SetBitField(Loc: Integer; const aValue: Integer); inline;
public
@@ -125,7 +125,7 @@ type
ISmartPointer<T> = reference to function: T;
TSmartPointer<T> = class(TInterfacedObject, ISmartPointer<T>)
- private
+ strict private
FValue: T;
FDestroyer: TSmartPointerDestroyer<T>;
public
@@ -147,7 +147,7 @@ type
class constructor Create;
class destructor Destroy;
class procedure DefaultLogDelegate(const Str: string);
- protected type
+ strict protected type
IGetAddrInfoWrapper = interface
function Init: Integer;
function GetRes: PAddrInfoW;
diff --git a/lib/delphi/src/Thrift.Stream.pas b/lib/delphi/src/Thrift.Stream.pas
index 3308c53a5..7cb9219b6 100644
--- a/lib/delphi/src/Thrift.Stream.pas
+++ b/lib/delphi/src/Thrift.Stream.pas
@@ -36,7 +36,6 @@ uses
Thrift.Utils;
type
-
IThriftStream = interface
['{2A77D916-7446-46C1-8545-0AEC0008DBCA}']
procedure Write( const buffer: TBytes; offset: Integer; count: Integer); overload;
@@ -51,9 +50,9 @@ type
end;
TThriftStreamImpl = class( TInterfacedObject, IThriftStream)
- private
+ strict private
procedure CheckSizeAndOffset( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer); overload;
- protected
+ strict protected
procedure Write( const buffer: TBytes; offset: Integer; count: Integer); overload; inline;
procedure Write( const pBuf : Pointer; offset: Integer; count: Integer); overload; virtual;
function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; overload; inline;
@@ -66,10 +65,10 @@ type
end;
TThriftStreamAdapterDelphi = class( TThriftStreamImpl )
- private
+ strict private
FStream : TStream;
FOwnsStream : Boolean;
- protected
+ strict protected
procedure Write( const pBuf : Pointer; offset: Integer; count: Integer); override;
function Read( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer): Integer; override;
procedure Open; override;
@@ -83,9 +82,9 @@ type
end;
TThriftStreamAdapterCOM = class( TThriftStreamImpl)
- private
+ strict private
FStream : IStream;
- protected
+ strict protected
procedure Write( const pBuf : Pointer; offset: Integer; count: Integer); override;
function Read( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer): Integer; override;
procedure Open; override;
diff --git a/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas b/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
index c666e7fed..87bf23b04 100644
--- a/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
+++ b/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
@@ -41,7 +41,7 @@ uses
type
TMsxmlHTTPClientImpl = class( TTransportImpl, IHTTPClient)
- private
+ strict private
FUri : string;
FInputStream : IThriftStream;
FOutputStream : IThriftStream;
@@ -52,7 +52,7 @@ type
FCustomHeaders : IThriftDictionary<string,string>;
function CreateRequest: IXMLHTTPRequest;
- protected
+ strict protected
function GetIsOpen: Boolean; override;
procedure Open(); override;
procedure Close(); override;
diff --git a/lib/delphi/src/Thrift.Transport.Pipes.pas b/lib/delphi/src/Thrift.Transport.Pipes.pas
index 77a343b0c..9368f2fa9 100644
--- a/lib/delphi/src/Thrift.Transport.Pipes.pas
+++ b/lib/delphi/src/Thrift.Transport.Pipes.pas
@@ -199,7 +199,7 @@ type
FClientAnonWrite : THandle;
FTimeOut: DWORD;
- protected
+ strict protected
function Accept(const fnAccepting: TProc): ITransport; override;
function CreateAnonPipe : Boolean;
diff --git a/lib/delphi/src/Thrift.Transport.WinHTTP.pas b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
index 262e38fb1..0bf7e456f 100644
--- a/lib/delphi/src/Thrift.Transport.WinHTTP.pas
+++ b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
@@ -37,7 +37,7 @@ uses
type
TWinHTTPClientImpl = class( TTransportImpl, IHTTPClient)
- private
+ strict private
FUri : string;
FInputStream : IThriftStream;
FOutputMemoryStream : TMemoryStream;
@@ -51,14 +51,14 @@ type
function CreateRequest: IWinHTTPRequest;
function SecureProtocolsAsWinHTTPFlags : Cardinal;
- private
+ strict private
type
TErrorInfo = ( SplitUrl, WinHTTPSession, WinHTTPConnection, WinHTTPRequest, RequestSetup, AutoProxy );
THTTPResponseStream = class( TThriftStreamImpl)
- private
+ strict private
FRequest : IWinHTTPRequest;
- protected
+ strict protected
procedure Write( const pBuf : Pointer; offset: Integer; count: Integer); override;
function Read( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer): Integer; override;
procedure Open; override;
@@ -71,7 +71,7 @@ type
destructor Destroy; override;
end;
- protected
+ strict protected
function GetIsOpen: Boolean; override;
procedure Open(); override;
procedure Close(); override;
diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas
index df087a1e4..b6e3c99f6 100644
--- a/lib/delphi/src/Thrift.Transport.pas
+++ b/lib/delphi/src/Thrift.Transport.pas
@@ -64,7 +64,7 @@ type
end;
TTransportImpl = class( TInterfacedObject, ITransport)
- protected
+ strict protected
function GetIsOpen: Boolean; virtual; abstract;
property IsOpen: Boolean read GetIsOpen;
function Peek: Boolean; virtual;
@@ -93,7 +93,7 @@ type
BadArgs,
Interrupted
);
- protected
+ strict protected
constructor HiddenCreate(const Msg: string);
class function GetType: TExceptionType; virtual; abstract;
public
@@ -110,37 +110,37 @@ type
end;
TTransportExceptionUnknown = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionNotOpen = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionAlreadyOpen = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionTimedOut = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionEndOfFile = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionBadArgs = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
TTransportExceptionInterrupted = class (TTransportExceptionSpecialized)
- protected
+ strict protected
class function GetType: TTransportException.TExceptionType; override;
end;
@@ -182,7 +182,7 @@ type
end;
TServerTransportImpl = class( TInterfacedObject, IServerTransport)
- protected
+ strict protected
procedure Listen; virtual; abstract;
procedure Close; virtual; abstract;
function Accept( const fnAccepting: TProc): ITransport; virtual; abstract;
@@ -199,9 +199,9 @@ type
TTcpSocketStreamImpl = class( TThriftStreamImpl )
{$IFDEF OLD_SOCKETS}
- private type
+ strict private type
TWaitForData = ( wfd_HaveData, wfd_Timeout, wfd_Error);
- private
+ strict private
FTcpClient : TCustomIpClient;
FTimeout : Integer;
function Select( ReadReady, WriteReady, ExceptFlag: PBoolean;
@@ -210,10 +210,10 @@ type
var wsaError, bytesReady : Integer): TWaitForData;
{$ELSE}
FTcpClient: TSocket;
- protected const
+ strict protected const
SLEEP_TIME = 200;
{$ENDIF}
- protected
+ strict protected
procedure Write( const pBuf : Pointer; offset, count: Integer); override;
function Read( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer): Integer; override;
procedure Open; override;
@@ -239,10 +239,10 @@ type
end;
TStreamTransportImpl = class( TTransportImpl, IStreamTransport)
- protected
+ strict protected
FInputStream : IThriftStream;
FOutputStream : IThriftStream;
- protected
+ strict protected
function GetIsOpen: Boolean; override;
function GetInputStream: IThriftStream;
@@ -261,12 +261,12 @@ type
end;
TBufferedStreamImpl = class( TThriftStreamImpl)
- private
+ strict private
FStream : IThriftStream;
FBufSize : Integer;
FReadBuffer : TMemoryStream;
FWriteBuffer : TMemoryStream;
- protected
+ strict protected
procedure Write( const pBuf : Pointer; offset: Integer; count: Integer); override;
function Read( const pBuf : Pointer; const buflen : Integer; offset: Integer; count: Integer): Integer; override;
procedure Open; override;
@@ -280,7 +280,7 @@ type
end;
TServerSocketImpl = class( TServerTransportImpl)
- private
+ strict private
{$IFDEF OLD_SOCKETS}
FServer : TTcpServer;
FPort : Integer;
@@ -290,7 +290,7 @@ type
{$ENDIF}
FUseBufferedSocket : Boolean;
FOwnsServer : Boolean;
- protected
+ strict protected
function Accept( const fnAccepting: TProc) : ITransport; override;
public
{$IFDEF OLD_SOCKETS}
@@ -306,7 +306,7 @@ type
end;
TBufferedTransportImpl = class( TTransportImpl )
- private
+ strict private
FInputBuffer : IThriftStream;
FOutputBuffer : IThriftStream;
FTransport : IStreamTransport;
@@ -314,7 +314,7 @@ type
procedure InitBuffers;
function GetUnderlyingTransport: ITransport;
- protected
+ strict protected
function GetIsOpen: Boolean; override;
procedure Flush; override;
public
@@ -329,7 +329,7 @@ type
end;
TSocketImpl = class(TStreamTransportImpl)
- private
+ strict private
{$IFDEF OLD_SOCKETS}
FClient : TCustomIpClient;
{$ELSE}
@@ -345,7 +345,7 @@ type
{$ENDIF}
procedure InitSocket;
- protected
+ strict protected
function GetIsOpen: Boolean; override;
public
procedure Open; override;
@@ -368,11 +368,11 @@ type
end;
TFramedTransportImpl = class( TTransportImpl)
- private const
+ strict private const
FHeaderSize : Integer = 4;
- private class var
+ strict private class var
FHeader_Dummy : array of Byte;
- protected
+ strict protected
FTransport : ITransport;
FWriteBuffer : TMemoryStream;
FReadBuffer : TMemoryStream;
diff --git a/lib/delphi/src/Thrift.TypeRegistry.pas b/lib/delphi/src/Thrift.TypeRegistry.pas
index c18e97fe6..3d31c52a3 100644
--- a/lib/delphi/src/Thrift.TypeRegistry.pas
+++ b/lib/delphi/src/Thrift.TypeRegistry.pas
@@ -29,7 +29,7 @@ type
TFactoryMethod<T> = function:T;
TypeRegistry = class
- private
+ strict private
class var FTypeInfoToFactoryLookup : TDictionary<Pointer, Pointer>;
public
class constructor Create;
diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas
index abc0c1eb6..716e4d22c 100644
--- a/lib/delphi/src/Thrift.pas
+++ b/lib/delphi/src/Thrift.pas
@@ -52,7 +52,7 @@ type
UnsupportedClientType
);
{$SCOPEDENUMS OFF}
- protected
+ strict protected
constructor HiddenCreate(const Msg: string);
class function GetType: TExceptionType; virtual; abstract;
class function GetSpecializedExceptionType(AType: TExceptionType): TApplicationExceptionSpecializedClass;
@@ -76,57 +76,57 @@ type
end;
TApplicationExceptionUnknown = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionUnknownMethod = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionInvalidMessageType = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionWrongMethodName = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionBadSequenceID = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionMissingResult = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionInternalError = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionProtocolError = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionInvalidTransform = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionInvalidProtocol = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
TApplicationExceptionUnsupportedClientType = class (TApplicationExceptionSpecialized)
- protected
+ strict protected
class function GetType: TApplicationException.TExceptionType; override;
end;
diff --git a/lib/delphi/test/serializer/TestSerializer.dpr b/lib/delphi/test/serializer/TestSerializer.dpr
index 56d0d15d4..39752cf70 100644
--- a/lib/delphi/test/serializer/TestSerializer.dpr
+++ b/lib/delphi/test/serializer/TestSerializer.dpr
@@ -22,7 +22,10 @@ program TestSerializer;
{$APPTYPE CONSOLE}
uses
- Classes, Windows, SysUtils, Generics.Collections,
+ Classes,
+ Windows,
+ SysUtils,
+ Generics.Collections,
Thrift in '..\..\src\Thrift.pas',
Thrift.Exception in '..\..\src\Thrift.Exception.pas',
Thrift.Socket in '..\..\src\Thrift.Socket.pas',
@@ -41,8 +44,6 @@ uses
DebugProtoTest,
TestSerializer.Data;
-
-
type
TTestSerializer = class //extends TestCase {
private type