47 : py_database_(py_database) {
57 if (py_descriptor ==
NULL) {
58 if (PyErr_ExceptionMatches(PyExc_KeyError)) {
67 if (py_descriptor == Py_None) {
74 message->message->GetDescriptor() == filedescriptor_descriptor) {
84 PyObject_CallMethod(py_descriptor,
"SerializeToString",
NULL));
85 if (serialized_pb ==
NULL) {
87 <<
"DescriptorDatabase method did not return a FileDescriptorProto";
93 if (PyBytes_AsStringAndSize(serialized_pb.
get(), &
str, &
len) < 0) {
95 <<
"DescriptorDatabase method did not return a FileDescriptorProto";
100 if (!file_proto.ParseFromArray(
str,
len)) {
102 <<
"DescriptorDatabase method did not return a FileDescriptorProto";
114 py_database_,
"FindFileByName",
"s#", filename.c_str(), filename.size()));
122 PyObject_CallMethod(
py_database_,
"FindFileContainingSymbol",
"s#",
123 symbol_name.c_str(), symbol_name.size()));
131 const string& containing_type,
int field_number,
134 PyObject_GetAttrString(
py_database_,
"FindFileContainingExtension"));
135 if (py_method ==
NULL) {
141 PyObject_CallFunction(py_method.
get(),
"s#i", containing_type.c_str(),
142 containing_type.size(), field_number));
151 const string& containing_type, std::vector<int>*
output) {
153 PyObject_GetAttrString(
py_database_,
"FindAllExtensionNumbers"));
154 if (py_method ==
NULL) {
160 PyObject_CallFunction(py_method.
get(),
"s#", containing_type.c_str(),
161 containing_type.size()));
162 if (py_list ==
NULL) {
166 Py_ssize_t
size = PyList_Size(py_list.
get());
168 for (Py_ssize_t
i = 0 ;
i <
size; ++
i) {
170 item_value = PyLong_AsLong(
item.get());
171 if (item_value < 0) {
173 <<
"FindAllExtensionNumbers method did not return "
174 <<
"valid extension numbers.";
178 output->push_back(item_value);