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
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137801 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index 4db56d4..e84cd69 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -763,13 +763,13 @@
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 @@
}
+// 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,