From 718f6eefb6791128a5290b3c7cf47f025ed60c66 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 6 Sep 2013 21:02:34 +0200 Subject: [PATCH] THRIFT-2162 Missing calls to inherited CTOR at misc. places Patch: Jens Geyer --- .../cpp/src/generate/t_delphi_generator.cc | 1 + lib/delphi/src/Thrift.Collections.pas | 2 ++ lib/delphi/src/Thrift.Console.pas | 1 + lib/delphi/src/Thrift.Protocol.pas | 11 +++++--- lib/delphi/src/Thrift.Serializer.pas | 2 ++ lib/delphi/src/Thrift.Server.pas | 5 ++++ lib/delphi/src/Thrift.Stream.pas | 2 ++ lib/delphi/src/Thrift.Transport.pas | 25 +++++++++++++------ lib/delphi/test/TestClient.pas | 6 ++++- .../multiplexed/Multiplex.Client.Main.pas | 1 + 10 files changed, 45 insertions(+), 11 deletions(-) diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc index 547031d2..fd396eb4 100644 --- a/compiler/cpp/src/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/generate/t_delphi_generator.cc @@ -1441,6 +1441,7 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { ".TClient.Create( const iprot: IProtocol; const oprot: IProtocol);" << endl; indent_impl(s_service_impl) << "begin" << endl; indent_up_impl(); + indent_impl(s_service_impl) << "inherited Create;" << endl; indent_impl(s_service_impl) << "iprot_ := iprot;" << endl; indent_impl(s_service_impl) << "oprot_ := oprot;" << endl; indent_down_impl(); diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas index 66ff1c00..3a0274c9 100644 --- a/lib/delphi/src/Thrift.Collections.pas +++ b/lib/delphi/src/Thrift.Collections.pas @@ -320,6 +320,7 @@ end; constructor TThriftDictionaryImpl.Create(ACapacity: Integer); begin + inherited Create; FDictionaly := TDictionary.Create( ACapacity ); end; @@ -449,6 +450,7 @@ end; constructor TThriftListImpl.Create; begin + inherited; FList := TList.Create; end; diff --git a/lib/delphi/src/Thrift.Console.pas b/lib/delphi/src/Thrift.Console.pas index 324efc3a..5d1345bf 100644 --- a/lib/delphi/src/Thrift.Console.pas +++ b/lib/delphi/src/Thrift.Console.pas @@ -84,6 +84,7 @@ end; constructor TGUIConsole.Create( AMemo: TMemo); begin + inherited Create; FMemo := AMemo; FLineBreak := True; end; diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index 1f272038..e88f1cfa 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -516,6 +516,7 @@ end; constructor TFieldImpl.Create(const AName: string; const AType: TType; AId: SmallInt); begin + inherited Create; FName := AName; FType := AType; FId := AId; @@ -523,6 +524,7 @@ end; constructor TFieldImpl.Create; begin + inherited Create; FName := ''; FType := Low(TType); FId := 0; @@ -702,7 +704,7 @@ end; constructor TMapImpl.Create; begin - + inherited Create; end; function TMapImpl.GetCount: Integer; @@ -792,7 +794,7 @@ end; constructor TSetImpl.Create; begin - + inherited Create; end; function TSetImpl.GetCount: Integer; @@ -826,7 +828,7 @@ end; constructor TListImpl.Create; begin - + inherited Create; end; function TListImpl.GetCount: Integer; @@ -853,6 +855,7 @@ end; constructor TBinaryProtocolImpl.Create( const trans: ITransport); begin + //no inherited Create( trans, False, True); end; @@ -1253,12 +1256,14 @@ end; constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean); begin + inherited Create; FStrictRead := AStrictRead; FStrictWrite := AStrictWrite; end; constructor TBinaryProtocolImpl.TFactory.Create; begin + //no inherited; Create( False, True ) end; diff --git a/lib/delphi/src/Thrift.Serializer.pas b/lib/delphi/src/Thrift.Serializer.pas index dce68639..43b5d29e 100644 --- a/lib/delphi/src/Thrift.Serializer.pas +++ b/lib/delphi/src/Thrift.Serializer.pas @@ -86,6 +86,7 @@ implementation constructor TSerializer.Create(); // Create a new TSerializer that uses the TBinaryProtocol by default. begin + //no inherited; Create( TBinaryProtocolImpl.TFactory.Create); end; @@ -156,6 +157,7 @@ end; constructor TDeserializer.Create(); // Create a new TDeserializer that uses the TBinaryProtocol by default. begin + //no inherited; Create( TBinaryProtocolImpl.TFactory.Create); end; diff --git a/lib/delphi/src/Thrift.Server.pas b/lib/delphi/src/Thrift.Server.pas index e6ab7ac4..7d39f6bd 100644 --- a/lib/delphi/src/Thrift.Server.pas +++ b/lib/delphi/src/Thrift.Server.pas @@ -120,6 +120,7 @@ begin InputTransFactory := TTransportFactoryImpl.Create; OutputTransFactory := TTransportFactoryImpl.Create; + //no inherited; Create( AProcessor, AServerTransport, @@ -143,6 +144,7 @@ begin InputTransFactory := TTransportFactoryImpl.Create; OutputTransFactory := TTransportFactoryImpl.Create; + //no inherited; Create( AProcessor, AServerTransport, @@ -163,6 +165,7 @@ begin InputProtocolFactory := TBinaryProtocolImpl.TFactory.Create; OutputProtocolFactory := TBinaryProtocolImpl.TFactory.Create; + //no inherited; Create( AProcessor, AServerTransport, ATransportFactory, ATransportFactory, InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate); end; @@ -173,6 +176,7 @@ constructor TServerImpl.Create(const AProcessor: IProcessor; const AInputProtocolFactory, AOutputProtocolFactory: IProtocolFactory; const ALogDelegate : TLogDelegate); begin + inherited Create; FProcessor := AProcessor; FServerTransport := AServerTransport; FInputTransportFactory := AInputTransportFactory; @@ -191,6 +195,7 @@ 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, diff --git a/lib/delphi/src/Thrift.Stream.pas b/lib/delphi/src/Thrift.Stream.pas index 81d5d2a6..c08f5eae 100644 --- a/lib/delphi/src/Thrift.Stream.pas +++ b/lib/delphi/src/Thrift.Stream.pas @@ -98,6 +98,7 @@ end; constructor TThriftStreamAdapterCOM.Create( const AStream: IStream); begin + inherited Create; FStream := AStream; end; @@ -221,6 +222,7 @@ end; constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean); begin + inherited Create; FStream := AStream; FOwnsStream := AOwnsStream; end; diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas index 8668e5a2..0d5b384d 100644 --- a/lib/delphi/src/Thrift.Transport.pas +++ b/lib/delphi/src/Thrift.Transport.pas @@ -502,6 +502,7 @@ end; constructor TTransportException.Create(AType: TExceptionType); begin + //no inherited; Create( AType, '' ) end; @@ -539,17 +540,20 @@ end; constructor TServerSocketImpl.Create( const AServer: TTcpServer; AClientTimeout: Integer); begin + inherited Create; FServer := AServer; FClientTimeout := AClientTimeout; end; constructor TServerSocketImpl.Create( const AServer: TTcpServer); begin + //no inherited; Create( AServer, 0 ); end; constructor TServerSocketImpl.Create(APort: Integer); begin + //no inherited; Create( APort, 0 ); end; @@ -616,6 +620,7 @@ end; constructor TServerSocketImpl.Create(APort, AClientTimeout: Integer; AUseBufferedSockets: Boolean); begin + inherited Create; FPort := APort; FClientTimeout := AClientTimeout; FUseBufferedSocket := AUseBufferedSockets; @@ -655,6 +660,7 @@ end; constructor TServerSocketImpl.Create(APort, AClientTimeout: Integer); begin + //no inherited; Create( APort, AClientTimeout, False ); end; @@ -666,27 +672,25 @@ var begin FClient := AClient; stream := TTcpSocketStreamImpl.Create( FClient); - FInputStream := stream; - FOutputStream := stream; + inherited Create( stream, stream); end; constructor TSocketImpl.Create(const AHost: string; APort: Integer); begin + //no inherited; Create( AHost, APort, 0); end; procedure TSocketImpl.Close; begin inherited Close; - if FClient <> nil then - begin - FClient.Free; - FClient := nil; - end; + if FClient <> nil + then FreeAndNil( FClient); end; constructor TSocketImpl.Create(const AHost: string; APort, ATimeout: Integer); begin + inherited Create(nil,nil); FHost := AHost; FPort := APort; FTimeout := ATimeout; @@ -781,6 +785,7 @@ end; constructor TBufferedStreamImpl.Create( const AStream: IThriftStream; ABufSize: Integer); begin + inherited Create; FStream := AStream; FBufSize := ABufSize; FReadBuffer := TMemoryStream.Create; @@ -916,6 +921,7 @@ end; constructor TStreamTransportImpl.Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream); begin + inherited Create; FInputStream := AInputStream; FOutputStream := AOutputStream; end; @@ -980,6 +986,7 @@ end; constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport); begin + //no inherited; Create( ATransport, 1024 ); end; @@ -991,6 +998,7 @@ end; constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport; ABufSize: Integer); begin + inherited Create; FTransport := ATransport; FBufSize := ABufSize; InitBuffers; @@ -1067,6 +1075,7 @@ end; constructor TFramedTransportImpl.Create; begin + inherited Create; InitWriteBuffer; end; @@ -1077,6 +1086,7 @@ end; constructor TFramedTransportImpl.Create( const ATrans: ITransport); begin + inherited Create; InitWriteBuffer; FTransport := ATrans; end; @@ -1206,6 +1216,7 @@ end; constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient); begin + inherited Create; FTcpClient := ATcpClient; end; diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas index 37fe7d7c..e63bd4cb 100644 --- a/lib/delphi/test/TestClient.pas +++ b/lib/delphi/test/TestClient.pas @@ -66,7 +66,9 @@ type procedure ClientTest; procedure JSONProtocolReadWriteTest; + {$IFDEF StressTest} procedure StressTest(const client : TThriftTest.Iface); + {$ENDIF} protected procedure Execute; override; public @@ -859,6 +861,7 @@ begin end; +{$IFDEF StressTest} procedure TClientThread.StressTest(const client : TThriftTest.Iface); begin while TRUE do begin @@ -875,7 +878,7 @@ begin end; end; end; - +{$ENDIF} procedure TClientThread.JSONProtocolReadWriteTest; // Tests only then read/write procedures of the JSON protocol @@ -1080,6 +1083,7 @@ end; constructor TThreadConsole.Create(AThread: TThread); begin + inherited Create; FThread := AThread; end; diff --git a/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas b/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas index 2cc7ab03..a1af40b8 100644 --- a/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas +++ b/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas @@ -78,6 +78,7 @@ end; constructor TTestClient.Create( const args: array of string); begin + inherited; ParseArgs(args); Setup; end; -- 2.17.1