コード例 #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
ファイル: bufferobject.py プロジェクト: Debug-Orz/Sypy
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
ファイル: bufferobject.py プロジェクト: purepython/pypy
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
ファイル: bufferobject.py プロジェクト: abhinavthomas/pypy
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
ファイル: bytesobject.py プロジェクト: mozillazg/pypy
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
ファイル: typeobject.py プロジェクト: mozillazg/pypy
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
ファイル: tupleobject.py プロジェクト: mozillazg/pypy
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
ファイル: memoryobject.py プロジェクト: zcxowwww/pypy
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
ファイル: intobject.py プロジェクト: tools-env/mesapy
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
ファイル: typeobject.py プロジェクト: mozillazg/pypy
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
ファイル: methodobject.py プロジェクト: sota/pypy-old
def init_methodobject(space):
    make_typedescr(W_PyCFunctionObject.typedef,
                   basestruct=PyCFunctionObject.TO,
                   attach=cfunction_attach,
                   dealloc=cfunction_dealloc)
コード例 #31
0
ファイル: methodobject.py プロジェクト: charred/pypy
def init_methodobject(space):
    make_typedescr(W_PyCFunctionObject.typedef,
                   basestruct=PyCFunctionObject.TO,
                   attach=cfunction_attach,
                   dealloc=cfunction_dealloc)
コード例 #32
0
ファイル: frameobject.py プロジェクト: gorakhargosh/pypy
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
ファイル: unicodeobject.py プロジェクト: purepython/pypy
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
ファイル: frameobject.py プロジェクト: zielmicha/pypy
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
ファイル: pytraceback.py プロジェクト: abhinavthomas/pypy
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)