This is an archive of the discontinued LLVM Phabricator instance.

[Python] Remove Python include from ScriptInterpreterPython.h
ClosedPublic

Authored by JDevlieghere on Mar 28 2019, 7:00 PM.

Details

Summary

This patch limits the scope of the python header to the python script interpreter plugin by removing the include from ScriptInterpreterPython.h. To make that possible I had to forward declare the PythonDataObjects and move the PythonScriptInterpreterLocker into ScriptInterpreterPython.cpp.

Diff Detail

Event Timeline

JDevlieghere created this revision.Mar 28 2019, 7:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2019, 7:00 PM
Herald added a subscriber: abidh. · View Herald Transcript
labath added a subscriber: labath.Mar 29 2019, 12:26 AM
labath added inline comments.
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
53–69

Instead of pimpl-ing each individual field, what if we just have one struct which contains all of these fields, and pimpl that?

This should make things more efficient (less heap traffic), and allow you to cut down on the number of forward declarations (particularly the ones from python headers worry me).

327

You could still keep this class inside ScriptInterpreterPython, and just forward-declare it in the header.
The cpp file can define it as class ScriptInterpreterPython::Locker.

lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
35

Python headers are fun. :)

Btw, I really like this cleanup.

labath added inline comments.Mar 29 2019, 1:33 AM
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
53–69

In fact, since ScriptInterpreterPython is already polymorphic, we might not need to pimpl anything at all. Since the only place where we create an instance if this class is the static Create function, we could just have that function create a subclass of ScriptInterpreterPython (and make ScriptInterpreterPython by moving all non-interface stuff into the subclass). WDYT?

Make ScriptInterpreterPython abstract.

labath accepted this revision.Mar 29 2019, 1:03 PM
labath added inline comments.
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
1229–1230

The ScriptInterpreterPythonImpl qualification on the Locker class is probably overkill. (I know it was present before this patch, but it's overkill there too :P ).

This revision is now accepted and ready to land.Mar 29 2019, 1:03 PM
JDevlieghere marked an inline comment as done.Mar 29 2019, 1:09 PM

Thanks for the review, Pavel!

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
1229–1230

Makes sense, I'll remove it before landing.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2019, 1:17 PM