Re: [PATCH 11/10] Split tdesc_type into multiple classes

Yao Qi
2017-12-05T16:46:09Z

Simon Marchi <simon.marchi@polymtl.ca> writes:

> Hi Yao,
>
> I revisited this patch, and implemented as best as I could what you
> suggested. This patch applies on top of the current series.
>
> This patch makes tdesc_type an abstract base class and creates three
> subclasses:
>
> - tdesc_type_builtin, for builtin types
> - tdesc_type_vector, for vector types
> - tdesc_type_with_fields, for struct, union, flag and enum types
>
> This allows getting rid of the union in tdesc_type and to not allow the
> std::vector separately. I tried to go further and create separate
> classes for struct, union, flag and enum, but it proved too difficult.
> One problem is that from the point of the of the target description
> code, the types tdesc_type_* are opaque (only forward-declared).
> Therefore, it doesn't know about inheritance relationship between those
> classes. This makes it impossible to make functions that accept a
> pointer to a base class and pass a pointer to a derived class, for
> example. I think this patch here is a good compromise, and if somebody
> wants to improve things further, the door is open.
>
> A make_gdb_type virtual pure method is added to tdesc_type, which
> replaces the current tdesc_gdb_type function. Calling this method on a
> tdesc_type returns the corresponding built gdb type.

Hi Simon,
Thanks for doing this, patch looks good to me.

--
Yao (齐尧)