mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
Use registry in gdbarch
gdbarch implements its own registry-like approach. This patch changes it to instead use registry.h. It's a rather large patch but largely uninteresting -- it's mostly a straightforward conversion from the old approach to the new one. The main benefit of this change is that it introduces type safety to the gdbarch registry. It also removes a bunch of code. One possible drawback is that, previously, the gdbarch registry differentiated between pre- and post-initialization setup. This doesn't seem very important to me, though.
This commit is contained in:
@@ -275,11 +275,10 @@ m2_language::emitchar (int ch, struct type *chtype,
|
||||
/* Called during architecture gdbarch initialisation to create language
|
||||
specific types. */
|
||||
|
||||
static void *
|
||||
static struct builtin_m2_type *
|
||||
build_m2_types (struct gdbarch *gdbarch)
|
||||
{
|
||||
struct builtin_m2_type *builtin_m2_type
|
||||
= GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_m2_type);
|
||||
struct builtin_m2_type *builtin_m2_type = new struct builtin_m2_type;
|
||||
|
||||
/* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
|
||||
builtin_m2_type->builtin_int
|
||||
@@ -297,20 +296,17 @@ build_m2_types (struct gdbarch *gdbarch)
|
||||
return builtin_m2_type;
|
||||
}
|
||||
|
||||
static struct gdbarch_data *m2_type_data;
|
||||
static const registry<gdbarch>::key<struct builtin_m2_type> m2_type_data;
|
||||
|
||||
const struct builtin_m2_type *
|
||||
builtin_m2_type (struct gdbarch *gdbarch)
|
||||
{
|
||||
return (const struct builtin_m2_type *) gdbarch_data (gdbarch, m2_type_data);
|
||||
}
|
||||
|
||||
|
||||
/* Initialization for Modula-2 */
|
||||
|
||||
void _initialize_m2_language ();
|
||||
void
|
||||
_initialize_m2_language ()
|
||||
{
|
||||
m2_type_data = gdbarch_data_register_post_init (build_m2_types);
|
||||
struct builtin_m2_type *result = m2_type_data.get (gdbarch);
|
||||
if (result == nullptr)
|
||||
{
|
||||
result = build_m2_types (gdbarch);
|
||||
m2_type_data.set (gdbarch, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user