From ed430af1814a97e4017f2f808d3ba28cc10802f1 Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Wed, 2 Oct 2024 10:02:40 -0700 Subject: [PATCH] Minor formatting/include cleanups. PiperOrigin-RevId: 681493832 --- pybind11_protobuf/BUILD | 13 +++---- pybind11_protobuf/check_unknown_fields.cc | 10 ++--- pybind11_protobuf/check_unknown_fields.h | 5 ++- pybind11_protobuf/enum_type_caster.h | 11 ++---- pybind11_protobuf/native_proto_caster.h | 15 +++----- pybind11_protobuf/proto_cast_util.cc | 12 ++---- pybind11_protobuf/proto_cast_util.h | 7 +--- pybind11_protobuf/proto_caster_impl.h | 17 ++++----- pybind11_protobuf/proto_utils.cc | 15 +++++--- pybind11_protobuf/proto_utils.h | 8 ++-- pybind11_protobuf/tests/BUILD | 19 +++++----- pybind11_protobuf/tests/compare.py | 8 ++-- .../tests/dynamic_message_module.cc | 14 ++++--- .../tests/dynamic_message_test.py | 6 +-- pybind11_protobuf/tests/extension_module.cc | 2 +- pybind11_protobuf/tests/message_module.cc | 12 +++--- pybind11_protobuf/tests/message_test.py | 2 +- pybind11_protobuf/tests/pass_by_module.cc | 13 ++++--- pybind11_protobuf/tests/pass_by_test.py | 9 +++-- .../tests/pass_proto2_message_module.cc | 2 +- .../tests/regression_wrappers_module.cc | 6 ++- .../tests/wrapped_proto_module.cc | 19 +++++----- pybind11_protobuf/wrapped_proto_caster.h | 37 +++++++++---------- 23 files changed, 123 insertions(+), 139 deletions(-) diff --git a/pybind11_protobuf/BUILD b/pybind11_protobuf/BUILD index 00cea18..2b7d851 100644 --- a/pybind11_protobuf/BUILD +++ b/pybind11_protobuf/BUILD @@ -11,7 +11,7 @@ pybind_library( "//visibility:public", ], deps = [ - "//net/proto2/public", + "@com_google_protobuf//:protobuf", ], ) @@ -25,8 +25,8 @@ pybind_library( ":check_unknown_fields", ":enum_type_caster", ":proto_cast_util", - "//net/proto2/public", "@com_google_absl//absl/strings:string_view", + "@com_google_protobuf//:protobuf", ], ) @@ -39,8 +39,6 @@ pybind_library( ], deps = [ ":check_unknown_fields", - "//net/proto2/proto:descriptor_cc_proto", - "//net/proto2/public", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", @@ -60,9 +58,9 @@ pybind_library( ], deps = [ ":proto_cast_util", - "//net/proto2/public", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/types:optional", + "@com_google_protobuf//:protobuf", ], ) @@ -71,13 +69,12 @@ cc_library( srcs = ["check_unknown_fields.cc"], hdrs = ["check_unknown_fields.h"], deps = [ - "//net/proto2/public", - "//net/proto2/python/public:proto_api", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", + "@com_google_protobuf//:protobuf", + "@com_google_protobuf//python:proto_api", ], ) diff --git a/pybind11_protobuf/check_unknown_fields.cc b/pybind11_protobuf/check_unknown_fields.cc index 982cf48..0e1e9ea 100644 --- a/pybind11_protobuf/check_unknown_fields.cc +++ b/pybind11_protobuf/check_unknown_fields.cc @@ -6,15 +6,16 @@ #include #include -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/message.h" -#include "net/proto2/public/unknown_field_set.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/message.h" +#include "google/protobuf/unknown_field_set.h" +#include "python/google/protobuf/proto_api.h" namespace pybind11_protobuf::check_unknown_fields { namespace { @@ -103,8 +104,7 @@ bool HasUnknownFields::FindUnknownFieldsRecursive( // Stop only if the extension is known by Python. if (py_proto_api->GetDefaultDescriptorPool()->FindExtensionByNumber( - unknown_field_parent_descriptor, - unknown_field_number)) { + unknown_field_parent_descriptor, unknown_field_number)) { field_fqn_parts.resize(depth); return true; } diff --git a/pybind11_protobuf/check_unknown_fields.h b/pybind11_protobuf/check_unknown_fields.h index 5a6d4ac..a448f83 100644 --- a/pybind11_protobuf/check_unknown_fields.h +++ b/pybind11_protobuf/check_unknown_fields.h @@ -2,10 +2,11 @@ #define PYBIND11_PROTOBUF_CHECK_UNKNOWN_FIELDS_H_ #include +#include -#include "net/proto2/public/message.h" -#include "net/proto2/python/public/proto_api.h" #include "absl/strings/string_view.h" +#include "google/protobuf/message.h" +#include "python/google/protobuf/proto_api.h" namespace pybind11_protobuf::check_unknown_fields { diff --git a/pybind11_protobuf/enum_type_caster.h b/pybind11_protobuf/enum_type_caster.h index 5daa6f1..d35ea8d 100644 --- a/pybind11_protobuf/enum_type_caster.h +++ b/pybind11_protobuf/enum_type_caster.h @@ -11,21 +11,18 @@ #include #include -#include #include -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/generated_enum_reflection.h" -#include "net/proto2/public/generated_enum_util.h" +#include "google/protobuf/generated_enum_util.h" // pybind11 type_caster specialization which translates Proto::Enum types // to/from ints. This will have ODR conflicts when users specify wrappers for // enums using py::enum_. // -// ::google::protobuf::is_proto_enum and ::google::protobuf::GetEnumDescriptor are require +// ::google::protobuf::is_proto_enum and ::google::protobuf::GetEnumDescriptor are required. // -// NOTE: The protobuf compiler does not generate ::google::protobuf::is_proto_enum traits -// for enumerations of oneof fields. +// NOTE: The protobuf compiler does not generate ::google::protobuf::is_proto_enum +// traits for enumerations of oneof fields. // // Example: // #include diff --git a/pybind11_protobuf/native_proto_caster.h b/pybind11_protobuf/native_proto_caster.h index 82db2ad..806531a 100644 --- a/pybind11_protobuf/native_proto_caster.h +++ b/pybind11_protobuf/native_proto_caster.h @@ -11,22 +11,17 @@ // IWYU #include -#include -#include -#include -#include #include -#include -#include "net/proto2/public/message.h" #include "absl/strings/string_view.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/enum_type_caster.h" #include "pybind11_protobuf/proto_caster_impl.h" -// pybind11::type_caster<> specialization for ::google::protobuf::Message types that -// that converts protocol buffer objects between C++ and python representations. -// This binder supports binaries linked with both native python protos -// and fast cpp python protos. +// pybind11::type_caster<> specialization for ::google::protobuf::Message types +// that that converts protocol buffer objects between C++ and python +// representations. This binder supports binaries linked with both native python +// protos and fast cpp python protos. // // When passing protos between python and C++, if possible, an underlying C++ // object may have ownership transferred, or may be copied if both instances diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc index 8d1fd1e..11a7704 100644 --- a/pybind11_protobuf/proto_cast_util.cc +++ b/pybind11_protobuf/proto_cast_util.cc @@ -11,9 +11,7 @@ #include #include #include -#include -#include "net/proto2/proto/descriptor.pb.h" #include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/log/log.h" @@ -25,6 +23,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor_database.h" #include "google/protobuf/dynamic_message.h" @@ -34,7 +33,6 @@ using ::google::protobuf::Descriptor; using ::google::protobuf::DescriptorDatabase; using ::google::protobuf::DescriptorPool; using ::google::protobuf::DynamicMessageFactory; -using ::google::protobuf::FileDescriptor; using ::google::protobuf::FileDescriptorProto; using ::google::protobuf::Message; using ::google::protobuf::MessageFactory; @@ -183,11 +181,9 @@ GlobalState::GlobalState() { // pybind11_protobuf casting needs a dependency on proto internals to work. try { - ImportCached("google3.net.proto2.python.public.descriptor"); - auto descriptor_pool = - ImportCached("google3.net.proto2.python.public.descriptor_pool"); - auto message_factory = - ImportCached("google3.net.proto2.python.public.message_factory"); + ImportCached("google.protobuf.descriptor"); + auto descriptor_pool = ImportCached("google.protobuf.descriptor_pool"); + auto message_factory = ImportCached("google.protobuf.message_factory"); global_pool_ = descriptor_pool.attr("Default")(); find_message_type_by_name_ = global_pool_.attr("FindMessageTypeByName"); if (hasattr(message_factory, "GetMessageClass")) { diff --git a/pybind11_protobuf/proto_cast_util.h b/pybind11_protobuf/proto_cast_util.h index 70c0eec..503f94f 100644 --- a/pybind11_protobuf/proto_cast_util.h +++ b/pybind11_protobuf/proto_cast_util.h @@ -6,16 +6,13 @@ #include #include -#include #include #include -#include -#include -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/message.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/message.h" // PYBIND11_PROTOBUF_ASSUME_FULL_ABI_COMPATIBILITY can be defined by users // certain about ABI compatibility between all Python extensions in their diff --git a/pybind11_protobuf/proto_caster_impl.h b/pybind11_protobuf/proto_caster_impl.h index db769f2..33df74d 100644 --- a/pybind11_protobuf/proto_caster_impl.h +++ b/pybind11_protobuf/proto_caster_impl.h @@ -8,16 +8,14 @@ #include #include -#include #include #include -#include #include #include -#include "net/proto2/proto/descriptor.pb.h" -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/message.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/proto_cast_util.h" // Enables unsafe conversions; currently these are a work in progress. @@ -74,8 +72,7 @@ struct proto_caster_load_impl { owned = std::unique_ptr(new ProtoType()); value = owned.get(); - return owned.get()->ParsePartialFromString( - PyBytesAsStringView(serialized_bytes)); + return owned->ParsePartialFromString(PyBytesAsStringView(serialized_bytes)); } // ensure_owned ensures that the owned member contains a copy of the @@ -126,8 +123,7 @@ struct proto_caster_load_impl<::google::protobuf::Message> { src, *descriptor_name) .release())); value = owned.get(); - return owned.get()->ParsePartialFromString( - PyBytesAsStringView(serialized_bytes)); + return owned->ParsePartialFromString(PyBytesAsStringView(serialized_bytes)); } // ensure_owned ensures that the owned member contains a copy of the @@ -156,7 +152,8 @@ struct fast_cpp_cast_impl { (policy == pybind11::return_value_policy::reference || policy == pybind11::return_value_policy::reference_internal)) { throw pybind11::type_error( - "Cannot return a const reference to a ::google::protobuf::Message derived " + "Cannot return a const reference to a ::google::protobuf::Message " + "derived " "type. Consider setting return_value_policy::copy in the " "pybind11 def()."); } diff --git a/pybind11_protobuf/proto_utils.cc b/pybind11_protobuf/proto_utils.cc index ed9acb4..8e9844b 100644 --- a/pybind11_protobuf/proto_utils.cc +++ b/pybind11_protobuf/proto_utils.cc @@ -7,17 +7,20 @@ #include -#include +#include +#include +#include #include #include #include +#include -#include "net/proto2/proto/descriptor.pb.h" -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/message.h" -#include "net/proto2/public/reflection.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/message.h" +#include "google/protobuf/reflection.h" namespace pybind11 { namespace google { @@ -516,7 +519,7 @@ struct FindMapPair { handle key, bool add_key = true) { // When using the proto reflection API, maps are represented as repeated // message fields (messages with 2 elements: 'key' and 'value'). If protocol - // buffers guarrantee a consistent (and useful) ordering of elements, + // buffers guarantee a consistent (and useful) ordering of elements, // it should be possible to do this search in O(log(n)) time. However, that // requires more knowledge of protobuf internals than I have, so for now // assume a random ordering of elements, in which case a O(n) search is diff --git a/pybind11_protobuf/proto_utils.h b/pybind11_protobuf/proto_utils.h index 2ccca62..fa2aeab 100644 --- a/pybind11_protobuf/proto_utils.h +++ b/pybind11_protobuf/proto_utils.h @@ -10,7 +10,7 @@ #include -#include "net/proto2/public/message.h" +#include "google/protobuf/message.h" namespace pybind11 { namespace google { @@ -19,9 +19,9 @@ namespace google { // Unlike ProtoSetField, this allows setting message, map and repeated fields. void ProtoInitFields(::google::protobuf::Message* message, kwargs kwargs_in); -// Wrapper around ::google::protobuf::Message::CopyFrom which can efficiently copy from -// either a wrapped C++ or native python proto. Throws an error if `other` -// is not a proto of the correct type. +// Wrapper around ::google::protobuf::Message::CopyFrom which can efficiently +// copy from either a wrapped C++ or native python proto. Throws an error if +// `other` is not a proto of the correct type. void ProtoCopyFrom(::google::protobuf::Message* msg, handle other); // Allocate and return the ProtoType given by the template argument. diff --git a/pybind11_protobuf/tests/BUILD b/pybind11_protobuf/tests/BUILD index be92ad2..0d68461 100644 --- a/pybind11_protobuf/tests/BUILD +++ b/pybind11_protobuf/tests/BUILD @@ -140,9 +140,8 @@ pybind_extension( name = "dynamic_message_module", srcs = ["dynamic_message_module.cc"], deps = [ - "//net/proto2/proto:descriptor_cc_proto", - "//net/proto2/public", "//pybind11_protobuf:native_proto_caster", + "@com_google_protobuf//:protobuf", ], ) @@ -171,7 +170,7 @@ pybind_extension( ":extension_in_other_file_in_deps_cc_proto", ":extension_nest_repeated_cc_proto", ":test_cc_proto", - "//net/proto2/public", + "@com_google_protobuf//:protobuf", "//pybind11_protobuf:native_proto_caster", ], ) @@ -203,8 +202,8 @@ pybind_extension( srcs = ["message_module.cc"], deps = [ ":test_cc_proto", - "//net/proto2/public", "//pybind11_protobuf:native_proto_caster", + "@com_google_protobuf//:protobuf", ], ) @@ -233,9 +232,8 @@ pybind_extension( srcs = ["pass_by_module.cc"], deps = [ ":test_cc_proto", - "//net/proto2/proto:descriptor_cc_proto", - "//net/proto2/public", "//pybind11_protobuf:native_proto_caster", + "@com_google_protobuf//:protobuf", ], ) @@ -247,9 +245,9 @@ py_test( srcs_version = "PY3", deps = [ ":test_py_pb2", - "@com_google_protobuf//:protobuf_python", "@com_google_absl_py//absl/testing:absltest", "@com_google_absl_py//absl/testing:parameterized", + "@com_google_protobuf//:protobuf_python", requirement("absl_py"), ], ) @@ -259,8 +257,8 @@ pybind_extension( name = "pass_proto2_message_module", srcs = ["pass_proto2_message_module.cc"], deps = [ - "//net/proto2/public", "//pybind11_protobuf:native_proto_caster", + "@com_google_protobuf//:protobuf", ], ) @@ -271,10 +269,11 @@ pybind_extension( srcs = ["wrapped_proto_module.cc"], deps = [ ":test_cc_proto", - "//net/proto2/public", "//pybind11_protobuf:wrapped_proto_caster", + "@com_google_absl//absl/functional:function_ref", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/types:optional", + "@com_google_protobuf//:protobuf", ], ) @@ -324,8 +323,8 @@ pybind_extension( name = "regression_wrappers_module", srcs = ["regression_wrappers_module.cc"], deps = [ - "//net/proto2/public", "//pybind11_protobuf:native_proto_caster", + "@com_google_protobuf//:protobuf", ], ) diff --git a/pybind11_protobuf/tests/compare.py b/pybind11_protobuf/tests/compare.py index d5591c7..2023417 100644 --- a/pybind11_protobuf/tests/compare.py +++ b/pybind11_protobuf/tests/compare.py @@ -47,10 +47,10 @@ def testXXX(self): import collections.abc as collections_abc import difflib -from google3.net.proto2.python.public import descriptor -from google3.net.proto2.python.public import descriptor_pool -from google3.net.proto2.python.public import message -from google3.net.proto2.python.public import text_format +from google.protobuf import descriptor +from google.protobuf import descriptor_pool +from google.protobuf import message +from google.protobuf import text_format def assertProtoEqual(self, a, b, check_initialized=True, # pylint: disable=invalid-name diff --git a/pybind11_protobuf/tests/dynamic_message_module.cc b/pybind11_protobuf/tests/dynamic_message_module.cc index 2929d76..8e56784 100644 --- a/pybind11_protobuf/tests/dynamic_message_module.cc +++ b/pybind11_protobuf/tests/dynamic_message_module.cc @@ -5,15 +5,17 @@ #include -#include +#include +#include #include #include +#include -#include "net/proto2/proto/descriptor.pb.h" -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/dynamic_message.h" -#include "net/proto2/public/message.h" -#include "net/proto2/public/text_format.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/dynamic_message.h" +#include "google/protobuf/message.h" +#include "google/protobuf/text_format.h" #include "pybind11_protobuf/native_proto_caster.h" namespace py = ::pybind11; diff --git a/pybind11_protobuf/tests/dynamic_message_test.py b/pybind11_protobuf/tests/dynamic_message_test.py index 4787999..0122338 100644 --- a/pybind11_protobuf/tests/dynamic_message_test.py +++ b/pybind11_protobuf/tests/dynamic_message_test.py @@ -10,10 +10,10 @@ from absl.testing import absltest from absl.testing import parameterized +from google.protobuf import descriptor_pb2 +from google.protobuf import descriptor_pool +from google.protobuf import message_factory -from google3.net.proto2.proto import descriptor_pb2 -from google3.net.proto2.python.public import descriptor_pool -from google3.net.proto2.python.public import message_factory from pybind11_protobuf.tests import compare from pybind11_protobuf.tests import dynamic_message_module as m from pybind11_protobuf.tests import test_pb2 diff --git a/pybind11_protobuf/tests/extension_module.cc b/pybind11_protobuf/tests/extension_module.cc index ed822de..c14c8ac 100644 --- a/pybind11_protobuf/tests/extension_module.cc +++ b/pybind11_protobuf/tests/extension_module.cc @@ -9,7 +9,7 @@ #include #include -#include "net/proto2/public/message.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/native_proto_caster.h" #include "pybind11_protobuf/tests/extension.pb.h" #include "pybind11_protobuf/tests/extension_nest_repeated.pb.h" diff --git a/pybind11_protobuf/tests/message_module.cc b/pybind11_protobuf/tests/message_module.cc index 97075b5..b037691 100644 --- a/pybind11_protobuf/tests/message_module.cc +++ b/pybind11_protobuf/tests/message_module.cc @@ -5,12 +5,10 @@ #include -#include -#include -#include +#include -#include "net/proto2/public/message.h" -#include "net/proto2/public/text_format.h" +#include "google/protobuf/message.h" +#include "google/protobuf/text_format.h" #include "pybind11_protobuf/native_proto_caster.h" #include "pybind11_protobuf/tests/test.pb.h" @@ -18,8 +16,8 @@ namespace py = ::pybind11; namespace { -using pybind11::test::IntMessage; -using pybind11::test::TestMessage; +using ::pybind11::test::IntMessage; +using ::pybind11::test::TestMessage; PYBIND11_MODULE(message_module, m) { pybind11_protobuf::ImportNativeProtoCasters(); diff --git a/pybind11_protobuf/tests/message_test.py b/pybind11_protobuf/tests/message_test.py index 7b96709..9873ebe 100644 --- a/pybind11_protobuf/tests/message_test.py +++ b/pybind11_protobuf/tests/message_test.py @@ -14,12 +14,12 @@ from absl.testing import absltest from absl.testing import parameterized +from google.protobuf import text_format from google.protobuf import any_pb2 from pybind11_protobuf.tests import compare from pybind11_protobuf.tests import message_module as m from pybind11_protobuf.tests import test_pb2 -from google3.net.proto2.python.public import text_format def get_py_message(): diff --git a/pybind11_protobuf/tests/pass_by_module.cc b/pybind11_protobuf/tests/pass_by_module.cc index 0d39dc6..498c0cc 100644 --- a/pybind11_protobuf/tests/pass_by_module.cc +++ b/pybind11_protobuf/tests/pass_by_module.cc @@ -6,15 +6,16 @@ #include #include +#include #include #include -#include +#include #include -#include "net/proto2/proto/descriptor.pb.h" -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/dynamic_message.h" -#include "net/proto2/public/message.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/dynamic_message.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/native_proto_caster.h" #include "pybind11_protobuf/tests/test.pb.h" @@ -22,7 +23,7 @@ namespace py = ::pybind11; namespace { -using pybind11::test::IntMessage; +using ::pybind11::test::IntMessage; bool CheckIntMessage(const IntMessage* message, int32_t value) { return message ? message->value() == value : false; diff --git a/pybind11_protobuf/tests/pass_by_test.py b/pybind11_protobuf/tests/pass_by_test.py index 0b44442..49cc1a6 100644 --- a/pybind11_protobuf/tests/pass_by_test.py +++ b/pybind11_protobuf/tests/pass_by_test.py @@ -9,11 +9,11 @@ from absl.testing import absltest from absl.testing import parameterized +from google.protobuf import descriptor_pool +from google.protobuf import message_factory from pybind11_protobuf.tests import pass_by_module as m from pybind11_protobuf.tests import test_pb2 -from google3.net.proto2.python.public import descriptor_pool -from google3.net.proto2.python.public import message_factory def get_abstract_pass_by_params(): @@ -60,7 +60,7 @@ def get_pass_by_params(): 'concrete_uptr_ref', 'concrete_wref', 'std_variant', - 'std_optional,' + 'std_optional,', ]: try: p.append((x, getattr(m, x))) @@ -115,7 +115,8 @@ def test_pool_proto_check(self, check_method): pool = descriptor_pool.Default() factory = message_factory.MessageFactory(pool) prototype = factory.GetPrototype( - pool.FindMessageTypeByName('pybind11.test.IntMessage')) + pool.FindMessageTypeByName('pybind11.test.IntMessage') + ) message = prototype(value=9) self.assertTrue(check_method(message, 9)) diff --git a/pybind11_protobuf/tests/pass_proto2_message_module.cc b/pybind11_protobuf/tests/pass_proto2_message_module.cc index 5993c4a..c8c34b8 100644 --- a/pybind11_protobuf/tests/pass_proto2_message_module.cc +++ b/pybind11_protobuf/tests/pass_proto2_message_module.cc @@ -7,7 +7,7 @@ #include -#include "net/proto2/public/message.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/native_proto_caster.h" PYBIND11_MODULE(pass_proto2_message_module, m) { diff --git a/pybind11_protobuf/tests/regression_wrappers_module.cc b/pybind11_protobuf/tests/regression_wrappers_module.cc index 374fc52..4f63ba3 100644 --- a/pybind11_protobuf/tests/regression_wrappers_module.cc +++ b/pybind11_protobuf/tests/regression_wrappers_module.cc @@ -5,8 +5,10 @@ #include -#include "net/proto2/public/descriptor.h" -#include "net/proto2/public/message.h" +#include +#include + +#include "google/protobuf/message.h" #include "pybind11_protobuf/native_proto_caster.h" namespace { diff --git a/pybind11_protobuf/tests/wrapped_proto_module.cc b/pybind11_protobuf/tests/wrapped_proto_module.cc index 6869671..364054e 100644 --- a/pybind11_protobuf/tests/wrapped_proto_module.cc +++ b/pybind11_protobuf/tests/wrapped_proto_module.cc @@ -6,14 +6,15 @@ #include #include -#include -#include -#include +#include +#include +#include #include -#include "net/proto2/public/dynamic_message.h" +#include "absl/functional/function_ref.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" +#include "google/protobuf/dynamic_message.h" #include "pybind11_protobuf/tests/test.pb.h" #include "pybind11_protobuf/wrapped_proto_caster.h" @@ -21,11 +22,11 @@ namespace py = ::pybind11; namespace { -using pybind11::test::IntMessage; -using pybind11::test::TestMessage; -using pybind11_protobuf::WithWrappedProtos; -using pybind11_protobuf::WrappedProto; -using pybind11_protobuf::WrappedProtoKind; +using ::pybind11::test::IntMessage; +using ::pybind11::test::TestMessage; +using ::pybind11_protobuf::WithWrappedProtos; +using ::pybind11_protobuf::WrappedProto; +using ::pybind11_protobuf::WrappedProtoKind; const TestMessage& GetStatic() { static TestMessage test_message = [] { diff --git a/pybind11_protobuf/wrapped_proto_caster.h b/pybind11_protobuf/wrapped_proto_caster.h index db7c62c..68a6f92 100644 --- a/pybind11_protobuf/wrapped_proto_caster.h +++ b/pybind11_protobuf/wrapped_proto_caster.h @@ -7,21 +7,18 @@ #include #include -#include #include -#include -#include #include #include -#include "net/proto2/public/message.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" +#include "google/protobuf/message.h" #include "pybind11_protobuf/proto_cast_util.h" #include "pybind11_protobuf/proto_caster_impl.h" -// pybind11::type_caster<> specialization for ::google::protobuf::Message types using -// pybind11_protobuf::WrappedProto<> wrappers. When passing from C++ to +// pybind11::type_caster<> specialization for ::google::protobuf::Message types +// using pybind11_protobuf::WrappedProto<> wrappers. When passing from C++ to // python a copy is always made. When passing from python to C++ a copy is // made for mutable and by-value types, but not for const reference types. // @@ -68,10 +65,10 @@ inline void ImportWrappedProtoCasters() { InitializePybindProtoCastUtil(); } /// Tag types for WrappedProto specialization. enum WrappedProtoKind : int { kConst, kValue, kMutable }; -/// WrappedProto wraps a ::google::protobuf::Message subtype, exposing implicit -/// constructors and implicit cast operators. The ConstTag variant allows -/// conversion to const; the MutableTag allows mutable conversion and enables -/// the type-caster specialization to enforce that a copy is made. +/// WrappedProto wraps a ::google::protobuf::Message subtype, exposing +/// implicit constructors and implicit cast operators. The ConstTag variant +/// allows conversion to const; the MutableTag allows mutable conversion and +/// enables the type-caster specialization to enforce that a copy is made. /// /// WrappedProto ALWAYS creates a copy. /// WrappedProto ALWAYS creates a copy. @@ -342,8 +339,8 @@ struct WrapHelper>::value>> { static constexpr auto kKind = DetectKind(); static_assert(kKind != WrappedProtoKind::kMutable, - "WithWrappedProtos() does not support mutable ::google::protobuf::Message " - "parameters."); + "WithWrappedProtos() does not support mutable " + "::google::protobuf::Message parameters."); using type = WrappedProto, kKind>; }; @@ -355,8 +352,8 @@ struct WrapHelper, // ::google::protobuf::Message, intrinsic_t>::value>> { static constexpr auto kKind = DetectKind(); static_assert(kKind != WrappedProtoKind::kMutable, - "WithWrappedProtos() does not support mutable ::google::protobuf::Message " - "parameters."); + "WithWrappedProtos() does not support mutable " + "::google::protobuf::Message parameters."); using type = absl::optional, kKind>>; }; @@ -371,8 +368,8 @@ struct WrapHelper, // ::google::protobuf::Message, intrinsic_t>::value>> { static constexpr auto kKind = DetectKind(); static_assert(kKind != WrappedProtoKind::kMutable, - "WithWrappedProtos() does not support mutable ::google::protobuf::Message " - "parameters."); + "WithWrappedProtos() does not support mutable " + "::google::protobuf::Message parameters."); using type = absl::StatusOr, kKind>>; }; @@ -401,8 +398,8 @@ struct WrapHelper>, // }; /// FunctionInvoker/ConstMemberInvoker/MemberInvoker are internal functions -/// that expose calls with equivalent signatures, replacing ::google::protobuf::Message -/// derived types with WrappedProto types. +/// that expose calls with equivalent signatures, replacing +/// ::google::protobuf::Message derived types with WrappedProto types. template struct FunctionInvoker; @@ -464,8 +461,8 @@ struct LambdaSignature { } // namespace impl /// WithWrappedProtos(...) wraps a function type and converts any -/// ::google::protobuf::Message derived types into a WrappedProto<...> of the same -/// underlying proto2 type. +/// ::google::protobuf::Message derived types into a WrappedProto<...> of the +/// same underlying proto2 type. template > auto WithWrappedProtos(F f) ->