[pypy-svn] pypy jitypes2: (david, antocuni)
antocuni
commits-noreply at bitbucket.org
Thu Jan 20 19:52:17 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r41085:1d94a149fbbd
Date: 2011-01-20 18:55 +0100
http://bitbucket.org/pypy/pypy/changeset/1d94a149fbbd/
Log: (david, antocuni) jit-friendly version of _unwrap_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
@@ -411,15 +411,19 @@
assert len(argtypes) == len(args)
newargs = []
for argtype, arg in zip(argtypes, args):
- shape = argtype._ffiargshape
- if isinstance(shape, str) and shape in "POszZ": # pointer types
- value = arg._get_buffer_value()
- elif is_struct_shape(shape):
- value = arg._buffer
- else:
- value = arg.value
+ value = self._unwrap_single_arg(argtype, arg)
newargs.append(value)
return newargs
+
+ def _unwrap_single_arg(self, argtype, arg):
+ shape = argtype._ffiargshape
+ if isinstance(shape, str) and shape in "POszZ": # pointer types
+ value = arg._get_buffer_value()
+ elif is_struct_shape(shape):
+ value = arg._buffer
+ else:
+ value = arg.value
+ return value
def _wrap_result(self, restype, result):
"""
@@ -533,11 +537,10 @@
_num_args = 1
def _are_assumptions_met(self, args):
- assert len(self._argtypes_) == self._num_args
- return (len(args) == self._num_args and
+ return (self._argtypes_ is not None and
+ len(args) == len(self._argtypes_) == self._num_args and
self.callable is None and
not self._com_index and
- self._argtypes_ is not None and
self._errcheck_ is None)
def __call__(self, *args):
@@ -572,5 +575,7 @@
assert len(wrapped_args) == len(args)
return wrapped_args
+ def _unwrap_args(self, argtypes, args):
+ return [self._unwrap_single_arg(argtypes[0], args[0])]
return CFuncPtr_1
More information about the Pypy-commit
mailing list