Use gdbpy_ref in gdbpy_lookup_symbol
This changes gdbpy_lookup_symbol to use gdbpy_ref. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-symbol.c (gdbpy_lookup_symbol): Use gdbpy_ref.
This commit is contained in:
parent
53a0cca3bd
commit
37fce74fb4
2 changed files with 12 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2017-01-10 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/py-symbol.c (gdbpy_lookup_symbol): Use gdbpy_ref.
|
||||||
|
|
||||||
2017-01-10 Tom Tromey <tom@tromey.com>
|
2017-01-10 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* python/py-value.c (value_has_field, get_field_flag)
|
* python/py-value.c (value_has_field, get_field_flag)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "python-internal.h"
|
#include "python-internal.h"
|
||||||
#include "objfiles.h"
|
#include "objfiles.h"
|
||||||
|
#include "py-ref.h"
|
||||||
|
|
||||||
typedef struct sympy_symbol_object {
|
typedef struct sympy_symbol_object {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
@ -374,7 +375,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
const char *name;
|
const char *name;
|
||||||
static char *keywords[] = { "name", "block", "domain", NULL };
|
static char *keywords[] = { "name", "block", "domain", NULL };
|
||||||
struct symbol *symbol = NULL;
|
struct symbol *symbol = NULL;
|
||||||
PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj;
|
PyObject *block_obj = NULL, *sym_obj, *bool_obj;
|
||||||
const struct block *block = NULL;
|
const struct block *block = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
|
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
|
||||||
|
@ -410,31 +411,28 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
ret_tuple = PyTuple_New (2);
|
gdbpy_ref ret_tuple (PyTuple_New (2));
|
||||||
if (!ret_tuple)
|
if (ret_tuple == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (symbol)
|
if (symbol)
|
||||||
{
|
{
|
||||||
sym_obj = symbol_to_symbol_object (symbol);
|
sym_obj = symbol_to_symbol_object (symbol);
|
||||||
if (!sym_obj)
|
if (!sym_obj)
|
||||||
{
|
|
||||||
Py_DECREF (ret_tuple);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sym_obj = Py_None;
|
sym_obj = Py_None;
|
||||||
Py_INCREF (Py_None);
|
Py_INCREF (Py_None);
|
||||||
}
|
}
|
||||||
PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
|
PyTuple_SET_ITEM (ret_tuple.get (), 0, sym_obj);
|
||||||
|
|
||||||
bool_obj = (is_a_field_of_this.type != NULL) ? Py_True : Py_False;
|
bool_obj = (is_a_field_of_this.type != NULL) ? Py_True : Py_False;
|
||||||
Py_INCREF (bool_obj);
|
Py_INCREF (bool_obj);
|
||||||
PyTuple_SET_ITEM (ret_tuple, 1, bool_obj);
|
PyTuple_SET_ITEM (ret_tuple.get (), 1, bool_obj);
|
||||||
|
|
||||||
return ret_tuple;
|
return ret_tuple.release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of
|
/* Implementation of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue