[pypy-commit] pypy ffistruct: fully migrate the whole W__StructInstance.getfield to use GetFieldConverter
antocuni
noreply at buildbot.pypy.org
Thu Jan 12 14:28:32 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r51274:5cd049bf9f55
Date: 2012-01-12 12:34 +0100
http://bitbucket.org/pypy/pypy/changeset/5cd049bf9f55/
Log: fully migrate the whole W__StructInstance.getfield to use
GetFieldConverter
diff --git a/pypy/module/_ffi/interp_struct.py b/pypy/module/_ffi/interp_struct.py
--- a/pypy/module/_ffi/interp_struct.py
+++ b/pypy/module/_ffi/interp_struct.py
@@ -136,25 +136,7 @@
def getfield(self, space, name):
w_ffitype, offset = self.structdescr.get_type_and_offset_for_field(name)
converter = GetFieldConverter(space, self.rawmem, offset)
- if w_ffitype.is_longlong():
- return converter.do_and_wrap(w_ffitype)
- #
- if w_ffitype.is_signed() or w_ffitype.is_unsigned() or w_ffitype.is_pointer():
- return converter.do_and_wrap(w_ffitype)
- #
- if w_ffitype.is_char():
- return converter.do_and_wrap(w_ffitype)
- #
- if w_ffitype.is_unichar():
- return converter.do_and_wrap(w_ffitype)
- #
- if w_ffitype.is_double():
- return converter.do_and_wrap(w_ffitype)
- #
- if w_ffitype.is_singlefloat():
- return converter.do_and_wrap(w_ffitype)
- #
- raise operationerrfmt(space.w_TypeError, 'Unknown type: %s', w_ffitype.name)
+ return converter.do_and_wrap(w_ffitype)
@unwrap_spec(name=str)
def setfield(self, space, name, w_value):
diff --git a/pypy/module/_ffi/type_converter.py b/pypy/module/_ffi/type_converter.py
--- a/pypy/module/_ffi/type_converter.py
+++ b/pypy/module/_ffi/type_converter.py
@@ -232,7 +232,7 @@
assert voidval is None
return space.w_None
else:
- assert False, "Return value shape '%s' not supported" % w_ffitype
+ self.error(w_ffitype)
def _longlong(self, w_ffitype):
# a separate function, which can be seen by the jit or not,
More information about the pypy-commit
mailing list