本文整理汇总了Python中pypy.rpython.tool.rffi_platform.configure函数的典型用法代码示例。如果您正苦于以下问题:Python configure函数的具体用法?Python configure怎么用?Python configure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了configure函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ifdef
def test_ifdef():
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
post_include_bits=[
"/* a C comment */",
"#define XYZZY 42",
"typedef int foo;",
"""
struct s {
int i;
double f;
};
""",
]
)
s = rffi_platform.Struct("struct s", [("i", rffi.INT)], ifdef="XYZZY")
z = rffi_platform.Struct("struct z", [("i", rffi.INT)], ifdef="FOOBAR")
foo = rffi_platform.SimpleType("foo", ifdef="XYZZY")
bar = rffi_platform.SimpleType("bar", ifdef="FOOBAR")
res = rffi_platform.configure(CConfig)
assert res["s"] is not None
assert res["z"] is None
assert res["foo"] is not None
assert res["bar"] is None
开发者ID:alkorzt,项目名称:pypy,代码行数:27,代码来源:test_rffi_platform.py
示例2: test_nested_structs_in_the_opposite_order
def test_nested_structs_in_the_opposite_order():
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
post_include_bits=[
"""
struct y {
int foo;
unsigned long bar;
};
struct x {
char c;
struct y y;
};
"""
]
)
y = rffi_platform.Struct("struct y", [("bar", rffi.SHORT)])
x = rffi_platform.Struct("struct x", [("y", y)])
res = rffi_platform.configure(CConfig)
c_x = res["x"]
c_y = res["y"]
assert isinstance(c_x, lltype.Struct)
assert isinstance(c_y, lltype.Struct)
assert c_x.c_y is c_y
开发者ID:alkorzt,项目名称:pypy,代码行数:25,代码来源:test_rffi_platform.py
示例3: configure_boehm_once
def configure_boehm_once(cls):
""" Configure boehm only once, since we don't cache failures
"""
if hasattr(cls, 'malloc_fn_ptr'):
return cls.malloc_fn_ptr
from pypy.rpython.tool import rffi_platform
compilation_info = rffi_platform.configure_boehm()
# Versions 6.x of libgc needs to use GC_local_malloc().
# Versions 7.x of libgc removed this function; GC_malloc() has
# the same behavior if libgc was compiled with
# THREAD_LOCAL_ALLOC.
class CConfig:
_compilation_info_ = compilation_info
HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")
config = rffi_platform.configure(CConfig)
if config['HAS_LOCAL_MALLOC']:
GC_MALLOC = "GC_local_malloc"
else:
GC_MALLOC = "GC_malloc"
malloc_fn_ptr = rffi.llexternal(GC_MALLOC,
[lltype.Signed], # size_t, but good enough
llmemory.GCREF,
compilation_info=compilation_info,
sandboxsafe=True,
_nowrapper=True)
cls.malloc_fn_ptr = malloc_fn_ptr
cls.compilation_info = compilation_info
return malloc_fn_ptr
开发者ID:craigkerstiens,项目名称:pypy,代码行数:29,代码来源:gc.py
示例4: register_os_uname
def register_os_uname(self):
CHARARRAY = lltype.FixedSizeArray(lltype.Char, 1)
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
includes = ['sys/utsname.h']
)
UTSNAME = platform.Struct('struct utsname', [
('sysname', CHARARRAY),
('nodename', CHARARRAY),
('release', CHARARRAY),
('version', CHARARRAY),
('machine', CHARARRAY)])
config = platform.configure(CConfig)
UTSNAMEP = lltype.Ptr(config['UTSNAME'])
os_uname = self.llexternal('uname', [UTSNAMEP], rffi.INT,
compilation_info=CConfig._compilation_info_)
def uname_llimpl():
l_utsbuf = lltype.malloc(UTSNAMEP.TO, flavor='raw')
result = os_uname(l_utsbuf)
if result == -1:
raise OSError(rposix.get_errno(), "os_uname failed")
retval = (
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_sysname)),
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_nodename)),
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_release)),
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_version)),
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_machine)),
)
lltype.free(l_utsbuf, flavor='raw')
return retval
return extdef([], (str, str, str, str, str),
"ll_os.ll_uname", llimpl=uname_llimpl)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:35,代码来源:ll_os.py
示例5: test_ifdef
def test_ifdef():
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
post_include_bits = ['/* a C comment */',
'#define XYZZY 42',
'typedef int foo;',
'''
struct s {
int i;
double f;
};
'''])
s = rffi_platform.Struct('struct s', [('i', rffi.INT)],
ifdef='XYZZY')
z = rffi_platform.Struct('struct z', [('i', rffi.INT)],
ifdef='FOOBAR')
foo = rffi_platform.SimpleType('foo', ifdef='XYZZY')
bar = rffi_platform.SimpleType('bar', ifdef='FOOBAR')
res = rffi_platform.configure(CConfig)
assert res['s'] is not None
assert res['z'] is None
assert res['foo'] is not None
assert res['bar'] is None
开发者ID:ieure,项目名称:pypy,代码行数:26,代码来源:test_rffi_platform.py
示例6: setup
def setup():
INSPECT = {'b': 'signed char',
'h': 'signed short',
'i': 'signed int',
'l': 'signed long',
'q': 'signed long long',
'B': 'unsigned char',
'H': 'unsigned short',
'I': 'unsigned int',
'L': 'unsigned long',
'Q': 'unsigned long long',
'P': 'char *',
'f': 'float',
'd': 'double',
}
pre_include_bits = []
for fmtchar, ctype in INSPECT.items():
pre_include_bits.append("""
struct about_%s {
char pad;
%s field;
};
""" % (fmtchar, ctype))
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
pre_include_bits = pre_include_bits
)
for fmtchar, ctype in INSPECT.items():
setattr(CConfig, fmtchar, rffi_platform.Struct(
"struct about_%s" % (fmtchar,),
[('field', lltype.FixedSizeArray(rffi.CHAR, 1))]))
cConfig = rffi_platform.configure(CConfig)
for fmtchar, ctype in INSPECT.items():
S = cConfig[fmtchar]
alignment = rffi.offsetof(S, 'c_field')
size = rffi.sizeof(S.c_field)
signed = 'a' <= fmtchar <= 'z'
if fmtchar == 'f':
pack = pack_float
unpack = unpack_float
elif fmtchar == 'd':
pack = pack_double
unpack = unpack_double
else:
cpython_checks_range = fmtchar in 'bBhH'
pack = std.make_int_packer(size, signed, cpython_checks_range)
unpack = std.make_int_unpacker(size, signed)
native_fmttable[fmtchar] = {'size': size,
'alignment': alignment,
'pack': pack,
'unpack': unpack}
开发者ID:alkorzt,项目名称:pypy,代码行数:58,代码来源:nativefmttable.py
示例7: configure
def configure(self, CConfig):
classes_seen = self.__dict__.setdefault('__classes_seen', {})
if CConfig in classes_seen:
return
from pypy.rpython.tool import rffi_platform as platform
# copy some stuff
self.compilation_info = CConfig._compilation_info_
self.__dict__.update(platform.configure(CConfig))
classes_seen[CConfig] = True
开发者ID:antoine1fr,项目名称:pygirl,代码行数:9,代码来源:extfunc.py
示例8: register_posix__getfullpathname
def register_posix__getfullpathname(self):
# this nt function is not exposed via os, but needed
# to get a correct implementation of os.abspath
# XXX why do we ignore WINAPI conventions everywhere?
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
includes = ['Windows.h']
)
MAX_PATH = platform.ConstantInteger('MAX_PATH')
DWORD = platform.SimpleType("DWORD", rffi.ULONG)
LPCTSTR = platform.SimpleType("LPCTSTR", rffi.CCHARP)
LPTSTR = platform.SimpleType("LPTSTR", rffi.CCHARP)
LPTSTRP = platform.SimpleType("LPTSTR*", rffi.CCHARPP)
config = platform.configure(CConfig)
MAX_PATH = config['MAX_PATH']
DWORD = config['DWORD']
LPCTSTR = config['LPCTSTR']
LPTSTR = config['LPTSTR']
LPTSTRP = config['LPTSTRP']
# XXX unicode?
GetFullPathName = self.llexternal('GetFullPathNameA',
[LPCTSTR, DWORD, LPTSTR, LPTSTRP], DWORD)
GetLastError = self.llexternal('GetLastError', [], DWORD)
##DWORD WINAPI GetFullPathName(
## __in LPCTSTR lpFileName,
## __in DWORD nBufferLength,
## __out LPTSTR lpBuffer,
## __out LPTSTR* lpFilePart
##);
def _getfullpathname_llimpl(lpFileName):
nBufferLength = MAX_PATH + 1
lpBuffer = lltype.malloc(LPTSTR.TO, nBufferLength, flavor='raw')
try:
res = GetFullPathName(
lpFileName, rffi.cast(DWORD, nBufferLength),
lpBuffer, lltype.nullptr(LPTSTRP.TO))
if res == 0:
error = GetLastError()
raise OSError(error, "_getfullpathname failed")
# XXX ntpath expects WindowsError :-(
result = rffi.charp2str(lpBuffer)
return result
finally:
lltype.free(lpBuffer, flavor='raw')
return extdef([str], # a single argument which is a str
str, # returns a string
"ll_os.posix__getfullpathname",
llimpl=_getfullpathname_llimpl)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:51,代码来源:ll_os.py
示例9: test_configure
def test_configure():
test_h = udir.join("test_ctypes_platform.h")
test_h.write("#define XYZZY 42\n")
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
pre_include_bits=["/* a C comment */", "#include <stdio.h>", "#include <test_ctypes_platform.h>"],
include_dirs=[str(udir)],
)
FILE = rffi_platform.Struct("FILE", [])
ushort = rffi_platform.SimpleType("unsigned short")
XYZZY = rffi_platform.ConstantInteger("XYZZY")
res = rffi_platform.configure(CConfig)
assert isinstance(res["FILE"], lltype.Struct)
assert res == {"FILE": res["FILE"], "ushort": rffi.USHORT, "XYZZY": 42}
开发者ID:alkorzt,项目名称:pypy,代码行数:17,代码来源:test_rffi_platform.py
示例10: test_padding_in_prebuilt_struct
def test_padding_in_prebuilt_struct(self):
from pypy.rpython.lltypesystem import rffi
from pypy.rpython.tool import rffi_platform
eci = rffi_platform.eci_from_header("""
typedef struct {
char c1; /* followed by one byte of padding */
short s1;
char c2; /* followed by 3 bytes of padding */
int i2;
char c3; /* followed by 3 or 7 bytes of padding */
long l3;
char c4;
} foobar_t;
""")
class CConfig:
_compilation_info_ = eci
STRUCT = rffi_platform.Struct("foobar_t",
[("c1", Signed),
("s1", Signed),
("l3", Signed)])
S = rffi_platform.configure(CConfig)['STRUCT']
assert 'get_padding_drop' in S._hints
s1 = malloc(S, immortal=True)
s1.c_c1 = rffi.cast(S.c_c1, -12)
s1.c_s1 = rffi.cast(S.c_s1, -7843)
s1.c_l3 = -98765432
s2 = malloc(S, immortal=True)
s2.c_c1 = rffi.cast(S.c_c1, -123)
s2.c_s1 = rffi.cast(S.c_s1, -789)
s2.c_l3 = -9999999
#
def f(n):
if n > 5:
s = s1
else:
s = s2
return s.c_l3
#
self.include_also_eci = eci
fn = self.getcompiled(f, [int])
res = fn(10)
assert res == -98765432
res = fn(1)
assert res == -9999999
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:44,代码来源:test_lltyped.py
示例11: test_configure
def test_configure():
test_h = udir.join('test_ctypes_platform.h')
test_h.write('#define XYZZY 42\n')
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
pre_include_bits = ["/* a C comment */",
"#include <stdio.h>",
"#include <test_ctypes_platform.h>"],
include_dirs = [str(udir)]
)
FILE = rffi_platform.Struct('FILE', [])
ushort = rffi_platform.SimpleType('unsigned short')
XYZZY = rffi_platform.ConstantInteger('XYZZY')
res = rffi_platform.configure(CConfig)
assert isinstance(res['FILE'], lltype.Struct)
assert res == {'FILE': res['FILE'],
'ushort': rffi.USHORT,
'XYZZY': 42}
开发者ID:ieure,项目名称:pypy,代码行数:21,代码来源:test_rffi_platform.py
示例12: __init__
def __init__(self, gcdescr, translator):
GcLLDescription.__init__(self, gcdescr, translator)
# grab a pointer to the Boehm 'malloc' function
from pypy.rpython.tool import rffi_platform
compilation_info = rffi_platform.check_boehm()
# Versions 6.x of libgc needs to use GC_local_malloc().
# Versions 7.x of libgc removed this function; GC_malloc() has
# the same behavior if libgc was compiled with
# THREAD_LOCAL_ALLOC.
class CConfig:
_compilation_info_ = compilation_info
HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")
config = rffi_platform.configure(CConfig)
if config['HAS_LOCAL_MALLOC']:
GC_MALLOC = "GC_local_malloc"
else:
GC_MALLOC = "GC_malloc"
malloc_fn_ptr = rffi.llexternal(GC_MALLOC,
[lltype.Signed], # size_t, but good enough
llmemory.GCREF,
compilation_info=compilation_info,
sandboxsafe=True,
_nowrapper=True)
self.funcptr_for_new = malloc_fn_ptr
# on some platform GC_init is required before any other
# GC_* functions, call it here for the benefit of tests
# XXX move this to tests
init_fn_ptr = rffi.llexternal("GC_init",
[], lltype.Void,
compilation_info=compilation_info,
sandboxsafe=True,
_nowrapper=True)
init_fn_ptr()
开发者ID:enyst,项目名称:plexnet,代码行数:37,代码来源:gc.py
示例13: ExternalCompilationInfo
eci = ExternalCompilationInfo(includes=["pcre.h"], \
include_dirs=Config.LIBPCRE_INCLUDE_DIRS, \
library_dirs=Config.LIBPCRE_LIBRARY_DIRS, \
libraries=Config.LIBPCRE_LIBRARIES, \
link_extra=Config.LIBPCRE_LINK_FLAGS, \
link_files=[Config.LIBPCRE_A])
class CConfig:
_compilation_info_ = eci
PCRE_DOTALL = platform.DefinedConstantInteger("PCRE_DOTALL")
PCRE_MULTILINE = platform.DefinedConstantInteger("PCRE_MULTILINE")
PCRE_INFO_CAPTURECOUNT = platform.DefinedConstantInteger("PCRE_INFO_CAPTURECOUNT")
PCRE_ANCHORED = platform.DefinedConstantInteger("PCRE_ANCHORED")
PCRE_ERROR_NOMATCH = platform.DefinedConstantInteger("PCRE_ERROR_NOMATCH")
cconfig = platform.configure(CConfig)
PCREP = rffi.COpaquePtr("pcre")
PCRE_DOTALL = cconfig["PCRE_DOTALL"]
PCRE_MULTILINE = cconfig["PCRE_MULTILINE"]
PCRE_INFO_CAPTURECOUNT = cconfig["PCRE_INFO_CAPTURECOUNT"]
PCRE_ANCHORED = cconfig["PCRE_ANCHORED"]
PCRE_ERROR_NOMATCH = cconfig["PCRE_ERROR_NOMATCH"]
pcre_compile = rffi.llexternal("pcre_compile", \
[rffi.CCHARP, rffi.INT, rffi.CCHARPP, rffi.INTP, rffi.VOIDP], PCREP, compilation_info=eci)
pcre_fullinfo = rffi.llexternal("pcre_fullinfo", \
[PCREP, rffi.VOIDP, rffi.INT, rffi.INTP], rffi.INT, compilation_info=eci)
pcre_exec = rffi.llexternal("pcre_exec", \
[PCREP, rffi.VOIDP, rffi.CCHARP, rffi.INT, rffi.INT, rffi.INT, rffi.INTP, rffi.INT], \
rffi.INT, compilation_info=eci)
开发者ID:cfbolz,项目名称:converge,代码行数:31,代码来源:Con_PCRE.py
示例14: register_os_listdir
def register_os_listdir(self):
# we need a different approach on Windows and on Posix
if sys.platform.startswith('win'):
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
includes = ['windows.h']
)
WIN32_FIND_DATA = platform.Struct('struct _WIN32_FIND_DATAA',
[('cFileName', lltype.FixedSizeArray(rffi.CHAR, 1))])
INVALID_HANDLE_VALUE = platform.ConstantInteger(
'INVALID_HANDLE_VALUE')
ERROR_FILE_NOT_FOUND = platform.ConstantInteger(
'ERROR_FILE_NOT_FOUND')
ERROR_NO_MORE_FILES = platform.ConstantInteger(
'ERROR_NO_MORE_FILES')
config = platform.configure(CConfig)
WIN32_FIND_DATA = config['WIN32_FIND_DATA']
INVALID_HANDLE_VALUE = config['INVALID_HANDLE_VALUE']
ERROR_FILE_NOT_FOUND = config['ERROR_FILE_NOT_FOUND']
ERROR_NO_MORE_FILES = config['ERROR_NO_MORE_FILES']
LPWIN32_FIND_DATA = lltype.Ptr(WIN32_FIND_DATA)
HANDLE = rffi.ULONG
#MAX_PATH = WIN32_FIND_DATA.c_cFileName.length
GetLastError = self.llexternal('GetLastError', [], lltype.Signed)
FindFirstFile = self.llexternal('FindFirstFile',
[rffi.CCHARP, LPWIN32_FIND_DATA],
HANDLE)
FindNextFile = self.llexternal('FindNextFile',
[HANDLE, LPWIN32_FIND_DATA],
rffi.INT)
FindClose = self.llexternal('FindClose',
[HANDLE],
rffi.INT)
def os_listdir_llimpl(path):
if path and path[-1] not in ('/', '\\', ':'):
path += '/'
path += '*.*'
filedata = lltype.malloc(WIN32_FIND_DATA, flavor='raw')
try:
result = []
hFindFile = FindFirstFile(path, filedata)
if hFindFile == INVALID_HANDLE_VALUE:
error = GetLastError()
if error == ERROR_FILE_NOT_FOUND:
return result
else:
# XXX guess error code :-(
raise OSError(errno.ENOENT, "FindFirstFile failed")
while True:
name = rffi.charp2str(rffi.cast(rffi.CCHARP,
filedata.c_cFileName))
if name != "." and name != "..": # skip these
result.append(name)
if not FindNextFile(hFindFile, filedata):
break
# FindNextFile sets error to ERROR_NO_MORE_FILES if
# it got to the end of the directory
error = GetLastError()
FindClose(hFindFile)
if error == ERROR_NO_MORE_FILES:
return result
else:
# XXX guess error code :-(
raise OSError(errno.EIO, "FindNextFile failed")
finally:
lltype.free(filedata, flavor='raw')
else:
compilation_info = ExternalCompilationInfo(
includes = ['sys/types.h', 'dirent.h']
)
class CConfig:
_compilation_info_ = compilation_info
DIRENT = platform.Struct('struct dirent',
[('d_name', lltype.FixedSizeArray(rffi.CHAR, 1))])
DIRP = rffi.COpaquePtr('DIR')
config = platform.configure(CConfig)
DIRENT = config['DIRENT']
DIRENTP = lltype.Ptr(DIRENT)
os_opendir = self.llexternal('opendir', [rffi.CCHARP], DIRP,
compilation_info=compilation_info)
os_readdir = self.llexternal('readdir', [DIRP], DIRENTP,
compilation_info=compilation_info)
os_closedir = self.llexternal('closedir', [DIRP], rffi.INT,
compilation_info=compilation_info)
def os_listdir_llimpl(path):
dirp = os_opendir(path)
if not dirp:
raise OSError(rposix.get_errno(), "os_opendir failed")
rposix.set_errno(0)
result = []
while True:
direntp = os_readdir(dirp)
if not direntp:
error = rposix.get_errno()
#.........这里部分代码省略.........
开发者ID:antoine1fr,项目名称:pygirl,代码行数:101,代码来源:ll_os.py
示例15: setattr
"""
_compilation_info_ = eci
# XXX If Z_PREFIX was defined for the libz build, then these types are
# named z_uInt, z_uLong, and z_Bytef instead.
uInt = rffi_platform.SimpleType('uInt', rffi.UINT)
uLong = rffi_platform.SimpleType('uLong', rffi.ULONG)
Bytef = rffi_platform.SimpleType('Bytef', rffi.UCHAR)
voidpf = rffi_platform.SimpleType('voidpf', rffi.VOIDP)
ZLIB_VERSION = rffi_platform.DefinedConstantString('ZLIB_VERSION')
for _name in constantnames:
setattr(SimpleCConfig, _name, rffi_platform.ConstantInteger(_name))
config = rffi_platform.configure(SimpleCConfig)
voidpf = config['voidpf']
uInt = config['uInt']
uLong = config['uLong']
Bytef = config['Bytef']
Bytefp = lltype.Ptr(lltype.Array(Bytef, hints={'nolength': True}))
ZLIB_VERSION = config['ZLIB_VERSION']
for _name in constantnames:
globals()[_name] = config[_name]
# The following parameter is copied from zutil.h, version 0.95,
# according to CPython's zlibmodule.c
DEFLATED = Z_DEFLATED
if MAX_MEM_LEVEL >= 8:
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:rzlib.py
示例16: setattr
"KQ_EV_ADD": "EV_ADD",
"KQ_EV_DELETE": "EV_DELETE",
"KQ_EV_ENABLE": "EV_ENABLE",
"KQ_EV_DISABLE": "EV_DISABLE",
"KQ_EV_ONESHOT": "EV_ONESHOT",
"KQ_EV_CLEAR": "EV_CLEAR",
# "KQ_EV_SYSFLAGS": None, # Python docs says "internal event" .. not defined on FreeBSD
# "KQ_EV_FLAG1": None, # Python docs says "internal event" .. not defined on FreeBSD
"KQ_EV_EOF": "EV_EOF",
"KQ_EV_ERROR": "EV_ERROR"
}
for symbol in symbol_map.values():
setattr(CConfig, symbol, rffi_platform.DefinedConstantInteger(symbol))
cconfig = rffi_platform.configure(CConfig)
kevent = cconfig["kevent"]
timespec = cconfig["timespec"]
for symbol in symbol_map:
globals()[symbol] = cconfig[symbol_map[symbol]]
syscall_kqueue = rffi.llexternal(
"kqueue",
[],
rffi.INT,
compilation_info=eci
)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:30,代码来源:interp_kqueue.py
示例17: globals
eci = eci.merge(RSDL.eci)
eci = eci.merge(eci)
eci = eci.merge(eci)
ChunkPtr = lltype.Ptr(lltype.ForwardReference())
class CConfig:
_compilation_info_ = eci
Chunk = platform.Struct('Mix_Chunk', [('allocated', rffi.INT),
('abuf', RSDL.Uint8P),
('alen', RSDL.Uint32),
('volume', RSDL.Uint8)])
globals().update(platform.configure(CConfig))
ChunkPtr.TO.become(Chunk)
Buffer = rffi.CArray(RSDL.Uint8)
def external(name, args, result):
return rffi.llexternal(name, args, result, compilation_info=eci)
OpenAudio = external('Mix_OpenAudio',
[rffi.INT, RSDL.Uint16, rffi.INT, rffi.INT],
rffi.INT)
CloseAudio = external('Mix_CloseAudio', [], lltype.Void)
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:29,代码来源:RMix.py
示例18: setup
def setup():
INSPECT = {'b': 'signed char',
'h': 'signed short',
'i': 'signed int',
'l': 'signed long',
'q': 'signed long long',
'B': 'unsigned char',
'H': 'unsigned short',
'I': 'unsigned int',
'L': 'unsigned long',
'Q': 'unsigned long long',
'P': 'char *',
'f': 'float',
'd': 'double',
'?': '_Bool',
}
pre_include_bits = ["""
#ifdef _MSC_VER
#define _Bool char
#endif"""]
field_names = dict.fromkeys(INSPECT)
for fmtchar, ctype in INSPECT.iteritems():
field_name = ctype.replace(" ", "_").replace("*", "star")
field_names[fmtchar] = field_name
pre_include_bits.append("""
struct about_%s {
char pad;
%s field;
};
""" % (field_name, ctype))
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
pre_include_bits = pre_include_bits
)
for fmtchar, ctype in INSPECT.items():
setattr(CConfig, field_names[fmtchar], rffi_platform.Struct(
"struct about_%s" % (field_names[fmtchar],),
[('field', lltype.FixedSizeArray(rffi.CHAR, 1))]))
cConfig = rffi_platform.configure(CConfig)
for fmtchar, ctype in INSPECT.items():
S = cConfig[field_names[fmtchar]]
alignment = rffi.offsetof(S, 'c_field')
size = rffi.sizeof(S.c_field)
signed = 'a' <= fmtchar <= 'z'
if fmtchar == 'f':
pack = pack_float
unpack = unpack_float
elif fmtchar == 'd':
pack = pack_double
unpack = unpack_double
elif fmtchar == '?':
pack = std.pack_bool
unpack = std.unpack_bool
else:
pack = std.make_int_packer(size, signed, True)
unpack = std.make_int_unpacker(size, signed)
native_fmttable[fmtchar] = {'size': size,
'alignment': alignment,
'pack': pack,
'unpack': unpack}
开发者ID:gorakhargosh,项目名称:pypy,代码行数:67,代码来源:nativefmttable.py
示例19: _expand
#pre_include_bits = ['#define _FILE_OFFSET_BITS 64'],
# ^^^ nowadays it's always set in all C files we produce.
includes = INCLUDES
)
if sys.platform != 'win32':
LL_STAT_FIELDS = STAT_FIELDS[:]
if TIMESPEC is not None:
class CConfig_for_timespec:
_compilation_info_ = compilation_info
TIMESPEC = TIMESPEC
TIMESPEC = lltype.Ptr(
platform.configure(CConfig_for_timespec)['TIMESPEC'])
def _expand(lst, originalname, timespecname):
for i, (_name, _TYPE) in enumerate(lst):
if _name == originalname:
# replace the 'st_atime' field of type rffi.DOUBLE
# with a field 'st_atim' of type 'struct timespec'
lst[i] = (timespecname, TIMESPEC.TO)
break
_expand(LL_STAT_FIELDS, 'st_atime', 'st_atim')
_expand(LL_STAT_FIELDS, 'st_mtime', 'st_mtim')
_expand(LL_STAT_FIELDS, 'st_ctime', 'st_ctim')
del _expand
else:
开发者ID:ieure,项目名称:pypy,代码行数:31,代码来源:ll_os_stat.py
示例20: ExternalCompilationInfo
from pypy.rpython.extregistry import ExtRegistryEntry
from pypy.annotation import model as annmodel
from pypy.rpython import rclass
from pypy.rlib import rtermios, rposix
from pypy.rpython.tool import rffi_platform
from pypy.translator.tool.cbuild import ExternalCompilationInfo
eci = ExternalCompilationInfo(
includes = ['termios.h', 'unistd.h']
)
class CConfig:
_compilation_info_ = eci
NCCS = rffi_platform.DefinedConstantInteger('NCCS')
NCCS = rffi_platform.configure(CConfig)['NCCS']
TCFLAG_T = rffi.UINT
CC_T = rffi.UCHAR
SPEED_T = rffi.UINT
INT = rffi.INT
TERMIOSP = rffi.CStructPtr('termios', ('c_iflag', TCFLAG_T), ('c_oflag', TCFLAG_T),
('c_cflag', TCFLAG_T), ('c_lflag', TCFLAG_T),
('c_cc', lltype.FixedSizeArray(CC_T, NCCS)))
def c_external(name, args, result):
return rffi.llexternal(name, args, result, compilation_info=eci)
c_tcsetattr = c_external('tcsetattr', [INT, INT, TERMIOSP], INT)
c_cfgetispeed = c_external('cfgetispeed', [TERMIOSP], SPEED_T)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:ll_termios.py
注:本文中的pypy.rpython.tool.rffi_platform.configure函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论