struct value_object *prev;
struct value *value;
PyObject *address;
- PyObject *type;
PyObject *dynamic_type;
PyObject *content_bytes;
};
self->value = nullptr;
Py_CLEAR (self->address);
- Py_CLEAR (self->type);
- Py_CLEAR (self->dynamic_type);
Py_CLEAR (self->content_bytes);
}
{
value_object *obj = (value_object *) self;
- if (!obj->type)
- {
- obj->type = type_to_type_object (obj->value->type ());
- if (!obj->type)
- return NULL;
- }
- Py_INCREF (obj->type);
- return obj->type;
+ return type_to_type_object (obj->value->type ());
}
/* Return dynamic type of the value. */
valpy_get_dynamic_type (PyObject *self, void *closure)
{
value_object *obj = (value_object *) self;
- struct type *type = NULL;
-
- if (obj->dynamic_type != NULL)
- {
- Py_INCREF (obj->dynamic_type);
- return obj->dynamic_type;
- }
+ struct type *type = nullptr;
try
{
else if (type->code () == TYPE_CODE_STRUCT)
type = value_rtti_type (val, NULL, NULL, NULL);
else
- {
- /* Re-use object's static type. */
- type = NULL;
- }
+ type = val->type ();
}
catch (const gdb_exception &except)
{
return gdbpy_handle_gdb_exception (nullptr, except);
}
- if (type == NULL)
- obj->dynamic_type = valpy_get_type (self, NULL);
- else
- obj->dynamic_type = type_to_type_object (type);
-
- Py_XINCREF (obj->dynamic_type);
- return obj->dynamic_type;
+ return type_to_type_object (type);
}
/* Implementation of gdb.Value.lazy_string ([encoding] [, length]) ->
value_object *val_obj;
val_obj = PyObject_New (value_object, &value_object_type);
- if (val_obj != NULL)
+ if (val_obj != nullptr)
{
val->incref ();
val_obj->value = val;
val_obj->next = nullptr;
val_obj->prev = nullptr;
- val_obj->address = NULL;
- val_obj->type = NULL;
- val_obj->dynamic_type = NULL;
+ val_obj->address = nullptr;
+ val_obj->dynamic_type = nullptr;
val_obj->content_bytes = nullptr;
note_value (val_obj);
}