{ "COMPLETE_LOCATION", location_completer },
{ "COMPLETE_COMMAND", command_completer },
{ "COMPLETE_SYMBOL", make_symbol_completion_list_fn },
+ { "COMPLETE_EXPRESSION", expression_completer },
};
#define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
PyErr_Clear ();
goto done;
}
- make_cleanup_py_decref (resultobj);
result = NULL;
if (PyInt_Check (resultobj))
done:
+ Py_XDECREF (resultobj);
do_cleanups (cleanup);
return result;
/* Helper for cmdpy_init which locates the command list to use and
pulls out the command name.
-
+
NAME is the command name list. The final word in the list is the
name of the new command. All earlier words must be existing prefix
commands.
*BASE_LIST is set to the final prefix command's list of
*sub-commands.
-
+
START_LIST is the list in which the search starts.
This function returns the xmalloc()d name of the new command. On
return -1;
pfx_name = NULL;
- if (is_prefix != NULL)
+ if (is_prefix != NULL)
{
cmp = PyObject_IsTrue (is_prefix);
if (cmp == 1)
{
int i, out;
-
+
/* Make a normalized form of the command name. */
pfx_name = xmalloc (strlen (name) + 2);
-
+
i = 0;
out = 0;
while (name[i])
/* Initialize the 'commands' code. */
-void
+int
gdbpy_initialize_commands (void)
{
int i;
cmdpy_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&cmdpy_object_type) < 0)
- return;
+ return -1;
/* Note: alias and user are special; pseudo appears to be unused,
and there is no reason to expose tui or xdb, I think. */
|| PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE",
class_maintenance) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0)
- return;
+ return -1;
for (i = 0; i < N_COMPLETERS; ++i)
{
if (PyModule_AddIntConstant (gdb_module, completers[i].name, i) < 0)
- return;
+ return -1;
}
- Py_INCREF (&cmdpy_object_type);
- PyModule_AddObject (gdb_module, "Command",
- (PyObject *) &cmdpy_object_type);
+ if (gdb_pymodule_addobject (gdb_module, "Command",
+ (PyObject *) &cmdpy_object_type) < 0)
+ return -1;
invoke_cst = PyString_FromString ("invoke");
+ if (invoke_cst == NULL)
+ return -1;
complete_cst = PyString_FromString ("complete");
+ if (complete_cst == NULL)
+ return -1;
+
+ return 0;
}
\f