summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-10-23 16:49:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-10-23 16:49:03 +0000
commit1695466fe3ec8f62176ec5c3793e580cfd4f3d5b (patch)
tree718dca4a06d30b313df033fa5498537b5040c077
parentd34a329c6843aca1f15d450d33530d6b4ca4e344 (diff)
downloadbcm5719-llvm-1695466fe3ec8f62176ec5c3793e580cfd4f3d5b.tar.gz
bcm5719-llvm-1695466fe3ec8f62176ec5c3793e580cfd4f3d5b.zip
Move Python.h includes out of the headers into the .cpp file where it's actually used.
Python.h includes a ton of macros that can cause weird behavior down the road. llvm-svn: 142754
-rw-r--r--lldb/include/lldb/Core/FormatClasses.h14
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreterPython.h8
-rw-r--r--lldb/source/Core/FormatClasses.cpp12
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp15
4 files changed, 24 insertions, 25 deletions
diff --git a/lldb/include/lldb/Core/FormatClasses.h b/lldb/include/lldb/Core/FormatClasses.h
index 59906f1626f..cf9258ae9fb 100644
--- a/lldb/include/lldb/Core/FormatClasses.h
+++ b/lldb/include/lldb/Core/FormatClasses.h
@@ -11,13 +11,6 @@
#define lldb_FormatClasses_h_
// C Includes
-
-#if defined (__APPLE__)
-#include <Python/Python.h>
-#else
-#include <Python.h>
-#endif
-
#include <stdint.h>
#include <unistd.h>
@@ -302,7 +295,7 @@ public:
{
private:
std::string m_python_class;
- PyObject* m_wrapper;
+ void *m_wrapper; // Wraps PyObject.
ScriptInterpreter *m_interpreter;
public:
@@ -310,10 +303,7 @@ public:
lldb::ValueObjectSP be);
virtual
- ~FrontEnd()
- {
- Py_XDECREF(m_wrapper);
- }
+ ~FrontEnd();
virtual uint32_t
CalculateNumChildren()
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
index 0ddaa7ff84f..1ac32722903 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
@@ -11,12 +11,6 @@
#ifndef liblldb_ScriptInterpreterPython_h_
#define liblldb_ScriptInterpreterPython_h_
-#if defined (__APPLE__)
-#include <Python/Python.h>
-#else
-#include <Python.h>
-#endif
-
#include "lldb/lldb-private.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Core/InputReader.h"
@@ -197,7 +191,7 @@ private:
lldb_utility::PseudoTerminal m_embedded_python_pty;
lldb::InputReaderSP m_embedded_thread_input_reader_sp;
FILE *m_dbg_stdout;
- PyObject *m_new_sysout;
+ void *m_new_sysout; // This is a PyObject.
std::string m_dictionary_name;
TerminalState m_terminal_state;
bool m_session_is_active;
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp
index abfb7fdd553..ef067344480 100644
--- a/lldb/source/Core/FormatClasses.cpp
+++ b/lldb/source/Core/FormatClasses.cpp
@@ -8,6 +8,11 @@
//===----------------------------------------------------------------------===//
// C Includes
+#if defined (__APPLE__)
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
// C++ Includes
#include <ostream>
@@ -243,7 +248,12 @@ SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass,
if (m_interpreter == NULL)
m_wrapper = NULL;
else
- m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
+ m_wrapper = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
+}
+
+SyntheticScriptProvider::FrontEnd::~FrontEnd()
+{
+ Py_XDECREF((PyObject*)m_wrapper);
}
lldb::ValueObjectSP
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 6b71c82b4e8..70fb3f8237c 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -8,8 +8,13 @@
//===----------------------------------------------------------------------===//
// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included in ScriptInterpreterPython.h, and that
-// must be the *FIRST* header file included here.
+// the *FIRST* header file included here.
+
+#if defined (__APPLE__)
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
#include "lldb/Interpreter/ScriptInterpreterPython.h"
@@ -242,11 +247,11 @@ ScriptInterpreterPython::~ScriptInterpreterPython ()
{
while (!GetPythonLock (1))
fprintf (tmp_fh, "Python interpreter locked on another thread; waiting to acquire lock...\n");
- Py_DECREF (m_new_sysout);
+ Py_DECREF ((PyObject*)m_new_sysout);
ReleasePythonLock ();
}
else
- Py_DECREF (m_new_sysout);
+ Py_DECREF ((PyObject*)m_new_sysout);
}
}
@@ -358,7 +363,7 @@ ScriptInterpreterPython::EnterSession ()
if ((m_new_sysout != NULL)
&& (sysmod != NULL)
&& (sysdict != NULL))
- PyDict_SetItemString (sysdict, "stdout", m_new_sysout);
+ PyDict_SetItemString (sysdict, "stdout", (PyObject*)m_new_sysout);
if (PyErr_Occurred())
PyErr_Clear ();
OpenPOWER on IntegriCloud