コード例 #1
0
ファイル: module.cpp プロジェクト: 398907877/thrift
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);
}
コード例 #2
0
ファイル: module.cpp プロジェクト: 917386389/thrift
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);
}