Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-01

googleapiconv issues

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wayne Sherman

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?

Reply by email

Michael Van Canneyt
to Wayne Sherman
Wayne Sherman wrote 38 lines
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

The latter. I must have missed the above when refactoring :/

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?

Both are fine for me.

But maybe it makes more sense to use a bugreport,
since that's where eventually a patch/merge request will have to end up ?

Michael.

Reply by email