[pypy-svn] r52534 - in pypy/dist/pypy/lib: _ctypes app_test/ctypes

pedronis at codespeak.net pedronis at codespeak.net
Fri Mar 14 19:59:46 CET 2008


Author: pedronis
Date: Fri Mar 14 19:59:44 2008
New Revision: 52534

Modified:
   pypy/dist/pypy/lib/_ctypes/union.py
   pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py
Log:
make this keepalive union manipulationt test pass too



Modified: pypy/dist/pypy/lib/_ctypes/union.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/union.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/union.py	Fri Mar 14 19:59:44 2008
@@ -101,6 +101,15 @@
             raise AttributeError(name)
         if getattr(value, '_objects', None) is not None:
             key = keepalive_key(getattr(self.__class__, name).num)
-            store_reference(self, key, value._objects)        
-        buf = self._ffiarrays[name].fromaddress(self._buffer.buffer, 1)
-        buf[0] = fieldtype._CData_value(value)
+            store_reference(self, key, value._objects)
+        arg = fieldtype._CData_value(value)
+        if fieldtype._fficompositesize is not None:
+            from ctypes import memmove
+            dest = self._buffer.buffer
+            memmove(dest, arg, fieldtype._fficompositesize)
+        else:
+            buf = self._ffiarrays[name].fromaddress(self._buffer.buffer, 1)
+            buf[0] = arg
+
+    def _get_buffer_value(self):
+        return self._buffer.buffer

Modified: pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py	(original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py	Fri Mar 14 19:59:44 2008
@@ -176,7 +176,6 @@
         assert s._objects == {'1': {}, '0:1': {'1': stuff}}
 
     def test_union_within_union(self):
-        py.test.skip("WIP")        
         class R(Union):
             _fields_ = [('p', POINTER(c_int))]
         



More information about the Pypy-commit mailing list