A little update
This commit is contained in:
@@ -91,14 +91,20 @@ type
|
|||||||
TFunction = class(TNamedItem)
|
TFunction = class(TNamedItem)
|
||||||
private
|
private
|
||||||
FResultType : TResultType;
|
FResultType : TResultType;
|
||||||
|
FClasse : TClasse;
|
||||||
function GetParam(Index : integer) : TParam;
|
function GetParam(Index : integer) : TParam;
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
constructor Create(Node : TDOMNode); override;
|
constructor Create(Node : TDOMNode); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function IsConstructor : boolean;
|
||||||
function IsDestructor : boolean;
|
function IsDestructor : boolean;
|
||||||
|
function HasParams : boolean;
|
||||||
|
procedure Start; override;
|
||||||
|
procedure Ends; override;
|
||||||
property ResultType : TResultType read FResultType;
|
property ResultType : TResultType read FResultType;
|
||||||
property Params[Index : integer] : TParam read GetParam;
|
property Params[Index : integer] : TParam read GetParam;
|
||||||
|
property Classe : TClasse read FClasse;
|
||||||
end;
|
end;
|
||||||
TTypedItem = class(TNamedItem)
|
TTypedItem = class(TNamedItem)
|
||||||
private
|
private
|
||||||
@@ -111,6 +117,7 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
procedure Middle; override;
|
||||||
end;
|
end;
|
||||||
TResultType = class(TNode)
|
TResultType = class(TNode)
|
||||||
private
|
private
|
||||||
@@ -309,6 +316,7 @@ begin
|
|||||||
for i := 0 to Node.ChildNodes.count - 1 do
|
for i := 0 to Node.ChildNodes.count - 1 do
|
||||||
begin
|
begin
|
||||||
aFunc := TFunction.Create(Node.ChildNodes.Item[i]);
|
aFunc := TFunction.Create(Node.ChildNodes.Item[i]);
|
||||||
|
aFunc.FClasse := Self;
|
||||||
WriteLn(aFunc.Name);
|
WriteLn(aFunc.Name);
|
||||||
WriteLn('');
|
WriteLn('');
|
||||||
List.AddObject(aFunc.Name, aFunc);
|
List.AddObject(aFunc.Name, aFunc);
|
||||||
@@ -384,6 +392,11 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFunction.IsConstructor : boolean;
|
||||||
|
begin
|
||||||
|
Result := (Name = Classe.Name);
|
||||||
|
end;
|
||||||
|
|
||||||
function TFunction.IsDestructor : boolean;
|
function TFunction.IsDestructor : boolean;
|
||||||
begin
|
begin
|
||||||
Result := (Name[1] = '~');
|
Result := (Name[1] = '~');
|
||||||
@@ -394,11 +407,87 @@ begin
|
|||||||
Result := FChildren.Objects[Index] as TParam;
|
Result := FChildren.Objects[Index] as TParam;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFunction.HasParams : boolean;
|
||||||
|
begin
|
||||||
|
Result := (Count > 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFunction.Start;
|
||||||
|
var
|
||||||
|
EndChar : string;
|
||||||
|
begin
|
||||||
|
WriteLn('Function Start');
|
||||||
|
if HasParams then
|
||||||
|
EndChar := '('
|
||||||
|
else
|
||||||
|
EndChar := '';
|
||||||
|
with SourceWriter.InterfacePas do
|
||||||
|
begin
|
||||||
|
if IsConstructor then
|
||||||
|
Add(Format(' constructor %s%s', [Name, EndChar]))
|
||||||
|
else if IsDestructor then
|
||||||
|
Add(Format(' destructor %s%s', [Name, EndChar]))
|
||||||
|
else if (ResultType.Typ = '') or (ResultType.Typ = 'void') then
|
||||||
|
Add(Format(' procedure %s%s', [Name, EndChar]))
|
||||||
|
else
|
||||||
|
Add(Format(' function %s%s', [Name, EndChar]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFunction.Ends;
|
||||||
|
var
|
||||||
|
s : string;
|
||||||
|
EndChar : string;
|
||||||
|
begin
|
||||||
|
WriteLn('Function ends');
|
||||||
|
if hasParams then
|
||||||
|
begin
|
||||||
|
EndChar := ')';
|
||||||
|
with SourceWriter.InterfacePas do
|
||||||
|
begin
|
||||||
|
// Delete the last '; '
|
||||||
|
s := Strings[Count - 1];
|
||||||
|
System.Delete(s, Length(s) - 1, 2);
|
||||||
|
Strings[Count - 1] := s;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
EndChar := '';
|
||||||
|
end;
|
||||||
|
with SourceWriter.InterfacePas do
|
||||||
|
begin
|
||||||
|
if not((ResultType.Typ = '') or (ResultType.Typ = 'void')) then
|
||||||
|
begin
|
||||||
|
WriteLn(ResultType.Typ);
|
||||||
|
WriteLn(Name);
|
||||||
|
s := Format('%s%s : %s;', [Strings[Count - 1], EndChar, CppToPas(ResultType.Typ)]);
|
||||||
|
Strings[Count - 1] := s;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Strings[Count - 1] := Format('%s%s;', [Strings[Count - 1], EndChar]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TTypedItem.GetType : string;
|
function TTypedItem.GetType : string;
|
||||||
begin
|
begin
|
||||||
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TParam.Middle;
|
||||||
|
var
|
||||||
|
s : string;
|
||||||
|
begin
|
||||||
|
WriteLn('Param Middle');
|
||||||
|
with SourceWriter.InterfacePas do
|
||||||
|
begin
|
||||||
|
WriteLn(Strings[Count - 1]);
|
||||||
|
s := Format('%s%s : %s; ', [Strings[Count - 1], Name, CppToPas(Typ)]);
|
||||||
|
Strings[Count - 1] := s;
|
||||||
|
WriteLn(Strings[Count - 1]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TResultType.GetType : string;
|
function TResultType.GetType : string;
|
||||||
begin
|
begin
|
||||||
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ var
|
|||||||
function CppToPas(CppType : string) : string;
|
function CppToPas(CppType : string) : string;
|
||||||
begin
|
begin
|
||||||
Result := aTypMap.Values[CppType];
|
Result := aTypMap.Values[CppType];
|
||||||
if Result = '' then
|
// if Result = '' then
|
||||||
aTypMap.Values[CppType] := '';
|
// aTypMap.Values[CppType] := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PasToCpp(PasType : string) : string;
|
function PasToCpp(PasType : string) : string;
|
||||||
@@ -34,6 +34,7 @@ initialization
|
|||||||
aTypMap.Sorted := True;
|
aTypMap.Sorted := True;
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
// WriteLn(aTypMap.Text);
|
||||||
aTypMap.SaveToFile(TypMapFileName);
|
aTypMap.SaveToFile(TypMapFileName);
|
||||||
aTypMap.Free;
|
aTypMap.Free;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user