File: __init__.py

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (58 lines) | stat: -rw-r--r-- 2,533 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
""" Low-level interface to clibffi
"""

from pypy.interpreter.mixedmodule import MixedModule
from pypy.module._rawffi import alt

class Module(MixedModule):
    interpleveldefs = {
        'CDLL'               : 'interp_rawffi.W_CDLL',
        'FuncPtr'            : 'interp_rawffi.W_FuncPtr',
        'Structure'          : 'structure.W_Structure',
        'StructureInstance'  : 'structure.W_StructureInstance',
        'StructureInstanceAutoFree' : 'structure.W_StructureInstanceAutoFree',
        'Array'              : 'array.W_Array',
        'ArrayInstance'      : 'array.W_ArrayInstance',
        'ArrayInstanceAutoFree' : 'array.W_ArrayInstanceAutoFree',
        'sizeof'             : 'interp_rawffi.sizeof',
        'alignment'          : 'interp_rawffi.alignment',
        'charp2string'       : 'interp_rawffi.charp2string',
        'wcharp2unicode'     : 'interp_rawffi.wcharp2unicode',
        'charp2rawstring'    : 'interp_rawffi.charp2rawstring',
        'wcharp2rawunicode'  : 'interp_rawffi.wcharp2rawunicode',
        'rawstring2charp'    : 'interp_rawffi.rawstring2charp',
        'CallbackPtr'        : 'callback.W_CallbackPtr',
        '_num_of_allocated_objects' : 'tracker.num_of_allocated_objects',
        'get_libc'           : 'interp_rawffi.get_libc',
        'get_errno'          : 'interp_rawffi.get_errno',
        'set_errno'          : 'interp_rawffi.set_errno',
        'get_last_error'     : 'interp_rawffi.get_last_error',
        'set_last_error'     : 'interp_rawffi.set_last_error',
        'SegfaultException'  : 'space.new_exception_class("_rawffi.SegfaultException")',
        'exit'               : 'interp_exit.exit',
    }

    appleveldefs = {
    }

    submodules = {
        'alt': alt.Module,
    }

    def buildloaders(cls):
        from pypy.module._rawffi import interp_rawffi

        if hasattr(interp_rawffi, 'FormatError'):
            Module.interpleveldefs['FormatError'] = 'interp_rawffi.FormatError'
        if hasattr(interp_rawffi, 'check_HRESULT'):
            Module.interpleveldefs['check_HRESULT'] = 'interp_rawffi.check_HRESULT'

        from rpython.rlib import clibffi
        for name in ['FUNCFLAG_STDCALL', 'FUNCFLAG_CDECL', 'FUNCFLAG_PYTHONAPI',
                     'FUNCFLAG_USE_ERRNO', 'FUNCFLAG_USE_LASTERROR',
                     ]:
            if hasattr(clibffi, name):
                Module.interpleveldefs[name] = "space.wrap(%r)" % getattr(clibffi, name)

        super(Module, cls).buildloaders()
    buildloaders = classmethod(buildloaders)