diff --git a/pybind11_protobuf/BUILD b/pybind11_protobuf/BUILD index f34fab0..b259ef8 100644 --- a/pybind11_protobuf/BUILD +++ b/pybind11_protobuf/BUILD @@ -11,7 +11,7 @@ pybind_library( "//visibility:public", ], deps = [ - "@com_google_protobuf//:protobuf", + "//third_party/protobuf:protobuf_lite", ], ) @@ -39,6 +39,7 @@ pybind_library( ], deps = [ ":check_unknown_fields", + "//third_party/protobuf:descriptor_pb", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", @@ -71,7 +72,6 @@ cc_library( deps = [ "@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", diff --git a/pybind11_protobuf/check_unknown_fields.cc b/pybind11_protobuf/check_unknown_fields.cc index 0639d09..9e50923 100644 --- a/pybind11_protobuf/check_unknown_fields.cc +++ b/pybind11_protobuf/check_unknown_fields.cc @@ -6,22 +6,23 @@ #include #include -#include "google/protobuf/descriptor.h" -#include "google/protobuf/message.h" -#include "google/protobuf/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 { using AllowListSet = absl::flat_hash_set; using MayContainExtensionsMap = - absl::flat_hash_map; + absl::flat_hash_map; AllowListSet* GetAllowList() { static auto* allow_list = new AllowListSet(); @@ -37,7 +38,7 @@ std::string MakeAllowListKey( /// Recurses through the message Descriptor class looking for valid extensions. /// Stores the result to `memoized`. -bool MessageMayContainExtensionsRecursive(const ::google::protobuf::Descriptor* descriptor, +bool MessageMayContainExtensionsRecursive(const google::protobuf::Descriptor* descriptor, MayContainExtensionsMap* memoized) { if (descriptor->extension_range_count() > 0) return true; @@ -48,7 +49,7 @@ bool MessageMayContainExtensionsRecursive(const ::google::protobuf::Descriptor* for (int i = 0; i < descriptor->field_count(); i++) { auto* fd = descriptor->field(i); - if (fd->cpp_type() != ::google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE) continue; + if (fd->cpp_type() != google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE) continue; if (MessageMayContainExtensionsRecursive(fd->message_type(), memoized)) { (*memoized)[descriptor] = true; return true; @@ -58,7 +59,7 @@ bool MessageMayContainExtensionsRecursive(const ::google::protobuf::Descriptor* return false; } -bool MessageMayContainExtensionsMemoized(const ::google::protobuf::Descriptor* descriptor) { +bool MessageMayContainExtensionsMemoized(const google::protobuf::Descriptor* descriptor) { static auto* memoized = new MayContainExtensionsMap(); static absl::Mutex lock; absl::MutexLock l(&lock); @@ -66,8 +67,8 @@ bool MessageMayContainExtensionsMemoized(const ::google::protobuf::Descriptor* d } struct HasUnknownFields { - HasUnknownFields(const ::google::protobuf::python::PyProto_API* py_proto_api, - const ::google::protobuf::Descriptor* root_descriptor) + HasUnknownFields(const google::protobuf::python::PyProto_API* py_proto_api, + const google::protobuf::Descriptor* root_descriptor) : py_proto_api(py_proto_api), root_descriptor(root_descriptor) {} std::string FieldFQN() const { return absl::StrJoin(field_fqn_parts, "."); } @@ -77,25 +78,25 @@ struct HasUnknownFields { : absl::StrCat(FieldFQN(), ".", unknown_field_number); } - bool FindUnknownFieldsRecursive(const ::google::protobuf::Message* sub_message, + bool FindUnknownFieldsRecursive(const google::protobuf::Message* sub_message, uint32_t depth); std::string BuildErrorMessage() const; - const ::google::protobuf::python::PyProto_API* py_proto_api; - const ::google::protobuf::Descriptor* root_descriptor = nullptr; - const ::google::protobuf::Descriptor* unknown_field_parent_descriptor = nullptr; + const google::protobuf::python::PyProto_API* py_proto_api; + const google::protobuf::Descriptor* root_descriptor = nullptr; + const google::protobuf::Descriptor* unknown_field_parent_descriptor = nullptr; std::vector field_fqn_parts; int unknown_field_number; }; /// Recurses through the message fields class looking for UnknownFields. bool HasUnknownFields::FindUnknownFieldsRecursive( - const ::google::protobuf::Message* sub_message, uint32_t depth) { - const ::google::protobuf::Reflection& reflection = *sub_message->GetReflection(); + const google::protobuf::Message* sub_message, uint32_t depth) { + const google::protobuf::Reflection& reflection = *sub_message->GetReflection(); // If there are unknown fields, stop searching. - const ::google::protobuf::UnknownFieldSet& unknown_field_set = + const google::protobuf::UnknownFieldSet& unknown_field_set = reflection.GetUnknownFields(*sub_message); if (!unknown_field_set.empty()) { unknown_field_parent_descriptor = sub_message->GetDescriptor(); @@ -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; } @@ -118,11 +118,11 @@ bool HasUnknownFields::FindUnknownFieldsRecursive( // Otherwise the method has to check all present fields, including // extensions to determine if they include unknown fields. - std::vector present_fields; + std::vector present_fields; reflection.ListFields(*sub_message, &present_fields); for (const auto* field : present_fields) { - if (field->cpp_type() != ::google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { + if (field->cpp_type() != google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { continue; } if (field->is_repeated()) { @@ -182,8 +182,8 @@ void AllowUnknownFieldsFor(absl::string_view top_message_descriptor_full_name, } std::optional CheckRecursively( - const ::google::protobuf::python::PyProto_API* py_proto_api, - const ::google::protobuf::Message* message) { + const google::protobuf::python::PyProto_API* py_proto_api, + const google::protobuf::Message* message) { const auto* root_descriptor = message->GetDescriptor(); HasUnknownFields search{py_proto_api, root_descriptor}; if (!search.FindUnknownFieldsRecursive(message, 0u)) { diff --git a/pybind11_protobuf/check_unknown_fields.h b/pybind11_protobuf/check_unknown_fields.h index 79ac001..b25b89f 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 "absl/strings/string_view.h" #include "google/protobuf/message.h" #include "python/google/protobuf/proto_api.h" -#include "absl/strings/string_view.h" namespace pybind11_protobuf::check_unknown_fields { @@ -46,8 +47,8 @@ void AllowUnknownFieldsFor(absl::string_view top_message_descriptor_full_name, absl::string_view unknown_field_parent_message_fqn); std::optional CheckRecursively( - const ::google::protobuf::python::PyProto_API* py_proto_api, - const ::google::protobuf::Message* top_message); + const google::protobuf::python::PyProto_API* py_proto_api, + const google::protobuf::Message* top_message); } // namespace pybind11_protobuf::check_unknown_fields diff --git a/pybind11_protobuf/enum_type_caster.h b/pybind11_protobuf/enum_type_caster.h index d30369b..9f7f94a 100644 --- a/pybind11_protobuf/enum_type_caster.h +++ b/pybind11_protobuf/enum_type_caster.h @@ -11,21 +11,19 @@ #include #include -#include #include -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_enum_reflection.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 require // -// 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 @@ -100,17 +98,17 @@ constexpr bool pybind11_protobuf_enable_enum_type_caster(...) { return true; } #if defined(PYBIND11_HAS_NATIVE_ENUM) template struct type_caster_enum_type_enabled< - EnumType, std::enable_if_t<(::google::protobuf::is_proto_enum::value && + EnumType, std::enable_if_t<(google::protobuf::is_proto_enum::value && pybind11_protobuf_enable_enum_type_caster( static_cast(nullptr)))>> : std::false_type {}; #endif // Specialization of pybind11::detail::type_caster for types satisfying -// ::google::protobuf::is_proto_enum. +// google::protobuf::is_proto_enum. template struct type_caster::value && + std::enable_if_t<(google::protobuf::is_proto_enum::value && pybind11_protobuf_enable_enum_type_caster( static_cast(nullptr)))>> : public pybind11_protobuf::enum_type_caster {}; diff --git a/pybind11_protobuf/native_proto_caster.h b/pybind11_protobuf/native_proto_caster.h index 6d020e0..cd64f4a 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 "google/protobuf/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 @@ -85,7 +80,7 @@ constexpr bool pybind11_protobuf_enable_type_caster(...) { return true; } template struct type_caster< ProtoType, - std::enable_if_t<(std::is_base_of<::google::protobuf::Message, ProtoType>::value && + std::enable_if_t<(std::is_base_of::value && pybind11_protobuf_enable_type_caster( static_cast(nullptr)))>> : public pybind11_protobuf::proto_caster< @@ -95,12 +90,12 @@ struct type_caster< template struct copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled< - ProtoType, enable_if_t::value>> + ProtoType, enable_if_t::value>> : std::false_type {}; template struct move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled< - ProtoType, enable_if_t::value>> + ProtoType, enable_if_t::value>> : std::false_type {}; #endif // PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT @@ -118,7 +113,7 @@ struct move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled< template struct move_only_holder_caster< ProtoType, HolderType, - std::enable_if_t<(std::is_base_of<::google::protobuf::Message, ProtoType>::value && + std::enable_if_t<(std::is_base_of::value && pybind11_protobuf_enable_type_caster( static_cast(nullptr)))>> : public pybind11_protobuf::move_only_holder_caster_impl struct copyable_holder_caster< ProtoType, HolderType, - std::enable_if_t<(std::is_base_of<::google::protobuf::Message, ProtoType>::value && + std::enable_if_t<(std::is_base_of::value && pybind11_protobuf_enable_type_caster( static_cast(nullptr)))>> : public pybind11_protobuf::copyable_holder_caster_impl #include #include -#include -#include "google/protobuf/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("google.protobuf.descriptor"); - auto descriptor_pool = - ImportCached("google.protobuf.descriptor_pool"); - auto message_factory = - ImportCached("google.protobuf.message_factory"); + ImportCached("google.protobuf"); + 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")) { @@ -221,6 +217,7 @@ py::module_ GlobalState::ImportCached(const std::string& module_name) { if (cached != import_cache_.end()) { return cached->second; } + LOG(INFO) << "ImportCached " << module_name; auto module = py::module_::import(module_name.c_str()); import_cache_[module_name] = module; return module; diff --git a/pybind11_protobuf/proto_cast_util.h b/pybind11_protobuf/proto_cast_util.h index f2ff440..52de848 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 "google/protobuf/descriptor.h" -#include "google/protobuf/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 @@ -52,11 +49,13 @@ absl::string_view PyBytesAsStringView(pybind11::bytes py_bytes); // various protobuf-related modules. void InitializePybindProtoCastUtil(); -// Imports a module pertaining to a given ::google::protobuf::Descriptor, if possible. -void ImportProtoDescriptorModule(const ::google::protobuf::Descriptor *); +// Imports a module pertaining to a given google::protobuf::Descriptor, if +// possible. +void ImportProtoDescriptorModule(const google::protobuf::Descriptor *); -// Returns a ::google::protobuf::Message* from a cpp_fast_proto, if backed by C++. -const ::google::protobuf::Message *PyProtoGetCppMessagePointer(pybind11::handle src); +// Returns a google::protobuf::Message* from a cpp_fast_proto, if backed by +// C++. +const google::protobuf::Message *PyProtoGetCppMessagePointer(pybind11::handle src); // Returns the protocol buffer's py_proto.DESCRIPTOR.full_name attribute. absl::optional PyProtoDescriptorFullName( @@ -64,31 +63,31 @@ absl::optional PyProtoDescriptorFullName( // Returns true if py_proto full name matches descriptor full name. bool PyProtoHasMatchingFullName(pybind11::handle py_proto, - const ::google::protobuf::Descriptor *descriptor); + const google::protobuf::Descriptor *descriptor); // Caller should enforce any type identity that is required. pybind11::bytes PyProtoSerializePartialToString(pybind11::handle py_proto, bool raise_if_error); // Allocates a C++ protocol buffer for a given name. -std::unique_ptr<::google::protobuf::Message> AllocateCProtoFromPythonSymbolDatabase( +std::unique_ptr AllocateCProtoFromPythonSymbolDatabase( pybind11::handle src, const std::string &full_name); // Serialize the py_proto and deserialize it into the provided message. // Caller should enforce any type identity that is required. -void CProtoCopyToPyProto(::google::protobuf::Message *message, pybind11::handle py_proto); +void CProtoCopyToPyProto(google::protobuf::Message *message, pybind11::handle py_proto); // Returns a handle to a python protobuf suitably -pybind11::handle GenericFastCppProtoCast(::google::protobuf::Message *src, +pybind11::handle GenericFastCppProtoCast(google::protobuf::Message *src, pybind11::return_value_policy policy, pybind11::handle parent, bool is_const); -pybind11::handle GenericPyProtoCast(::google::protobuf::Message *src, +pybind11::handle GenericPyProtoCast(google::protobuf::Message *src, pybind11::return_value_policy policy, pybind11::handle parent, bool is_const); -pybind11::handle GenericProtoCast(::google::protobuf::Message *src, +pybind11::handle GenericProtoCast(google::protobuf::Message *src, pybind11::return_value_policy policy, pybind11::handle parent, bool is_const); diff --git a/pybind11_protobuf/proto_caster_impl.h b/pybind11_protobuf/proto_caster_impl.h index 12e693d..3105460 100644 --- a/pybind11_protobuf/proto_caster_impl.h +++ b/pybind11_protobuf/proto_caster_impl.h @@ -8,15 +8,13 @@ #include #include -#include #include #include -#include #include #include -#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/message.h" #include "pybind11_protobuf/proto_cast_util.h" @@ -52,10 +50,10 @@ struct proto_caster_load_impl { // Attempt to use the PyProto_API to get an underlying C++ message pointer // from the object. - const ::google::protobuf::Message *message = + const google::protobuf::Message *message = pybind11_protobuf::PyProtoGetCppMessagePointer(src); if (message) { - value = ::google::protobuf::DynamicCastToGenerated(message); + value = google::protobuf::DynamicCastToGenerated(message); if (value) { // If the capability were available, then we could probe PyProto_API and // allow c++ mutability based on the python reference count. @@ -74,12 +72,11 @@ 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 - // ::google::protobuf::Message. + // google::protobuf::Message. void ensure_owned() { if (value && !owned) { owned = std::unique_ptr(value->New()); @@ -93,8 +90,8 @@ struct proto_caster_load_impl { }; template <> -struct proto_caster_load_impl<::google::protobuf::Message> { - using ProtoType = ::google::protobuf::Message; +struct proto_caster_load_impl { + using ProtoType = google::protobuf::Message; bool load(pybind11::handle src, bool convert) { if (src.is_none()) { @@ -126,12 +123,11 @@ 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 - // ::google::protobuf::Message. + // google::protobuf::Message. void ensure_owned() { if (value && !owned) { owned = std::unique_ptr(value->New()); @@ -140,12 +136,12 @@ struct proto_caster_load_impl<::google::protobuf::Message> { } } - const ::google::protobuf::Message *value; - std::unique_ptr<::google::protobuf::Message> owned; + const google::protobuf::Message *value; + std::unique_ptr owned; }; struct fast_cpp_cast_impl { - inline static pybind11::handle cast_impl(::google::protobuf::Message *src, + inline static pybind11::handle cast_impl(google::protobuf::Message *src, pybind11::return_value_policy policy, pybind11::handle parent, bool is_const) { @@ -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()."); } @@ -174,7 +171,7 @@ struct fast_cpp_cast_impl { }; struct native_cast_impl { - inline static pybind11::handle cast_impl(::google::protobuf::Message *src, + inline static pybind11::handle cast_impl(google::protobuf::Message *src, pybind11::return_value_policy policy, pybind11::handle parent, bool is_const) { diff --git a/pybind11_protobuf/proto_utils.cc b/pybind11_protobuf/proto_utils.cc index 2701727..a8348bb 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 "google/protobuf/descriptor.pb.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" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" namespace pybind11 { namespace google { @@ -30,16 +33,16 @@ namespace google { // It code be moved back to proto_utils.h with added unit testing. // Gets the field with the given name from the given message as a python object. -object ProtoGetField(::google::protobuf::Message* message, absl::string_view name); -object ProtoGetField(::google::protobuf::Message* message, - const ::google::protobuf::FieldDescriptor* field_desc); +object ProtoGetField(google::protobuf::Message* message, absl::string_view name); +object ProtoGetField(google::protobuf::Message* message, + const google::protobuf::FieldDescriptor* field_desc); // Sets the field with the given name in the given message from a python object. // As in the native API, message, repeated, and map fields cannot be set. -void ProtoSetField(::google::protobuf::Message* message, absl::string_view name, +void ProtoSetField(google::protobuf::Message* message, absl::string_view name, handle value); -void ProtoSetField(::google::protobuf::Message* message, - const ::google::protobuf::FieldDescriptor* field_desc, handle value); +void ProtoSetField(google::protobuf::Message* message, + const google::protobuf::FieldDescriptor* field_desc, handle value); // If py_proto is a native c or wrapped python proto, sets name and returns // true. If py_proto is not a proto, returns false. @@ -59,7 +62,7 @@ bool PyProtoCheckType(handle py_proto) { // Returns whether py_proto is a proto based on whether it has a descriptor // with the name of the proto. template <> -inline bool PyProtoCheckType<::google::protobuf::Message>(handle py_proto) { +inline bool PyProtoCheckType(handle py_proto) { return PyProtoFullName(py_proto, nullptr); } @@ -68,11 +71,11 @@ std::string PyProtoSerializeToString(handle py_proto); // Gets the descriptor for the proto specified by the argument, which can be a // native python proto, a wrapped C proto, or a string with the full type name. -const ::google::protobuf::Descriptor* PyProtoGetDescriptor(handle py_proto); +const google::protobuf::Descriptor* PyProtoGetDescriptor(handle py_proto); // Allocate and return a message instance for the given descriptor. -std::unique_ptr<::google::protobuf::Message> PyProtoAllocateMessage( - const ::google::protobuf::Descriptor* descriptor, kwargs kwargs_in); +std::unique_ptr PyProtoAllocateMessage( + const google::protobuf::Descriptor* descriptor, kwargs kwargs_in); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // END CODE MOVED HERE FROM proto_utils.h @@ -94,35 +97,35 @@ struct GenericEnum {}; // template functions don't exist in C++, so you must define a class with a // static member function (HandleField) which will be called. template