aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/pyext/message_module.cc
diff options
context:
space:
mode:
authorGravatar Thomas Colthurst <thomaswc@google.com>2018-05-29 18:26:11 -0400
committerGravatar Thomas Colthurst <thomaswc@google.com>2018-05-30 10:33:02 -0400
commit7c6514245b6e256cc97dd31a6da1e2c72de487e6 (patch)
tree275ae5a08d02048d24cd230176d8db053deb189c /python/google/protobuf/pyext/message_module.cc
parent7d1a8fff1b424e63f6bbdd1f9f828f6f9f40e84f (diff)
Introduce Proto C API; based on cl/198113115 by amauryfa
Diffstat (limited to 'python/google/protobuf/pyext/message_module.cc')
-rw-r--r--python/google/protobuf/pyext/message_module.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/google/protobuf/pyext/message_module.cc b/python/google/protobuf/pyext/message_module.cc
index 7c4df47f..f5c8f295 100644
--- a/python/google/protobuf/pyext/message_module.cc
+++ b/python/google/protobuf/pyext/message_module.cc
@@ -31,9 +31,26 @@
#include <Python.h>
#include <google/protobuf/pyext/message.h>
+#include <google/protobuf/proto_api.h>
#include <google/protobuf/message_lite.h>
+namespace {
+
+// C++ API. Clients get at this via proto_api.h
+struct ApiImplementation : google::protobuf::python::PyProto_API {
+ const google::protobuf::Message*
+ GetMessagePointer(PyObject* msg) const override {
+ return google::protobuf::python::PyMessage_GetMessagePointer(msg);
+ }
+ google::protobuf::Message*
+ GetMutableMessagePointer(PyObject* msg) const override {
+ return google::protobuf::python::PyMessage_GetMutableMessagePointer(msg);
+ }
+};
+
+} // namespace
+
static PyObject* GetPythonProto3PreserveUnknownsDefault(
PyObject* /*m*/, PyObject* /*args*/) {
if (google::protobuf::internal::GetProto3PreserveUnknownsDefault()) {