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 PythonObject (PyObject* py_obj) :
40 PythonObject (const PythonObject &rhs) :
46 PythonObject (const lldb::ScriptInterpreterObjectSP &script_object_sp);
55 operator = (const PythonObject &rhs)
63 Reset (const PythonObject &object)
65 return Reset(object.GetPythonObject());
69 Reset (PyObject* py_obj = NULL)
71 if (py_obj != m_py_obj)
84 _PyObject_Dump (m_py_obj);
90 Dump (Stream &strm) const;
93 GetPythonObject () const
104 explicit operator bool () const
106 return m_py_obj != NULL;
113 class PythonString: public PythonObject
118 PythonString (PyObject *o);
119 PythonString (const PythonObject &object);
120 PythonString (const lldb::ScriptInterpreterObjectSP &script_object_sp);
121 PythonString (const char* string);
122 virtual ~PythonString ();
125 Reset (PyObject* py_obj = NULL);
134 SetString (const char* string);
137 class PythonInteger: public PythonObject
142 PythonInteger (PyObject* py_obj);
143 PythonInteger (const PythonObject &object);
144 PythonInteger (const lldb::ScriptInterpreterObjectSP &script_object_sp);
145 PythonInteger (int64_t value);
146 virtual ~PythonInteger ();
149 Reset (PyObject* py_obj = NULL);
155 SetInteger (int64_t value);
158 class PythonList: public PythonObject
163 PythonList (PyObject* py_obj);
164 PythonList (const PythonObject &object);
165 PythonList (const lldb::ScriptInterpreterObjectSP &script_object_sp);
166 PythonList (uint32_t count);
167 virtual ~PythonList ();
170 Reset (PyObject* py_obj = NULL);
176 GetItemAtIndex (uint32_t index);
179 SetItemAtIndex (uint32_t index, const PythonObject &object);
182 AppendItem (const PythonObject &object);
185 class PythonDictionary: public PythonObject
190 PythonDictionary (PyObject* object);
191 PythonDictionary (const PythonObject &object);
192 PythonDictionary (const lldb::ScriptInterpreterObjectSP &script_object_sp);
193 virtual ~PythonDictionary ();
196 Reset (PyObject* object = NULL);
201 GetItemForKey (const PythonString &key) const;
204 GetItemForKeyAsString (const PythonString &key, const char *fail_value = NULL) const;
207 GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value = 0) const;
210 GetItemForKey (const char *key) const;
212 typedef bool (*DictionaryIteratorCallback)(PythonString* key, PythonDictionary* dict);
218 GetKeyAtPosition (uint32_t pos) const;
221 GetValueAtPosition (uint32_t pos) const;
224 SetItemForKey (const PythonString &key, const PythonObject& value);
227 } // namespace lldb_private
229 #endif // liblldb_PythonDataObjects_h_