Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Native C well-known types #7944

Merged
merged 14 commits into from
Oct 29, 2020
Merged

Conversation

haberman
Copy link
Member

@haberman haberman commented Oct 6, 2020

This PR changes our implementation of the well-known types to be native C, instead of PHP source code embedded into the native extension.

It is hoped that this new design will be measurably more efficient than the old approach. Previously the pure-PHP code for the well-known types was registered with an autoloader and had to be loaded separately for each request.

(This returns us back to the state we were in prior to 3.13.x, with respect to the well-known types).

C Output from Code Generator

The PHP code generator can now output native C extension code for messages and enums. There is an internal-only option internal_generate_c_wkt that is used to generate the well-known types into a wkt.inc file that is #included from the C extension.

New Base Classes for Timestamp and Any

The generated types for Timestamp and Any have extra, hand-written methods like pack() and unpack(). Before this PR, these extra methods had been added by editing the generated code for Timestamp and Any. This made it impossible to regenerate the well-known types without obliterating these hand-written methods.

With this PR there are now base classes that contain the hand-written methods. This allows us to regenerate the well-known types without losing manual edits.

These hand-written methods like pack() and unpack() unfortunately need to be implemented in both C and PHP. In C there is no base class, we simply emit extra methods in the method list.

@haberman haberman merged commit c5f7b4b into protocolbuffers:master Oct 29, 2020
haberman added a commit to haberman/protobuf that referenced this pull request Nov 10, 2020
These files should have been added/removed in
protocolbuffers#7944, but
this was missed and Kokoro does not test "pear package".
haberman added a commit that referenced this pull request Nov 10, 2020
These files should have been added/removed in
#7944, but
this was missed and Kokoro does not test "pear package".
@haberman haberman deleted the php-wkt branch December 6, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants