[pypy-commit] creflect default: unknown types
arigo
noreply at buildbot.pypy.org
Thu Dec 4 19:12:48 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r150:121223620cdd
Date: 2014-12-04 16:08 +0100
http://bitbucket.org/cffi/creflect/changeset/121223620cdd/
Log: unknown types
diff --git a/zeffir/ffi_obj.c b/zeffir/ffi_obj.c
--- a/zeffir/ffi_obj.c
+++ b/zeffir/ffi_obj.c
@@ -134,7 +134,7 @@
return (CTypeDescrObject *)arg;
}
else {
- PyErr_SetString(PyExc_TypeError, "expected a string or a CType object");
+ PyErr_SetString(PyExc_TypeError, "expected a string or a ctype object");
return NULL;
}
}
@@ -145,6 +145,11 @@
if (ct == NULL)
return NULL;
+ if (ct->ct_size < 0) {
+ PyErr_Format(PyExc_ValueError, "don't know the size of ctype '%s': "
+ "incomplete type", ct->ct_name);
+ return NULL;
+ }
return PyInt_FromSsize_t(ct->ct_size);
}
diff --git a/zeffir/test/ctype.crx b/zeffir/test/ctype.crx
--- a/zeffir/test/ctype.crx
+++ b/zeffir/test/ctype.crx
@@ -11,4 +11,6 @@
typedef float bar_t;
typedef long double rbar_t;
+typedef ... unknown_t;
+
// CREFLECT: end
diff --git a/zeffir/test/test_ctype.py b/zeffir/test/test_ctype.py
--- a/zeffir/test/test_ctype.py
+++ b/zeffir/test/test_ctype.py
@@ -1,3 +1,4 @@
+import py
import support
@@ -85,3 +86,8 @@
#
assert ffi.sizeof("rbar_t") == ffi.sizeof("float")
assert repr(ffi.typeof("rbar_t")) == "<ctype 'float'>"
+
+def test_unknown_type():
+ ffi, lib = support.compile_and_open('ctype')
+ assert repr(ffi.typeof("unknown_t")) == "<ctype '$unknown_t'>"
+ py.test.raises(ValueError, ffi.sizeof, "unknown_t")
More information about the pypy-commit
mailing list