[pypy-svn] r36003 - in pypy/dist/pypy/rlib/rctypes: . test

arigo at codespeak.net arigo at codespeak.net
Wed Dec 27 19:44:33 CET 2006


Author: arigo
Date: Wed Dec 27 19:44:30 2006
New Revision: 36003

Modified:
   pypy/dist/pypy/rlib/rctypes/rpointer.py
   pypy/dist/pypy/rlib/rctypes/test/test_rprimitive.py
Log:
Assignment to pointer[0].


Modified: pypy/dist/pypy/rlib/rctypes/rpointer.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/rpointer.py	(original)
+++ pypy/dist/pypy/rlib/rctypes/rpointer.py	Wed Dec 27 19:44:30 2006
@@ -30,6 +30,13 @@
         return self.contentscontroller.return_value(contentsobj)
     getitem._annspecialcase_ = 'specialize:arg(0)'
 
+    def setitem(self, obj, index, value):
+        if index != 0:
+            raise ValueError("assignment to pointer[x] with x != 0")
+            # not supported by ctypes either
+        contentsobj = obj.get_contents()
+        self.contentscontroller.set_value(contentsobj, value)
+
 PointerCTypeController.register_for_metatype(PointerType)
 
 register_function_impl(pointer, rctypesobject.pointer,

Modified: pypy/dist/pypy/rlib/rctypes/test/test_rprimitive.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/test/test_rprimitive.py	(original)
+++ pypy/dist/pypy/rlib/rctypes/test/test_rprimitive.py	Wed Dec 27 19:44:30 2006
@@ -202,7 +202,6 @@
             t.view()
             
     def test_annotate_set_primitive_ptritem(self):
-        py.test.skip("in-progress")
         def func(x):
             cs = pointer(c_short())
             cs[0] = x



More information about the Pypy-commit mailing list