[pypy-commit] pypy ffistruct: rename dispatchers into the more descriptive {FromAppLevel, ToAppLevel}Converter, and add docstrings
antocuni
noreply at buildbot.pypy.org
Fri Nov 11 16:32:40 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r49317:4c293ed22500
Date: 2011-11-10 22:14 +0100
http://bitbucket.org/pypy/pypy/changeset/4c293ed22500/
Log: rename dispatchers into the more descriptive
{FromAppLevel,ToAppLevel}Converter, and add docstrings
diff --git a/pypy/module/_ffi/interp_funcptr.py b/pypy/module/_ffi/interp_funcptr.py
--- a/pypy/module/_ffi/interp_funcptr.py
+++ b/pypy/module/_ffi/interp_funcptr.py
@@ -12,7 +12,7 @@
from pypy.rlib.rdynload import DLOpenError
from pypy.rlib.rarithmetic import intmask, r_uint
from pypy.rlib.objectmodel import we_are_translated
-from pypy.module._ffi.dispatcher import UnwrapDispatcher, WrapDispatcher
+from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
def unwrap_ffitype(space, w_argtype, allow_void=False):
@@ -48,7 +48,7 @@
self.func.name, expected, arg, given)
#
argchain = libffi.ArgChain()
- argpusher = PushArgumentDispatcher(space, argchain, self.to_free)
+ argpusher = PushArgumentConverter(space, argchain, self.to_free)
for i in range(expected):
w_argtype = self.argtypes_w[i]
w_arg = args_w[i]
@@ -58,7 +58,7 @@
def call(self, space, args_w):
self = jit.promote(self)
argchain = self.build_argchain(space, args_w)
- func_caller = CallFunctionDispatcher(space, self.func, argchain)
+ func_caller = CallFunctionConverter(space, self.func, argchain)
return func_caller.do_and_wrap(self.w_restype)
#return self._do_call(space, argchain)
@@ -77,14 +77,14 @@
return space.wrap(rffi.cast(rffi.LONG, self.func.funcsym))
-class PushArgumentDispatcher(UnwrapDispatcher):
+class PushArgumentConverter(FromAppLevelConverter):
"""
- A dispatcher used by W_FuncPtr to unwrap the app-level objects into
+ A converter used by W_FuncPtr to unwrap the app-level objects into
low-level types and push them to the argchain.
"""
def __init__(self, space, argchain, to_free):
- UnwrapDispatcher.__init__(self, space)
+ FromAppLevelConverter.__init__(self, space)
self.argchain = argchain
self.to_free = to_free
@@ -129,14 +129,14 @@
self.argchain.arg_raw(ptrval)
-class CallFunctionDispatcher(WrapDispatcher):
+class CallFunctionConverter(ToAppLevelConverter):
"""
- A dispatcher used by W_FuncPtr to call the function, expect the result of
+ A converter used by W_FuncPtr to call the function, expect the result of
a correct low-level type and wrap it to the corresponding app-level type
"""
def __init__(self, space, func, argchain):
- WrapDispatcher.__init__(self, space)
+ ToAppLevelConverter.__init__(self, space)
self.func = func
self.argchain = argchain
diff --git a/pypy/module/_ffi/dispatcher.py b/pypy/module/_ffi/type_converter.py
rename from pypy/module/_ffi/dispatcher.py
rename to pypy/module/_ffi/type_converter.py
--- a/pypy/module/_ffi/dispatcher.py
+++ b/pypy/module/_ffi/type_converter.py
@@ -5,7 +5,13 @@
from pypy.module._rawffi.structure import W_StructureInstance, W_Structure
from pypy.module._ffi.interp_ffitype import app_types
-class UnwrapDispatcher(object):
+class FromAppLevelConverter(object):
+ """
+ Unwrap an app-level object to the corresponding low-level type, following
+ the conversion rules which apply to the specified w_ffitype. Once
+ unwrapped, the value is passed to the corresponding handle_* method.
+ Subclasses should override the desired ones.
+ """
def __init__(self, space):
self.space = space
@@ -166,7 +172,13 @@
-class WrapDispatcher(object):
+class ToAppLevelConverter(object):
+ """
+ Wrap a low-level value to an app-level object, following the conversion
+ rules which apply to the specified w_ffitype. The value is got by calling
+ the get_* method corresponding to the w_ffitype. Subclasses should
+ override the desired ones.
+ """
def __init__(self, space):
self.space = space
More information about the pypy-commit
mailing list