diff options
Diffstat (limited to 'gdb/python')
| -rw-r--r-- | gdb/python/py-arch.c | 4 | ||||
| -rw-r--r-- | gdb/python/py-lazy-string.c | 2 | ||||
| -rw-r--r-- | gdb/python/py-symbol.c | 2 | ||||
| -rw-r--r-- | gdb/python/py-type.c | 45 | ||||
| -rw-r--r-- | gdb/python/py-value.c | 4 | ||||
| -rw-r--r-- | gdb/python/py-xmethods.c | 2 | ||||
| -rw-r--r-- | gdb/python/python-internal.h | 2 | ||||
| -rw-r--r-- | gdb/python/python.c | 2 |
8 files changed, 31 insertions, 32 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index eb4a7c63530..cf740821dfa 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -314,7 +314,7 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw) return nullptr; } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Implementation of gdb.void_type. */ @@ -324,7 +324,7 @@ archpy_void_type (PyObject *self, PyObject *args) struct gdbarch *gdbarch; ARCHPY_REQUIRE_VALID (self, gdbarch); - return type_to_type_object (builtin_type (gdbarch)->builtin_void); + return type_to_type_object (builtin_type (gdbarch)->builtin_void).release (); } /* __repr__ implementation for gdb.Architecture. */ diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index fe248f6e78f..26998064206 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -235,7 +235,7 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length, str_obj->encoding = NULL; else str_obj->encoding = xstrdup (encoding); - str_obj->type = type_to_type_object (type); + str_obj->type = type_to_type_object (type).release (); return (PyObject *) str_obj; } diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 80c7705aa68..7b6164fb20d 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -73,7 +73,7 @@ sympy_get_type (PyObject *self, void *closure) return Py_None; } - return type_to_type_object (symbol->type ()); + return type_to_type_object (symbol->type ()).release (); } static PyObject * diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 017937c1c0a..8f8f6e326a8 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -132,7 +132,7 @@ convert_field (struct type *type, int field) if (result == NULL) return NULL; - gdbpy_ref<> arg (type_to_type_object (type)); + gdbpy_ref<> arg = type_to_type_object (type); if (arg == NULL) return NULL; if (PyObject_SetAttrString (result.get (), "parent_type", arg.get ()) < 0) @@ -202,7 +202,7 @@ convert_field (struct type *type, int field) if (type->field (field).type () == NULL) arg = gdbpy_ref<>::new_reference (Py_None); else - arg.reset (type_to_type_object (type->field (field).type ())); + arg = type_to_type_object (type->field (field).type ()); if (arg == NULL) return NULL; if (PyObject_SetAttrString (result.get (), "type", arg.get ()) < 0) @@ -283,7 +283,7 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) gdbpy_ref<> type_holder; if (checked_type != type) { - type_holder.reset (type_to_type_object (checked_type)); + type_holder = type_to_type_object (checked_type); if (type_holder == nullptr) return nullptr; py_type = type_holder.get (); @@ -489,7 +489,7 @@ typy_strip_typedefs (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Strip typedefs and pointers/reference from a type. Then check that @@ -580,7 +580,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (array); + return type_to_type_object (array).release (); } /* Return an array type. */ @@ -614,7 +614,7 @@ typy_pointer (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Return the range of a type represented by SELF. The return type is @@ -686,7 +686,7 @@ typy_reference (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Return a Type object which represents the target type of SELF. */ @@ -702,7 +702,7 @@ typy_target (PyObject *self, PyObject *args) return NULL; } - return type_to_type_object (type->target_type ()); + return type_to_type_object (type->target_type ()).release (); } /* Return a const-qualified type variant. */ @@ -720,7 +720,7 @@ typy_const (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Return a volatile-qualified type variant. */ @@ -738,7 +738,7 @@ typy_volatile (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Return an unqualified type variant. */ @@ -756,7 +756,7 @@ typy_unqualified (PyObject *self, PyObject *args) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Return the size of the type represented by SELF, in bytes. */ @@ -978,7 +978,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block, if (! argtype) return NULL; - return type_to_type_object (argtype); + return type_to_type_object (argtype).release (); } static PyObject * @@ -1037,7 +1037,7 @@ typy_template_argument (PyObject *self, PyObject *args) sym = TYPE_TEMPLATE_ARGUMENT (type, argno); if (sym->loc_class () == LOC_TYPEDEF) - return type_to_type_object (sym->type ()); + return type_to_type_object (sym->type ()).release (); else if (sym->loc_class () == LOC_OPTIMIZED_OUT) { PyErr_Format (PyExc_RuntimeError, @@ -1423,7 +1423,7 @@ typy_iterator_dealloc (PyObject *obj) } /* Create a new Type referring to TYPE. */ -PyObject * +gdbpy_ref<> type_to_type_object (struct type *type) { type_object *type_obj; @@ -1450,14 +1450,13 @@ type_to_type_object (struct type *type) else type_obj = typy_registry.lookup (type->arch_owner (), type); - if (type_obj != nullptr) - return (PyObject*)type_obj; - - type_obj = PyObject_New (type_object, &type_object_type); - if (type_obj) - set_type (type_obj, type); - - return (PyObject *) type_obj; + if (type_obj == nullptr) + { + type_obj = PyObject_New (type_object, &type_object_type); + if (type_obj) + set_type (type_obj, type); + } + return gdbpy_ref<> (type_obj); } struct type * @@ -1499,7 +1498,7 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw) if (! type) return NULL; - return type_to_type_object (type); + return type_to_type_object (type).release (); } static int diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c0fcfb882e1..a5b2303728c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -432,7 +432,7 @@ valpy_get_type (PyObject *self, void *closure) { value_object *obj = (value_object *) self; - return type_to_type_object (obj->value->type ()); + return type_to_type_object (obj->value->type ()).release (); } /* Return dynamic type of the value. */ @@ -484,7 +484,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) return gdbpy_handle_gdb_exception (nullptr, except); } - return type_to_type_object (type); + return type_to_type_object (type).release (); } /* Implementation of gdb.Value.lazy_string ([encoding] [, length]) -> diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index 64f9807cfee..1fafafb4d24 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -123,7 +123,7 @@ gdbpy_get_matching_xmethod_workers gdbpy_enter enter_py; - gdbpy_ref<> py_type (type_to_type_object (obj_type)); + gdbpy_ref<> py_type = type_to_type_object (obj_type); if (py_type == NULL) { gdbpy_print_stack (); diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index c7e812d6893..6fa37cf85bd 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -501,7 +501,7 @@ gdbpy_ref<> symbol_to_symbol_object (struct symbol *sym); gdbpy_ref<> block_to_block_object (const struct block *block, struct objfile *objfile); gdbpy_ref<> value_to_value_object (struct value *v); -PyObject *type_to_type_object (struct type *); +gdbpy_ref<> type_to_type_object (struct type *); PyObject *frame_info_to_frame_object (const frame_info_ptr &frame); PyObject *symtab_to_linetable_object (PyObject *symtab); gdbpy_ref<> pspace_to_pspace_object (struct program_space *); diff --git a/gdb/python/python.c b/gdb/python/python.c index aec2c7559a8..9862d1a726f 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -2105,7 +2105,7 @@ gdbpy_apply_type_printers (const struct extension_language_defn *extlang, gdbpy_enter enter_py; - gdbpy_ref<> type_obj (type_to_type_object (type)); + gdbpy_ref<> type_obj = type_to_type_object (type); if (type_obj == NULL) { gdbpy_print_stack (); |
