[pypy-commit] cffi wchar_t: verifier support for wchar_t.
arigo
noreply at buildbot.pypy.org
Mon Jul 9 17:13:27 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: wchar_t
Changeset: r611:81b70da2aaed
Date: 2012-07-09 17:13 +0200
http://bitbucket.org/cffi/cffi/changeset/81b70da2aaed/
Log: verifier support for wchar_t.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3930,6 +3930,12 @@
return PyString_FromStringAndSize(&x, 1);
}
+#ifdef HAVE_WCHAR_H
+static PyObject *_cffi_from_c_wchar_t(wchar_t x) {
+ return _my_PyUnicode_FromWideChar(&x, 1);
+}
+#endif
+
static void *cffi_exports[] = {
_cffi_to_c_char_p,
_cffi_to_c_signed_char,
@@ -3955,6 +3961,13 @@
convert_to_object,
convert_from_object,
convert_struct_to_owning_object,
+#ifdef HAVE_WCHAR_H
+ _convert_to_wchar_t,
+ _cffi_from_c_wchar_t,
+#else
+ 0,
+ 0,
+#endif
};
/************************************************************/
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -619,7 +619,11 @@
((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
#define _cffi_from_c_struct \
((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
-#define _CFFI_NUM_EXPORTS 19
+#define _cffi_to_c_wchar_t \
+ ((wchar_t(*)(PyObject *))_cffi_exports[19])
+#define _cffi_from_c_wchar_t \
+ ((PyObject *(*)(wchar_t))_cffi_exports[20])
+#define _CFFI_NUM_EXPORTS 21
#if SIZEOF_LONG < SIZEOF_LONG_LONG
# define _cffi_to_c_long_long PyLong_AsLongLong
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -115,7 +115,7 @@
#
ffi.cdef("wchar_t foo(wchar_t);")
lib = ffi.verify("wchar_t foo(wchar_t x) { return x+1; }")
- assert lib.foo(ffi.new("wchar_t[]", uniexample1)) == uniexample2
+ assert lib.foo(uniexample1) == uniexample2
def test_no_argument():
ffi = FFI()
More information about the pypy-commit
mailing list