From a37a065c3392ab52abd6a896ac1e95b4878cafad Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Sun, 24 Jul 2011 00:14:56 +0000 Subject: Python synthetic children: - 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 --- lldb/source/Core/FormatClasses.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lldb/source/Core/FormatClasses.cpp') diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index f301a7bbc3a..9a232ae7af4 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -21,8 +21,10 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatClasses.h" #include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -156,3 +158,25 @@ SyntheticFilter::GetDescription() sstr.Printf("}"); return sstr.GetString(); } + +SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, + lldb::ValueObjectSP be) : +SyntheticChildrenFrontEnd(be), +m_python_class(pclass) +{ + m_interpreter = be->GetUpdatePoint().GetTarget()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); +} + +std::string +SyntheticScriptProvider::GetDescription() +{ + StreamString sstr; + sstr.Printf("%s%s%s Python class: %s", + m_cascades ? "" : " (not cascading)", + m_skip_pointers ? " (skip pointers)" : "", + m_skip_references ? " (skip references)" : "", + m_python_class.c_str()); + + return sstr.GetString(); +} \ No newline at end of file -- cgit v1.2.3