SBFile.i
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//===-- SWIG Interface for SBFile -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a file."
) SBFile;
class SBFile
{
public:
SBFile();
%feature("docstring", "
Initialize a SBFile from a file descriptor. mode is
'r', 'r+', or 'w', like fdopen.");
SBFile(int fd, const char *mode, bool transfer_ownership);
%feature("docstring", "initialize a SBFile from a python file object");
SBFile(FileSP file);
%extend {
static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
return lldb::SBFile(BORROWED);
}
static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
return lldb::SBFile(FORCE_IO_METHODS);
}
static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
}
}
#ifdef SWIGPYTHON
%pythoncode {
@classmethod
def Create(cls, file, borrow=False, force_io_methods=False):
"""
Create a SBFile from a python file object, with options.
If borrow is set then the underlying file will
not be closed when the SBFile is closed or destroyed.
If force_scripting_io is set then the python read/write
methods will be called even if a file descriptor is available.
"""
if borrow:
if force_io_methods:
return cls.MakeBorrowedForcingIOMethods(file)
else:
return cls.MakeBorrowed(file)
else:
if force_io_methods:
return cls.MakeForcingIOMethods(file)
else:
return cls(file)
}
#endif
~SBFile ();
%feature("autodoc", "Read(buffer) -> SBError, bytes_read") Read;
SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
%feature("autodoc", "Write(buffer) -> SBError, written_read") Write;
SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
void Flush();
bool IsValid() const;
operator bool() const;
SBError Close();
%feature("docstring", "
Convert this SBFile into a python io.IOBase file object.
If the SBFile is itself a wrapper around a python file object,
this will return that original object.
The file returned from here should be considered borrowed,
in the sense that you may read and write to it, and flush it,
etc, but you should not close it. If you want to close the
SBFile, call SBFile.Close().
If there is no underlying python file to unwrap, GetFile will
use the file descriptor, if available to create a new python
file object using `open(fd, mode=..., closefd=False)`
");
FileSP GetFile();
};
} // namespace lldb