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 #include "lldb/lldb-python.h"
24 namespace lldb_private {
34 explicit PythonObject (PyObject* py_obj) :
40 PythonObject (const PythonObject &rhs) :
46 explicit PythonObject (const lldb::ScriptInterpreterObjectSP &script_object_sp);
55 Reset (const PythonObject &object)
57 return Reset(object.get());
61 Reset (PyObject* py_obj = NULL)
63 if (py_obj != m_py_obj)
65 if (Py_IsInitialized())
68 if (Py_IsInitialized())
78 _PyObject_Dump (m_py_obj);
84 Dump (Stream &strm) const;
98 explicit operator bool () const
100 return m_py_obj != NULL;
104 IsNULLOrNone () const;
110 class PythonString: public PythonObject
115 PythonString (PyObject *o);
116 PythonString (const PythonObject &object);
117 PythonString (const lldb::ScriptInterpreterObjectSP &script_object_sp);
118 PythonString (const char* string);
119 virtual ~PythonString ();
122 Reset (PyObject* py_obj = NULL);
131 SetString (const char* string);
134 class PythonInteger: public PythonObject
139 PythonInteger (PyObject* py_obj);
140 PythonInteger (const PythonObject &object);
141 PythonInteger (const lldb::ScriptInterpreterObjectSP &script_object_sp);
142 PythonInteger (int64_t value);
143 virtual ~PythonInteger ();
146 Reset (PyObject* py_obj = NULL);
152 SetInteger (int64_t value);
155 class PythonList: public PythonObject
159 PythonList (bool create_empty);
160 PythonList (PyObject* py_obj);
161 PythonList (const PythonObject &object);
162 PythonList (const lldb::ScriptInterpreterObjectSP &script_object_sp);
163 PythonList (uint32_t count);
164 virtual ~PythonList ();
167 Reset (PyObject* py_obj = NULL);
173 GetItemAtIndex (uint32_t index);
176 SetItemAtIndex (uint32_t index, const PythonObject &object);
179 AppendItem (const PythonObject &object);
182 class PythonDictionary: public PythonObject
186 explicit PythonDictionary (bool create_empty);
187 PythonDictionary (PyObject* object);
188 PythonDictionary (const PythonObject &object);
189 PythonDictionary (const lldb::ScriptInterpreterObjectSP &script_object_sp);
190 virtual ~PythonDictionary ();
193 Reset (PyObject* object = NULL);
198 GetItemForKey (const PythonString &key) const;
201 GetItemForKeyAsString (const PythonString &key, const char *fail_value = NULL) const;
204 GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value = 0) const;
207 GetItemForKey (const char *key) const;
209 typedef bool (*DictionaryIteratorCallback)(PythonString* key, PythonDictionary* dict);
215 GetKeyAtPosition (uint32_t pos) const;
218 GetValueAtPosition (uint32_t pos) const;
221 SetItemForKey (const PythonString &key, PyObject *value);
224 SetItemForKey (const PythonString &key, const PythonObject& value);
227 } // namespace lldb_private
229 #endif // liblldb_PythonDataObjects_h_