<rdar://problem/11975483> Removing user-visible references to 'dict' as a parameter name for Python summary-generating functions since it is a Python keyword.

llvm-svn: 161467
This commit is contained in:
Enrico Granata 2012-08-08 02:06:30 +00:00
parent 316d5e4e9a
commit 40d557107f
8 changed files with 24 additions and 24 deletions

View File

@ -558,7 +558,7 @@ protected:
else if (m_options.m_function_name.size())
{
std::string oneliner(m_options.m_function_name);
oneliner += "(frame, bp_loc, dict)";
oneliner += "(frame, bp_loc, internal_dict)";
m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
oneliner.c_str());
}

View File

@ -330,7 +330,7 @@ CommandObjectCommandsSource::CommandOptions::g_option_table[] =
static const char *g_python_command_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
"You must define a Python function with this signature:\n"
"def my_command_impl(debugger, args, result, dict):";
"def my_command_impl(debugger, args, result, internal_dict):";
class CommandObjectCommandsAlias : public CommandObjectRaw

View File

@ -742,7 +742,7 @@ CommandObjectTypeFormatList_LoopCallback (
//-------------------------------------------------------------------------
static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
"def function (valobj,dict):";
"def function (valobj,internal_dict):";
class TypeScriptAddInputReader : public InputReaderEZ
{
@ -1050,7 +1050,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
return false;
}
std::string code = (" " + m_options.m_python_function + "(valobj,dict)");
std::string code = (" " + m_options.m_python_function + "(valobj,internal_dict)");
script_format.reset(new ScriptSummaryFormat(m_options.m_flags,
funct_name,

View File

@ -772,7 +772,7 @@ FormatManager::LoadLibcxxFormatters()
.SetHideItemNames(false);
#ifndef LLDB_DISABLE_PYTHON
std::string code(" lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,dict)");
std::string code(" lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,internal_dict)");
lldb::TypeSummaryImplSP std_string_summary_sp(new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.libcxx.stdstring_SummaryProvider",code.c_str()));
TypeCategoryImpl::SharedPointer libcxx_category_sp = GetCategory(m_libcxx_category_name);
@ -868,7 +868,7 @@ AddScriptSummary(TypeCategoryImpl::SharedPointer category_sp,
{
std::string code(" ");
code.append(funct_name).append("(valobj,dict)");
code.append(funct_name).append("(valobj,internal_dict)");
lldb::TypeSummaryImplSP summary_sp(new ScriptSummaryFormat(flags,
funct_name,

View File

@ -1466,9 +1466,9 @@ ScriptInterpreterPython::GenerateFunction(const char *signature, const StringLis
StringList auto_generated_function;
auto_generated_function.AppendString (signature);
auto_generated_function.AppendString (" global_dict = globals()"); // Grab the global dictionary
auto_generated_function.AppendString (" new_keys = dict.keys()"); // Make a list of keys in the session dict
auto_generated_function.AppendString (" new_keys = internal_dict.keys()"); // Make a list of keys in the session dict
auto_generated_function.AppendString (" old_keys = global_dict.keys()"); // Save list of keys in global dict
auto_generated_function.AppendString (" global_dict.update (dict)"); // Add the session dictionary to the
auto_generated_function.AppendString (" global_dict.update (internal_dict)"); // Add the session dictionary to the
// global dictionary.
// Wrap everything up inside the function, increasing the indentation.
@ -1480,7 +1480,7 @@ ScriptInterpreterPython::GenerateFunction(const char *signature, const StringLis
auto_generated_function.AppendString (sstr.GetData());
}
auto_generated_function.AppendString (" for key in new_keys:"); // Iterate over all the keys from session dict
auto_generated_function.AppendString (" dict[key] = global_dict[key]"); // Update session dict values
auto_generated_function.AppendString (" internal_dict[key] = global_dict[key]"); // Update session dict values
auto_generated_function.AppendString (" if key not in old_keys:"); // If key was not originally in global dict
auto_generated_function.AppendString (" del global_dict[key]"); // ...then remove key/value from global dict
@ -1508,7 +1508,7 @@ ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, std
// ValueObject as parameter to the function.
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_type_print_func", num_created_functions, name_token));
sstr.Printf ("def %s (valobj, dict):", auto_generated_function_name.c_str());
sstr.Printf ("def %s (valobj, internal_dict):", auto_generated_function_name.c_str());
if (!GenerateFunction(sstr.GetData(), user_input))
return false;
@ -1531,7 +1531,7 @@ ScriptInterpreterPython::GenerateScriptAliasFunction (StringList &user_input, st
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_cmd_alias_func", num_created_functions));
sstr.Printf ("def %s (debugger, args, result, dict):", auto_generated_function_name.c_str());
sstr.Printf ("def %s (debugger, args, result, internal_dict):", auto_generated_function_name.c_str());
if (!GenerateFunction(sstr.GetData(),user_input))
return false;
@ -1651,7 +1651,7 @@ ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user
return false;
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_bp_callback_func_",num_created_functions));
sstr.Printf ("def %s (frame, bp_loc, dict):", auto_generated_function_name.c_str());
sstr.Printf ("def %s (frame, bp_loc, internal_dict):", auto_generated_function_name.c_str());
if (!GenerateFunction(sstr.GetData(), user_input))
return false;

View File

@ -86,7 +86,7 @@ class BreakpointCommandTestCase(TestBase):
"here.close()"])
self.expect("breakpoint command list 3", "Breakpoint 3 command ok",
substrs = ["Breakpoint commands:",
"bktptcmd.function(frame, bp_loc, dict)"])
"bktptcmd.function(frame, bp_loc, internal_dict)"])
self.runCmd("command script import --allow-reload ./bktptcmd.py")

View File

@ -300,12 +300,12 @@ Enter your Python command(s). Type 'DONE' to end.
debugging requirements. </p>
<p>To write a python function that implements a new LDB command define the function to take four arguments as follows:</p>
<code><pre><tt>def command_function(<b>debugger</b>, <b>command</b>, <b>result</b>, <b>dict</b>):
<code><pre><tt>def command_function(<b>debugger</b>, <b>command</b>, <b>result</b>, <b>internal_dict</b>):
<font color=green># Your code goes here</font>
</tt></pre></code>
Optionally, you can also provide a Python docstring, and LLDB will use it when providing help for your command, as in:
<code><pre><tt>def command_function(<b>debugger</b>, <b>command</b>, <b>result</b>, <b>dict</b>):
<code><pre><tt>def command_function(<b>debugger</b>, <b>command</b>, <b>result</b>, <b>internal_dict</b>):
<font color=green>"""This command takes a lot of options and does many fancy things"""</font>
<font color=green># Your code goes here</font>
</tt></pre></code>
@ -357,7 +357,7 @@ Enter your Python command(s). Type 'DONE' to end.
</tr>
<tr>
<td class="content">
<b>dict</b>
<b>internal_dict</b>
</td>
<td class="content">
<b>python dict object</b>
@ -373,11 +373,11 @@ Enter your Python command(s). Type 'DONE' to end.
don't have to change your PYTHONPATH for temporary scripts. It also has another convenience
that if your new script module has a function of the form:</p>
<code><pre><tt>def __lldb_init_module(<b>debugger</b>, <b>dict</b>):
<code><pre><tt>def __lldb_init_module(<b>debugger</b>, <b>internal_dict</b>):
<font color=green># Command Initialization code goes here</font>
</tt></pre></code>
<p>where <b>debugger</b> and <b>dict</b> are as above, that function will get run when the module is loaded
<p>where <b>debugger</b> and <b>internal_dict</b> are as above, that function will get run when the module is loaded
allowing you to add whatever commands you want into the current debugger. Note that
this function will only be run when using the LLDB comand <b>command script import</b>,
it will not get run if anyone imports your module from another module.
@ -410,11 +410,11 @@ import commands
import optparse
import shlex
def ls(debugger, command, result, dict):
def ls(debugger, command, result, internal_dict):
result.PutCString(commands.getoutput('/bin/ls %s' % command))
<font color=green># And the initialization code to add your commands </font>
def __lldb_init_module(debugger, dict):
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f ls.ls ls')
print 'The "ls" python command has been installed and is ready for use.'
</tt></pre></code>

View File

@ -819,7 +819,7 @@
<td class="content">
<b>(lldb)</b> type summary add -P Rectangle<br/>
Enter your Python command(s). Type 'DONE' to end.<br/>
def function (valobj,dict):<br/>
def function (valobj,internal_dict):<br/>
&nbsp;&nbsp;&nbsp;&nbsp;height_val = valobj.GetChildMemberWithName('height')<br/>
&nbsp;&nbsp;&nbsp;&nbsp;width_val = valobj.GetChildMemberWithName('width')<br/>
&nbsp;&nbsp;&nbsp;&nbsp;height = height_val.GetValueAsUnsigned(0)<br/>
@ -841,9 +841,9 @@ def function (valobj,dict):<br/>
the LLDB <a href="docs.html">doxygen documentation</a> when it becomes available.</p>
<p>As a brief introduction, your script is encapsulated into a function that is
passed two parameters: <code>valobj</code> and <code>dict</code>.</p>
passed two parameters: <code>valobj</code> and <code>internal_dict</code>.</p>
<p><code>dict</code> is an internal support parameter used by LLDB and you should
<p><code>internal_dict</code> is an internal support parameter used by LLDB and you should
not touch it.<br/><code>valobj</code> is the object encapsulating the actual
variable being displayed, and its type is <a href="http://llvm.org/svn/llvm-project/lldb/trunk/include/lldb/API/SBValue.h">SBValue</a>.
Out of the many possible operations on an SBValue, the basic one is retrieve the children objects
@ -1029,7 +1029,7 @@ def function (valobj,dict):<br/>
must be implemented by the Python class):</p>
<code>
<font color=blue>class</font> SyntheticChildrenProvider:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>def</font> __init__(self, valobj, dict):<br/>
&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>def</font> __init__(self, valobj, internal_dict):<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>this call should initialize the Python object using valobj as the variable to provide synthetic children for</i> <br/>
&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>def</font> num_children(self): <br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>this call should return the number of children that you want your object to have</i> <br/>