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)
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)
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 ();
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
return gdbpy_handle_gdb_exception (nullptr, except);
}
- return type_to_type_object (array);
+ return type_to_type_object (array).release ();
}
/* Return an array type. */
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
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. */
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. */
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. */
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. */
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. */
if (! argtype)
return NULL;
- return type_to_type_object (argtype);
+ return type_to_type_object (argtype).release ();
}
static PyObject *
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,
}
/* Create a new Type referring to TYPE. */
-PyObject *
+gdbpy_ref<>
type_to_type_object (struct type *type)
{
type_object *type_obj;
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 *
if (! type)
return NULL;
- return type_to_type_object (type);
+ return type_to_type_object (type).release ();
}
static int