remove FILE* usage from SBStream.i

Summary:
This patch removes FILE* and replaces it with SBFile and FileSP the
SWIG interface for `SBStream.i`.   And this is the last one.   With
this change, nothing in the python API will can access a FILE* method
on the C++ side.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68960

llvm-svn: 374924
This commit is contained in:
Lawrence D'Anna committed 2019-10-15 17:41:40 +00:00
1 parent fdfd6ab12e
commit 30cf609548
4 files changed
+59 -3

No files matched your search

+16 -2
View File
@@ -9,6 +9,7 @@
#include "lldb/API/SBStream.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBFile.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/Status.h"
@@ -108,8 +109,19 @@ void SBStream::RedirectToFile(const char *path, bool append) {
void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
LLDB_RECORD_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool), fh,
transfer_fh_ownership);
FileSP file = std::make_unique<NativeFile>(fh, transfer_fh_ownership);
return RedirectToFile(file);
}
if (fh == nullptr)
void SBStream::RedirectToFile(SBFile file) {
LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (SBFile), file)
RedirectToFile(file.GetFile());
}
void SBStream::RedirectToFile(FileSP file_sp) {
LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (FileSP), file_sp);
if (!file_sp || !file_sp->IsValid())
return;
std::string local_data;
@@ -120,7 +132,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
m_opaque_up = std::make_unique<StreamFile>(fh, transfer_fh_ownership);
m_opaque_up = std::make_unique<StreamFile>(file_sp);
m_is_file = true;
// If we had any data locally in our StreamString, then pass that along to
@@ -184,6 +196,8 @@ void RegisterMethods<SBStream>(Registry &R) {
LLDB_REGISTER_METHOD(const char *, SBStream, GetData, ());
LLDB_REGISTER_METHOD(size_t, SBStream, GetSize, ());
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (const char *, bool));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (FileSP));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (SBFile));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
LLDB_REGISTER_METHOD(void, SBStream, Clear, ());