2010-02-26 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com> * python/py-type.c (typy_lookup_typename): Add in block argument. If provided restrict lookup to specified blocks. (gdbpy_lookup_type): Likewise. (typy_lookup_type): Likewise. 2010-02-26 Phil Muldoon <pmuldoon@redhat.com> Tom Tromey <tromey@redhat.com> * gdb.texinfo (Types In Python): Describe block argument in template_argument and gdb.lookup_type.
This commit is contained in:
parent
624f1a6562
commit
5107b1496b
4 changed files with 62 additions and 16 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-02-26 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* python/py-type.c (typy_lookup_typename): Add in block argument.
|
||||||
|
If provided restrict lookup to specified blocks.
|
||||||
|
(gdbpy_lookup_type): Likewise.
|
||||||
|
(typy_lookup_type): Likewise.
|
||||||
|
|
||||||
2010-02-25 Daniel Jacobowitz <dan@codesourcery.com>
|
2010-02-25 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
Symbian config
|
Symbian config
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2010-02-26 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* gdb.texinfo (Types In Python): Describe block argument in
|
||||||
|
template_argument and gdb.lookup_type.
|
||||||
|
|
||||||
2010-02-24 Tom Tromey <tromey@redhat.com>
|
2010-02-24 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* gdb.texinfo (Cygwin Native): Fix typo.
|
* gdb.texinfo (Cygwin Native): Fix typo.
|
||||||
|
|
|
@ -19869,6 +19869,9 @@ module:
|
||||||
This function looks up a type by name. @var{name} is the name of the
|
This function looks up a type by name. @var{name} is the name of the
|
||||||
type to look up. It must be a string.
|
type to look up. It must be a string.
|
||||||
|
|
||||||
|
If @var{block} is given, then @var{name} is looked up in that scope.
|
||||||
|
Otherwise, it is searched for globally.
|
||||||
|
|
||||||
Ordinarily, this function will return an instance of @code{gdb.Type}.
|
Ordinarily, this function will return an instance of @code{gdb.Type}.
|
||||||
If the named type cannot be found, it will throw an exception.
|
If the named type cannot be found, it will throw an exception.
|
||||||
@end defun
|
@end defun
|
||||||
|
@ -19991,7 +19994,7 @@ If the type does not have a target, this method will throw an
|
||||||
exception.
|
exception.
|
||||||
@end defmethod
|
@end defmethod
|
||||||
|
|
||||||
@defmethod Type template_argument n
|
@defmethod Type template_argument n [block]
|
||||||
If this @code{gdb.Type} is an instantiation of a template, this will
|
If this @code{gdb.Type} is an instantiation of a template, this will
|
||||||
return a new @code{gdb.Type} which represents the type of the
|
return a new @code{gdb.Type} which represents the type of the
|
||||||
@var{n}th template argument.
|
@var{n}th template argument.
|
||||||
|
@ -19999,7 +20002,8 @@ return a new @code{gdb.Type} which represents the type of the
|
||||||
If this @code{gdb.Type} is not a template type, this will throw an
|
If this @code{gdb.Type} is not a template type, this will throw an
|
||||||
exception. Ordinarily, only C@t{++} code will have template types.
|
exception. Ordinarily, only C@t{++} code will have template types.
|
||||||
|
|
||||||
@var{name} is searched for globally.
|
If @var{block} is given, then @var{name} is looked up in that scope.
|
||||||
|
Otherwise, it is searched for globally.
|
||||||
@end defmethod
|
@end defmethod
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ typy_get_sizeof (PyObject *self, void *closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct type *
|
static struct type *
|
||||||
typy_lookup_typename (char *type_name)
|
typy_lookup_typename (char *type_name, struct block *block)
|
||||||
{
|
{
|
||||||
struct type *type = NULL;
|
struct type *type = NULL;
|
||||||
volatile struct gdb_exception except;
|
volatile struct gdb_exception except;
|
||||||
|
@ -448,7 +448,7 @@ typy_lookup_typename (char *type_name)
|
||||||
type = lookup_enum (type_name + 5, NULL);
|
type = lookup_enum (type_name + 5, NULL);
|
||||||
else
|
else
|
||||||
type = lookup_typename (python_language, python_gdbarch,
|
type = lookup_typename (python_language, python_gdbarch,
|
||||||
type_name, NULL, 0);
|
type_name, block, 0);
|
||||||
}
|
}
|
||||||
if (except.reason < 0)
|
if (except.reason < 0)
|
||||||
{
|
{
|
||||||
|
@ -462,7 +462,8 @@ typy_lookup_typename (char *type_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct type *
|
static struct type *
|
||||||
typy_lookup_type (struct demangle_component *demangled)
|
typy_lookup_type (struct demangle_component *demangled,
|
||||||
|
struct block *block)
|
||||||
{
|
{
|
||||||
struct type *type;
|
struct type *type;
|
||||||
char *type_name;
|
char *type_name;
|
||||||
|
@ -477,7 +478,7 @@ typy_lookup_type (struct demangle_component *demangled)
|
||||||
|| demangled_type == DEMANGLE_COMPONENT_CONST
|
|| demangled_type == DEMANGLE_COMPONENT_CONST
|
||||||
|| demangled_type == DEMANGLE_COMPONENT_VOLATILE)
|
|| demangled_type == DEMANGLE_COMPONENT_VOLATILE)
|
||||||
{
|
{
|
||||||
type = typy_lookup_type (demangled->u.s_binary.left);
|
type = typy_lookup_type (demangled->u.s_binary.left, block);
|
||||||
if (! type)
|
if (! type)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -495,7 +496,7 @@ typy_lookup_type (struct demangle_component *demangled)
|
||||||
}
|
}
|
||||||
|
|
||||||
type_name = cp_comp_to_string (demangled, 10);
|
type_name = cp_comp_to_string (demangled, 10);
|
||||||
type = typy_lookup_typename (type_name);
|
type = typy_lookup_typename (type_name, block);
|
||||||
xfree (type_name);
|
xfree (type_name);
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
@ -509,17 +510,30 @@ typy_template_argument (PyObject *self, PyObject *args)
|
||||||
struct demangle_component *demangled;
|
struct demangle_component *demangled;
|
||||||
const char *err;
|
const char *err;
|
||||||
struct type *argtype;
|
struct type *argtype;
|
||||||
|
struct block *block = NULL;
|
||||||
|
PyObject *block_obj = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTuple (args, "i", &argno))
|
if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (block_obj)
|
||||||
|
{
|
||||||
|
block = block_object_to_block (block_obj);
|
||||||
|
if (! block)
|
||||||
|
{
|
||||||
|
PyErr_SetString (PyExc_RuntimeError,
|
||||||
|
_("Second argument must be block."));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type = check_typedef (type);
|
type = check_typedef (type);
|
||||||
if (TYPE_CODE (type) == TYPE_CODE_REF)
|
if (TYPE_CODE (type) == TYPE_CODE_REF)
|
||||||
type = check_typedef (TYPE_TARGET_TYPE (type));
|
type = check_typedef (TYPE_TARGET_TYPE (type));
|
||||||
|
|
||||||
if (TYPE_NAME (type) == NULL)
|
if (TYPE_NAME (type) == NULL)
|
||||||
{
|
{
|
||||||
PyErr_SetString (PyExc_RuntimeError, "null type name");
|
PyErr_SetString (PyExc_RuntimeError, _("Null type name."));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +552,7 @@ typy_template_argument (PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
|
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
|
||||||
{
|
{
|
||||||
PyErr_SetString (PyExc_RuntimeError, "type is not a template");
|
PyErr_SetString (PyExc_RuntimeError, _("Type is not a template."));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,12 +564,12 @@ typy_template_argument (PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (! demangled)
|
if (! demangled)
|
||||||
{
|
{
|
||||||
PyErr_Format (PyExc_RuntimeError, "no argument %d in template",
|
PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
|
||||||
argno);
|
argno);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
argtype = typy_lookup_type (demangled->u.s_binary.left);
|
argtype = typy_lookup_type (demangled->u.s_binary.left, block);
|
||||||
if (! argtype)
|
if (! argtype)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -696,14 +710,28 @@ type_object_to_type (PyObject *obj)
|
||||||
PyObject *
|
PyObject *
|
||||||
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
|
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "name", NULL };
|
static char *keywords[] = { "name", "block", NULL };
|
||||||
char *type_name = NULL;
|
char *type_name = NULL;
|
||||||
struct type *type = NULL;
|
struct type *type = NULL;
|
||||||
|
PyObject *block_obj = NULL;
|
||||||
|
struct block *block = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &type_name))
|
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords,
|
||||||
|
&type_name, &block_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
type = typy_lookup_typename (type_name);
|
if (block_obj)
|
||||||
|
{
|
||||||
|
block = block_object_to_block (block_obj);
|
||||||
|
if (! block)
|
||||||
|
{
|
||||||
|
PyErr_SetString (PyExc_RuntimeError,
|
||||||
|
_("'block' argument must be a Block."));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type = typy_lookup_typename (type_name, block);
|
||||||
if (! type)
|
if (! type)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -777,7 +805,7 @@ Return a type formed by stripping this type of all typedefs."},
|
||||||
"target () -> Type\n\
|
"target () -> Type\n\
|
||||||
Return the target type of this type." },
|
Return the target type of this type." },
|
||||||
{ "template_argument", typy_template_argument, METH_VARARGS,
|
{ "template_argument", typy_template_argument, METH_VARARGS,
|
||||||
"template_argument (arg) -> Type\n\
|
"template_argument (arg, [block]) -> Type\n\
|
||||||
Return the type of a template argument." },
|
Return the type of a template argument." },
|
||||||
{ "unqualified", typy_unqualified, METH_NOARGS,
|
{ "unqualified", typy_unqualified, METH_NOARGS,
|
||||||
"unqualified () -> Type\n\
|
"unqualified () -> Type\n\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue