forked from GitHub/gf-core
Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic
This commit is contained in:
@@ -20,8 +20,9 @@
|
|||||||
#define PyStringObject PyUnicodeObject
|
#define PyStringObject PyUnicodeObject
|
||||||
#define PyString_Check PyUnicode_Check
|
#define PyString_Check PyUnicode_Check
|
||||||
#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
|
#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
|
||||||
// #define PyString_FromFormat PyUnicode_FromFormat
|
#define PyString_FromFormat PyUnicode_FromFormat
|
||||||
// #define PyString_Concat(ps,s) {PyObject* tmp = *(ps); *(ps) = PyUnicode_Concat(tmp,s); Py_DECREF(tmp);}
|
// #define PyString_Concat(ps,s) {PyObject* tmp = *(ps); *(ps) = PyUnicode_Concat(tmp,s); Py_DECREF(tmp);}
|
||||||
|
#define PyString_Concat PyUnicode_Concat
|
||||||
#define PyString_Compare PyUnicode_Compare
|
#define PyString_Compare PyUnicode_Compare
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ ExprLit_richcompare(ExprLitObject *t1, ExprLitObject *t2, int op)
|
|||||||
if (t1->type != t2->type) goto done;
|
if (t1->type != t2->type) goto done;
|
||||||
|
|
||||||
if (t1->type == 0) {
|
if (t1->type == 0) {
|
||||||
if (PyLong_AsLong(t1->value) != PyLong_AsLong(t2->value)) goto done;
|
int o1, o2;
|
||||||
|
int l1 = PyLong_AsLongAndOverflow(t1->value, &o1);
|
||||||
|
int l2 = PyLong_AsLongAndOverflow(t2->value, &o2);
|
||||||
|
if (!(l1 == l2 && o1 == o2)) goto done;
|
||||||
} else if (t1->type == 1) {
|
} else if (t1->type == 1) {
|
||||||
if (PyFloat_AsDouble(t1->value) != PyFloat_AsDouble(t2->value)) goto done;
|
if (PyFloat_AsDouble(t1->value) != PyFloat_AsDouble(t2->value)) goto done;
|
||||||
} else if (t1->type == 2) {
|
} else if (t1->type == 2) {
|
||||||
|
|||||||
@@ -80,12 +80,22 @@ PgfExpr eimplarg(PgfUnmarshaller *this, PgfExpr expr)
|
|||||||
PgfLiteral lint(PgfUnmarshaller *this, size_t size, uintmax_t *v)
|
PgfLiteral lint(PgfUnmarshaller *this, size_t size, uintmax_t *v)
|
||||||
{
|
{
|
||||||
intmax_t *v0 = (intmax_t *)v;
|
intmax_t *v0 = (intmax_t *)v;
|
||||||
if (size > 1) {
|
if (size == 0) {
|
||||||
PyErr_SetString(PyExc_NotImplementedError, "multi-part integers not implemented"); // TODO
|
return (PgfLiteral) 0;
|
||||||
Py_RETURN_NOTIMPLEMENTED;
|
} else if (size > 1) {
|
||||||
|
// TODO: string concatenation works but probably not optimal
|
||||||
|
PyObject *sb = PyString_FromFormat("%ld", *v0);
|
||||||
|
for (size_t n = 1; n < size; n++) {
|
||||||
|
uintmax_t *vn = v + n;
|
||||||
|
PyObject *t = PyString_FromFormat("%lu", *vn);
|
||||||
|
sb = PyString_Concat(sb, t);
|
||||||
|
}
|
||||||
|
PyObject *i = PyLong_FromUnicodeObject(sb, 10);
|
||||||
|
return (PgfLiteral) i;
|
||||||
|
} else {
|
||||||
|
PyObject *i = PyLong_FromLong(*v0);
|
||||||
|
return (PgfLiteral) i;
|
||||||
}
|
}
|
||||||
PyObject *i = PyLong_FromLong(*v0);
|
|
||||||
return (PgfLiteral) i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PgfLiteral lflt(PgfUnmarshaller *this, double v)
|
PgfLiteral lflt(PgfUnmarshaller *this, double v)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ if libraries==['']:
|
|||||||
|
|
||||||
pgf_module = Extension('pgf',
|
pgf_module = Extension('pgf',
|
||||||
sources = ['pypgf.c', 'marshaller.c', 'expr.c'],
|
sources = ['pypgf.c', 'marshaller.c', 'expr.c'],
|
||||||
extra_compile_args = ['-std=c99', '-Werror', '-Wno-error=int-conversion', '-Wno-comment'],
|
extra_compile_args = ['-std=c99', '-Werror', '-Wno-error=int-conversion', '-Wno-error=unused-variable', '-Wno-comment'],
|
||||||
include_dirs = includes,
|
include_dirs = includes,
|
||||||
library_dirs = libraries,
|
library_dirs = libraries,
|
||||||
libraries = ['pgf'])
|
libraries = ['pgf'])
|
||||||
|
|||||||
@@ -139,11 +139,11 @@ def test_readExpr_equality_int():
|
|||||||
def test_readExpr_equality_int_neg():
|
def test_readExpr_equality_int_neg():
|
||||||
assert pgf.readExpr("-123") == pgf.readExpr("-123")
|
assert pgf.readExpr("-123") == pgf.readExpr("-123")
|
||||||
|
|
||||||
# def test_readExpr_equality_int_big():
|
def test_readExpr_equality_int_big():
|
||||||
# assert pgf.readExpr("774763251095801167872") == pgf.readExpr("774763251095801167872")
|
assert pgf.readExpr("774763251095801167872") == pgf.readExpr("774763251095801167872")
|
||||||
|
|
||||||
# def test_readExpr_equality_int_big_neg():
|
def test_readExpr_equality_int_big_neg():
|
||||||
# assert pgf.readExpr("-774763251095801167872") == pgf.readExpr("-774763251095801167872")
|
assert pgf.readExpr("-774763251095801167872") == pgf.readExpr("-774763251095801167872")
|
||||||
|
|
||||||
def test_readExpr_inequality_int():
|
def test_readExpr_inequality_int():
|
||||||
assert pgf.readExpr("123") != pgf.readExpr("456")
|
assert pgf.readExpr("123") != pgf.readExpr("456")
|
||||||
|
|||||||
Reference in New Issue
Block a user