- you can now define a Python class as a synthetic children producer for a type
the class must adhere to this "interface":
def __init__(self, valobj, dict):
def get_child_at_index(self, index):
def get_child_index(self, name):
then using type synth add -l className typeName
(e.g. type synth add -l fooSynthProvider foo)
(This is still WIP with lots to be added)
A small test case is available also as reference
llvm-svn: 135865
79 lines
1.5 KiB
C++
79 lines
1.5 KiB
C++
//===---------------------PythonPointer.h ------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef utility_PythonPointer_h_
|
|
#define utility_PythonPointer_h_
|
|
|
|
#include <algorithm>
|
|
#include <memory>
|
|
|
|
#if defined (__APPLE__)
|
|
#include <Python/Python.h>
|
|
#else
|
|
#include <Python.h>
|
|
#endif
|
|
|
|
namespace lldb_private {
|
|
|
|
template<class T>
|
|
class PythonPointer
|
|
{
|
|
public:
|
|
typedef PyObject* element_type;
|
|
private:
|
|
element_type* ptr_;
|
|
bool my_ref;
|
|
public:
|
|
|
|
PythonPointer(element_type p, bool steal_ref = false) :
|
|
ptr_(p),
|
|
my_ref(!steal_ref)
|
|
{
|
|
if (my_ref)
|
|
Py_INCREF(ptr_);
|
|
}
|
|
|
|
PythonPointer(const PythonPointer& r, bool steal_ref = false) :
|
|
ptr_(r.ptr_),
|
|
my_ref(!steal_ref)
|
|
{
|
|
if (my_ref)
|
|
Py_INCREF(ptr_);
|
|
}
|
|
|
|
~PythonPointer()
|
|
{
|
|
if (my_ref)
|
|
Py_XDECREF(ptr_);
|
|
}
|
|
|
|
PythonPointer
|
|
StealReference()
|
|
{
|
|
return PythonPointer(ptr_,true);
|
|
}
|
|
|
|
PythonPointer
|
|
DuplicateReference()
|
|
{
|
|
return PythonPointer(ptr_, false);
|
|
}
|
|
|
|
element_type get() const {return ptr_;}
|
|
|
|
bool IsNull() { return ptr_ == NULL; }
|
|
bool IsNone() { return ptr_ == Py_None; }
|
|
|
|
operator PyObject* () { return ptr_; }
|
|
};
|
|
|
|
} // namespace lldb
|
|
|
|
#endif // utility_PythonPointer_h_
|