Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two feature #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ __recovery/

# Castalia statistics file (since XE7 Castalia is distributed with Delphi)
*.stat
/Generator/Test/Win32
125 changes: 92 additions & 33 deletions Generator/ProtoBufGenerator.dproj

Large diffs are not rendered by default.

Binary file modified Generator/ProtoBufGenerator.res
Binary file not shown.
163 changes: 74 additions & 89 deletions Generator/ProtoBufGeneratorConsole.dproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Generator/Test/ProtoBufGeneratorTests.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ program ProtoBufGeneratorTests;
uses
DUnitTestRunner,
TestuProtoBufParserClasses in 'TestuProtoBufParserClasses.pas',
TestuProtoBufGenerator in 'TestuProtoBufGenerator.pas',
uProtoBufParserClasses in '..\uProtoBufParserClasses.pas',
uProtoBufParserAbstractClasses in '..\uProtoBufParserAbstractClasses.pas',
uProtoBufGenerator in '..\uProtoBufGenerator.pas',
Expand All @@ -25,7 +26,6 @@ uses
pbOutput in '..\..\pbOutput.pas',
pbPublic in '..\..\pbPublic.pas',
StrBuffer in '..\..\StrBuffer.pas',
TestuProtoBufGenerator in 'TestuProtoBufGenerator.pas',
TestProtoBuf in 'TestProtoBuf.pas';

{R *.RES}
Expand Down
53 changes: 22 additions & 31 deletions Generator/Test/ProtoBufGeneratorTests.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Base)'=='true') or '$(Base_OSX32)'!=''">
<Base_OSX32>true</Base_OSX32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
Expand Down Expand Up @@ -59,9 +54,6 @@
<DCC_F>false</DCC_F>
<DCC_K>false</DCC_K>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_OSX32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXInterBaseDriver;emsclientfiredac;DataSnapFireDAC;tethering;FireDACMSSQLDriver;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;FireDACIBDriver;fmx;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;soapserver;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;DataSnapServer;xmlrtl;DataSnapNativeClient;ibxbindings;fmxobj;FireDACDSDriver;soapmidas;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;bindcomp;DBXInformixDriver;IndyIPClient;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;dsnapxml;dbrtl;FireDACMongoDBDriver;IndyProtocols;inetdbxpress;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
Expand Down Expand Up @@ -96,6 +88,7 @@
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="TestuProtoBufParserClasses.pas"/>
<DCCReference Include="TestuProtoBufGenerator.pas"/>
<DCCReference Include="..\uProtoBufParserClasses.pas"/>
<DCCReference Include="..\uProtoBufParserAbstractClasses.pas"/>
<DCCReference Include="..\uProtoBufGenerator.pas"/>
Expand All @@ -104,7 +97,6 @@
<DCCReference Include="..\..\pbOutput.pas"/>
<DCCReference Include="..\..\pbPublic.pas"/>
<DCCReference Include="..\..\StrBuffer.pas"/>
<DCCReference Include="TestuProtoBufGenerator.pas"/>
<DCCReference Include="TestProtoBuf.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
Expand Down Expand Up @@ -147,23 +139,38 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgsqlite3.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="..\..\Ready\ProtoBufGeneratorTests.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>ProtoBufGeneratorTests.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgsqlite3.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
<DeployClass Name="DependencyModule">
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
</DeployFile>
<DeployClass Name="ProjectiOSDeviceResourceRules">
<Platform Name="iOSDevice64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXResource">
Expand Down Expand Up @@ -543,27 +550,12 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DependencyModule">
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
<DeployClass Name="ProjectiOSDeviceResourceRules">
<Platform Name="iOSDevice64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
Expand All @@ -576,7 +568,6 @@
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
</Deployment>
<Platforms>
<Platform value="OSX32">False</Platform>
<Platform value="Win32">True</Platform>
<Platform value="Win64">False</Platform>
</Platforms>
Expand Down
6 changes: 3 additions & 3 deletions Generator/Test/TestGeneratedProtoBufPas.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unit TestGeneratedProtoBufPas;
unit TestGeneratedProtoBufPas;
{

Delphi DUnit Test Case
Expand Down Expand Up @@ -76,7 +76,7 @@ procedure TestTTestMsg1.TestSaveLoadFromBuf;
begin
FTestMsg1.DefField1 := 1;
FTestMsg1.DefField2 := 3;
FTestMsg1.DefField3 := 'as������';
FTestMsg1.DefField3 := 'asôâàóöé';
FTestMsg1.DefField4 := -2.5;
FTestMsg1.DefField5 := True;
FTestMsg1.DefField6 := TEnumG0.g2;
Expand All @@ -85,7 +85,7 @@ procedure TestTTestMsg1.TestSaveLoadFromBuf;
FTestMsg1.DefField9 := 5.5;
FTestMsg1.FieldArr1List.Add(-5);
FTestMsg1.FieldArr2List.Add(234);
FTestMsg1.FieldArr3List.Add('asdf�������');
FTestMsg1.FieldArr3List.Add('asdfçöóêãøò');

tmp := TTestMsg1.Create;
try
Expand Down
10 changes: 5 additions & 5 deletions Generator/Test/TestProtoBuf.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unit TestProtoBuf;
unit TestProtoBuf;
{

Delphi DUnit Test Case
Expand Down Expand Up @@ -71,8 +71,8 @@ procedure TestProtoBufMethods.TestDecodeZigZag;
CheckEquals(Int64($FFFFFFFFC0000000), decodeZigZag64($000000007FFFFFFF));
CheckEquals(Int64($000000007FFFFFFF), decodeZigZag64($00000000FFFFFFFE));
CheckEquals(Int64($FFFFFFFF80000000), decodeZigZag64($00000000FFFFFFFF));
CheckEquals(Int64($7FFFFFFFFFFFFFFF), decodeZigZag64($FFFFFFFFFFFFFFFE));
CheckEquals(Int64($8000000000000000), decodeZigZag64($FFFFFFFFFFFFFFFF));
CheckEquals(Int64($7FFFFFFFFFFFFFFF), decodeZigZag64(Int64($FFFFFFFFFFFFFFFE)));
CheckEquals(Int64($8000000000000000), decodeZigZag64(Int64($FFFFFFFFFFFFFFFF)));
end;

procedure TestProtoBufMethods.TestEncodeDecodeZigZag;
Expand Down Expand Up @@ -196,7 +196,7 @@ TLittleEndianCase = record

procedure TestProtoBufMethods.TestReadString;
const
TEST_string = '�������� ������';
TEST_string:string = 'Òåñòîâàÿ ñòðîêà';
TEST_integer = 12345678;
TEST_single = 12345.123;
TEST_double = 1234567890.123;
Expand Down Expand Up @@ -316,7 +316,7 @@ TVarintCase = record
for i := 0 to 7 do
begin
t := VarintCases[i];
// ������� �������� �����
// 耦玟囹?蝈耱钼 狍翦?
SetLength(buf, t.Size);
for j := 1 to t.Size do
buf[j] := AnsiChar(t.bytes[j]);
Expand Down
6 changes: 3 additions & 3 deletions Generator/uProtoBufGenerator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ procedure TProtoBufGenerator.GenerateImplementationSection(Proto: TProtoFile; SL
end;
SL.Add(' if Result then');
SL.Add(' exit;');
SL.Add(' case fieldNumber of');
SL.Add(' case FieldNumber of');
for i := 0 to ProtoMsg.Count - 1 do
begin
Prop := ProtoMsg[i];
Expand Down Expand Up @@ -412,7 +412,7 @@ procedure TProtoBufGenerator.GenerateImplementationSection(Proto: TProtoFile; SL
SL.Add(Format(' F%s.Add(T%s(ProtoBuf.readEnum));', [DelphiProp.PropertyName, Prop.PropType]));
end
else
SL.Add(Format(' F%s.AddFromBuf(ProtoBuf, fieldNumber);', [DelphiProp.PropertyName]));
SL.Add(Format(' F%s.AddFromBuf(ProtoBuf, FieldNumber);', [DelphiProp.PropertyName]));
end;
SL.Add(' Result := True;');
SL.Add(' end;');
Expand Down Expand Up @@ -594,7 +594,7 @@ SL.Add(Format(' T%s = class(T%s)', [ProtoMsg.Name, s]));
SL.Add(' destructor Destroy; override;');
SL.Add('');
end;
SL.Add('');

for i := 0 to ProtoMsg.Count - 1 do
begin
Prop := ProtoMsg[i];
Expand Down
17 changes: 14 additions & 3 deletions Generator/ufmMain.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@ object fmMain: TfmMain
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
DesignSize = (
458
154)
PixelsPerInch = 96
TextHeight = 13
object edProtoFileName: TEdit
object edtProtoFiles: TEdit
Left = 8
Top = 16
Width = 409
Height = 21
TabStop = False
Anchors = [akLeft, akTop, akRight]
Font.Charset = DEFAULT_CHARSET
Font.Color = clGray
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
ReadOnly = True
TabOrder = 0
TextHint = 'Choose proto file'
Text = 'Use "..." Choose .proto files Or Drag files into window~'
end
object btnOpenProtoFile: TButton
Left = 423
Expand All @@ -45,13 +55,14 @@ object fmMain: TfmMain
TabOrder = 2
OnClick = btnGenerateClick
end
object edOutputFolder: TEdit
object edtOutputFolder: TEdit
Left = 8
Top = 53
Width = 409
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 3
Text = '.\PbOut'
TextHint = 'Choose output folder'
end
object btnChooseOutputFolder: TButton
Expand Down
Loading