- enum_class = g_new(struct type_class_bitfield, 1);
- enum_class->table.value_to_quark = g_hash_table(enum_val_hash,
- enum_val_equal);
- enum_class->table.quark_to_value = g_hash_table_new_full(g_direct_hash,
- g_direct_equal,
- NULL, enum_val_free);
- bitfield_class = &enum_class->p;
- bitfield_class->start_offset = start_offset;
- int_class = &bitfield_class->p;
- int_class->p.name = g_quark_from_string(name);
- int_class->p.alignment = alignment;
- int_class->len = len;
- int_class->byte_order = byte_order;
- int_class->signedness = signedness;
- bitfield_class->start_offset = start_offset;
- if (int_class->p.name) {
- ret = register_type(&int_class->p);
- if (ret) {
- g_hash_table_destroy(enum_class->table.value_to_quark);
- g_hash_table_destroy(enum_class->table.quark_to_value);
- g_free(enum_class);
- return NULL;
- }
- }
- return enum_class;
+ _enum = g_new(struct definition_enum, 1);
+ declaration_ref(&enum_declaration->p);
+ _enum->p.declaration = declaration;
+ _enum->declaration = enum_declaration;
+ _enum->p.ref = 1;
+ /*
+ * Use INT_MAX order to ensure that all fields of the parent
+ * scope are seen as being prior to this scope.
+ */
+ _enum->p.index = root_name ? INT_MAX : index;
+ _enum->p.name = field_name;
+ _enum->p.path = new_definition_path(parent_scope, field_name, root_name);
+ _enum->p.scope = new_definition_scope(parent_scope, field_name, root_name);
+ _enum->value = NULL;
+ ret = register_field_definition(field_name, &_enum->p,
+ parent_scope);
+ assert(!ret);
+ definition_integer_parent =
+ enum_declaration->integer_declaration->p.definition_new(&enum_declaration->integer_declaration->p,
+ _enum->p.scope,
+ g_quark_from_static_string("container"), 0, NULL);
+ _enum->integer = container_of(definition_integer_parent,
+ struct definition_integer, p);
+ return &_enum->p;