Example #1
0
static PyObject*
decode_binary(PyObject *self, PyObject *args) {
    PyObject* output_obj = NULL;
    PyObject* transport = NULL;
    PyObject* typeargs = NULL;
    StructTypeArgs parsedargs;
    PyObject* string_limit_obj = NULL;
    PyObject* container_limit_obj = NULL;
    long string_limit = 0;
    long container_limit = 0;
    DecodeBuffer input = {0, 0};
    PyObject* ret = NULL;

    if (!PyArg_ParseTuple(args, "OOOOO", &output_obj, &transport, &typeargs, &string_limit_obj, &container_limit_obj)) {
        return NULL;
    }
    string_limit = as_long_or(string_limit_obj, INT32_MAX);
    container_limit = as_long_or(container_limit_obj, INT32_MAX);

    if (!parse_struct_args(&parsedargs, typeargs)) {
        return NULL;
    }

    if (!decode_buffer_from_obj(&input, transport)) {
        return NULL;
    }

    ret = decode_struct(&input, output_obj, parsedargs.klass, parsedargs.spec, string_limit, container_limit);
    free_decodebuf(&input);
    return  ret;
}
static PyObject*
decode_binary(PyObject *self, PyObject *args) {
  PyObject* output_obj = NULL;
  PyObject* transport = NULL;
  PyObject* typeargs = NULL;
  StructTypeArgs parsedargs;
  DecodeBuffer input = {};

  if (!PyArg_ParseTuple(args, "OOO", &output_obj, &transport, &typeargs)) {
    return NULL;
  }

  if (!parse_struct_args(&parsedargs, typeargs)) {
    return NULL;
  }

  if (!decode_buffer_from_obj(&input, transport)) {
    return NULL;
  }

  if (!decode_struct(&input, output_obj, parsedargs.spec)) {
    free_decodebuf(&input);
    return NULL;
  }

  free_decodebuf(&input);

  Py_RETURN_NONE;
}