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

[C++] Refactor util::Status #8354

Merged
merged 4 commits into from Mar 12, 2021
Merged

Conversation

Yannic
Copy link
Contributor

@Yannic Yannic commented Feb 28, 2021

This change refactors util::Status to have a similar shape as the
recently open-sourced absl::Status. This will allow Protobuf to
eventually use absl::Status and reduce the codesize.

Note that there is more work required before absl::Status can be used.

@@ -37,61 +37,64 @@
namespace google {
namespace protobuf {
namespace util {
namespace error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for moving this to a new internal subdirectory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just stylistic preference. We can keep the implementation in this file if you'd like, with or without namespace status_internal (although I'd prefer keeping the namespace to already give a hint that the symbols will come from a different namespace eventually)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think it would be good to keep the code in the same files but moving them into a status_internal namespace sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, done!

Copy link
Contributor Author

@Yannic Yannic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running presubmit!

I tried looking at the logs but it seems like I don't have permissions.

@@ -37,61 +37,64 @@
namespace google {
namespace protobuf {
namespace util {
namespace error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just stylistic preference. We can keep the implementation in this file if you'd like, with or without namespace status_internal (although I'd prefer keeping the namespace to already give a hint that the symbols will come from a different namespace eventually)

@acozzette
Copy link
Member

The CI run is showing an error like this:

src/google/protobuf/util/internal/json_stream_parser_test.cc:153:38: error: 'class google::protobuf::util::status_internal::Status' has no member named 'error_message'
     StringPiece error_message(result.error_message());
                                      ^

This change refactors util::Status to have a similar shape as the
recently open-sourced absl::Status. This will allow Protobuf to
eventually use absl::Status and reduce the codesize.

Note that there is more work required before absl::Status can be used.
@Yannic
Copy link
Contributor Author

Yannic commented Mar 9, 2021

The CI run is showing an error like this:

src/google/protobuf/util/internal/json_stream_parser_test.cc:153:38: error: 'class google::protobuf::util::status_internal::Status' has no member named 'error_message'
     StringPiece error_message(result.error_message());
                                      ^

Thanks! Looks like there was a second use of result.error_message() added there recently, rebased and fixed, PTAL

@acozzette
Copy link
Member

Thanks @Yannic, it looks like there are a couple more call sites to fix in the conformance tests:

conformance_cpp.cc:137:54: error: no member named 'error_message' in 'google::protobuf::util::status_internal::Status'
                                  std::string(status.error_message()));
                                              ~~~~~~ ^
conformance_cpp.cc:192:32: error: no member named 'error_message' in 'google::protobuf::util::status_internal::Status'
            std::string(status.error_message()));

@Yannic
Copy link
Contributor Author

Yannic commented Mar 10, 2021

Thanks @Yannic, it looks like there are a couple more call sites to fix in the conformance tests:

conformance_cpp.cc:137:54: error: no member named 'error_message' in 'google::protobuf::util::status_internal::Status'
                                  std::string(status.error_message()));
                                              ~~~~~~ ^
conformance_cpp.cc:192:32: error: no member named 'error_message' in 'google::protobuf::util::status_internal::Status'
            std::string(status.error_message()));

Thanks, fixed

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.

None yet

3 participants