1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELD_SET_H__ 9 #define GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELD_SET_H__ 10 11 #define PY_SSIZE_T_CLEAN 12 #include <Python.h> 13 14 #include <memory> 15 #include <set> 16 17 #include "google/protobuf/pyext/message.h" 18 19 namespace google { 20 namespace protobuf { 21 22 class UnknownField; 23 class UnknownFieldSet; 24 25 namespace python { 26 struct CMessage; 27 28 struct PyUnknownFieldSet { 29 PyObject_HEAD; 30 // If parent is nullptr, it is a top UnknownFieldSet. 31 PyUnknownFieldSet* parent; 32 33 // Top UnknownFieldSet owns fields pointer. Sub UnknownFieldSet 34 // does not own fields pointer. 35 UnknownFieldSet* fields; 36 }; 37 38 struct PyUnknownField { 39 PyObject_HEAD; 40 // Every Python PyUnknownField holds a reference to its parent 41 // PyUnknownFieldSet in order to keep it alive. 42 PyUnknownFieldSet* parent; 43 44 // The UnknownField index in UnknownFieldSet. 45 Py_ssize_t index; 46 }; 47 48 extern PyTypeObject PyUnknownFieldSet_Type; 49 extern PyTypeObject PyUnknownField_Type; 50 51 } // namespace python 52 } // namespace protobuf 53 } // namespace google 54 55 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELD_SET_H__ 56