diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2011-08-17 01:30:04 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2011-08-17 01:30:04 +0000 |
commit | 99f0b8f9351889901fbe7fd16104543bd4c1bbf1 (patch) | |
tree | 1b8e0f09fe0711d4d6de2ebea80ccec1fee4796f /lldb/source/Interpreter/ScriptInterpreterPython.cpp | |
parent | b3457c9eefdea3e9e9386628bc6cd31f85478172 (diff) | |
download | bcm5719-llvm-99f0b8f9351889901fbe7fd16104543bd4c1bbf1.tar.gz bcm5719-llvm-99f0b8f9351889901fbe7fd16104543bd4c1bbf1.zip |
When defining a scripted command, it is possible to provide a docstring and that will be used as the help text for the command
If no docstring is provided, a default help text is created
LLDB will refuse to create scripted commands if the scripting language is anything but Python
Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code
llvm-svn: 137801
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 4db56d4ac23..e84cd699549 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -763,13 +763,13 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string, case eCharPtr: // "char *" { const char format[3] = "s#"; - success = PyArg_Parse (py_return, format, (char **) &ret_value); + success = PyArg_Parse (py_return, format, (char **) ret_value); break; } case eCharStrOrNone: // char* or NULL if py_return == Py_None { const char format[3] = "z"; - success = PyArg_Parse (py_return, format, (char **) &ret_value); + success = PyArg_Parse (py_return, format, (char **) ret_value); break; } case eBool: @@ -1972,6 +1972,26 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, } +// in Python, a special attribute __doc__ contains the docstring +// for an object (function, method, class, ...) if any is defined +// Otherwise, the attribute's value is None +std::string +ScriptInterpreterPython::GetDocumentationForItem(const char* item) +{ + std::string command(item); + command += ".__doc__"; + + char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully + + if (ExecuteOneLineWithReturn (command.c_str(), + ScriptInterpreter::eCharStrOrNone, + &result_ptr) && result_ptr) + { + return std::string(result_ptr); + } + else + return std::string(""); +} void ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback python_swig_init_callback, |