Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r46246:263ef79f483f Date: 2011-08-03 15:30 +0200 http://bitbucket.org/pypy/pypy/changeset/263ef79f483f/
Log: merge heads diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py --- a/lib_pypy/_ctypes/function.py +++ b/lib_pypy/_ctypes/function.py @@ -91,13 +91,15 @@ raise TypeError( "item %d in _argtypes_ has no from_param method" % ( i + 1,)) - # - if all([hasattr(argtype, '_ffiargshape') for argtype in argtypes]): - fastpath_cls = make_fastpath_subclass(self.__class__) - fastpath_cls.enable_fastpath_maybe(self) self._argtypes_ = list(argtypes) + self._check_argtypes_for_fastpath() argtypes = property(_getargtypes, _setargtypes) + def _check_argtypes_for_fastpath(self): + if all([hasattr(argtype, '_ffiargshape') for argtype in self._argtypes_]): + fastpath_cls = make_fastpath_subclass(self.__class__) + fastpath_cls.enable_fastpath_maybe(self) + def _getparamflags(self): return self._paramflags @@ -216,6 +218,7 @@ import ctypes restype = ctypes.c_int self._ptr = self._getfuncptr_fromaddress(self._argtypes_, restype) + self._check_argtypes_for_fastpath() return diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py b/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py @@ -1,4 +1,4 @@ -from ctypes import CDLL, POINTER, pointer, c_byte, c_int, c_char_p +from ctypes import CDLL, POINTER, pointer, c_byte, c_int, c_char_p, CFUNCTYPE, c_void_p, c_size_t import sys import py from support import BaseCTypesTestChecker @@ -46,6 +46,12 @@ tf_b.argtypes = (c_byte,) assert tf_b(-126) == -42 + def test_from_cfunctype(self): + from _ctypes import _memmove_addr + functype = CFUNCTYPE(c_void_p, c_void_p, c_void_p, c_size_t) + my_memmove = functype(_memmove_addr) + assert my_memmove._is_fastpath + def test_undeclared_restype(self): # make sure we get a fresh function try: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit