[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

Lawrence D'Anna via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 30 17:01:50 PDT 2019


lawrence_danna marked 2 inline comments as done.
lawrence_danna added inline comments.


================
Comment at: lldb/include/lldb/API/SBFile.h:16-21
+/* These tags make no difference at the c++ level, but
+ * when the constructors are called from python they control
+ * how python files are converted by SWIG into FileSP */
+struct FileBorrow {};
+struct FileForceScriptingIO {};
+struct FileBorrowAndForceScriptingIO {};
----------------
labath wrote:
> I don't think we have anything similar to this in any of our SB classes. It might be better to avoid it. Could the same thing be achieved e.g. with a static factory function (`static SBFile SBFile::Create(FileSP file_sp, bool borrow, bool force_scripting_io)`) ?
I don't think it can be done that way, because we want those bools to control how the python object is translated into a C++ object, so we need a different swig wrapper for each possibility, which means we need a different c++ function to wrap  for each possibility.

One way around this would be to have SWIG translate the python object into an intermediate object that just takes a reference, and then perform further translation inside the SB layer.    But we can't do that either, because scripting support is not part of the base LLDB library, it's a plugin.    And in fact Xcode ships two versions of the plugin, one for python2 and one for python3.    The SB needs to be agnostic about different versions of python, so it can't do the translation itself.   


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68188/new/

https://reviews.llvm.org/D68188





More information about the lldb-commits mailing list