OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 }; | 105 }; |
106 | 106 |
107 struct MessageMapContainer : public MapContainer { | 107 struct MessageMapContainer : public MapContainer { |
108 // The type used to create new child messages. | 108 // The type used to create new child messages. |
109 CMessageClass* message_class; | 109 CMessageClass* message_class; |
110 | 110 |
111 // A dict mapping Message* -> CMessage. | 111 // A dict mapping Message* -> CMessage. |
112 PyObject* message_dict; | 112 PyObject* message_dict; |
113 }; | 113 }; |
114 | 114 |
115 bool InitMapContainers(); | 115 #if PY_MAJOR_VERSION >= 3 |
| 116 extern PyObject *MessageMapContainer_Type; |
| 117 extern PyType_Spec MessageMapContainer_Type_spec; |
| 118 extern PyObject *ScalarMapContainer_Type; |
| 119 extern PyType_Spec ScalarMapContainer_Type_spec; |
| 120 #else |
| 121 extern PyTypeObject MessageMapContainer_Type; |
| 122 extern PyTypeObject ScalarMapContainer_Type; |
| 123 #endif |
116 | 124 |
117 extern PyTypeObject* MessageMapContainer_Type; | |
118 extern PyTypeObject* ScalarMapContainer_Type; | |
119 extern PyTypeObject MapIterator_Type; // Both map types use the same iterator. | 125 extern PyTypeObject MapIterator_Type; // Both map types use the same iterator. |
120 | 126 |
121 // Builds a MapContainer object, from a parent message and a | 127 // Builds a MapContainer object, from a parent message and a |
122 // field descriptor. | 128 // field descriptor. |
123 extern PyObject* NewScalarMapContainer( | 129 extern PyObject* NewScalarMapContainer( |
124 CMessage* parent, const FieldDescriptor* parent_field_descriptor); | 130 CMessage* parent, const FieldDescriptor* parent_field_descriptor); |
125 | 131 |
126 // Builds a MessageMap object, from a parent message and a | 132 // Builds a MessageMap object, from a parent message and a |
127 // field descriptor. | 133 // field descriptor. |
128 extern PyObject* NewMessageMapContainer( | 134 extern PyObject* NewMessageMapContainer( |
129 CMessage* parent, const FieldDescriptor* parent_field_descriptor, | 135 CMessage* parent, const FieldDescriptor* parent_field_descriptor, |
130 CMessageClass* message_class); | 136 CMessageClass* message_class); |
131 | 137 |
132 } // namespace python | 138 } // namespace python |
133 } // namespace protobuf | 139 } // namespace protobuf |
134 | 140 |
135 } // namespace google | 141 } // namespace google |
136 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__ | 142 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__ |
OLD | NEW |