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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 PyObject* values; | 79 PyObject* values; |
80 } ExtensionDict; | 80 } ExtensionDict; |
81 | 81 |
82 extern PyTypeObject ExtensionDict_Type; | 82 extern PyTypeObject ExtensionDict_Type; |
83 | 83 |
84 namespace extension_dict { | 84 namespace extension_dict { |
85 | 85 |
86 // Builds an Extensions dict for a specific message. | 86 // Builds an Extensions dict for a specific message. |
87 ExtensionDict* NewExtensionDict(CMessage *parent); | 87 ExtensionDict* NewExtensionDict(CMessage *parent); |
88 | 88 |
| 89 // Gets the number of extension values in this ExtensionDict as a python object. |
| 90 // |
| 91 // Returns a new reference. |
| 92 PyObject* len(ExtensionDict* self); |
| 93 |
| 94 // Releases extensions referenced outside this dictionary to keep outside |
| 95 // references alive. |
| 96 // |
| 97 // Returns 0 on success, -1 on failure. |
| 98 int ReleaseExtension(ExtensionDict* self, |
| 99 PyObject* extension, |
| 100 const FieldDescriptor* descriptor); |
| 101 |
| 102 // Gets an extension from the dict for the given extension descriptor. |
| 103 // |
| 104 // Returns a new reference. |
| 105 PyObject* subscript(ExtensionDict* self, PyObject* key); |
| 106 |
| 107 // Assigns a value to an extension in the dict. Can only be used for singular |
| 108 // simple types. |
| 109 // |
| 110 // Returns 0 on success, -1 on failure. |
| 111 int ass_subscript(ExtensionDict* self, PyObject* key, PyObject* value); |
| 112 |
| 113 // Clears an extension from the dict. Will release the extension if there |
| 114 // is still an external reference left to it. |
| 115 // |
| 116 // Returns None on success. |
| 117 PyObject* ClearExtension(ExtensionDict* self, |
| 118 PyObject* extension); |
| 119 |
| 120 // Gets an extension from the dict given the extension name as opposed to |
| 121 // descriptor. |
| 122 // |
| 123 // Returns a new reference. |
| 124 PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* name); |
| 125 |
| 126 // Gets an extension from the dict given the extension field number as |
| 127 // opposed to descriptor. |
| 128 // |
| 129 // Returns a new reference. |
| 130 PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* number); |
| 131 |
89 } // namespace extension_dict | 132 } // namespace extension_dict |
90 } // namespace python | 133 } // namespace python |
91 } // namespace protobuf | 134 } // namespace protobuf |
92 | 135 |
93 } // namespace google | 136 } // namespace google |
94 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__ | 137 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__ |
OLD | NEW |