summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-09 19:45:41 +0000
committerZachary Turner <zturner@google.com>2015-10-09 19:45:41 +0000
commit22c8efcd3446c59415e2c65ae230668b0563c714 (patch)
tree3ab230bf5389c955af13430300da435f36181adc /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
parent3a1acdd9557e0eb0393ad84809a89753bcc5b49f (diff)
downloadbcm5719-llvm-22c8efcd3446c59415e2c65ae230668b0563c714.tar.gz
bcm5719-llvm-22c8efcd3446c59415e2c65ae230668b0563c714.zip
Port native Python-API to 3.x
With this change, liblldb is 95% of the way towards being able to work under both Python 2.x and Python 3.x. This should introduce no functional change for Python 2.x, but for Python 3.x there are some important changes. Primarily, these are: 1) PyString doesn't exist in Python 3. Everything is a PyUnicode. To account for this, PythonString now stores a PyBytes instead of a PyString. In Python 2, this is equivalent to a PyUnicode, and in Python 3, we do a conversion from PyUnicode to PyBytes and store the PyBytes. 2) PyInt doesn't exist in Python 3. Everything is a PyLong. To account for this, PythonInteger stores a PyLong instead of a PyInt. In Python 2.x, this requires doing a conversion to PyLong when creating a PythonInteger from a PyInt. In 3.x, there is no PyInt anyway, so we can assume everything is a PyLong. 3) PyFile_FromFile doesn't exist in Python 3. Instead there is a PyFile_FromFd. This is not addressed in this patch because it will require quite a large change to plumb fd's all the way through the system into the ScriptInterpreter. This is the only remaining piece of the puzzle to get LLDB supporting Python 3.x. Being able to run the test suite is not addressed in this patch. After the extension module can compile and you can enter an embedded 3.x interpreter, the test suite will be addressed in a followup. llvm-svn: 249886
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 43963589cc1..33275d55468 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -156,7 +156,7 @@ enum class PyObjectType
protected:
PyObject* m_py_obj;
};
-
+
class PythonString: public PythonObject
{
public:
@@ -167,6 +167,8 @@ enum class PyObjectType
PythonString (const char *string);
virtual ~PythonString ();
+ static bool Check(PyObject *py_obj);
+
virtual bool
Reset (PyObject* py_obj = NULL);
@@ -180,7 +182,7 @@ enum class PyObjectType
StructuredData::StringSP CreateStructuredString() const;
};
-
+
class PythonInteger: public PythonObject
{
public:
@@ -190,7 +192,9 @@ enum class PyObjectType
PythonInteger (const PythonObject &object);
PythonInteger (int64_t value);
virtual ~PythonInteger ();
-
+
+ static bool Check(PyObject *py_obj);
+
virtual bool
Reset (PyObject* py_obj = NULL);
@@ -205,13 +209,13 @@ enum class PyObjectType
class PythonList: public PythonObject
{
public:
-
- PythonList (bool create_empty);
+ PythonList();
PythonList (PyObject* py_obj);
PythonList (const PythonObject &object);
- PythonList (uint32_t count);
virtual ~PythonList ();
-
+
+ static bool Check(PyObject *py_obj);
+
virtual bool
Reset (PyObject* py_obj = NULL);
@@ -231,12 +235,13 @@ enum class PyObjectType
class PythonDictionary: public PythonObject
{
public:
-
- explicit PythonDictionary (bool create_empty);
+ PythonDictionary();
PythonDictionary (PyObject* object);
PythonDictionary (const PythonObject &object);
virtual ~PythonDictionary ();
-
+
+ static bool Check(PyObject *py_obj);
+
virtual bool
Reset (PyObject* object = NULL);
OpenPOWER on IntegriCloud