Lines Matching refs:descriptor
38 #include <google/protobuf/descriptor.pb.h>
40 #include <google/protobuf/pyext/descriptor.h>
65 // Store interned descriptors, so that the same C++ descriptor yields the same
81 // message_descriptor = Descriptor(
156 // Helper functions for descriptor objects.
158 // A set of templates to retrieve the C++ FileDescriptor of any descriptor.
160 const FileDescriptor* GetFileDescriptor(const DescriptorClass* descriptor) {
161 return descriptor->file();
164 const FileDescriptor* GetFileDescriptor(const FileDescriptor* descriptor) {
165 return descriptor;
168 const FileDescriptor* GetFileDescriptor(const EnumValueDescriptor* descriptor) {
169 return descriptor->type()->file();
172 const FileDescriptor* GetFileDescriptor(const OneofDescriptor* descriptor) {
173 return descriptor->containing_type()->file();
184 static PyObject* GetOrBuildOptions(const DescriptorClass *descriptor) {
186 // containing the descriptor.
188 GetFileDescriptor(descriptor)->pool());
193 if (descriptor_options->find(descriptor) != descriptor_options->end()) {
194 PyObject *value = (*descriptor_options)[descriptor];
201 const Message& options(descriptor->options());
202 const Descriptor *message_type = options.GetDescriptor();
251 (*pool->descriptor_options)[descriptor] = value.get();
256 // Copy the C++ descriptor to a Python message.
260 static PyObject* CopyToPythonProto(const DescriptorClass *descriptor,
262 const Descriptor* self_descriptor =
274 descriptor->CopyTo(descriptor_message);
282 // Pointer to the C++ proto2 descriptor.
284 const void* descriptor;
291 // FileDescriptor structure "inherits" from the base descriptor.
301 namespace descriptor {
303 // Creates or retrieve a Python descriptor of the specified type.
304 // Objects are interned: the same descriptor will return the same object if it
311 const DescriptorClass* descriptor,
316 if (descriptor == NULL) {
323 interned_descriptors.find(descriptor);
329 // Create a new descriptor object
335 py_descriptor->descriptor = descriptor;
339 std::make_pair(descriptor, reinterpret_cast<PyObject*>(py_descriptor)));
343 GetFileDescriptor(descriptor)->pool());
360 interned_descriptors.erase(self->descriptor);
402 } // namespace descriptor
405 if (!PyObject_TypeCheck(obj, &descriptor::PyBaseDescriptor_Type)) {
409 return reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor;
415 static const Descriptor* _GetDescriptor(PyBaseDescriptor* self) {
416 return reinterpret_cast<const Descriptor*>(self->descriptor);
432 // Retuns the canonical class for the given descriptor.
433 // This is the class that was registered with the primary descriptor pool
434 // which contains this descriptor.
506 const Descriptor* descriptor = _GetDescriptor(self);
507 PyObject* range_list = PyList_New(descriptor->extension_range_count());
509 for (int i = 0; i < descriptor->extension_range_count(); i++) {
510 const Descriptor::ExtensionRange* range = descriptor->extension_range(i);
520 const Descriptor* containing_type =
589 { "file", (getter)GetFile, NULL, "File descriptor"},
649 "A Message Descriptor", // tp_doc
659 &descriptor::PyBaseDescriptor_Type, // tp_base
663 const Descriptor* message_descriptor) {
664 return descriptor::NewInternedDescriptor(
668 const Descriptor* PyMessageDescriptor_AsDescriptor(PyObject* obj) {
673 return reinterpret_cast<const Descriptor*>(
674 reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
682 return reinterpret_cast<const FieldDescriptor*>(self->descriptor);
806 const Descriptor* message_type = _GetDescriptor(self)->message_type();
820 const Descriptor* containing_type =
835 const Descriptor* extension_scope =
939 "A Field Descriptor", // tp_doc
949 &descriptor::PyBaseDescriptor_Type, // tp_base
954 return descriptor::NewInternedDescriptor(
964 reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
972 return reinterpret_cast<const EnumDescriptor*>(self->descriptor);
1000 const Descriptor* containing_type =
1050 { "file", (getter)GetFile, NULL, "File descriptor"},
1087 "A Enum Descriptor", // tp_doc
1097 &descriptor::PyBaseDescriptor_Type, // tp_base
1102 return descriptor::NewInternedDescriptor(
1112 reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
1120 return reinterpret_cast<const EnumValueDescriptor*>(self->descriptor);
1201 "A EnumValue Descriptor", // tp_doc
1211 &descriptor::PyBaseDescriptor_Type, // tp_base
1216 return descriptor::NewInternedDescriptor(
1224 return reinterpret_cast<const FileDescriptor*>(self->base.descriptor);
1229 descriptor::Dealloc(&self->base);
1365 "A File Descriptor", // tp_doc
1375 &descriptor::PyBaseDescriptor_Type, // tp_base
1395 PyObject* py_descriptor = descriptor::NewInternedDescriptor(
1418 reinterpret_cast<PyBaseDescriptor*>(obj)->descriptor);
1426 return reinterpret_cast<const OneofDescriptor*>(self->descriptor);
1446 const Descriptor* containing_type =
1488 "A Oneof Descriptor", // tp_doc
1498 &descriptor::PyBaseDescriptor_Type, // tp_base
1503 return descriptor::NewInternedDescriptor(