当前位置: 首页>>代码示例>>Python>>正文


Python CDLL.getpointer方法代码示例

本文整理汇总了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)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:test_zrpy_releasegil.py

示例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)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:14,代码来源:test_funcptr.py

示例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
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:15,代码来源:test_ztranslation.py

示例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
开发者ID:overminder,项目名称:YASI,代码行数:16,代码来源:ffi.py

示例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)
开发者ID:ieure,项目名称:pypy,代码行数:24,代码来源:test__ffi.py

示例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)
开发者ID:alkorzt,项目名称:pypy,代码行数:26,代码来源:test_newgc.py


注:本文中的pypy.rlib.libffi.CDLL.getpointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。