+ return enum_type;
+
+register_error:
+ g_hash_table_destroy(enum_type->table.value_to_quark_set);
+ g_hash_table_destroy(enum_type->table.quark_to_range_set);
+ type_unref(enum_type->integer_type);
+ g_free(enum_type);
+ return NULL;
+}
+
+static
+struct declaration *
+ _enum_declaration_new(struct type *type,
+ struct declaration_scope *parent_scope)
+{
+ struct type_enum *enum_type =
+ container_of(type, struct type_enum, p);
+ struct declaration_enum *_enum;
+ struct declaration_integer_parent *declaration_integer_parent;
+
+ _enum = g_new(struct declaration_enum, 1);
+ type_ref(&enum_type->p);
+ _enum->p.type = enum_type;
+ _enum->p.ref = 1;
+ _enum->value = NULL;
+ declaration_integer_parent =
+ enum_type->integer_type->p.declaration_new(&enum_type->integer_type->p,
+ parent_scope);
+ _enum->integer = container_of(declaration_integer_parent,
+ struct declaration_integer, p);
+ return &_enum->p;
+}
+
+static
+void _enum_declaration_free(struct declaration *declaration)
+{
+ struct declaration_enum *_enum =
+ container_of(declaration, struct declaration_enum, p);
+
+ declaration_unref(_enum->integer);
+ type_unref(_enum->p.type);
+ if (_enum->value)
+ g_array_unref(_enum->value, TRUE);
+ g_free(_enum);