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