- struct_class = g_new(struct type_class_struct, 1);
- type_class = &float_class->p;
-
- struct_class->fields_by_name = g_hash_table_new(g_direct_hash,
- g_direct_equal);
- struct_class->fields = g_array_sized_new(false, false,
- sizeof(struct field),
- DEFAULT_NR_STRUCT_FIELDS)
- type_class->name = g_quark_from_string(name);
- type_class->alignment = 1;
- type_class->copy = struct_copy;
- type_class->free = _struct_type_free;
-
- if (type_class->name) {
- ret = ctf_register_type(type_class);
- if (ret)
- goto error_register;
+ _struct = g_new(struct declaration_struct, 1);
+ type_ref(&struct_type->p);
+ _struct->p.type = type;
+ _struct->type = struct_type;
+ _struct->p.ref = 1;
+ _struct->scope = new_declaration_scope(parent_scope);
+ _struct->fields = g_array_sized_new(FALSE, TRUE,
+ sizeof(struct field),
+ DEFAULT_NR_STRUCT_FIELDS);
+ g_array_set_size(_struct->fields, struct_type->fields->len);
+ for (i = 0; i < struct_type->fields->len; i++) {
+ struct type_field *type_field =
+ &g_array_index(struct_type->fields,
+ struct type_field, i);
+ struct field *field = &g_array_index(_struct->fields,
+ struct field, i);
+
+ field->name = type_field->name;
+ field->declaration =
+ type_field->type->declaration_new(type_field->type,
+ _struct->scope);
+ ret = register_declaration(field->name,
+ field->declaration, _struct->scope);
+ assert(!ret);