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


Python W_CType.string方法代码示例

本文整理汇总了Python中pypy.module._cffi_backend.ctypeobj.W_CType.string方法的典型用法代码示例。如果您正苦于以下问题:Python W_CType.string方法的具体用法?Python W_CType.string怎么用?Python W_CType.string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.module._cffi_backend.ctypeobj.W_CType的用法示例。


在下文中一共展示了W_CType.string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: string

# 需要导入模块: from pypy.module._cffi_backend.ctypeobj import W_CType [as 别名]
# 或者: from pypy.module._cffi_backend.ctypeobj.W_CType import string [as 别名]
 def string(self, cdataobj, maxlen):
     space = self.space
     if isinstance(self.ctitem, ctypeprim.W_CTypePrimitive):
         cdata = cdataobj._cdata
         if not cdata:
             raise operationerrfmt(space.w_RuntimeError,
                                   "cannot use string() on %s",
                                   space.str_w(cdataobj.repr()))
         #
         from pypy.module._cffi_backend import ctypearray
         length = maxlen
         if length < 0 and isinstance(self, ctypearray.W_CTypeArray):
             length = cdataobj.get_array_length()
         #
         # pointer to a primitive type of size 1: builds and returns a str
         if self.ctitem.size == rffi.sizeof(lltype.Char):
             if length < 0:
                 s = rffi.charp2str(cdata)
             else:
                 s = rffi.charp2strn(cdata, length)
             keepalive_until_here(cdataobj)
             return space.wrap(s)
         #
         # pointer to a wchar_t: builds and returns a unicode
         if self.is_unichar_ptr_or_array():
             cdata = rffi.cast(rffi.CWCHARP, cdata)
             if length < 0:
                 u = rffi.wcharp2unicode(cdata)
             else:
                 u = rffi.wcharp2unicoden(cdata, length)
             keepalive_until_here(cdataobj)
             return space.wrap(u)
     #
     return W_CType.string(self, cdataobj, maxlen)
开发者ID:charred,项目名称:pypy,代码行数:36,代码来源:ctypeptr.py

示例2: string

# 需要导入模块: from pypy.module._cffi_backend.ctypeobj import W_CType [as 别名]
# 或者: from pypy.module._cffi_backend.ctypeobj.W_CType import string [as 别名]
 def string(self, cdataobj, maxlen):
     if self.size == 1:
         with cdataobj as ptr:
             s = ptr[0]
         return self.space.wrap(s)
     return W_CType.string(self, cdataobj, maxlen)
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:ctypeprim.py

示例3: string

# 需要导入模块: from pypy.module._cffi_backend.ctypeobj import W_CType [as 别名]
# 或者: from pypy.module._cffi_backend.ctypeobj.W_CType import string [as 别名]
 def string(self, cdataobj, maxlen):
     if self.size == 1:
         s = cdataobj._cdata[0]
         keepalive_until_here(cdataobj)
         return self.space.wrap(s)
     return W_CType.string(self, cdataobj, maxlen)
开发者ID:kipras,项目名称:pypy,代码行数:8,代码来源:ctypeprim.py

示例4: string

# 需要导入模块: from pypy.module._cffi_backend.ctypeobj import W_CType [as 别名]
# 或者: from pypy.module._cffi_backend.ctypeobj.W_CType import string [as 别名]
 def string(self, cdataobj, maxlen):
     # Can't use ffi.string() on a function pointer
     return W_CType.string(self, cdataobj, maxlen)
开发者ID:mozillazg,项目名称:pypy,代码行数:5,代码来源:ctypefunc.py


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