示例#1
0
    def descr_from_buffer(self, w_python_buffer):
        """\
Return a <cdata 'char[]'> that points to the data of the given Python
object, which must support the buffer interface.  Note that this is
not meant to be used on the built-in types str, unicode, or bytearray
(you can build 'char[]' arrays explicitly) but only on objects
containing large quantities of raw data in some other format, like
'array.array' or numpy arrays."""
        #
        w_ctchara = newtype._new_chara_type(self.space)
        return func.from_buffer(self.space, w_ctchara, w_python_buffer)
示例#2
0
文件: ffi_obj.py 项目: pypyjs/pypy
    def descr_from_buffer(self, w_python_buffer):
        """\
Return a <cdata 'char[]'> that points to the data of the given Python
object, which must support the buffer interface.  Note that this is
not meant to be used on the built-in types str, unicode, or bytearray
(you can build 'char[]' arrays explicitly) but only on objects
containing large quantities of raw data in some other format, like
'array.array' or numpy arrays."""
        #
        w_ctchara = newtype._new_chara_type(self.space)
        return func.from_buffer(self.space, w_ctchara, w_python_buffer)
示例#3
0
    def descr_from_buffer(self, w_cdecl, w_python_buffer=None,
                                require_writable=0):
        """\
Return a <cdata 'char[]'> that points to the data of the given Python
object, which must support the buffer interface.  Note that this is
not meant to be used on the built-in types str or unicode
(you can build 'char[]' arrays explicitly) but only on objects
containing large quantities of raw data in some other format, like
'array.array' or numpy arrays."""
        #
        if w_python_buffer is None:
            w_python_buffer = w_cdecl
            w_ctype = newtype._new_chara_type(self.space)
        else:
            w_ctype = self.ffi_type(w_cdecl, ACCEPT_STRING | ACCEPT_CTYPE)
        return func.from_buffer(self.space, w_ctype, w_python_buffer,
                                require_writable)