-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gerben-s
approved these changes
Oct 6, 2020
TeBoring
approved these changes
Oct 8, 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".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 awkt.inc
file that is#included
from the C extension.New Base Classes for
Timestamp
andAny
The generated types for
Timestamp
andAny
have extra, hand-written methods likepack()
andunpack()
. Before this PR, these extra methods had been added by editing the generated code forTimestamp
andAny
. 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()
andunpack()
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.