xref: /freebsd/contrib/llvm-project/lldb/bindings/interface/SBFileExtensions.i (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1 %extend lldb::SBFile {
MakeBorrowed(lldb::FileSP BORROWED)2     static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
3         return lldb::SBFile(BORROWED);
4     }
MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS)5     static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
6         return lldb::SBFile(FORCE_IO_METHODS);
7     }
MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS)8     static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
9         return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
10     }
11 
12 #ifdef SWIGPYTHON
13     %pythoncode {
14         @classmethod
15         def Create(cls, file, borrow=False, force_io_methods=False):
16             """
17             Create a SBFile from a python file object, with options.
18 
19             If borrow is set then the underlying file will
20             not be closed when the SBFile is closed or destroyed.
21 
22             If force_scripting_io is set then the python read/write
23             methods will be called even if a file descriptor is available.
24             """
25             if borrow:
26                 if force_io_methods:
27                     return cls.MakeBorrowedForcingIOMethods(file)
28                 else:
29                     return cls.MakeBorrowed(file)
30             else:
31                 if force_io_methods:
32                     return cls.MakeForcingIOMethods(file)
33                 else:
34                     return cls(file)
35     }
36 #endif
37 }
38