zturner added inline comments.
================
Comment at:
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1075-1096
+static int readfn(void *ctx, char *buffer, int n)
+{
+ auto state = PyGILState_Ensure();
+ auto *file = (PyObject *) ctx;
+ int result = -1;
+ auto pybuffer = PyBuffer_FromMemory(buffer, n);
+ PyObject *pyresult = NULL;
----------------
I am still pretty unhappy about these functions, and passing function pointers
into the `File` class.
I think another approach would be this:
1) Make the `File` class contain a member `std::unique_ptr<IOObject>
LowLevelIo;`
2) In `File.cpp`, define something called `class DefaultLowLevelIo : public
IOObject` that implements the virtual methods against an fd.
3) In `PythonDataObjects`, define `PythonFileIo : public IOObject` and
implement the virtual methods against a `PyObject`.
4) Add an additional constructor to `File` which takes a
`std::unique_ptr<IOObject> LowLevelIo`, which we can use when creating one of
these from a python file.
One advantage of this method is that it allows the `PythonFileIo` class to be
easily tested.
(Also, sorry for not getting back to reviewing this several weeks ago)
Repository:
rL LLVM
https://reviews.llvm.org/D38829
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits