* Only specify override for destructor in interface section. Add inherited to constructor, Tstreamclass is TMemoryStream

git-svn-id: trunk@25618 -
This commit is contained in:
michael 2013-10-02 07:51:45 +00:00
parent 38f72cf39b
commit 50b9b65395

View File

@ -224,8 +224,6 @@ Type
procedure SetAncestorClass(const AValue: String); procedure SetAncestorClass(const AValue: String);
procedure SetClassName(const AValue: String); procedure SetClassName(const AValue: String);
procedure SetUnitname(const AValue: String); procedure SetUnitname(const AValue: String);
procedure WritePropertyGetterImpl(Strings: TStrings; F: TFieldPropDef);
procedure WritePropertySetterImpl(Strings: TStrings; F: TFieldPropDef);
Protected Protected
// Overrides from base class // Overrides from base class
Function GetFieldDefs: TFieldPropDefs; override; Function GetFieldDefs: TFieldPropDefs; override;
@ -240,6 +238,10 @@ Type
// //
// Interface routines // Interface routines
// //
// Write property getter implementation
procedure WritePropertyGetterImpl(Strings: TStrings; F: TFieldPropDef); virtual;
// Write property setter implementation
procedure WritePropertySetterImpl(Strings: TStrings; F: TFieldPropDef); virtual;
// Create class declaration. // Create class declaration.
procedure CreateDeclaration(Strings: TStrings); virtual; procedure CreateDeclaration(Strings: TStrings); virtual;
// Create class head. Override to add after class start. // Create class head. Override to add after class start.
@ -720,6 +722,8 @@ constructor TDDClassCodeGenerator.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FFieldDefs:=CreateFieldPropDefs; FFieldDefs:=CreateFieldPropDefs;
StringsClass:='TStringList';
StreamClass:='TMemoryStream';
end; end;
destructor TDDClassCodeGenerator.Destroy; destructor TDDClassCodeGenerator.Destroy;
@ -867,7 +871,7 @@ begin
AddLn(Strings,'begin'); AddLn(Strings,'begin');
IncIndent; IncIndent;
Try Try
AddLn(Strings,Format('Result:=F%s',[F.PropertyName])); AddLn(Strings,Format('Result:=F%s;',[F.PropertyName]));
Finally Finally
DecIndent; DecIndent;
end; end;
@ -901,6 +905,7 @@ begin
if (L>0) then if (L>0) then
begin begin
S:=StringReplace(S,'%PROPNAME%',F.PropertyName,[rfReplaceAll,rfIgnoreCase]); S:=StringReplace(S,'%PROPNAME%',F.PropertyName,[rfReplaceAll,rfIgnoreCase]);
L:=Length(S);
if (S[L]<>';') then if (S[L]<>';') then
S:=S+';'; S:=S+';';
AddLn(Strings,S); AddLn(Strings,S);
@ -950,6 +955,7 @@ begin
S:=ConstructorDeclaration(True); S:=ConstructorDeclaration(True);
BeginMethod(Strings,S); BeginMethod(Strings,S);
AddLn(Strings,'begin'); AddLn(Strings,'begin');
AddLn(Strings,' inherited;');
IncIndent; IncIndent;
Try Try
For I:=0 to Fields.Count-1 do For I:=0 to Fields.Count-1 do
@ -1153,7 +1159,9 @@ begin
Result:='Destructor '; Result:='Destructor ';
If Impl then If Impl then
Result:=Result+ClassOptions.ObjectClassName+'.'; Result:=Result+ClassOptions.ObjectClassName+'.';
Result:=Result+'Destroy; Override;'; Result:=Result+'Destroy;';
if not Impl then
Result:=Result+' Override;';
end; end;
procedure TDDClassCodeGenerator.GenerateClass(Stream: TStream); procedure TDDClassCodeGenerator.GenerateClass(Stream: TStream);