1 //===-- PythonDataObjects.h----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_PythonDataObjects_h_
11 #define liblldb_PythonDataObjects_h_
16 // Other libraries and framework includes
18 #include "lldb/lldb-defines.h"
19 #include "lldb/Core/ConstString.h"
20 #include "lldb/Core/Flags.h"
21 #include "lldb/Interpreter/OptionValue.h"
22 #if defined (__APPLE__)
23 #include <Python/Python.h>
28 namespace lldb_private {
38 PythonObject (PyObject* py_obj) :
44 PythonObject (const PythonObject &rhs) :
50 PythonObject (const lldb::ScriptInterpreterObjectSP &script_object_sp);
59 operator = (const PythonObject &rhs)
67 Reset (const PythonObject &object)
69 return Reset(object.GetPythonObject());
73 Reset (PyObject* py_obj = NULL)
75 if (py_obj != m_py_obj)
88 _PyObject_Dump (m_py_obj);
94 Dump (Stream &strm) const;
97 GetPythonObject () const
108 operator bool () const
110 return m_py_obj != NULL;
117 class PythonString: public PythonObject
122 PythonString (PyObject *o);
123 PythonString (const PythonObject &object);
124 PythonString (const lldb::ScriptInterpreterObjectSP &script_object_sp);
125 PythonString (const char* string);
126 virtual ~PythonString ();
129 Reset (PyObject* py_obj = NULL);
138 SetString (const char* string);
141 class PythonInteger: public PythonObject
146 PythonInteger (PyObject* py_obj);
147 PythonInteger (const PythonObject &object);
148 PythonInteger (const lldb::ScriptInterpreterObjectSP &script_object_sp);
149 PythonInteger (int64_t value);
150 virtual ~PythonInteger ();
153 Reset (PyObject* py_obj = NULL);
159 SetInteger (int64_t value);
162 class PythonList: public PythonObject
167 PythonList (PyObject* py_obj);
168 PythonList (const PythonObject &object);
169 PythonList (const lldb::ScriptInterpreterObjectSP &script_object_sp);
170 PythonList (uint32_t count);
171 virtual ~PythonList ();
174 Reset (PyObject* py_obj = NULL);
180 GetItemAtIndex (uint32_t index);
183 SetItemAtIndex (uint32_t index, const PythonObject &object);
186 AppendItem (const PythonObject &object);
189 class PythonDictionary: public PythonObject
194 PythonDictionary (PyObject* object);
195 PythonDictionary (const PythonObject &object);
196 PythonDictionary (const lldb::ScriptInterpreterObjectSP &script_object_sp);
197 virtual ~PythonDictionary ();
200 Reset (PyObject* object = NULL);
205 GetItemForKey (const PythonString &key) const;
208 GetItemForKeyAsString (const PythonString &key, const char *fail_value = NULL) const;
211 GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value = 0) const;
214 GetItemForKey (const char *key) const;
216 typedef bool (*DictionaryIteratorCallback)(PythonString* key, PythonDictionary* dict);
222 GetKeyAtPosition (uint32_t pos) const;
225 GetValueAtPosition (uint32_t pos) const;
228 SetItemForKey (const PythonString &key, const PythonObject& value);
231 } // namespace lldb_private
233 #endif // liblldb_PythonDataObjects_h_