本文整理汇总了Python中pypy.translator.c.database.LowLevelDatabase.gettype方法的典型用法代码示例。如果您正苦于以下问题:Python LowLevelDatabase.gettype方法的具体用法?Python LowLevelDatabase.gettype怎么用?Python LowLevelDatabase.gettype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.translator.c.database.LowLevelDatabase
的用法示例。
在下文中一共展示了LowLevelDatabase.gettype方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_typedef
# 需要导入模块: from pypy.translator.c.database import LowLevelDatabase [as 别名]
# 或者: from pypy.translator.c.database.LowLevelDatabase import gettype [as 别名]
def test_typedef():
A = Typedef(Signed, 'test4')
db = LowLevelDatabase()
assert db.gettype(A) == "test4 @"
PA = CArrayPtr(A)
assert db.gettype(PA) == "test4 *@"
F = FuncType((A,), A)
assert db.gettype(F) == "test4 (@)(test4)"
示例2: generate_macro_wrapper
# 需要导入模块: from pypy.translator.c.database import LowLevelDatabase [as 别名]
# 或者: from pypy.translator.c.database.LowLevelDatabase import gettype [as 别名]
def generate_macro_wrapper(name, macro, functype, eci):
"""Wraps a function-like macro inside a real function, and expose
it with llexternal."""
# Generate the function call
from pypy.translator.c.database import LowLevelDatabase
from pypy.translator.c.support import cdecl
wrapper_name = 'pypy_macro_wrapper_%s' % (name,)
argnames = ['arg%d' % (i,) for i in range(len(functype.ARGS))]
db = LowLevelDatabase()
implementationtypename = db.gettype(functype, argnames=argnames)
if functype.RESULT is lltype.Void:
pattern = '%s { %s(%s); }'
else:
pattern = '%s { return %s(%s); }'
source = pattern % (
cdecl(implementationtypename, wrapper_name),
macro, ', '.join(argnames))
# Now stuff this source into a "companion" eci that will be used
# by ll2ctypes. We replace eci._with_ctypes, so that only one
# shared library is actually compiled (when ll2ctypes calls the
# first function)
ctypes_eci = eci.merge(ExternalCompilationInfo(
separate_module_sources=[source],
export_symbols=[wrapper_name],
))
if hasattr(eci, '_with_ctypes'):
ctypes_eci = eci._with_ctypes.merge(ctypes_eci)
eci._with_ctypes = ctypes_eci
func = llexternal(wrapper_name, functype.ARGS, functype.RESULT,
compilation_info=eci, _nowrapper=True)
# _nowrapper=True returns a pointer which is not hashable
return lambda *args: func(*args)
示例3: test_intlong_unique
# 需要导入模块: from pypy.translator.c.database import LowLevelDatabase [as 别名]
# 或者: from pypy.translator.c.database.LowLevelDatabase import gettype [as 别名]
def test_intlong_unique():
A = INT_real
B = Signed
db = LowLevelDatabase()
assert db.gettype(A) == "int @"
assert db.gettype(B) == "long @"
示例4: test_voidp
# 需要导入模块: from pypy.translator.c.database import LowLevelDatabase [as 别名]
# 或者: from pypy.translator.c.database.LowLevelDatabase import gettype [as 别名]
def test_voidp():
A = VOIDP
db = LowLevelDatabase()
assert db.gettype(A) == "void *@"