[pypy-svn] pypy jitypes2: (antocuni, david)

antocuni commits-noreply at bitbucket.org
Thu Jan 20 19:52:16 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r41084:304991c1ae47
Date: 2011-01-20 18:45 +0100
http://bitbucket.org/pypy/pypy/changeset/304991c1ae47/

Log:	(antocuni, david) add a jit-friendly version of _convert_args

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
@@ -533,6 +533,7 @@
         _num_args = 1
 
         def _are_assumptions_met(self, args):
+            assert len(self._argtypes_) == self._num_args
             return (len(args) == self._num_args and
                     self.callable is None and
                     not self._com_index and
@@ -559,4 +560,17 @@
             assert self._errcheck_ is None
             return result
 
+    def _convert_args(self, argtypes, args):
+        """
+        jit-friendly version assuming that len(argtypes) == len(args)
+        """
+        assert self._paramflags is None
+        try:
+            wrapped_args = [self._conv_param(argtypes[0], args[0], 0)]
+        except (UnicodeError, TypeError, ValueError), e:
+            raise ArgumentError(str(e))
+        assert len(wrapped_args) == len(args)
+        return wrapped_args
+
+
     return CFuncPtr_1


More information about the Pypy-commit mailing list