Example #1
0
def test_unique():
    m = NameManager()
    sn = m.seennames
    check = [
        m.uniquename('something0'),
        m.uniquename('something', with_number=True),
        m.uniquename('something', with_number=True),
        m.uniquename('something2', with_number=True),
        m.uniquename('something1'),
        m.uniquename('something1_1'),
        ]
    assert check == ['something0', 'something0_1', 'something1',
                     'something2_0', 'something1_1', 'something1_1_1']
Example #2
0
 def __init__(self, database):
     self.database = database
     self.extrafiles = []
     self.headers_to_precompile = []
     self.path = None
     self.namespace = NameManager()
Example #3
0
File: api.py Project: juokaz/pypy
#
# In contexts (2) and (3), a function declaring a PyObject argument type will
# receive a wrapped pypy object if the parameter name starts with 'w_', a
# reference (= rffi pointer) otherwise; conversion is automatic.  Context (2)
# only allows calls with a wrapped object.
#
# Functions with a PyObject return type should return a wrapped object.
#
# Functions may raise exceptions.  In context (3), the exception flows normally
# through the calling function.  In context (1) and (2), the exception is
# caught; if it is an OperationError, it is stored in the thread state; other
# exceptions generate a OperationError(w_SystemError); and the funtion returns
# the error value specifed in the API.
#

cpyext_namespace = NameManager('cpyext_')

class ApiFunction:
    def __init__(self, argtypes, restype, callable, error=_NOT_SPECIFIED,
                 c_name=None):
        self.argtypes = argtypes
        self.restype = restype
        self.functype = lltype.Ptr(lltype.FuncType(argtypes, restype))
        self.callable = callable
        if error is not _NOT_SPECIFIED:
            self.error_value = error
        self.c_name = c_name

        # extract the signature from the (CPython-level) code object
        from pypy.interpreter import pycode
        argnames, varargname, kwargname = pycode.cpython_code_signature(callable.func_code)