예제 #1
0
def init_dictobject(space):
    "Type description of PyDictObject"
    make_typedescr(space.w_dict.layout.typedef,
                   basestruct=PyDictObject.TO,
                   attach=dict_attach,
                   dealloc=dict_dealloc,
                   realize=dict_realize)
예제 #2
0
def init_bufferobject(space):
    "Type description of PyBufferObject"
    make_typedescr(space.gettypefor(Buffer).instancetypedef,
                   basestruct=PyBufferObject.TO,
                   attach=buffer_attach,
                   dealloc=buffer_dealloc,
                   realize=buffer_realize)
예제 #3
0
def init_stringobject(space):
    "Type description of PyStringObject"
    make_typedescr(space.w_str.instancetypedef,
                   basestruct=PyStringObject.TO,
                   attach=string_attach,
                   dealloc=string_dealloc,
                   realize=string_realize)
예제 #4
0
def init_bufferobject(space):
    "Type description of PyBufferObject"
    make_typedescr(space.gettypefor(Buffer).instancetypedef,
                   basestruct=PyBufferObject.TO,
                   attach=buffer_attach,
                   dealloc=buffer_dealloc,
                   realize=buffer_realize)
예제 #5
0
def init_bufferobject(space):
    "Type description of PyBufferObject"
    make_typedescr(space.w_buffer.layout.typedef,
                   basestruct=PyBufferObject.TO,
                   attach=buffer_attach,
                   dealloc=buffer_dealloc,
                   realize=buffer_realize)
예제 #6
0
def init_bytesobject(space):
    "Type description of PyBytesObject"
    make_typedescr(space.w_str.layout.typedef,
                   basestruct=PyBytesObject.TO,
                   attach=bytes_attach,
                   dealloc=bytes_dealloc,
                   realize=bytes_realize)
예제 #7
0
def init_stringobject(space):
    "Type description of PyTupleObject"
    make_typedescr(space.w_tuple.layout.typedef,
                   basestruct=PyTupleObject.TO,
                   attach=tuple_attach,
                   dealloc=tuple_dealloc,
                   realize=tuple_realize)
예제 #8
0
def init_bytesobject(space):
    "Type description of PyBytesObject"
    make_typedescr(space.w_bytes.layout.typedef,
                   basestruct=PyBytesObject.TO,
                   attach=bytes_attach,
                   dealloc=bytes_dealloc,
                   realize=bytes_realize)
예제 #9
0
def init_bufferobject(space):
    "Type description of PyBufferObject"
    make_typedescr(space.w_buffer.layout.typedef,
                   basestruct=PyBufferObject.TO,
                   attach=buffer_attach,
                   dealloc=buffer_dealloc,
                   realize=buffer_realize)
예제 #10
0
def init_typeobject(space):
    make_typedescr(space.w_type.layout.typedef,
                   basestruct=PyTypeObject,
                   alloc=type_alloc,
                   attach=type_attach,
                   realize=type_realize,
                   dealloc=type_dealloc)
예제 #11
0
def init_typeobject(space):
    make_typedescr(space.w_type.layout.typedef,
                   basestruct=PyHeapTypeObject.TO,
                   alloc=type_alloc,
                   attach=type_attach,
                   realize=type_realize,
                   dealloc=type_dealloc)
예제 #12
0
def init_stringobject(space):
    "Type description of PyTupleObject"
    make_typedescr(space.w_tuple.layout.typedef,
                   basestruct=PyTupleObject.TO,
                   attach=tuple_attach,
                   dealloc=tuple_dealloc,
                   realize=tuple_realize)
예제 #13
0
def init_typeobject(space):
    # Probably a hack
    space.model.typeorder[W_PyCTypeObject] = [(W_PyCTypeObject, None),
                                              (W_TypeObject, None),
                                              (W_Root, None)]

    make_typedescr(space.w_type.instancetypedef,
                   basestruct=PyTypeObject,
                   alloc=type_alloc,
                   attach=type_attach,
                   realize=type_realize,
                   dealloc=type_dealloc)

    # some types are difficult to create because of cycles.
    # - object.ob_type = type
    # - type.ob_type   = type
    # - tuple.ob_type  = type
    # - type.tp_base   = object
    # - tuple.tp_base  = object
    # - type.tp_bases is a tuple
    # - object.tp_bases is a tuple
    # - tuple.tp_bases is a tuple

    # insert null placeholders to please create_ref()
    track_reference(space, lltype.nullptr(PyObject.TO), space.w_type)
    track_reference(space, lltype.nullptr(PyObject.TO), space.w_object)
    track_reference(space, lltype.nullptr(PyObject.TO), space.w_tuple)
    track_reference(space, lltype.nullptr(PyObject.TO), space.w_str)

    # create the objects
    py_type = create_ref(space, space.w_type)
    py_object = create_ref(space, space.w_object)
    py_tuple = create_ref(space, space.w_tuple)
    py_str = create_ref(space, space.w_str)

    # form cycles
    pto_type = rffi.cast(PyTypeObjectPtr, py_type)
    py_type.c_ob_type = pto_type
    py_object.c_ob_type = pto_type
    py_tuple.c_ob_type = pto_type

    pto_object = rffi.cast(PyTypeObjectPtr, py_object)
    pto_type.c_tp_base = pto_object
    pto_tuple = rffi.cast(PyTypeObjectPtr, py_tuple)
    pto_tuple.c_tp_base = pto_object

    pto_type.c_tp_bases.c_ob_type = pto_tuple
    pto_object.c_tp_bases.c_ob_type = pto_tuple
    pto_tuple.c_tp_bases.c_ob_type = pto_tuple

    for typ in (py_type, py_object, py_tuple, py_str):
        heaptype = rffi.cast(PyHeapTypeObject, typ)
        heaptype.c_ht_name.c_ob_type = pto_type

    # Restore the mapping
    track_reference(space, py_type, space.w_type, replace=True)
    track_reference(space, py_object, space.w_object, replace=True)
    track_reference(space, py_tuple, space.w_tuple, replace=True)
    track_reference(space, py_str, space.w_str, replace=True)
예제 #14
0
def init_unicodeobject(space):
    make_typedescr(
        space.w_unicode.instancetypedef,
        basestruct=PyUnicodeObject.TO,
        attach=unicode_attach,
        dealloc=unicode_dealloc,
        realize=unicode_realize,
    )
예제 #15
0
def init_memoryobject(space):
    "Type description of PyDictObject"
    make_typedescr(W_MemoryView.typedef,
                   basestruct=PyMemoryViewObject.TO,
                   attach=memory_attach,
                   dealloc=memory_dealloc,
                   realize=memory_realize,
                   )
예제 #16
0
def init_tupleobject(space):
    "Type description of PyTupleObject"
    state = space.fromcache(State)
    make_typedescr(space.w_tuple.layout.typedef,
                   basestruct=PyTupleObject.TO,
                   attach=tuple_attach,
                   alloc=tuple_alloc,
                   dealloc=state.C._PyPy_tuple_dealloc,
                   realize=tuple_realize)
예제 #17
0
def init_intobject(space):
    "Type description of PyIntObject"
    state = space.fromcache(State)
    make_typedescr(space.w_int.layout.typedef,
                   basestruct=PyIntObject.TO,
                   attach=int_attach,
                   alloc=int_alloc,
                   dealloc=state.C._PyPy_int_dealloc,
                   realize=int_realize)
예제 #18
0
def init_functionobject(space):
    make_typedescr(Function.typedef,
                   basestruct=PyFunctionObject.TO,
                   attach=function_attach,
                   dealloc=function_dealloc)
    make_typedescr(PyCode.typedef,
                   basestruct=PyCodeObject.TO,
                   attach=code_attach,
                   dealloc=code_dealloc)
예제 #19
0
def init_functionobject(space):
    make_typedescr(Function.typedef,
                   basestruct=PyFunctionObject.TO,
                   attach=function_attach,
                   dealloc=function_dealloc)
    make_typedescr(PyCode.typedef,
                   basestruct=PyCodeObject.TO,
                   attach=code_attach,
                   dealloc=code_dealloc)
예제 #20
0
파일: setobject.py 프로젝트: zcxowwww/pypy
def init_setobject(space):
    "Type description of PySetObject"
    make_typedescr(space.w_set.layout.typedef,
                   basestruct=PySetObject.TO,
                   attach=set_attach,
                   dealloc=set_dealloc)
    make_typedescr(
        space.w_frozenset.layout.typedef,  # same as 'set'
        basestruct=PySetObject.TO,
        attach=set_attach,
        dealloc=set_dealloc)
예제 #21
0
def init_memberdescrobject(space):
    make_typedescr(
        W_MemberDescr.typedef,
        basestruct=cts.gettype('PyMemberDescrObject'),
        attach=memberdescr_attach,
        realize=memberdescr_realize,
        dealloc=descr_dealloc,
    )
    make_typedescr(
        W_GetSetPropertyEx.typedef,
        basestruct=cts.gettype('PyGetSetDescrObject'),
        attach=getsetdescr_attach,
        dealloc=descr_dealloc,
    )
    make_typedescr(
        W_PyCClassMethodObject.typedef,
        basestruct=cts.gettype('PyMethodDescrObject'),
        attach=methoddescr_attach,
        realize=classmethoddescr_realize,
        dealloc=descr_dealloc,
    )
    make_typedescr(
        W_PyCMethodObject.typedef,
        basestruct=cts.gettype('PyMethodDescrObject'),
        attach=methoddescr_attach,
        realize=methoddescr_realize,
        dealloc=descr_dealloc,
    )
예제 #22
0
def init_datetime(space):
    # no realize functions since there are no getters
    make_typedescr(
        W_DateTime_Time.typedef,
        basestruct=PyDateTime_Time.TO,
        attach=type_attach,
        dealloc=type_dealloc,
    )

    # why do we need date_dealloc? Since W_DateTime_Date is the base class for
    # app level datetime.date. If a c-extension class uses datetime.date for its
    # base class and defines a tp_dealloc, we will get this:
    # c_class->tp_dealloc == tp_dealloc_func
    # c_class->tp_base == datetime.date,
    #                     datetime.date->tp_dealloc = _PyPy_subtype_dealloc
    # datetime.date->tp_base = W_DateTime_Date
    #                    W_DateTime_Date->tp_dealloc = _PyPy_subtype_dealloc
    # but _PyPy_subtype_dealloc will call tp_dealloc_func, which can call its
    # base's tp_dealloc and we get recursion. So break the recursion by setting
    # W_DateTime_Date->tp_dealloc
    make_typedescr(
        W_DateTime_Date.typedef,
        basestruct=PyDateTime_DateTime.TO,
        attach=type_attach,
        dealloc=date_dealloc,
    )

    make_typedescr(
        W_DateTime_Delta.typedef,
        basestruct=PyDateTime_Delta.TO,
        attach=timedeltatype_attach,
    )
예제 #23
0
def init_memberdescrobject(space):
    make_typedescr(W_MemberDescr.typedef,
                   basestruct=PyMemberDescrObject.TO,
                   attach=memberdescr_attach,
                   realize=memberdescr_realize,
                   )
    make_typedescr(W_GetSetPropertyEx.typedef,
                   basestruct=PyGetSetDescrObject.TO,
                   attach=getsetdescr_attach,
                   )
    make_typedescr(W_PyCClassMethodObject.typedef,
                   basestruct=PyMethodDescrObject.TO,
                   attach=methoddescr_attach,
                   realize=classmethoddescr_realize,
                   )
    make_typedescr(W_PyCMethodObject.typedef,
                   basestruct=PyMethodDescrObject.TO,
                   attach=methoddescr_attach,
                   realize=methoddescr_realize,
                   )
예제 #24
0
파일: cdatetime.py 프로젝트: zcxowwww/pypy
def init_datetime(space):
    # no realize functions since there are no getters
    make_typedescr(W_DateTime_Time.typedef,
                   basestruct=PyDateTime_Time.TO,
                   attach=type_attach,
                   dealloc=type_dealloc,
                  )

    make_typedescr(W_DateTime_Date.typedef,
                   basestruct=PyDateTime_DateTime.TO,
                   attach=type_attach,
                   dealloc=type_dealloc,
                  )

    make_typedescr(W_DateTime_Delta.typedef,
                   basestruct=PyDateTime_Delta.TO,
                   attach=timedeltatype_attach,
                  )
예제 #25
0
def init_floatobject(space):
    "Type description of PyFloatObject"
    make_typedescr(space.w_float.layout.typedef,
                   basestruct=PyFloatObject.TO,
                   attach=float_attach,
                   realize=float_realize)
예제 #26
0
파일: intobject.py 프로젝트: charred/pypy
def init_intobject(space):
    "Type description of PyIntObject"
    make_typedescr(space.w_int.instancetypedef,
                   basestruct=PyIntObject.TO,
                   realize=int_realize)
예제 #27
0
def init_genobject(space):
    make_typedescr(GeneratorIterator.typedef,
                   basestruct=cts.gettype('PyGenObject'),
                   attach=gi_attach,
                   dealloc=gi_dealloc)
예제 #28
0
def init_stopiterationobject(space):
    "Type description of PyStopIterationObject"
    make_typedescr(W_StopIteration.typedef,
                   basestruct=PyStopIterationObject.TO,
                   attach=stopiteration_attach,
                   dealloc=stopiteration_dealloc)
예제 #29
0
파일: intobject.py 프로젝트: cimarieta/usp
def init_intobject(space):
    "Type description of PyIntObject"
    make_typedescr(space.w_int.layout.typedef, basestruct=PyIntObject.TO, attach=int_attach, realize=int_realize)
예제 #30
0
def init_methodobject(space):
    make_typedescr(W_PyCFunctionObject.typedef,
                   basestruct=PyCFunctionObject.TO,
                   attach=cfunction_attach,
                   dealloc=cfunction_dealloc)
예제 #31
0
def init_methodobject(space):
    make_typedescr(W_PyCFunctionObject.typedef,
                   basestruct=PyCFunctionObject.TO,
                   attach=cfunction_attach,
                   dealloc=cfunction_dealloc)
예제 #32
0
def init_frameobject(space):
    make_typedescr(PyFrame.typedef,
                   basestruct=PyFrameObject.TO,
                   attach=frame_attach,
                   dealloc=frame_dealloc,
                   realize=frame_realize)
예제 #33
0
파일: sliceobject.py 프로젝트: Qointum/pypy
def init_sliceobject(space):
    "Type description of PySliceObject"
    make_typedescr(W_SliceObject.typedef,
                   basestruct=PySliceObject.TO,
                   attach=slice_attach,
                   dealloc=slice_dealloc)
예제 #34
0
def init_unicodeobject(space):
    make_typedescr(space.w_unicode.instancetypedef,
                   basestruct=PyUnicodeObject.TO,
                   attach=unicode_attach,
                   dealloc=unicode_dealloc,
                   realize=unicode_realize)
예제 #35
0
def init_sliceobject(space):
    "Type description of PySliceObject"
    make_typedescr(W_SliceObject.typedef,
                   basestruct=PySliceObject.TO,
                   attach=slice_attach,
                   dealloc=slice_dealloc)
예제 #36
0
def init_frameobject(space):
    make_typedescr(PyFrame.typedef,
                   basestruct=PyFrameObject.TO,
                   attach=frame_attach,
                   dealloc=frame_dealloc,
                   realize=frame_realize)
예제 #37
0
def init_moduleobject(space):
    make_typedescr(Module.typedef,
                   basestruct=PyModuleObject.TO,
                   dealloc=module_dealloc)
예제 #38
0
def init_complexobject(space):
    "Type description of PyComplexObject"
    make_typedescr(space.w_complex.layout.typedef,
                   basestruct=PyComplexObject.TO,
                   attach=complex_attach,
                   realize=complex_realize)
예제 #39
0
def init_traceback(space):
    make_typedescr(PyTraceback.typedef,
                   basestruct=PyTracebackObject.TO,
                   attach=traceback_attach,
                   dealloc=traceback_dealloc)
예제 #40
0
def init_traceback(space):
    make_typedescr(PyTraceback.typedef,
                   basestruct=PyTracebackObject.TO,
                   attach=traceback_attach,
                   dealloc=traceback_dealloc)
예제 #41
0
파일: intobject.py 프로젝트: zielmicha/pypy
def init_intobject(space):
    "Type description of PyIntObject"
    make_typedescr(space.w_int.instancetypedef,
                   basestruct=PyIntObject.TO,
                   attach=int_attach,
                   realize=int_realize)