[pypy-svn] r51691 - pypy/dist/pypy/module/_rawffi

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Feb 20 16:02:09 CET 2008


Author: cfbolz
Date: Wed Feb 20 16:02:09 2008
New Revision: 51691

Modified:
   pypy/dist/pypy/module/_rawffi/array.py
   pypy/dist/pypy/module/_rawffi/structure.py
Log:
be less clever and hopefully fix translation


Modified: pypy/dist/pypy/module/_rawffi/array.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/array.py	(original)
+++ pypy/dist/pypy/module/_rawffi/array.py	Wed Feb 20 16:02:09 2008
@@ -37,20 +37,10 @@
             return W_ArrayInstanceAutoFree(space, self, length)
         return W_ArrayInstance(space, self, length)
 
-    def descr_call(self, space, length, __args__):
-        args_w, kwargs_w = __args__.unpack()
-        if len(args_w) > 1:
-            raise OperationError(space.w_TypeError,
-                                 space.wrap("too many arguments"))
-        autofree = False
-        if 'autofree' in kwargs_w:
-            autofree = space.is_true(kwargs_w.pop('autofree'))
-        if len(kwargs_w):
-            raise OperationError(space.w_TypeError,
-                                 space.wrap("unknown keyword argument"))
+    def descr_call(self, space, length, w_items=None, autofree=False):
         result = self.allocate(space, length, autofree)
-        if len(args_w) == 1:
-            items_w = space.unpackiterable(args_w[0])
+        if not space.is_w(w_items, space.w_None):
+            items_w = space.unpackiterable(w_items)
             iterlength = len(items_w)
             if iterlength > length:
                 raise OperationError(space.w_ValueError,
@@ -103,7 +93,7 @@
     __new__  = interp2app(descr_new_array,
                           unwrap_spec=[ObjSpace, W_Root, W_Root]),
     __call__ = interp2app(W_Array.descr_call,
-                          unwrap_spec=['self', ObjSpace, int, Arguments]),
+                          unwrap_spec=['self', ObjSpace, int, W_Root, int]),
     __repr__ = interp2app(W_Array.descr_repr),
     fromaddress = interp2app(W_Array.fromaddress),
     gettypecode = interp2app(W_Array.descr_gettypecode),

Modified: pypy/dist/pypy/module/_rawffi/structure.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/structure.py	(original)
+++ pypy/dist/pypy/module/_rawffi/structure.py	Wed Feb 20 16:02:09 2008
@@ -69,21 +69,11 @@
             raise OperationError(space.w_AttributeError, space.wrap(
                 "C Structure has no attribute %s" % attr))
 
-    def descr_call(self, space, __args__):
-        args_w, kwargs_w = __args__.unpack()
-        if args_w:
-            raise OperationError(space.w_TypeError,
-                                 space.wrap("too many arguments"))
-        autofree = False
-        if 'autofree' in kwargs_w:
-            autofree = space.is_true(kwargs_w.pop('autofree'))
-        if len(kwargs_w):
-            raise OperationError(space.w_TypeError,
-                                 space.wrap("unknown keyword argument"))
+    def descr_call(self, space, autofree=False):
         if autofree:
             return space.wrap(W_StructureInstanceAutoFree(space, self))
         return space.wrap(W_StructureInstance(space, self, 0))
-    descr_call.unwrap_spec = ['self', ObjSpace, Arguments]
+    descr_call.unwrap_spec = ['self', ObjSpace, int]
 
     def descr_repr(self, space):
         fieldnames = ' '.join(["'%s'" % name for name, _ in self.fields])



More information about the Pypy-commit mailing list