[pypy-commit] pypy default: Replace annenforce args with signature() in rsandbox

alex_gaynor noreply at buildbot.pypy.org
Fri Mar 22 05:40:58 CET 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r62635:0b27e32c2000
Date: 2013-03-21 21:40 -0700
http://bitbucket.org/pypy/pypy/changeset/0b27e32c2000/

Log:	Replace annenforce args with signature() in rsandbox

diff --git a/rpython/translator/sandbox/rsandbox.py b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -3,7 +3,10 @@
 trampolines that marshal their input arguments, dump them to STDOUT,
 and wait for an answer on STDIN.  Enable with 'translate.py --sandbox'.
 """
-from rpython.rlib import rmarshal
+import py
+
+from rpython.rlib import rmarshal, types
+from rpython.rlib.signature import signature
 
 # ____________________________________________________________
 #
@@ -12,12 +15,10 @@
 
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.annotator import model as annmodel
-from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.objectmodel import CDefinedIntSymbolic
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator
 from rpython.tool.ansi_print import ansi_log
-import py
+
 log = py.log.Producer("sandbox")
 py.log.setconsumer("sandbox", ansi_log)
 
@@ -27,13 +28,15 @@
 ll_read_not_sandboxed = rffi.llexternal('read',
                                         [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
                                         rffi.SIZE_T,
-                                        sandboxsafe = True)
+                                        sandboxsafe=True)
 
 ll_write_not_sandboxed = rffi.llexternal('write',
                                          [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
                                          rffi.SIZE_T,
-                                         sandboxsafe = True)
+                                         sandboxsafe=True)
 
+
+ at signature(types.int(), types.ptr(rffi.CCHARP.TO), types.int(), returns=types.none())
 def writeall_not_sandboxed(fd, buf, length):
     while length > 0:
         size = rffi.cast(rffi.SIZE_T, length)
@@ -43,22 +46,6 @@
         length -= count
         buf = lltype.direct_ptradd(lltype.direct_arrayitems(buf), count)
         buf = rffi.cast(rffi.CCHARP, buf)
-writeall_not_sandboxed._annenforceargs_ = [int, rffi.CCHARP, int]
-
-##def readall_not_sandboxed(fd, length):
-##    buf = lltype.malloc(rffi.CCHARP.TO, length, flavor='raw')
-##    p = buf
-##    got = 0
-##    while got < length:
-##        size1 = rffi.cast(rffi.SIZE_T, length - got)
-##        count = rffi.cast(lltype.Signed, ll_read_not_sandboxed(fd, p, size1))
-##        if count <= 0:
-##            raise IOError
-##        got += count
-##        p = lltype.direct_ptradd(lltype.direct_arrayitems(p), count)
-##        p = rffi.cast(rffi.CCHARP, p)
-##    return buf
-##readall_not_sandboxed._annenforceargs_ = [int, int]
 
 
 class FdLoader(rmarshal.Loader):
@@ -112,13 +99,14 @@
     elif error == 8: raise IndexError
     else:            raise RuntimeError
 
+
+ at signature(types.str(), returns=types.none())
 def not_implemented_stub(msg):
     STDERR = 2
     buf = rffi.str2charp(msg + '\n')
     writeall_not_sandboxed(STDERR, buf, len(msg) + 1)
     rffi.free_charp(buf)
     raise RuntimeError(msg)  # XXX in RPython, the msg is ignored at the moment
-not_implemented_stub._annenforceargs_ = [str]
 
 dump_string = rmarshal.get_marshaller(str)
 load_int    = rmarshal.get_loader(int)


More information about the pypy-commit mailing list