[fpc-devel] googleapiconv issues
Wayne Sherman
wsherman at gmail.com
Fri Jan 6 04:33:43 CET 2023
The google api binding generator "googleapiconv" is generating empty
files for the api pascal bindings and it also causes access violations
randomly. I have not found the issue with AVs yet, but I found out
why it is creating empty source code files.
restcodegen.pp TRestCodeGenerator was refactored in 2018 to use pascodegen:
- TRestCodeGenerator = Class(TComponent)
+ TRestCodeGenerator = Class(TPascalCodeGenerator)
ref: https://gitlab.com/freepascal.org/fpc/source/-/commit/d7fa0b19988f753873f498b9424dcf82ba1b271e#b4a1b63d04b721fa6db35bc226d44a63a21fda40
Before the refactoring, TRestCodeGenerator.SaveToStream used to call
"Execute;" if the source code string list was empty:
procedure TRestCodeGenerator.SaveToStream(const AStream : TStream);
begin
if (FSource.Count=0) then
Execute;
FSource.SaveToStream(AStream)
end;
ref: https://gitlab.com/freepascal.org/fpc/source/-/blob/0eddef3d093c53fca0526b7bc558ffeef42a79df/packages/fcl-web/src/base/restcodegen.pp#L186
Now "Execute;" is not being called and no code is generated because
pascodegen.pp "TPascalCodeGenerator.SaveToStream" looks like this:
procedure TPascalCodeGenerator.SaveToStream(const AStream : TStream);
begin
FSource.SaveToStream(AStream)
end;
ref: https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/fcl-base/src/pascodegen.pp#L255
Two options to fix this are:
1) Add the "FSource" check and "Execute;" statements to
TPascalCodeGenerator.SaveToStream
or
2) Add "Execute;" to TGoogleAPIConverter.DoConversion
(googleapiconv.pp) before it calls "SaveToStream" here:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/googleapi/generator/googleapiconv.pp#L575
Question: Do you prefer I discuss issues like this here on the
mailing list or instead open a bug report and discuss in the bug
report?
More information about the fpc-devel
mailing list