mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 08:09:28 +02:00
* Improved code generator to take care of some corner cases (duplicate identifiers, linefeeds in descriptions)
git-svn-id: trunk@33775 -
This commit is contained in:
parent
2121a3ae39
commit
1d54f9f3e7
@ -280,6 +280,7 @@ Type
|
|||||||
private
|
private
|
||||||
FDescription: String;
|
FDescription: String;
|
||||||
FeTagrequired: Boolean;
|
FeTagrequired: Boolean;
|
||||||
|
FflatPath: string;
|
||||||
FhttpMethod: string;
|
FhttpMethod: string;
|
||||||
Fid: string;
|
Fid: string;
|
||||||
fMediaUpload: TMediaUpload;
|
fMediaUpload: TMediaUpload;
|
||||||
@ -307,6 +308,7 @@ Type
|
|||||||
Property parameterOrder : TStringArray Read FParameterOrder Write FParameterOrder;
|
Property parameterOrder : TStringArray Read FParameterOrder Write FParameterOrder;
|
||||||
Property parameters : TRestMethodParams read fparameters write fparameters;
|
Property parameters : TRestMethodParams read fparameters write fparameters;
|
||||||
Property path : string read fpath Write fpath;
|
Property path : string read fpath Write fpath;
|
||||||
|
Property flatPath : string read FflatPath Write FflatPath;
|
||||||
Property request : trequest read frequest write frequest;
|
Property request : trequest read frequest write frequest;
|
||||||
Property response : tresponse read fresponse write fresponse;
|
Property response : tresponse read fresponse write fresponse;
|
||||||
property scopes : TStringArray Read Fscopes write Fscopes;
|
property scopes : TStringArray Read Fscopes write Fscopes;
|
||||||
@ -769,6 +771,8 @@ Var
|
|||||||
BaseArrayElement : Boolean;
|
BaseArrayElement : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if (S.Name='Component') and (NamePrefix='') then
|
||||||
|
NamePrefix:='_';
|
||||||
dt:=GetSchemaDataType(S);
|
dt:=GetSchemaDataType(S);
|
||||||
BaseArrayElement:=(dt=dtArray) and S.Items.BaseType;
|
BaseArrayElement:=(dt=dtArray) and S.Items.BaseType;
|
||||||
DoLog('[%s] Examining : %s (Ref : %s type: %s) Toplevel %s',[NamePrefix,S.Name,S.ref,S._type,BoolToStr(IsTopLevel,'True','False')]);
|
DoLog('[%s] Examining : %s (Ref : %s type: %s) Toplevel %s',[NamePrefix,S.Name,S.ref,S._type,BoolToStr(IsTopLevel,'True','False')]);
|
||||||
@ -1061,7 +1065,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
N:=S.PropertyName;
|
N:=S.PropertyName;
|
||||||
tn:=GetPropertyType(AClassName,S);
|
tn:=GetPropertyType(AClassName,S);
|
||||||
AddLn('Procedure Set%s(AIndex : Integer; Const AValue : %s); virtual;',[N,tn]);
|
AddLn('Procedure Set%s(AIndex : Integer; const AValue : %s); virtual;',[N,tn]);
|
||||||
end;
|
end;
|
||||||
if NeedSetArrayLength and not UseListForArray then
|
if NeedSetArrayLength and not UseListForArray then
|
||||||
begin
|
begin
|
||||||
@ -1216,7 +1220,7 @@ begin
|
|||||||
NeedGetWritename:=NeedGetWritename or (CompareText(N,S.Name)<>0);
|
NeedGetWritename:=NeedGetWritename or (CompareText(N,S.Name)<>0);
|
||||||
TN:=GetPropertyType(AClassName,S);
|
TN:=GetPropertyType(AClassName,S);
|
||||||
Addln('');
|
Addln('');
|
||||||
AddLn('Procedure %s.Set%s(AIndex : Integer; Const AValue : %s); ',[AClassName,N,tn]);
|
AddLn('Procedure %s.Set%s(AIndex : Integer; const AValue : %s); ',[AClassName,N,tn]);
|
||||||
SimpleMethodBody([Format('If (F%s=AValue) then exit;',[N]),
|
SimpleMethodBody([Format('If (F%s=AValue) then exit;',[N]),
|
||||||
Format('F%s:=AValue;',[N]),
|
Format('F%s:=AValue;',[N]),
|
||||||
'MarkPropertyChanged(AIndex);']);
|
'MarkPropertyChanged(AIndex);']);
|
||||||
@ -1553,6 +1557,8 @@ begin
|
|||||||
Add('DefaultAPI');
|
Add('DefaultAPI');
|
||||||
Add('API');
|
Add('API');
|
||||||
Add('Notification');
|
Add('Notification');
|
||||||
|
Add('UpdateAction');
|
||||||
|
Add('ExecuteAction');
|
||||||
end;
|
end;
|
||||||
// Actual paramters
|
// Actual paramters
|
||||||
For P in M.parameters do
|
For P in M.parameters do
|
||||||
@ -1921,8 +1927,15 @@ Procedure TDiscoveryJSONToPas.CreateAPIClassImplementation;
|
|||||||
|
|
||||||
Procedure StringRes(AValue : String);
|
Procedure StringRes(AValue : String);
|
||||||
|
|
||||||
|
Var
|
||||||
|
S : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SimpleMethodBody([Format('Result:=%s;',[MakePascalString(AValue,True)])]);
|
S:=MakePascalString(AValue,True);
|
||||||
|
S:=StringReplace(S,#13#10,'''#13#10''',[rfReplaceAll]);
|
||||||
|
S:=StringReplace(S,#10,'''#10''',[rfReplaceAll]);
|
||||||
|
S:=StringReplace(S,#13,'''#13''',[rfReplaceAll]);
|
||||||
|
SimpleMethodBody([Format('Result:=%s;',[S])]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
Loading…
Reference in New Issue
Block a user