Commits

Antonio Cuni  committed cd0a99a Draft Merge

merge heads

  • Participants
  • Parent commits 15f1a0a, a747c67
  • Branches ffistruct

Comments (0)

Files changed (4)

File pypy/jit/metainterp/optimizeopt/fficall.py

 from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rlib.objectmodel import we_are_translated
-from pypy.rlib.libffi import Func
-from pypy.rlib.debug import debug_print
-from pypy.rlib import libffi, clibffi
-from pypy.jit.codewriter.effectinfo import EffectInfo
-from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
-from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
+from pypy.rlib.rarithmetic import intmask
 
 
 class FuncInfo(object):
         else:
             assert False, "unsupported ffitype or kind"
         #
-        fieldsize = ffitype.c_size
+        fieldsize = intmask(ffitype.c_size)
         return self.optimizer.cpu.fielddescrof_dynamic(offset, fieldsize,
                                                        is_pointer, is_float, is_signed)
     

File pypy/module/_ffi/interp_struct.py

     get_pointer = get_unsigned
 
     def get_char(self, w_ffitype):
-        return libffi.struct_getfield_int(w_ffitype.get_ffitype(),
-                                          self.rawmem, self.offset)
+        intval = libffi.struct_getfield_int(w_ffitype.get_ffitype(),
+                                            self.rawmem, self.offset)
+        return rffi.cast(rffi.UCHAR, intval)
 
     def get_unichar(self, w_ffitype):
-        return libffi.struct_getfield_int(w_ffitype.get_ffitype(),
-                                          self.rawmem, self.offset)
+        intval = libffi.struct_getfield_int(w_ffitype.get_ffitype(),
+                                            self.rawmem, self.offset)
+        return rffi.cast(rffi.WCHAR_T, intval)
 
     def get_float(self, w_ffitype):
         return libffi.struct_getfield_float(w_ffitype.get_ffitype(),
 
     def get_struct(self, w_ffitype, w_structdescr):
         assert isinstance(w_structdescr, W__StructDescr)
-        innermem = rffi.ptradd(self.rawmem, self.offset)
+        rawmem = rffi.cast(rffi.CCHARP, self.rawmem)
+        innermem = rffi.cast(rffi.VOIDP, rffi.ptradd(rawmem, self.offset))
         # we return a reference to the inner struct, not a copy
         # autofree=False because it's still owned by the parent struct
         return W__StructInstance(w_structdescr, allocate=False, autofree=False,
                                            self.rawmem, self.offset, singlefloatval)
 
     def handle_struct(self, w_ffitype, w_structinstance):
-        dst = rffi.ptradd(self.rawmem, self.offset)
+        rawmem = rffi.cast(rffi.CCHARP, self.rawmem)
+        dst = rffi.cast(rffi.VOIDP, rffi.ptradd(rawmem, self.offset))
         src = w_structinstance.rawmem
         length = w_ffitype.sizeof()
         rffi.c_memcpy(dst, src, length)

File pypy/module/_ffi/type_converter.py

             unicodeval = self.space.unicode_w(w_obj)
             self.handle_unichar_p(w_ffitype, w_obj, unicodeval)
             return True
+        return False
 
     def convert_pointer_arg_maybe(self, w_arg, w_argtype):
         """

File pypy/rlib/clibffi.py

 from pypy.rlib.rdynload import dlopen, dlclose, dlsym, dlsym_byordinal
 from pypy.rlib.rdynload import DLOpenError, DLLHANDLE
 from pypy.rlib import jit
+from pypy.rlib.objectmodel import specialize
 from pypy.tool.autopath import pypydir
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.translator.platform import platform
                                         ('ffistruct', FFI_TYPE_P.TO),
                                         ('members', lltype.Array(FFI_TYPE_P))))
 
+@specialize.arg(3)
 def make_struct_ffitype_e(size, aligment, field_types, track_allocation=True):
     """Compute the type of a structure.  Returns a FFI_STRUCT_P out of
        which the 'ffistruct' member is a regular FFI_TYPE.