1 //===-- SWIG Interface for SBFile -----------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
21 %feature("docstring", "
22 Initialize a SBFile from a file descriptor. mode is
23 'r', 'r+', or 'w', like fdopen.");
24 SBFile(int fd, const char *mode, bool transfer_ownership);
26 %feature("docstring", "initialize a SBFile from a python file object");
30 static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
31 return lldb::SBFile(BORROWED);
33 static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
34 return lldb::SBFile(FORCE_IO_METHODS);
36 static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
37 return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
44 def Create(cls, file, borrow=False, force_io_methods=False):
46 Create a SBFile from a python file object, with options.
48 If borrow is set then the underlying file will
49 not be closed when the SBFile is closed or destroyed.
51 If force_scripting_io is set then the python read/write
52 methods will be called even if a file descriptor is available.
56 return cls.MakeBorrowedForcingIOMethods(file)
58 return cls.MakeBorrowed(file)
61 return cls.MakeForcingIOMethods(file)
69 %feature("autodoc", "Read(buffer) -> SBError, bytes_read") Read;
70 SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
72 %feature("autodoc", "Write(buffer) -> SBError, written_read") Write;
73 SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
79 operator bool() const;
83 %feature("docstring", "
84 Convert this SBFile into a python io.IOBase file object.
86 If the SBFile is itself a wrapper around a python file object,
87 this will return that original object.
89 The file returned from here should be considered borrowed,
90 in the sense that you may read and write to it, and flush it,
91 etc, but you should not close it. If you want to close the
92 SBFile, call SBFile.Close().
94 If there is no underlying python file to unwrap, GetFile will
95 use the file descriptor, if available to create a new python
96 file object using `open(fd, mode=..., closefd=False)`