summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorEnrico Granata <granata.enrico@gmail.com>2011-07-25 16:59:05 +0000
committerEnrico Granata <granata.enrico@gmail.com>2011-07-25 16:59:05 +0000
commitc53114e30aa428ff2fcfd48927ef05b3d250a371 (patch)
tree5c42691b0243ffe52882e00b4e8d4ea3c8aebd79 /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent6d28d7f2a3079745a79fb95210e641ca844a902a (diff)
downloadbcm5719-llvm-c53114e30aa428ff2fcfd48927ef05b3d250a371.tar.gz
bcm5719-llvm-c53114e30aa428ff2fcfd48927ef05b3d250a371.zip
new flag -P to type synth add lets you type a Python class interactively
added a final newline to fooSynthProvider.py new option to automatically save user input in InputReaderEZ checking for NULL pointers in several new places llvm-svn: 135916
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 03eadc6f549..82cad851028 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -1249,6 +1249,54 @@ ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, Str
return true;
}
+bool
+ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output)
+{
+ static int num_created_classes = 0;
+ user_input.RemoveBlankLines ();
+ int num_lines = user_input.GetSize ();
+ StreamString sstr;
+
+ // Check to see if we have any data; if not, just return.
+ if (user_input.GetSize() == 0)
+ return false;
+
+ // Wrap all user input into a Python class
+
+ sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes);
+ ++num_created_classes;
+ std::string auto_generated_class_name = sstr.GetData();
+
+ sstr.Clear();
+ StringList auto_generated_class;
+
+ // Create the function name & definition string.
+
+ sstr.Printf ("class %s:", auto_generated_class_name.c_str());
+ auto_generated_class.AppendString (sstr.GetData());
+
+ // Wrap everything up inside the class, increasing the indentation.
+
+ for (int i = 0; i < num_lines; ++i)
+ {
+ sstr.Clear ();
+ sstr.Printf (" %s", user_input.GetStringAtIndex (i));
+ auto_generated_class.AppendString (sstr.GetData());
+ }
+
+
+ // Verify that the results are valid Python.
+ // (even though the method is ExportFunctionDefinitionToInterpreter, a class will actually be exported)
+ // (TODO: rename that method to ExportDefinitionToInterpreter)
+ if (!ExportFunctionDefinitionToInterpreter (auto_generated_class))
+ return false;
+
+ // Store the name of the auto-generated class
+
+ output.AppendString (auto_generated_class_name.c_str());
+ return true;
+}
+
void*
ScriptInterpreterPython::CreateSyntheticScriptedProvider (std::string class_name,
lldb::ValueObjectSP valobj)
OpenPOWER on IntegriCloud