| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 Message* sub_message = | 139 Message* sub_message = |
| 140 message->GetReflection()->AddMessage(message, | 140 message->GetReflection()->AddMessage(message, |
| 141 self->parent_field_descriptor); | 141 self->parent_field_descriptor); |
| 142 CMessage* cmsg = cmessage::NewEmptyMessage(self->child_message_class); | 142 CMessage* cmsg = cmessage::NewEmptyMessage(self->child_message_class); |
| 143 if (cmsg == NULL) | 143 if (cmsg == NULL) |
| 144 return NULL; | 144 return NULL; |
| 145 | 145 |
| 146 cmsg->owner = self->owner; | 146 cmsg->owner = self->owner; |
| 147 cmsg->message = sub_message; | 147 cmsg->message = sub_message; |
| 148 cmsg->parent = self->parent; | 148 cmsg->parent = self->parent; |
| 149 if (cmessage::InitAttributes(cmsg, args, kwargs) < 0) { | 149 if (cmessage::InitAttributes(cmsg, kwargs) < 0) { |
| 150 Py_DECREF(cmsg); | 150 Py_DECREF(cmsg); |
| 151 return NULL; | 151 return NULL; |
| 152 } | 152 } |
| 153 | 153 |
| 154 PyObject* py_cmsg = reinterpret_cast<PyObject*>(cmsg); | 154 PyObject* py_cmsg = reinterpret_cast<PyObject*>(cmsg); |
| 155 if (PyList_Append(self->child_messages, py_cmsg) < 0) { | 155 if (PyList_Append(self->child_messages, py_cmsg) < 0) { |
| 156 Py_DECREF(py_cmsg); | 156 Py_DECREF(py_cmsg); |
| 157 return NULL; | 157 return NULL; |
| 158 } | 158 } |
| 159 return py_cmsg; | 159 return py_cmsg; |
| 160 } | 160 } |
| 161 | 161 |
| 162 static PyObject* AddToReleased(RepeatedCompositeContainer* self, | 162 static PyObject* AddToReleased(RepeatedCompositeContainer* self, |
| 163 PyObject* args, | 163 PyObject* args, |
| 164 PyObject* kwargs) { | 164 PyObject* kwargs) { |
| 165 GOOGLE_CHECK_RELEASED(self); | 165 GOOGLE_CHECK_RELEASED(self); |
| 166 | 166 |
| 167 // Create a new Message detached from the rest. | 167 // Create a new Message detached from the rest. |
| 168 PyObject* py_cmsg = PyEval_CallObjectWithKeywords( | 168 PyObject* py_cmsg = PyEval_CallObjectWithKeywords( |
| 169 self->child_message_class->AsPyObject(), args, kwargs); | 169 self->child_message_class->AsPyObject(), NULL, kwargs); |
| 170 if (py_cmsg == NULL) | 170 if (py_cmsg == NULL) |
| 171 return NULL; | 171 return NULL; |
| 172 | 172 |
| 173 if (PyList_Append(self->child_messages, py_cmsg) < 0) { | 173 if (PyList_Append(self->child_messages, py_cmsg) < 0) { |
| 174 Py_DECREF(py_cmsg); | 174 Py_DECREF(py_cmsg); |
| 175 return NULL; | 175 return NULL; |
| 176 } | 176 } |
| 177 return py_cmsg; | 177 return py_cmsg; |
| 178 } | 178 } |
| 179 | 179 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Returns 0 if successful; returns -1 and sets an exception if | 359 // Returns 0 if successful; returns -1 and sets an exception if |
| 360 // unsuccessful. | 360 // unsuccessful. |
| 361 static int SortPythonMessages(RepeatedCompositeContainer* self, | 361 static int SortPythonMessages(RepeatedCompositeContainer* self, |
| 362 PyObject* args, | 362 PyObject* args, |
| 363 PyObject* kwds) { | 363 PyObject* kwds) { |
| 364 ScopedPyObjectPtr m(PyObject_GetAttrString(self->child_messages, "sort")); | 364 ScopedPyObjectPtr m(PyObject_GetAttrString(self->child_messages, "sort")); |
| 365 if (m == NULL) | 365 if (m == NULL) |
| 366 return -1; | 366 return -1; |
| 367 if (ScopedPyObjectPtr(PyObject_Call(m.get(), args, kwds)) == NULL) | 367 if (PyObject_Call(m.get(), args, kwds) == NULL) |
| 368 return -1; | 368 return -1; |
| 369 if (self->message != NULL) { | 369 if (self->message != NULL) { |
| 370 ReorderAttached(self); | 370 ReorderAttached(self); |
| 371 } | 371 } |
| 372 return 0; | 372 return 0; |
| 373 } | 373 } |
| 374 | 374 |
| 375 static PyObject* Sort(RepeatedCompositeContainer* self, | 375 static PyObject* Sort(RepeatedCompositeContainer* self, |
| 376 PyObject* args, | 376 PyObject* args, |
| 377 PyObject* kwds) { | 377 PyObject* kwds) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 0, // tp_dict | 603 0, // tp_dict |
| 604 0, // tp_descr_get | 604 0, // tp_descr_get |
| 605 0, // tp_descr_set | 605 0, // tp_descr_set |
| 606 0, // tp_dictoffset | 606 0, // tp_dictoffset |
| 607 0, // tp_init | 607 0, // tp_init |
| 608 }; | 608 }; |
| 609 | 609 |
| 610 } // namespace python | 610 } // namespace python |
| 611 } // namespace protobuf | 611 } // namespace protobuf |
| 612 } // namespace google | 612 } // namespace google |
| OLD | NEW |