[pypy-svn] r61031 - pypy/branch/oo-jit/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Fri Jan 16 11:59:52 CET 2009


Author: fijal
Date: Fri Jan 16 11:59:49 2009
New Revision: 61031

Modified:
   pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
A temporary hack for inability to properly compare lltype.FuncType without
going into recursive hash (wrongly)


Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py	Fri Jan 16 11:59:49 2009
@@ -480,8 +480,14 @@
             return new_opaque_object(llobj)
         container = llobj._obj
         if isinstance(T.TO, lltype.FuncType):
-            if llobj._obj in _all_callbacks:
-                return _all_callbacks[llobj._obj]
+            # XXX a temporary workaround for comparison of lltype.FuncType
+            key = llobj._obj.__dict__.copy()
+            key['_TYPE'] = repr(key['_TYPE'])
+            items = key.items()
+            items.sort()
+            key = tuple(items)
+            if key in _all_callbacks:
+                return _all_callbacks[key]
             v1voidlist = [(i, getattr(container, '_void' + str(i), None))
                              for i in range(len(T.TO.ARGS))
                                  if T.TO.ARGS[i] is lltype.Void]
@@ -534,7 +540,7 @@
                 ctypes_func_type = get_ctypes_type(T)
                 res = ctypes_func_type(callback)
             _callback2obj[ctypes.cast(res, ctypes.c_void_p).value] = container
-            _all_callbacks[llobj._obj] = res
+            _all_callbacks[key] = res
             return res
 
         if container._storage is None:



More information about the Pypy-commit mailing list