gorealis v2 refactor (#5)

* Changing default timeout for start maintenance.

* Upgrading dependencies to gorealis v2 and thrift  0.12.0

* Refactored to update to gorealis v2.
This commit is contained in:
Renan DelValle 2018-12-27 11:31:51 -08:00 committed by GitHub
parent ad4dd9606e
commit 6ab5c9334d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1335 changed files with 137431 additions and 61530 deletions

View file

@ -113,7 +113,8 @@ public:
if (!readBytes(&buf, sizeof(int16_t))) {
return false;
}
val = static_cast<int16_t>(ntohs(*reinterpret_cast<int16_t*>(buf)));
memcpy(&val, buf, sizeof(int16_t));
val = ntohs(val);
return true;
}
@ -122,7 +123,8 @@ public:
if (!readBytes(&buf, sizeof(int32_t))) {
return false;
}
val = static_cast<int32_t>(ntohl(*reinterpret_cast<int32_t*>(buf)));
memcpy(&val, buf, sizeof(int32_t));
val = ntohl(val);
return true;
}
@ -131,7 +133,8 @@ public:
if (!readBytes(&buf, sizeof(int64_t))) {
return false;
}
val = static_cast<int64_t>(ntohll(*reinterpret_cast<int64_t*>(buf)));
memcpy(&val, buf, sizeof(int64_t));
val = ntohll(val);
return true;
}

View file

@ -162,7 +162,8 @@ public:
if (!readBytes(&buf, 8)) {
return false;
}
transfer.f = letohll(*reinterpret_cast<int64_t*>(buf));
memcpy(&transfer.f, buf, sizeof(int64_t));
transfer.f = letohll(transfer.f);
val = transfer.t;
return true;
}

View file

@ -87,12 +87,7 @@ static PyObject* decode_impl(PyObject* args) {
}
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
int32_t default_limit = (std::numeric_limits<int32_t>::max)();
protocol.setStringLengthLimit(
as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(string_length_limit)),
default_limit));

View file

@ -33,8 +33,8 @@ class ProtocolBase {
public:
ProtocolBase()
: stringLimit_(std::numeric_limits<int32_t>::max()),
containerLimit_(std::numeric_limits<int32_t>::max()),
: stringLimit_((std::numeric_limits<int32_t>::max)()),
containerLimit_((std::numeric_limits<int32_t>::max)()),
output_(NULL) {}
inline virtual ~ProtocolBase();

View file

@ -102,7 +102,7 @@ inline bool ProtocolBase<Impl>::writeBuffer(char* data, size_t size) {
PyErr_SetString(PyExc_IOError, "failed to write to cStringIO object");
return false;
}
if (len != size) {
if (static_cast<size_t>(len) != size) {
PyErr_Format(PyExc_EOFError, "write length mismatch: expected %lu got %d", size, len);
return false;
}
@ -144,7 +144,7 @@ inline int read_buffer(PyObject* buf, char** output, int len) {
*output = PyBytes_AS_STRING(buf2->buf) + buf2->pos;
#endif
Py_ssize_t pos0 = buf2->pos;
buf2->pos = std::min(buf2->pos + static_cast<Py_ssize_t>(len), buf2->string_size);
buf2->pos = (std::min)(buf2->pos + static_cast<Py_ssize_t>(len), buf2->string_size);
return static_cast<int>(buf2->pos - pos0);
}
}
@ -212,7 +212,7 @@ inline bool check_ssize_t_32(Py_ssize_t len) {
if (INT_CONV_ERROR_OCCURRED(len)) {
return false;
}
if (!CHECK_RANGE(len, 0, std::numeric_limits<int32_t>::max())) {
if (!CHECK_RANGE(len, 0, (std::numeric_limits<int32_t>::max)())) {
PyErr_SetString(PyExc_OverflowError, "size out of range: exceeded INT32_MAX");
return false;
}
@ -360,8 +360,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
case T_I08: {
int8_t val;
if (!parse_pyint(value, &val, std::numeric_limits<int8_t>::min(),
std::numeric_limits<int8_t>::max())) {
if (!parse_pyint(value, &val, (std::numeric_limits<int8_t>::min)(),
(std::numeric_limits<int8_t>::max)())) {
return false;
}
@ -371,8 +371,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
case T_I16: {
int16_t val;
if (!parse_pyint(value, &val, std::numeric_limits<int16_t>::min(),
std::numeric_limits<int16_t>::max())) {
if (!parse_pyint(value, &val, (std::numeric_limits<int16_t>::min)(),
(std::numeric_limits<int16_t>::max)())) {
return false;
}
@ -382,8 +382,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
case T_I32: {
int32_t val;
if (!parse_pyint(value, &val, std::numeric_limits<int32_t>::min(),
std::numeric_limits<int32_t>::max())) {
if (!parse_pyint(value, &val, (std::numeric_limits<int32_t>::min)(),
(std::numeric_limits<int32_t>::max)())) {
return false;
}
@ -397,8 +397,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
return false;
}
if (!CHECK_RANGE(nval, std::numeric_limits<int64_t>::min(),
std::numeric_limits<int64_t>::max())) {
if (!CHECK_RANGE(nval, (std::numeric_limits<int64_t>::min)(),
(std::numeric_limits<int64_t>::max)())) {
PyErr_SetString(PyExc_OverflowError, "int out of range");
return false;
}

View file

@ -98,13 +98,13 @@ bool parse_map_args(MapTypeArgs* dest, PyObject* typeargs) {
}
bool parse_struct_args(StructTypeArgs* dest, PyObject* typeargs) {
if (PyTuple_Size(typeargs) != 2) {
PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for struct args");
if (PyList_Size(typeargs) != 2) {
PyErr_SetString(PyExc_TypeError, "expecting list of size 2 for struct args");
return false;
}
dest->klass = PyTuple_GET_ITEM(typeargs, 0);
dest->spec = PyTuple_GET_ITEM(typeargs, 1);
dest->klass = PyList_GET_ITEM(typeargs, 0);
dest->spec = PyList_GET_ITEM(typeargs, 1);
return true;
}

View file

@ -23,6 +23,7 @@
#include <Python.h>
#ifdef _MSC_VER
#define __STDC_FORMAT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <stdint.h>