本文整理汇总了Python中pypy.rlib.libffi.CDLL.getpointer方法的典型用法代码示例。如果您正苦于以下问题:Python CDLL.getpointer方法的具体用法?Python CDLL.getpointer怎么用?Python CDLL.getpointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.rlib.libffi.CDLL
的用法示例。
在下文中一共展示了CDLL.getpointer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: before
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
def before(n, x):
libc = CDLL(libc_name)
c_strchr = libc.getpointer('strchr', [types.pointer, types.sint],
types.pointer)
glob.c_strchr = c_strchr
return (n, None, None, None, None, None,
None, None, None, None, None, None)
示例2: setup_class
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
def setup_class(cls):
space = gettestobjspace(usemodules=('_ffi', '_rawffi'))
cls.space = space
cls.w_iswin32 = space.wrap(sys.platform == 'win32')
cls.w_libfoo_name = space.wrap(cls.prepare_c_example())
cls.w_libc_name = space.wrap(get_libc_name())
libm_name = get_libm_name(sys.platform)
cls.w_libm_name = space.wrap(libm_name)
libm = CDLL(libm_name)
pow = libm.getpointer('pow', [], types.void)
pow_addr = rffi.cast(rffi.LONG, pow.funcsym)
cls.w_pow_addr = space.wrap(pow_addr)
示例3: libffi_stuff
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
def libffi_stuff(i, j):
lib = CDLL(libm_name)
func = lib.getpointer('fabs', [types.double], types.double)
res = 0.0
x = float(j)
while i > 0:
jitdriver2.jit_merge_point(i=i, res=res, func=func, x=x)
promote(func)
argchain = ArgChain()
argchain.arg(x)
res = func.call(argchain, rffi.DOUBLE)
i -= 1
return res
示例4: W_CDLL
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
class W_CDLL(W_Root):
def __init__(self, libpath):
self.libpath = libpath
self.handle = CDLL(libpath)
@unroll_safe # XXX necessary?
def getpointer(self, name, argtypes_w, w_restype):
argtypes = [wtype_to_ffitype(w_type) for w_type in argtypes_w]
restype = wtype_to_ffitype(w_restype)
funcptr = self.handle.getpointer(name, argtypes, restype)
return W_ForeignClosure(funcptr, name, argtypes_w, w_restype)
def to_string(self):
return '#<library-handle %s>' % self.libpath
示例5: setup_class
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
def setup_class(cls):
from pypy.rpython.lltypesystem import rffi
from pypy.rlib.libffi import get_libc_name, CDLL, types
from pypy.rlib.test.test_libffi import get_libm_name
space = gettestobjspace(usemodules=('_ffi', '_rawffi'))
cls.space = space
cls.w_iswin32 = space.wrap(sys.platform == 'win32')
cls.w_libfoo_name = space.wrap(cls.prepare_c_example())
cls.w_libc_name = space.wrap(get_libc_name())
libm_name = get_libm_name(sys.platform)
cls.w_libm_name = space.wrap(libm_name)
libm = CDLL(libm_name)
pow = libm.getpointer('pow', [], types.void)
pow_addr = rffi.cast(rffi.LONG, pow.funcsym)
cls.w_pow_addr = space.wrap(pow_addr)
#
# these are needed for test_single_float_args
from ctypes import c_float
f_12_34 = c_float(12.34).value
f_56_78 = c_float(56.78).value
f_result = c_float(f_12_34 + f_56_78).value
cls.w_f_12_34_plus_56_78 = space.wrap(f_result)
示例6: f
# 需要导入模块: from pypy.rlib.libffi import CDLL [as 别名]
# 或者: from pypy.rlib.libffi.CDLL import getpointer [as 别名]
def f():
libc = CDLL(get_libc_name())
qsort = libc.getpointer('qsort', [ffi_type_pointer, slong,
slong, ffi_type_pointer],
ffi_type_void)
ptr = CallbackFuncPtr([ffi_type_pointer, ffi_type_pointer],
ffi_type_sint, callback)
TP = rffi.CArray(rffi.INT)
to_sort = lltype.malloc(TP, 4, flavor='raw')
to_sort[0] = 4
to_sort[1] = 3
to_sort[2] = 1
to_sort[3] = 2
qsort.push_arg(rffi.cast(rffi.VOIDP, to_sort))
qsort.push_arg(rffi.sizeof(rffi.INT))
qsort.push_arg(4)
qsort.push_arg(rffi.cast(rffi.VOIDP, ptr.ll_closure))
qsort.call(lltype.Void)
result = [to_sort[i] for i in range(4)] == [1,2,3,4]
lltype.free(to_sort, flavor='raw')
keepalive_until_here(ptr)
return int(result)