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)
76 _PyObject_Dump (m_py_obj);
82 Dump (Stream &strm) const;
96 explicit operator bool () const
98 return m_py_obj != NULL;
102 IsNULLOrNone () const;
108 class PythonString: public PythonObject
113 PythonString (PyObject *o);
114 PythonString (const PythonObject &object);
115 PythonString (const lldb::ScriptInterpreterObjectSP &script_object_sp);
116 PythonString (const char* string);
117 virtual ~PythonString ();
120 Reset (PyObject* py_obj = NULL);
129 SetString (const char* string);
132 class PythonInteger: public PythonObject
137 PythonInteger (PyObject* py_obj);
138 PythonInteger (const PythonObject &object);
139 PythonInteger (const lldb::ScriptInterpreterObjectSP &script_object_sp);
140 PythonInteger (int64_t value);
141 virtual ~PythonInteger ();
144 Reset (PyObject* py_obj = NULL);
150 SetInteger (int64_t value);
153 class PythonList: public PythonObject
157 PythonList (bool create_empty);
158 PythonList (PyObject* py_obj);
159 PythonList (const PythonObject &object);
160 PythonList (const lldb::ScriptInterpreterObjectSP &script_object_sp);
161 PythonList (uint32_t count);
162 virtual ~PythonList ();
165 Reset (PyObject* py_obj = NULL);
171 GetItemAtIndex (uint32_t index);
174 SetItemAtIndex (uint32_t index, const PythonObject &object);
177 AppendItem (const PythonObject &object);
180 class PythonDictionary: public PythonObject
184 explicit PythonDictionary (bool create_empty);
185 PythonDictionary (PyObject* object);
186 PythonDictionary (const PythonObject &object);
187 PythonDictionary (const lldb::ScriptInterpreterObjectSP &script_object_sp);
188 virtual ~PythonDictionary ();
191 Reset (PyObject* object = NULL);
196 GetItemForKey (const PythonString &key) const;
199 GetItemForKeyAsString (const PythonString &key, const char *fail_value = NULL) const;
202 GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value = 0) const;
205 GetItemForKey (const char *key) const;
207 typedef bool (*DictionaryIteratorCallback)(PythonString* key, PythonDictionary* dict);
213 GetKeyAtPosition (uint32_t pos) const;
216 GetValueAtPosition (uint32_t pos) const;
219 SetItemForKey (const PythonString &key, PyObject *value);
222 SetItemForKey (const PythonString &key, const PythonObject& value);
225 } // namespace lldb_private
227 #endif // liblldb_PythonDataObjects_h_