本文整理汇总了Python中pypy.module._cffi_backend.ctypeobj.W_CType.cast方法的典型用法代码示例。如果您正苦于以下问题:Python W_CType.cast方法的具体用法?Python W_CType.cast怎么用?Python W_CType.cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.module._cffi_backend.ctypeobj.W_CType
的用法示例。
在下文中一共展示了W_CType.cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cast
# 需要导入模块: from pypy.module._cffi_backend.ctypeobj import W_CType [as 别名]
# 或者: from pypy.module._cffi_backend.ctypeobj.W_CType import cast [as 别名]
def cast(self, w_ob):
# cast to a pointer, to a funcptr, or to an array.
# Note that casting to an array is an extension to the C language,
# which seems to be necessary in order to sanely get a
# <cdata 'int[3]'> at some address.
if self.size < 0:
return W_CType.cast(self, w_ob)
space = self.space
if (isinstance(w_ob, cdataobj.W_CData) and
isinstance(w_ob.ctype, W_CTypePtrOrArray)):
value = w_ob._cdata
else:
value = misc.as_unsigned_long(space, w_ob, strict=False)
value = rffi.cast(rffi.CCHARP, value)
return cdataobj.W_CData(space, value, self)