Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r197:d0a4621d2df2 Date: 2014-12-11 14:15 +0000 http://bitbucket.org/cffi/creflect/changeset/d0a4621d2df2/
Log: Can't call a "..." function right now diff --git a/zeffir/builder.c b/zeffir/builder.c --- a/zeffir/builder.c +++ b/zeffir/builder.c @@ -805,6 +805,10 @@ if (PyErr_Occurred()) return; + if (type->ct_flags & CT_FUNCTION) { + type = zef_get_pointer_type(cb, type, quals); + } + PyObject *l_dict = ((zeffir_builder_t *)cb)->l_dict; PyObject *x = make_global_var(type, addr); diff --git a/zeffir/cfunc.c b/zeffir/cfunc.c --- a/zeffir/cfunc.c +++ b/zeffir/cfunc.c @@ -205,8 +205,11 @@ zfs = (ZefFuncSupportObject *)ct->ct_stuff; if (zfs->zfs_trampl == NULL) { - PyErr_SetString(ZefError, "cdata '%s' cannot be called, because no " - "wrapper was generated for functions of this type "); + const char *extra = (zfs->zfs_dotdotdot ? + " (because signature ends in '...')" : ""); + PyErr_Format(ZefError, "cdata '%s' cannot be called, because no " + "wrapper was generated for functions of this type%s", + ct->ct_name, extra); return NULL; } diff --git a/zeffir/test/function.crx b/zeffir/test/function.crx --- a/zeffir/test/function.crx +++ b/zeffir/test/function.crx @@ -18,11 +18,16 @@ *p++ = 0; } +void cant_call_dotdotdot(int x, ...) +{ +} + // CREFLECT: start int simple_function(int); int add_from_array(int array[], int count); void returning_nothing(char *); +void cant_call_dotdotdot(int x, ...); // CREFLECT: end diff --git a/zeffir/test/test_function.py b/zeffir/test/test_function.py --- a/zeffir/test/test_function.py +++ b/zeffir/test/test_function.py @@ -40,3 +40,12 @@ assert str(e.value) == ("typeof(lib.func) not supported: the " "exact type of functions is unknown (declare that " "function as a function pointer instead)") + +def test_cant_call_dotdotdot(): + ffi, lib = support.compile_and_open('function') + p = lib.cant_call_dotdotdot + assert ffi.typeof(p) == ffi.typeof("void(*)(int, ...)") + e = py.test.raises(ffi.error, p, 5) + assert str(e.value) == ("cdata 'void(int, ...)' cannot be called, because " + "no wrapper was generated for functions of this " + "type (because signature ends in '...')") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit