[pypy-commit] pypy ffistruct: migrate more cases to the GetFieldConverter

antocuni noreply at buildbot.pypy.org
Thu Jan 12 14:28:28 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r51270:7a8280eed4bb
Date: 2012-01-12 12:22 +0100
http://bitbucket.org/pypy/pypy/changeset/7a8280eed4bb/

Log:	migrate more cases to the 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
@@ -140,10 +140,7 @@
             return converter.do_and_wrap(w_ffitype)
         #
         if w_ffitype.is_signed() or w_ffitype.is_unsigned() or w_ffitype.is_pointer():
-            value = libffi.struct_getfield_int(w_ffitype.ffitype, self.rawmem, offset)
-            if w_ffitype.is_signed():
-                return space.wrap(value)
-            return space.wrap(r_uint(value))
+            return converter.do_and_wrap(w_ffitype)
         #
         if w_ffitype.is_char():
             value = libffi.struct_getfield_int(w_ffitype.ffitype, self.rawmem, offset)
@@ -215,6 +212,36 @@
         return r_ulonglong(longlongval)
 
 
+    def get_signed(self, w_ffitype):
+        return libffi.struct_getfield_int(w_ffitype.ffitype, self.rawmem, self.offset)
+
+    def get_unsigned(self, w_ffitype):
+        value = libffi.struct_getfield_int(w_ffitype.ffitype, self.rawmem, self.offset)
+        return r_uint(value)
+
+    get_unsigned_which_fits_into_a_signed = get_signed
+    get_pointer = get_unsigned
+
+    ## def get_char(self, w_ffitype):
+    ##     ...
+
+    ## def get_unichar(self, w_ffitype):
+    ##     ...
+
+    ## def get_float(self, w_ffitype):
+    ##     ...
+
+    ## def get_singlefloat(self, w_ffitype):
+    ##     ...
+
+    ## def get_struct(self, w_datashape):
+    ##     ...
+
+    ## def get_void(self, w_ffitype):
+    ##     ...
+
+
+
 
 W__StructInstance.typedef = TypeDef(
     '_StructInstance',


More information about the pypy-commit mailing list