static bool decode_buffer_from_obj(DecodeBuffer* dest, PyObject* obj) { dest->stringiobuf = PyObject_GetAttr(obj, INTERN_STRING(cstringio_buf)); if (!dest->stringiobuf) { return false; } if (!PycStringIO_InputCheck(dest->stringiobuf)) { free_decodebuf(dest); PyErr_SetString(PyExc_TypeError, "expecting stringio input"); return false; } dest->refill_callable = PyObject_GetAttr(obj, INTERN_STRING(cstringio_refill)); if(!dest->refill_callable) { free_decodebuf(dest); return false; } if (!PyCallable_Check(dest->refill_callable)) { free_decodebuf(dest); PyErr_SetString(PyExc_TypeError, "expecting callable"); return false; } return true; }
static PyObject* decode_impl(PyObject* args) { PyObject* output_obj = NULL; PyObject* oprot = NULL; PyObject* typeargs = NULL; if (!PyArg_ParseTuple(args, "OOO", &output_obj, &oprot, &typeargs)) { return NULL; } T protocol; protocol.setStringLengthLimit( as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(string_length_limit)), INT32_MAX)); protocol.setContainerLengthLimit( as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(container_length_limit)), INT32_MAX)); ScopedPyObject transport(PyObject_GetAttr(oprot, INTERN_STRING(trans))); if (!transport) { return NULL; } StructTypeArgs parsedargs; if (!parse_struct_args(&parsedargs, typeargs)) { return NULL; } if (!protocol.prepareDecodeBufferFromTransport(transport.get())) { return NULL; } return protocol.readStruct(output_obj, parsedargs.klass, parsedargs.spec); }
static PyObject* decode_impl(PyObject* args) { PyObject* output_obj = NULL; PyObject* oprot = NULL; PyObject* typeargs = NULL; if (!PyArg_ParseTuple(args, "OOO", &output_obj, &oprot, &typeargs)) { return NULL; } T protocol; #ifdef _MSC_VER // workaround strange VC++ 2015 bug where #else path does not compile int32_t default_limit = INT32_MAX; #else int32_t default_limit = std::numeric_limits<int32_t>::max(); #endif protocol.setStringLengthLimit( as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(string_length_limit)), default_limit)); protocol.setContainerLengthLimit( as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(container_length_limit)), default_limit)); ScopedPyObject transport(PyObject_GetAttr(oprot, INTERN_STRING(trans))); if (!transport) { return NULL; } StructTypeArgs parsedargs; if (!parse_struct_args(&parsedargs, typeargs)) { return NULL; } if (!protocol.prepareDecodeBufferFromTransport(transport.get())) { return NULL; } return protocol.readStruct(output_obj, parsedargs.klass, parsedargs.spec); }
int CTracer_intern_strings(void) { int ret = RET_ERROR; #define INTERN_STRING(v, s) \ v = MyText_InternFromString(s); \ if (v == NULL) { \ goto error; \ } INTERN_STRING(str_trace, "trace") INTERN_STRING(str_file_tracer, "file_tracer") INTERN_STRING(str__coverage_enabled, "_coverage_enabled") INTERN_STRING(str__coverage_plugin, "_coverage_plugin") INTERN_STRING(str__coverage_plugin_name, "_coverage_plugin_name") INTERN_STRING(str_dynamic_source_filename, "dynamic_source_filename") INTERN_STRING(str_line_number_range, "line_number_range") ret = RET_OK; error: return ret; }