Rename "type" to "declaration"
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 4 Apr 2011 20:14:32 +0000 (16:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 4 Apr 2011 20:14:32 +0000 (16:14 -0400)
Follows CTF pre-v1.7
commit 457d8b0a0cff67a7489b7eead5b8b26701b430f8

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
21 files changed:
formats/ctf/types/array.c
formats/ctf/types/enum.c
formats/ctf/types/float.c
formats/ctf/types/integer.c
formats/ctf/types/sequence.c
formats/ctf/types/string.c
formats/ctf/types/struct.c
formats/ctf/types/variant.c
include/babeltrace/ctf/metadata.h
include/babeltrace/ctf/types.h
include/babeltrace/format.h
include/babeltrace/types.h
types/array.c
types/enum.c
types/float.c
types/integer.c
types/sequence.c
types/string.c
types/struct.c
types/types.c
types/variant.c

index 64d889e01d3867da6ed2820c61f8c79f060990b7..8cfd0ae574fbba544990ea8b99cfa2bcee30db49 100644 (file)
 #include <babeltrace/ctf/types.h>
 
 void ctf_array_begin(struct stream_pos *pos,
-                    const struct type_array *array_type)
+                    const struct declaration_array *array_declaration)
 {
        /* No need to align, because the first field will align itself. */
 }
 
 void ctf_array_end(struct stream_pos *pos,
-                  const struct type_array *array_type)
+                  const struct declaration_array *array_declaration)
 {
 }
index d0b284e67598c1474e09529689f19fb88677cc6f..15e2590ad6b2cb1c65e57857234eb91dfe1ba22f 100644 (file)
  * The caller should unref the GArray.
  */
 GArray *ctf_enum_read(struct stream_pos *pos,
-                     const struct type_enum *src)
+                     const struct declaration_enum *src)
 {
-       const struct type_integer *integer_type = src->integer_type;
+       const struct declaration_integer *integer_declaration = src->integer_declaration;
 
-       if (!integer_type->signedness) {
+       if (!integer_declaration->signedness) {
                uint64_t v;
 
-               v = ctf_uint_read(pos, integer_type);
+               v = ctf_uint_read(pos, integer_declaration);
                return enum_uint_to_quark_set(src, v);
        } else {
                int64_t v;
 
-               v = ctf_int_read(pos, integer_type);
+               v = ctf_int_read(pos, integer_declaration);
                return enum_int_to_quark_set(src, v);
        }
 }
@@ -45,20 +45,20 @@ GArray *ctf_enum_read(struct stream_pos *pos,
  * Arbitrarily choose the start of the first matching range.
  */
 void ctf_enum_write(struct stream_pos *pos,
-                   const struct type_enum *dest,
+                   const struct declaration_enum *dest,
                    GQuark q)
 {
-       const struct type_integer *integer_type = dest->integer_type;
+       const struct declaration_integer *integer_declaration = dest->integer_declaration;
        GArray *array;
 
        array = enum_quark_to_range_set(dest, q);
        assert(array);
 
-       if (!integer_type->signedness) {
+       if (!integer_declaration->signedness) {
                uint64_t v = g_array_index(array, struct enum_range, 0).start._unsigned;
-               ctf_uint_write(pos, integer_type, v);
+               ctf_uint_write(pos, integer_declaration, v);
        } else {
                int64_t v = g_array_index(array, struct enum_range, 0).start._unsigned;
-               ctf_int_write(pos, integer_type, v);
+               ctf_int_write(pos, integer_declaration, v);
        }
 }
index f15c2856001f608cde70c093af8f77e7e9779786..ee9a8318660f115d5787f94cf50becd4ab99de70 100644 (file)
@@ -32,7 +32,7 @@
 
 /*
  * Aliasing float/double and unsigned long is not strictly permitted by strict
- * aliasing, but in practice type prunning is well supported, and this permits
+ * aliasing, but in practice declaration prunning is well supported, and this permits
  * us to use per-word read/writes rather than per-byte.
  */
 
@@ -69,68 +69,68 @@ struct pos_len {
 };
 
 void _ctf_float_copy(struct stream_pos *destp,
-                    const struct type_float *dest_type,
+                    const struct declaration_float *dest_declaration,
                     struct stream_pos *srcp,
-                    const struct type_float *src_type)
+                    const struct declaration_float *src_declaration)
 {
        uint8_t sign;
        int64_t exp;
        uint64_t mantissa;
 
        /* Read */
-       if (src_type->byte_order == LITTLE_ENDIAN) {
-               mantissa = ctf_uint_read(srcp, src_type->mantissa);
-               exp = ctf_int_read(srcp, src_type->exp);
-               sign = ctf_uint_read(srcp, src_type->sign);
+       if (src_declaration->byte_order == LITTLE_ENDIAN) {
+               mantissa = ctf_uint_read(srcp, src_declaration->mantissa);
+               exp = ctf_int_read(srcp, src_declaration->exp);
+               sign = ctf_uint_read(srcp, src_declaration->sign);
        } else {
-               sign = ctf_uint_read(srcp, src_type->sign);
-               exp = ctf_int_read(srcp, src_type->exp);
-               mantissa = ctf_uint_read(srcp, src_type->mantissa);
+               sign = ctf_uint_read(srcp, src_declaration->sign);
+               exp = ctf_int_read(srcp, src_declaration->exp);
+               mantissa = ctf_uint_read(srcp, src_declaration->mantissa);
        }
        /* Write */
-       if (dest_type->byte_order == LITTLE_ENDIAN) {
-               ctf_uint_write(destp, dest_type->mantissa, mantissa);
-               ctf_int_write(destp, dest_type->exp, exp);
-               ctf_uint_write(destp, dest_type->sign, sign);
+       if (dest_declaration->byte_order == LITTLE_ENDIAN) {
+               ctf_uint_write(destp, dest_declaration->mantissa, mantissa);
+               ctf_int_write(destp, dest_declaration->exp, exp);
+               ctf_uint_write(destp, dest_declaration->sign, sign);
        } else {
-               ctf_uint_write(destp, dest_type->sign, sign);
-               ctf_int_write(destp, dest_type->exp, exp);
-               ctf_uint_write(destp, dest_type->mantissa, mantissa);
+               ctf_uint_write(destp, dest_declaration->sign, sign);
+               ctf_int_write(destp, dest_declaration->exp, exp);
+               ctf_uint_write(destp, dest_declaration->mantissa, mantissa);
        }
 }
 
 void ctf_float_copy(struct stream_pos *dest, struct stream_pos *src,
-                   const struct type_float *float_type)
+                   const struct declaration_float *float_declaration)
 {
-       align_pos(src, float_type->p.alignment);
-       align_pos(dest, float_type->p.alignment);
-       _ctf_float_copy(dest, float_type, src, float_type);
+       align_pos(src, float_declaration->p.alignment);
+       align_pos(dest, float_declaration->p.alignment);
+       _ctf_float_copy(dest, float_declaration, src, float_declaration);
 }
 
 double ctf_double_read(struct stream_pos *srcp,
-                      const struct type_float *float_type)
+                      const struct declaration_float *float_declaration)
 {
        union doubleIEEE754 u;
-       struct type_float *dest_type = float_type_new(NULL,
+       struct declaration_float *dest_declaration = float_declaration_new(NULL,
                                DBL_MANT_DIG,
                                sizeof(double) * CHAR_BIT - DBL_MANT_DIG,
                                BYTE_ORDER,
                                __alignof__(double));
        struct stream_pos destp;
 
-       align_pos(srcp, float_type->p.alignment);
+       align_pos(srcp, float_declaration->p.alignment);
        init_pos(&destp, (char *) u.bits);
-       _ctf_float_copy(&destp, dest_type, srcp, float_type);
-       type_unref(&dest_type->p);
+       _ctf_float_copy(&destp, dest_declaration, srcp, float_declaration);
+       declaration_unref(&dest_declaration->p);
        return u.v;
 }
 
 void ctf_double_write(struct stream_pos *destp,
-                     const struct type_float *float_type,
+                     const struct declaration_float *float_declaration,
                      double v)
 {
        union doubleIEEE754 u;
-       struct type_float *src_type = float_type_new(NULL,
+       struct declaration_float *src_declaration = float_declaration_new(NULL,
                                DBL_MANT_DIG,
                                sizeof(double) * CHAR_BIT - DBL_MANT_DIG,
                                BYTE_ORDER,
@@ -138,36 +138,36 @@ void ctf_double_write(struct stream_pos *destp,
        struct stream_pos srcp;
 
        u.v = v;
-       align_pos(destp, float_type->p.alignment);
+       align_pos(destp, float_declaration->p.alignment);
        init_pos(&srcp, (char *) u.bits);
-       _ctf_float_copy(destp, float_type, &srcp, src_type);
-       type_unref(&src_type->p);
+       _ctf_float_copy(destp, float_declaration, &srcp, src_declaration);
+       declaration_unref(&src_declaration->p);
 }
 
 long double ctf_ldouble_read(struct stream_pos *srcp,
-                            const struct type_float *float_type)
+                            const struct declaration_float *float_declaration)
 {
        union ldoubleIEEE754 u;
-       struct type_float *dest_type = float_type_new(NULL,
+       struct declaration_float *dest_declaration = float_declaration_new(NULL,
                                LDBL_MANT_DIG,
                                sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG,
                                BYTE_ORDER,
                                __alignof__(long double));
        struct stream_pos destp;
 
-       align_pos(srcp, float_type->p.alignment);
+       align_pos(srcp, float_declaration->p.alignment);
        init_pos(&destp, (char *) u.bits);
-       _ctf_float_copy(&destp, dest_type, srcp, float_type);
-       type_unref(&dest_type->p);
+       _ctf_float_copy(&destp, dest_declaration, srcp, float_declaration);
+       declaration_unref(&dest_declaration->p);
        return u.v;
 }
 
 void ctf_ldouble_write(struct stream_pos *destp,
-                      const struct type_float *float_type,
+                      const struct declaration_float *float_declaration,
                       long double v)
 {
        union ldoubleIEEE754 u;
-       struct type_float *src_type = float_type_new(NULL,
+       struct declaration_float *src_declaration = float_declaration_new(NULL,
                                LDBL_MANT_DIG,
                                sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG,
                                BYTE_ORDER,
@@ -175,8 +175,8 @@ void ctf_ldouble_write(struct stream_pos *destp,
        struct stream_pos srcp;
 
        u.v = v;
-       align_pos(destp, float_type->p.alignment);
+       align_pos(destp, float_declaration->p.alignment);
        init_pos(&srcp, (char *) u.bits);
-       _ctf_float_copy(destp, float_type, &srcp, src_type);
-       type_unref(&src_type->p);
+       _ctf_float_copy(destp, float_declaration, &srcp, src_declaration);
+       declaration_unref(&src_declaration->p);
 }
index 66e2a321eaf4bf6b12cbc37f3d5a1d091b3d8f27..fb6e0d425d2c7cbf420b11595aeff664ff1516a6 100644 (file)
 
 static
 uint64_t _aligned_uint_read(struct stream_pos *pos,
-                      const struct type_integer *integer_type)
+                      const struct declaration_integer *integer_declaration)
 {
-       int rbo = (integer_type->byte_order != BYTE_ORDER);     /* reverse byte order */
+       int rbo = (integer_declaration->byte_order != BYTE_ORDER);      /* reverse byte order */
 
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        assert(!(pos->offset % CHAR_BIT));
-       switch (integer_type->len) {
+       switch (integer_declaration->len) {
        case 8:
        {
                uint8_t v;
 
                v = *(const uint8_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return v;
        }
        case 16:
@@ -44,7 +44,7 @@ uint64_t _aligned_uint_read(struct stream_pos *pos,
                uint16_t v;
 
                v = *(const uint16_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT16_SWAP_LE_BE(v) : v;
        }
        case 32:
@@ -52,7 +52,7 @@ uint64_t _aligned_uint_read(struct stream_pos *pos,
                uint32_t v;
 
                v = *(const uint32_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT32_SWAP_LE_BE(v) : v;
        }
        case 64:
@@ -60,7 +60,7 @@ uint64_t _aligned_uint_read(struct stream_pos *pos,
                uint64_t v;
 
                v = *(const uint64_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT64_SWAP_LE_BE(v) : v;
        }
        default:
@@ -70,19 +70,19 @@ uint64_t _aligned_uint_read(struct stream_pos *pos,
 
 static
 int64_t _aligned_int_read(struct stream_pos *pos,
-                    const struct type_integer *integer_type)
+                    const struct declaration_integer *integer_declaration)
 {
-       int rbo = (integer_type->byte_order != BYTE_ORDER);     /* reverse byte order */
+       int rbo = (integer_declaration->byte_order != BYTE_ORDER);      /* reverse byte order */
 
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        assert(!(pos->offset % CHAR_BIT));
-       switch (integer_type->len) {
+       switch (integer_declaration->len) {
        case 8:
        {
                int8_t v;
 
                v = *(const int8_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return v;
        }
        case 16:
@@ -90,7 +90,7 @@ int64_t _aligned_int_read(struct stream_pos *pos,
                int16_t v;
 
                v = *(const int16_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT16_SWAP_LE_BE(v) : v;
        }
        case 32:
@@ -98,7 +98,7 @@ int64_t _aligned_int_read(struct stream_pos *pos,
                int32_t v;
 
                v = *(const int32_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT32_SWAP_LE_BE(v) : v;
        }
        case 64:
@@ -106,7 +106,7 @@ int64_t _aligned_int_read(struct stream_pos *pos,
                int64_t v;
 
                v = *(const int64_t *)pos->base;
-               move_pos(pos, integer_type->len);
+               move_pos(pos, integer_declaration->len);
                return rbo ? GUINT64_SWAP_LE_BE(v) : v;
        }
        default:
@@ -116,17 +116,17 @@ int64_t _aligned_int_read(struct stream_pos *pos,
 
 static
 void _aligned_uint_write(struct stream_pos *pos,
-                   const struct type_integer *integer_type,
+                   const struct declaration_integer *integer_declaration,
                    uint64_t v)
 {
-       int rbo = (integer_type->byte_order != BYTE_ORDER);     /* reverse byte order */
+       int rbo = (integer_declaration->byte_order != BYTE_ORDER);      /* reverse byte order */
 
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        assert(!(pos->offset % CHAR_BIT));
        if (pos->dummy)
                goto end;
 
-       switch (integer_type->len) {
+       switch (integer_declaration->len) {
        case 8: *(uint8_t *) get_pos_addr(pos) = (uint8_t) v;
                break;
        case 16:
@@ -147,22 +147,22 @@ void _aligned_uint_write(struct stream_pos *pos,
                assert(0);
        }
 end:
-       move_pos(pos, integer_type->len);
+       move_pos(pos, integer_declaration->len);
 }
 
 static
 void _aligned_int_write(struct stream_pos *pos,
-                  const struct type_integer *integer_type,
+                  const struct declaration_integer *integer_declaration,
                   int64_t v)
 {
-       int rbo = (integer_type->byte_order != BYTE_ORDER);     /* reverse byte order */
+       int rbo = (integer_declaration->byte_order != BYTE_ORDER);      /* reverse byte order */
 
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        assert(!(pos->offset % CHAR_BIT));
        if (pos->dummy)
                goto end;
 
-       switch (integer_type->len) {
+       switch (integer_declaration->len) {
        case 8: *(int8_t *) get_pos_addr(pos) = (int8_t) v;
                break;
        case 16:
@@ -183,72 +183,72 @@ void _aligned_int_write(struct stream_pos *pos,
                assert(0);
        }
 end:
-       move_pos(pos, integer_type->len);
+       move_pos(pos, integer_declaration->len);
        return;
 }
 
 uint64_t ctf_uint_read(struct stream_pos *pos,
-                       const struct type_integer *integer_type)
+                       const struct declaration_integer *integer_declaration)
 {
        uint64_t v = 0;
 
-       align_pos(pos, integer_type->p.alignment);
-       if (integer_type->byte_order == LITTLE_ENDIAN)
+       align_pos(pos, integer_declaration->p.alignment);
+       if (integer_declaration->byte_order == LITTLE_ENDIAN)
                bt_bitfield_read_le(pos->base, unsigned long, pos->offset,
-                                   integer_type->len, &v);
+                                   integer_declaration->len, &v);
        else
                bt_bitfield_read_be(pos->base, unsigned long, pos->offset,
-                                   integer_type->len, &v);
-       move_pos(pos, integer_type->len);
+                                   integer_declaration->len, &v);
+       move_pos(pos, integer_declaration->len);
        return v;
 }
 
 int64_t ctf_int_read(struct stream_pos *pos,
-                       const struct type_integer *integer_type)
+                       const struct declaration_integer *integer_declaration)
 {
        int64_t v = 0;
 
-       align_pos(pos, integer_type->p.alignment);
-       if (integer_type->byte_order == LITTLE_ENDIAN)
+       align_pos(pos, integer_declaration->p.alignment);
+       if (integer_declaration->byte_order == LITTLE_ENDIAN)
                bt_bitfield_read_le(pos->base, unsigned long, pos->offset,
-                                   integer_type->len, &v);
+                                   integer_declaration->len, &v);
        else
                bt_bitfield_read_be(pos->base, unsigned long, pos->offset,
-                                   integer_type->len, &v);
-       move_pos(pos, integer_type->len);
+                                   integer_declaration->len, &v);
+       move_pos(pos, integer_declaration->len);
        return v;
 }
 
 void ctf_uint_write(struct stream_pos *pos,
-                       const struct type_integer *integer_type,
+                       const struct declaration_integer *integer_declaration,
                        uint64_t v)
 {
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        if (pos->dummy)
                goto end;
-       if (integer_type->byte_order == LITTLE_ENDIAN)
+       if (integer_declaration->byte_order == LITTLE_ENDIAN)
                bt_bitfield_write_le(pos->base, unsigned long, pos->offset,
-                                    integer_type->len, v);
+                                    integer_declaration->len, v);
        else
                bt_bitfield_write_be(pos->base, unsigned long, pos->offset,
-                                    integer_type->len, v);
+                                    integer_declaration->len, v);
 end:
-       move_pos(pos, integer_type->len);
+       move_pos(pos, integer_declaration->len);
 }
 
 void ctf_int_write(struct stream_pos *pos,
-                       const struct type_integer *integer_type,
+                       const struct declaration_integer *integer_declaration,
                        int64_t v)
 {
-       align_pos(pos, integer_type->p.alignment);
+       align_pos(pos, integer_declaration->p.alignment);
        if (pos->dummy)
                goto end;
-       if (integer_type->byte_order == LITTLE_ENDIAN)
+       if (integer_declaration->byte_order == LITTLE_ENDIAN)
                bt_bitfield_write_le(pos->base, unsigned long, pos->offset,
-                                    integer_type->len, v);
+                                    integer_declaration->len, v);
        else
                bt_bitfield_write_be(pos->base, unsigned long, pos->offset,
-                                    integer_type->len, v);
+                                    integer_declaration->len, v);
 end:
-       move_pos(pos, integer_type->len);
+       move_pos(pos, integer_declaration->len);
 }
index 127c6588ef33fedff14362138a29a3b29c69ad88..24e09069e57cd7f4581fbc58dd7ab65a986c5907 100644 (file)
 #include <babeltrace/ctf/types.h>
 
 void ctf_sequence_begin(struct stream_pos *pos,
-                       const struct type_sequence *sequence_type)
+                       const struct declaration_sequence *sequence_declaration)
 {
-       align_pos(pos, sequence_type->p.alignment);
+       align_pos(pos, sequence_declaration->p.alignment);
 }
 
 void ctf_sequence_end(struct stream_pos *pos,
-                     const struct type_sequence *sequence_type)
+                     const struct declaration_sequence *sequence_declaration)
 {
 }
index 125e7b3b484814b3b3620044d006357b8df02c3f..31b1d593a10eeac25698dd29224015611ff164bb 100644 (file)
 #include <string.h>
 
 void ctf_string_copy(struct stream_pos *dest, struct stream_pos *src,
-                    const struct type_string *string_type)
+                    const struct declaration_string *string_declaration)
 {
        size_t len;
        char *destaddr, *srcaddr;
 
-       align_pos(src, string_type->p.alignment);
+       align_pos(src, string_declaration->p.alignment);
        srcaddr = get_pos_addr(src);
        len = strlen(srcaddr) + 1;
        if (dest->dummy)
                goto end;
-       align_pos(dest, string_type->p.alignment);
+       align_pos(dest, string_declaration->p.alignment);
        destaddr = get_pos_addr(dest);
        strcpy(destaddr, srcaddr);
 end:
@@ -40,12 +40,12 @@ end:
 }
 
 void ctf_string_read(char **dest, struct stream_pos *src,
-                    const struct type_string *string_type)
+                    const struct declaration_string *string_declaration)
 {
        size_t len;
        char *srcaddr;
 
-       align_pos(src, string_type->p.alignment);
+       align_pos(src, string_declaration->p.alignment);
        srcaddr = get_pos_addr(src);
        len = strlen(srcaddr) + 1;
        *dest = g_realloc(*dest, len);
@@ -54,12 +54,12 @@ void ctf_string_read(char **dest, struct stream_pos *src,
 }
 
 void ctf_string_write(struct stream_pos *dest, const char *src,
-                     const struct type_string *string_type)
+                     const struct declaration_string *string_declaration)
 {
        size_t len;
        char *destaddr;
 
-       align_pos(dest, string_type->p.alignment);
+       align_pos(dest, string_declaration->p.alignment);
        len = strlen(src) + 1;
        if (dest->dummy)
                goto end;
index 4eda7d6994d15b097f7a5d0d7f37b5d27cbf6f5b..dc3a06eb0a8bcda6b6474d7a426d275fee5f0ba8 100644 (file)
 #include <babeltrace/ctf/types.h>
 
 void ctf_struct_begin(struct stream_pos *pos,
-                     const struct type_struct *struct_type)
+                     const struct declaration_struct *struct_declaration)
 {
-       align_pos(pos, struct_type->p.alignment);
+       align_pos(pos, struct_declaration->p.alignment);
 }
 
 void ctf_struct_end(struct stream_pos *pos,
-                   const struct type_struct *struct_type)
+                   const struct declaration_struct *struct_declaration)
 {
 }
index 4422f1088a4171a24bafc016c883861ef031f42f..75dba56d8e5163b3f2db412b6fe6abc6b43a1e88 100644 (file)
 #include <babeltrace/ctf/types.h>
 
 void ctf_variant_begin(struct stream_pos *pos,
-                      const struct type_variant *variant_type)
+                      const struct declaration_variant *variant_declaration)
 {
 }
 
 void ctf_variant_end(struct stream_pos *pos,
-                    const struct type_variant *variant_type)
+                    const struct declaration_variant *variant_declaration)
 {
 }
index 5547480922ede2466ea78fac251caad80404797c..85ff1cb8145922ec31ef59443907218114de5a02 100644 (file)
@@ -46,11 +46,11 @@ struct ctf_event;
 
 struct ctf_trace {
        /* root scope */
-       struct type_scope *root_type_scope;
+       struct declaration_scope *root_declaration_scope;
        /* root scope */
        struct definition_scope *root_definition_scope;
 
-       struct type_scope *type_scope;
+       struct declaration_scope *declaration_scope;
        struct definition_scope *definition_scope;
        GPtrArray *streams;                     /* Array of struct ctf_stream pointers*/
 
@@ -85,7 +85,7 @@ struct ctf_trace {
 struct ctf_stream {
        struct ctf_trace *trace;
        /* parent is lexical scope conaining the stream scope */
-       struct type_scope *type_scope;
+       struct declaration_scope *declaration_scope;
        /* parent is trace scope */
        struct definition_scope *definition_scope;
        GPtrArray *events_by_id;                /* Array of struct ctf_event pointers indexed by id */
@@ -120,7 +120,7 @@ struct ctf_event {
        /* stream mapped by stream_id */
        struct ctf_stream *stream;
        /* parent is lexical scope conaining the event scope */
-       struct type_scope *type_scope;
+       struct declaration_scope *declaration_scope;
        /* parent is stream scope */
        struct definition_scope *definition_scope;
        struct definition_struct *context;
index d0073e4c8d51d64459222df739286327a23a4142..73288ef6681117bb8b8bd839f5bf5fc3f5f738fd 100644 (file)
  */
 
 uint64_t ctf_uint_read(struct stream_pos *pos,
-               const struct type_integer *integer_type);
+               const struct declaration_integer *integer_declaration);
 int64_t ctf_int_read(struct stream_pos *pos,
-               const struct type_integer *integer_type);
+               const struct declaration_integer *integer_declaration);
 void ctf_uint_write(struct stream_pos *pos,
-               const struct type_integer *integer_type,
+               const struct declaration_integer *integer_declaration,
                uint64_t v);
 void ctf_int_write(struct stream_pos *pos,
-               const struct type_integer *integer_type,
+               const struct declaration_integer *integer_declaration,
                int64_t v);
 
 double ctf_double_read(struct stream_pos *pos,
-                       const struct type_float *src);
+                       const struct declaration_float *src);
 void ctf_double_write(struct stream_pos *pos,
-               const struct type_float *dest,
+               const struct declaration_float *dest,
                double v);
 long double ctf_ldouble_read(struct stream_pos *pos,
-                            const struct type_float *src);
+                            const struct declaration_float *src);
 void ctf_ldouble_write(struct stream_pos *pos,
-               const struct type_float *dest,
+               const struct declaration_float *dest,
                long double v);
 void ctf_float_copy(struct stream_pos *destp,
                struct stream_pos *srcp,
-               const struct type_float *float_type);
+               const struct declaration_float *float_declaration);
 
 void ctf_string_copy(struct stream_pos *dest, struct stream_pos *src,
-                    const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
 void ctf_string_read(char **dest, struct stream_pos *src,
-                    const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
 void ctf_string_write(struct stream_pos *dest, const char *src,
-                     const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
 void ctf_string_free_temp(char *string);
 
 GArray *ctf_enum_read(struct stream_pos *pos,
-                     const struct type_enum *src);
+               const struct declaration_enum *src);
 void ctf_enum_write(struct stream_pos *pos,
-               const struct type_enum *dest,
+               const struct declaration_enum *dest,
                GQuark q);
 void ctf_struct_begin(struct stream_pos *pos,
-                     const struct type_struct *struct_type);
+               const struct declaration_struct *struct_declaration);
 void ctf_struct_end(struct stream_pos *pos,
-                   const struct type_struct *struct_type);
+               const struct declaration_struct *struct_declaration);
 void ctf_variant_begin(struct stream_pos *pos,
-                      const struct type_variant *variant_type);
+               const struct declaration_variant *variant_declaration);
 void ctf_variant_end(struct stream_pos *pos,
-                    const struct type_variant *variant_type);
+               const struct declaration_variant *variant_declaration);
 void ctf_array_begin(struct stream_pos *pos,
-                    const struct type_array *array_type);
+               const struct declaration_array *array_declaration);
 void ctf_array_end(struct stream_pos *pos,
-                  const struct type_array *array_type);
+               const struct declaration_array *array_declaration);
 void ctf_sequence_begin(struct stream_pos *pos,
-                       const struct type_sequence *sequence_type);
+               const struct declaration_sequence *sequence_declaration);
 void ctf_sequence_end(struct stream_pos *pos,
-                     const struct type_sequence *sequence_type);
+               const struct declaration_sequence *sequence_declaration);
 
 #endif /* _BABELTRACE_CTF_TYPES_H */
index 6cae14efc3744ab7de264c7b672321a0857cd3de..ad2f0cd10f41435b09a3647aa47338a2d464d046 100644 (file)
@@ -27,31 +27,31 @@ struct format {
        GQuark name;
 
        uint64_t (*uint_read)(struct stream_pos *pos,
-                       const struct type_integer *integer_type);
+               const struct declaration_integer *integer_declaration);
        int64_t (*int_read)(struct stream_pos *pos,
-                       const struct type_integer *integer_type);
+               const struct declaration_integer *integer_declaration);
        void (*uint_write)(struct stream_pos *pos,
-                          const struct type_integer *integer_type,
-                          uint64_t v);
+               const struct declaration_integer *integer_declaration,
+               uint64_t v);
        void (*int_write)(struct stream_pos *pos,
-                         const struct type_integer *integer_type,
-                         int64_t v);
+               const struct declaration_integer *integer_declaration,
+               int64_t v);
 
        void (*float_copy)(struct stream_pos *destp,
-                          struct stream_pos *srcp,
-                          const struct type_float *float_type);
+               struct stream_pos *srcp,
+               const struct declaration_float *float_declaration);
        double (*double_read)(struct stream_pos *pos,
-                             const struct type_float *float_type);
+               const struct declaration_float *float_declaration);
        void (*double_write)(struct stream_pos *pos,
-                            const struct type_float *float_type,
-                            double v);
+               const struct declaration_float *float_declaration,
+               double v);
 
        void (*string_copy)(struct stream_pos *dest, struct stream_pos *src,
-                           const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
        void (*string_read)(char **dest, struct stream_pos *src,
-                           const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
        void (*string_write)(struct stream_pos *dest, const char *src,
-                            const struct type_string *string_type);
+               const struct declaration_string *string_declaration);
        void (*string_free_temp)(char *string);
 
        /*
@@ -59,26 +59,26 @@ struct format {
         * g_array_unref().
         */
        GArray *(*enum_read)(struct stream_pos *pos,
-                           const struct type_enum *src);
+               const struct declaration_enum *src);
        void (*enum_write)(struct stream_pos *pos,
-                          const struct type_enum *dest,
-                          GQuark q);
+               const struct declaration_enum *dest,
+               GQuark q);
        void (*struct_begin)(struct stream_pos *pos,
-                            const struct type_struct *struct_type);
+               const struct declaration_struct *struct_declaration);
        void (*struct_end)(struct stream_pos *pos,
-                          const struct type_struct *struct_type);
+               const struct declaration_struct *struct_declaration);
        void (*variant_begin)(struct stream_pos *pos,
-                             const struct type_variant *variant_type);
+               const struct declaration_variant *variant_declaration);
        void (*variant_end)(struct stream_pos *pos,
-                           const struct type_variant *variant_type);
+               const struct declaration_variant *variant_declaration);
        void (*array_begin)(struct stream_pos *pos,
-                            const struct type_array *array_type);
+               const struct declaration_array *array_declaration);
        void (*array_end)(struct stream_pos *pos,
-                          const struct type_array *array_type);
+               const struct declaration_array *array_declaration);
        void (*sequence_begin)(struct stream_pos *pos,
-                            const struct type_sequence *sequence_type);
+               const struct declaration_sequence *sequence_declaration);
        void (*sequence_end)(struct stream_pos *pos,
-                          const struct type_sequence *sequence_type);
+               const struct declaration_sequence *sequence_declaration);
 };
 
 struct format *bt_lookup_format(GQuark qname);
index 144b018a6146264f76819a29cfbda2f4c3612d8e..0bcb8594dfe6e88b548feeefe7403b43480cacdb 100644 (file)
@@ -88,16 +88,16 @@ struct format;
 struct definition;
 
 /* type scope */
-struct type_scope {
+struct declaration_scope {
        /* Hash table mapping type name GQuark to "struct declaration" */
-       GHashTable *type_definitions;
-       /* Hash table mapping struct name GQuark to "struct type_struct" */
-       GHashTable *struct_types;
-       /* Hash table mapping variant name GQuark to "struct type_variant" */
-       GHashTable *variant_types;
+       GHashTable *typedef_declarations;
+       /* Hash table mapping struct name GQuark to "struct declaration_struct" */
+       GHashTable *struct_declarations;
+       /* Hash table mapping variant name GQuark to "struct declaration_variant" */
+       GHashTable *variant_declarations;
        /* Hash table mapping enum name GQuark to "struct type_enum" */
-       GHashTable *enum_types;
-       struct type_scope *parent_scope;
+       GHashTable *enum_declarations;
+       struct declaration_scope *parent_scope;
 };
 
 /* definition scope */
@@ -120,17 +120,17 @@ enum ctf_type_id {
        NR_CTF_TYPES,
 };
 
-struct type {
+struct declaration {
        enum ctf_type_id id;
        GQuark name;            /* type name */
        size_t alignment;       /* type alignment, in bits */
        int ref;                /* number of references to the type */
        /*
-        * type_free called with type ref is decremented to 0.
+        * declaration_free called with declaration ref is decremented to 0.
         */
-       void (*type_free)(struct type *type);
+       void (*declaration_free)(struct declaration *declaration);
        struct definition *
-               (*definition_new)(struct type *type,
+               (*definition_new)(struct declaration *declaration,
                                  struct definition_scope *parent_scope);
        /*
         * definition_free called with definition ref is decremented to 0.
@@ -146,7 +146,7 @@ struct type {
 };
 
 struct definition {
-       struct type *type;
+       struct declaration *declaration;
        int ref;                /* number of references to the definition */
 };
 
@@ -155,8 +155,8 @@ struct definition {
  * integers, except that their read/write functions must be able to deal with
  * read/write non aligned on CHAR_BIT.
  */
-struct type_integer {
-       struct type p;
+struct declaration_integer {
+       struct declaration p;
        size_t len;             /* length, in bits. */
        int byte_order;         /* byte order */
        int signedness;
@@ -164,7 +164,7 @@ struct type_integer {
 
 struct definition_integer {
        struct definition p;
-       struct type_integer *type;
+       struct declaration_integer *declaration;
        /* Last values read */
        union {
                uint64_t _unsigned;
@@ -172,18 +172,18 @@ struct definition_integer {
        } value;
 };
 
-struct type_float {
-       struct type p;
-       struct type_integer *sign;
-       struct type_integer *mantissa;
-       struct type_integer *exp;
+struct declaration_float {
+       struct declaration p;
+       struct declaration_integer *sign;
+       struct declaration_integer *mantissa;
+       struct declaration_integer *exp;
        int byte_order;
        /* TODO: we might want to express more info about NaN, +inf and -inf */
 };
 
 struct definition_float {
        struct definition p;
-       struct type_float *type;
+       struct declaration_float *declaration;
        /* Last values read */
        long double value;
 };
@@ -226,33 +226,33 @@ struct enum_table {
        GHashTable *quark_to_range_set;         /* (GQuark, range GArray) */
 };
 
-struct type_enum {
-       struct type p;
-       struct type_integer *integer_type;
+struct declaration_enum {
+       struct declaration p;
+       struct declaration_integer *integer_declaration;
        struct enum_table table;
 };
 
 struct definition_enum {
        struct definition p;
        struct definition_integer *integer;
-       struct type_enum *type;
+       struct declaration_enum *declaration;
        /* Last GQuark values read. Keeping a reference on the GQuark array. */
        GArray *value;
 };
 
-struct type_string {
-       struct type p;
+struct declaration_string {
+       struct declaration p;
 };
 
 struct definition_string {
        struct definition p;
-       struct type_string *type;
+       struct declaration_string *declaration;
        char *value;    /* freed at definition_string teardown */
 };
 
-struct type_field {
+struct declaration_field {
        GQuark name;
-       struct type *type;
+       struct declaration *declaration;
 };
 
 struct field {
@@ -260,71 +260,72 @@ struct field {
        struct definition *definition;
 };
 
-struct type_struct {
-       struct type p;
+struct declaration_struct {
+       struct declaration p;
        GHashTable *fields_by_name;     /* Tuples (field name, field index) */
-       struct type_scope *scope;
-       GArray *fields;                 /* Array of type_field */
+       struct declaration_scope *scope;
+       GArray *fields;                 /* Array of declaration_field */
 };
 
 struct definition_struct {
        struct definition p;
-       struct type_struct *type;
+       struct declaration_struct *declaration;
        struct definition_scope *scope;
        GArray *fields;                 /* Array of struct field */
 };
 
-struct type_variant {
-       struct type p;
+struct declaration_variant {
+       struct declaration p;
        GHashTable *fields_by_tag;      /* Tuples (field tag, field index) */
-       struct type_scope *scope;
-       GArray *fields;                 /* Array of type_field */
+       struct declaration_scope *scope;
+       GArray *fields;                 /* Array of declaration_field */
        GQuark tag_name;                /* TODO */
        /* Tag name must be nonzero and must exist when defining the variant */
 };
 
 struct definition_variant {
        struct definition p;
-       struct type_variant *type;
+       struct declaration_variant *declaration;
        struct definition_scope *scope;
        struct definition *enum_tag;
        GArray *fields;                 /* Array of struct field */
        struct field *current_field;    /* Last field read */
 };
 
-struct type_array {
-       struct type p;
+struct declaration_array {
+       struct declaration p;
        size_t len;
-       struct type *elem;
-       struct type_scope *scope;
+       struct declaration *elem;
+       struct declaration_scope *scope;
 };
 
 struct definition_array {
        struct definition p;
-       struct type_array *type;
+       struct declaration_array *declaration;
        struct definition_scope *scope;
        struct field current_element;           /* struct field */
 };
 
-struct type_sequence {
-       struct type p;
-       struct type_integer *len_type;
-       struct type *elem;
-       struct type_scope *scope;
+struct declaration_sequence {
+       struct declaration p;
+       struct declaration_integer *len_declaration;
+       struct declaration *elem;
+       struct declaration_scope *scope;
 };
 
 struct definition_sequence {
        struct definition p;
-       struct type_sequence *type;
+       struct declaration_sequence *declaration;
        struct definition_scope *scope;
        struct definition_integer *len;
        struct field current_element;           /* struct field */
 };
 
-int register_type(GQuark type_name, struct definition *definition,
-                 struct type_scope *scope);
-struct definition *lookup_type(GQuark type_name,
-                              struct type_scope *scope);
+int register_declaration(GQuark declaration_name,
+                        struct declaration *declaration,
+                        struct declaration_scope *scope);
+struct declaration *lookup_declaration(GQuark declaration_name,
+                                      struct declaration_scope *scope);
 
 /*
  * Type scopes also contain a separate registry for struct, variant and
@@ -332,22 +333,27 @@ struct definition *lookup_type(GQuark type_name,
  * that a named variant can be declared without specifying its target
  * "choice" tag field immediately.
  */
-int register_struct_type(GQuark struct_name, struct type_struct *struct_type,
-                        struct type_scope *scope);
-struct type_struct *lookup_struct_type(GQuark struct_name,
-                                      struct type_scope *scope);
-int register_variant_type(GQuark variant_name,
-                         struct type_variant *variant_type,
-                         struct type_scope *scope);
-struct type_variant *lookup_variant_type(GQuark variant_name,
-                                        struct type_scope *scope);
-int register_enum_type(GQuark enum_name, struct type_enum *enum_type,
-                      struct type_scope *scope);
-struct type_enum *lookup_enum_type(GQuark enum_name,
-                                  struct type_scope *scope);
-
-struct type_scope *new_type_scope(struct type_scope *parent_scope);
-void free_type_scope(struct type_scope *scope);
+int register_struct_declaration(GQuark struct_name,
+                               struct declaration_struct *struct_declaration,
+                               struct declaration_scope *scope);
+struct declaration_struct *
+       lookup_struct_declaration(GQuark struct_name,
+                                 struct declaration_scope *scope);
+int register_variant_declaration(GQuark variant_name,
+                         struct declaration_variant *variant_declaration,
+                         struct declaration_scope *scope);
+struct declaration_variant *lookup_variant_declaration(GQuark variant_name,
+                                        struct declaration_scope *scope);
+int register_enum_declaration(GQuark enum_name,
+                             struct declaration_enum *enum_declaration,
+                             struct declaration_scope *scope);
+struct declaration_enum *
+       lookup_enum_declaration(GQuark enum_name,
+                               struct declaration_scope *scope);
+
+struct declaration_scope *
+       new_declaration_scope(struct declaration_scope *parent_scope);
+void free_declaration_scope(struct declaration_scope *scope);
 
 /*
  * field_definition is for field definitions. They are registered into
@@ -363,15 +369,15 @@ struct definition_scope *
        new_definition_scope(struct definition_scope *parent_scope);
 void free_definition_scope(struct definition_scope *scope);
 
-void type_ref(struct type *type);
-void type_unref(struct type *type);
+void declaration_ref(struct declaration *declaration);
+void declaration_unref(struct declaration *declaration);
 
 void definition_ref(struct definition *definition);
 void definition_unref(struct definition *definition);
 
-/* Nameless types can be created by passing a NULL name */
+/* Nameless declarations can be created by passing a NULL name */
 
-struct type_integer *integer_type_new(const char *name,
+struct declaration_integer *integer_declaration_new(const char *name,
                                      size_t len, int byte_order,
                                      int signedness, size_t alignment);
 
@@ -379,7 +385,7 @@ struct type_integer *integer_type_new(const char *name,
  * mantissa_len is the length of the number of bytes represented by the mantissa
  * (e.g. result of DBL_MANT_DIG). It includes the leading 1.
  */
-struct type_float *float_type_new(const char *name,
+struct declaration_float *float_declaration_new(const char *name,
                                  size_t mantissa_len,
                                  size_t exp_len, int byte_order,
                                  size_t alignment);
@@ -393,44 +399,50 @@ struct type_float *float_type_new(const char *name,
  * Returns a GArray of GQuark or NULL.
  * Caller must release the GArray with g_array_unref().
  */
-GArray *enum_uint_to_quark_set(const struct type_enum *enum_type, uint64_t v);
+GArray *enum_uint_to_quark_set(const struct declaration_enum *enum_declaration,
+                              uint64_t v);
 
 /*
  * Returns a GArray of GQuark or NULL.
  * Caller must release the GArray with g_array_unref().
  */
-GArray *enum_int_to_quark_set(const struct type_enum *enum_type, uint64_t v);
+GArray *enum_int_to_quark_set(const struct declaration_enum *enum_declaration,
+                             uint64_t v);
 
 /*
  * Returns a GArray of struct enum_range or NULL.
  * Callers do _not_ own the returned GArray (and therefore _don't_ need to
  * release it).
  */
-GArray *enum_quark_to_range_set(const struct type_enum *enum_type, GQuark q);
-void enum_signed_insert(struct type_enum *enum_type,
+GArray *enum_quark_to_range_set(const struct declaration_enum *enum_declaration,
+                               GQuark q);
+void enum_signed_insert(struct declaration_enum *enum_declaration,
                         int64_t start, int64_t end, GQuark q);
-void enum_unsigned_insert(struct type_enum *enum_type,
+void enum_unsigned_insert(struct declaration_enum *enum_declaration,
                          uint64_t start, uint64_t end, GQuark q);
-size_t enum_get_nr_enumerators(struct type_enum *enum_type);
-
-struct type_enum *enum_type_new(const char *name,
-                               struct type_integer *integer_type);
-
-struct type_struct *struct_type_new(const char *name,
-                                   struct type_scope *parent_scope);
-void struct_type_add_field(struct type_struct *struct_type,
-                          const char *field_name, struct type *field_type);
+size_t enum_get_nr_enumerators(struct declaration_enum *enum_declaration);
+
+struct declaration_enum *
+       enum_declaration_new(const char *name,
+                            struct declaration_integer *integer_declaration);
+
+struct declaration_struct *
+       struct_declaration_new(const char *name,
+                              struct declaration_scope *parent_scope);
+void struct_declaration_add_field(struct declaration_struct *struct_declaration,
+                                 const char *field_name,
+                                 struct declaration *field_declaration);
 /*
  * Returns the index of a field within a structure.
  */
-unsigned long struct_type_lookup_field_index(struct type_struct *struct_type,
-                                            GQuark field_name);
+unsigned long struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
+                                                   GQuark field_name);
 /*
  * field returned only valid as long as the field structure is not appended to.
  */
-struct type_field *
-struct_type_get_field_from_index(struct type_struct *struct_type,
-                                unsigned long index);
+struct declaration_field *
+struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
+                                       unsigned long index);
 struct field *
 struct_get_field_from_index(struct definition_struct *struct_definition,
                            unsigned long index);
@@ -440,12 +452,12 @@ struct_get_field_from_index(struct definition_struct *struct_definition,
  * from numeric values to a single tag. Overlapping tag value ranges are
  * therefore forbidden.
  */
-struct type_variant *variant_type_new(const char *name,
-                                     struct type_scope *parent_scope);
-void variant_type_add_field(struct type_variant *variant_type,
-                           const char *tag_name, struct type *tag_type);
-struct type_field *
-variant_type_get_field_from_tag(struct type_variant *variant_type, GQuark tag);
+struct declaration_variant *variant_declaration_new(const char *name,
+                                     struct declaration_scope *parent_scope);
+void variant_declaration_add_field(struct declaration_variant *variant_declaration,
+                                  const char *tag_name, struct declaration *tag_declaration);
+struct declaration_field *
+       variant_declaration_get_field_from_tag(struct declaration_variant *variant_declaration, GQuark tag);
 /*
  * Returns 0 on success, -EPERM on error.
  */
@@ -456,24 +468,26 @@ int variant_definition_set_tag(struct definition_variant *variant,
  * field returned only valid as long as the variant structure is not appended
  * to.
  */
-struct field *
-variant_get_current_field(struct definition_variant *variant);
+struct field *variant_get_current_field(struct definition_variant *variant);
 
 /*
- * elem_type passed as parameter now belongs to the array. No need to free it
- * explicitly. "len" is the number of elements in the array.
+ * elem_declaration passed as parameter now belongs to the array. No
+ * need to free it explicitly. "len" is the number of elements in the
+ * array.
  */
-struct type_array *array_type_new(const char *name,
-                                 size_t len, struct type *elem_type,
-                                 struct type_scope *parent_scope);
+struct declaration_array *
+       array_declaration_new(const char *name,
+                       size_t len, struct declaration *elem_declaration,
+                       struct declaration_scope *parent_scope);
 
 /*
- * int_type and elem_type passed as parameter now belong to the sequence. No
- * need to free them explicitly.
+ * int_declaration and elem_declaration passed as parameter now belong
+ * to the sequence. No need to free them explicitly.
  */
-struct type_sequence *sequence_type_new(const char *name,
-                                       struct type_integer *len_type, 
-                                       struct type *elem_type,
-                                       struct type_scope *parent_scope);
+struct declaration_sequence *
+       sequence_declaration_new(const char *name,
+                       struct declaration_integer *len_declaration, 
+                       struct declaration *elem_declaration,
+                       struct declaration_scope *parent_scope);
 
-#endif /* _BABELTRACE_TYPES_H */
+#endif /* _BABELTRACE_declarationS_H */
index b13ba39267c0dbbec791c2d30980ef50938d5cfa..7b1d92a5747d54b23b0a1366f0cb5a127159d1a8 100644 (file)
@@ -20,7 +20,7 @@
 #include <babeltrace/format.h>
 
 static
-struct definition *_array_definition_new(struct type *type,
+struct definition *_array_definition_new(struct declaration *declaration,
                        struct definition_scope *parent_scope);
 static
 void _array_definition_free(struct definition *definition);
@@ -31,73 +31,74 @@ void array_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_array *array =
                container_of(definition, struct definition_array, p);
-       struct type_array *array_type = array->type;
+       struct declaration_array *array_declaration = array->declaration;
        uint64_t i;
 
-       fsrc->array_begin(src, array_type);
-       fdest->array_begin(dest, array_type);
+       fsrc->array_begin(src, array_declaration);
+       fdest->array_begin(dest, array_declaration);
 
-       for (i = 0; i < array_type->len; i++) {
+       for (i = 0; i < array_declaration->len; i++) {
                struct definition *elem = array->current_element.definition;
-               elem->type->copy(dest, fdest, src, fsrc, elem);
+               elem->declaration->copy(dest, fdest, src, fsrc, elem);
        }
-       fsrc->array_end(src, array_type);
-       fdest->array_end(dest, array_type);
+       fsrc->array_end(src, array_declaration);
+       fdest->array_end(dest, array_declaration);
 }
 
 static
-void _array_type_free(struct type *type)
+void _array_declaration_free(struct declaration *declaration)
 {
-       struct type_array *array_type =
-               container_of(type, struct type_array, p);
+       struct declaration_array *array_declaration =
+               container_of(declaration, struct declaration_array, p);
 
-       free_type_scope(array_type->scope);
-       type_unref(array_type->elem);
-       g_free(array_type);
+       free_declaration_scope(array_declaration->scope);
+       declaration_unref(array_declaration->elem);
+       g_free(array_declaration);
 }
 
-struct type_array *
-       array_type_new(const char *name, size_t len, struct type *elem_type,
-                      struct type_scope *parent_scope)
+struct declaration_array *
+       array_declaration_new(const char *name, size_t len,
+                             struct declaration *elem_declaration,
+                             struct declaration_scope *parent_scope)
 {
-       struct type_array *array_type;
-       struct type *type;
+       struct declaration_array *array_declaration;
+       struct declaration *declaration;
 
-       array_type = g_new(struct type_array, 1);
-       type = &array_type->p;
-       array_type->len = len;
-       type_ref(elem_type);
-       array_type->elem = elem_type;
-       array_type->scope = new_type_scope(parent_scope);
-       type->id = CTF_TYPE_ARRAY;
-       type->name = g_quark_from_string(name);
+       array_declaration = g_new(struct declaration_array, 1);
+       declaration = &array_declaration->p;
+       array_declaration->len = len;
+       declaration_ref(elem_declaration);
+       array_declaration->elem = elem_declaration;
+       array_declaration->scope = new_declaration_scope(parent_scope);
+       declaration->id = CTF_TYPE_ARRAY;
+       declaration->name = g_quark_from_string(name);
        /* No need to align the array, the first element will align itself */
-       type->alignment = 1;
-       type->copy = array_copy;
-       type->type_free = _array_type_free;
-       type->definition_new = _array_definition_new;
-       type->definition_free = _array_definition_free;
-       type->ref = 1;
-       return array_type;
+       declaration->alignment = 1;
+       declaration->copy = array_copy;
+       declaration->declaration_free = _array_declaration_free;
+       declaration->definition_new = _array_definition_new;
+       declaration->definition_free = _array_definition_free;
+       declaration->ref = 1;
+       return array_declaration;
 }
 
 static
 struct definition *
-       _array_definition_new(struct type *type,
+       _array_definition_new(struct declaration *declaration,
                              struct definition_scope *parent_scope)
 {
-       struct type_array *array_type =
-               container_of(type, struct type_array, p);
+       struct declaration_array *array_declaration =
+               container_of(declaration, struct declaration_array, p);
        struct definition_array *array;
 
        array = g_new(struct definition_array, 1);
-       type_ref(&array_type->p);
-       array->p.type = type;
-       array->type = array_type;
+       declaration_ref(&array_declaration->p);
+       array->p.declaration = declaration;
+       array->declaration = array_declaration;
        array->p.ref = 1;
        array->scope = new_definition_scope(parent_scope);
        array->current_element.definition =
-               array_type->elem->definition_new(array_type->elem,
+               array_declaration->elem->definition_new(array_declaration->elem,
                                                  parent_scope);
        return &array->p;
 }
@@ -110,8 +111,8 @@ void _array_definition_free(struct definition *definition)
        struct definition *elem_definition =
                array->current_element.definition;
 
-       elem_definition->type->definition_free(elem_definition);
+       elem_definition->declaration->definition_free(elem_definition);
        free_definition_scope(array->scope);
-       type_unref(array->p.type);
+       declaration_unref(array->p.declaration);
        g_free(array);
 }
index 932eedf5ed3e554d07a324f7b115efaa85776793..67c23f0905983ad6bb5831b139d2eed9fc7e5a53 100644 (file)
@@ -22,8 +22,8 @@
 #include <glib.h>
 
 static
-struct definition *_enum_definition_new(struct type *type,
-                                struct definition_scope *parent_scope);
+struct definition *_enum_definition_new(struct declaration *declaration,
+                                       struct definition_scope *parent_scope);
 static
 void _enum_definition_free(struct definition *definition);
 
@@ -37,17 +37,17 @@ void enum_range_set_free(void *ptr)
  * Returns a GArray or NULL.
  * Caller must release the GArray with g_array_unref().
  */
-GArray *enum_uint_to_quark_set(const struct type_enum *enum_type,
+GArray *enum_uint_to_quark_set(const struct declaration_enum *enum_declaration,
                               uint64_t v)
 {
        struct enum_range_to_quark *iter;
        GArray *qs, *ranges = NULL;
 
        /* Single values lookup */
-       qs = g_hash_table_lookup(enum_type->table.value_to_quark_set, &v);
+       qs = g_hash_table_lookup(enum_declaration->table.value_to_quark_set, &v);
 
        /* Range lookup */
-       cds_list_for_each_entry(iter, &enum_type->table.range_to_quark, node) {
+       cds_list_for_each_entry(iter, &enum_declaration->table.range_to_quark, node) {
                if (iter->range.start._unsigned > v || iter->range.end._unsigned < v)
                        continue;
                if (!ranges) {
@@ -79,16 +79,17 @@ GArray *enum_uint_to_quark_set(const struct type_enum *enum_type,
  * Returns a GArray or NULL.
  * Caller must release the GArray with g_array_unref().
  */
-GArray *enum_int_to_quark_set(const struct type_enum *enum_type, uint64_t v)
+GArray *enum_int_to_quark_set(const struct declaration_enum *enum_declaration,
+                             uint64_t v)
 {
        struct enum_range_to_quark *iter;
        GArray *qs, *ranges = NULL;
 
        /* Single values lookup */
-       qs = g_hash_table_lookup(enum_type->table.value_to_quark_set, &v);
+       qs = g_hash_table_lookup(enum_declaration->table.value_to_quark_set, &v);
 
        /* Range lookup */
-       cds_list_for_each_entry(iter, &enum_type->table.range_to_quark, node) {
+       cds_list_for_each_entry(iter, &enum_declaration->table.range_to_quark, node) {
                if (iter->range.start._signed > v || iter->range.end._signed < v)
                        continue;
                if (!ranges) {
@@ -141,20 +142,20 @@ void enum_val_free(void *ptr)
 }
 
 static
-void enum_signed_insert_value_to_quark_set(struct type_enum *enum_type,
+void enum_signed_insert_value_to_quark_set(struct declaration_enum *enum_declaration,
                        int64_t v, GQuark q)
 {
        int64_t *valuep;
        GArray *array;
 
-       array = g_hash_table_lookup(enum_type->table.value_to_quark_set, &v);
+       array = g_hash_table_lookup(enum_declaration->table.value_to_quark_set, &v);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE, sizeof(GQuark), 1);
                g_array_set_size(array, 1);
                g_array_index(array, GQuark, array->len - 1) = q;
                valuep = g_new(int64_t, 1);
                *valuep = v;
-               g_hash_table_insert(enum_type->table.value_to_quark_set, valuep, array);
+               g_hash_table_insert(enum_declaration->table.value_to_quark_set, valuep, array);
        } else {
                g_array_set_size(array, array->len + 1);
                g_array_index(array, GQuark, array->len - 1) = q;
@@ -162,20 +163,20 @@ void enum_signed_insert_value_to_quark_set(struct type_enum *enum_type,
 }
 
 static
-void enum_unsigned_insert_value_to_quark_set(struct type_enum *enum_type,
+void enum_unsigned_insert_value_to_quark_set(struct declaration_enum *enum_declaration,
                         uint64_t v, GQuark q)
 {
        uint64_t *valuep;
        GArray *array;
 
-       array = g_hash_table_lookup(enum_type->table.value_to_quark_set, &v);
+       array = g_hash_table_lookup(enum_declaration->table.value_to_quark_set, &v);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE, sizeof(GQuark), 1);
                g_array_set_size(array, 1);
                g_array_index(array, GQuark, array->len - 1) = q;
                valuep = g_new(uint64_t, 1);
                *valuep = v;
-               g_hash_table_insert(enum_type->table.value_to_quark_set, valuep, array);
+               g_hash_table_insert(enum_declaration->table.value_to_quark_set, valuep, array);
        } else {
                g_array_set_size(array, array->len + 1);
                g_array_index(array, GQuark, array->len - 1) = q;
@@ -200,18 +201,18 @@ void enum_val_free(void *ptr)
 }
 
 static
-void enum_signed_insert_value_to_quark_set(struct type_enum *enum_type,
+void enum_signed_insert_value_to_quark_set(struct declaration_enum *enum_declaration,
                        int64_t v, GQuark q)
 {
        GArray *array;
 
-       array = g_hash_table_lookup(enum_type->table.value_to_quark_set,
+       array = g_hash_table_lookup(enum_declaration->table.value_to_quark_set,
                                    (gconstpointer) v);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE, sizeof(GQuark), 1);
                g_array_set_size(array, 1);
                g_array_index(array, GQuark, array->len - 1) = q;
-               g_hash_table_insert(enum_type->table.value_to_quark_set,
+               g_hash_table_insert(enum_declaration->table.value_to_quark_set,
                                    (gpointer) v, array);
        } else {
                g_array_set_size(array, array->len + 1);
@@ -220,18 +221,18 @@ void enum_signed_insert_value_to_quark_set(struct type_enum *enum_type,
 }
 
 static
-void enum_unsigned_insert_value_to_quark_set(struct type_enum *enum_type,
+void enum_unsigned_insert_value_to_quark_set(struct declaration_enum *enum_declaration,
                         uint64_t v, GQuark q)
 {
        GArray *array;
 
-       array = g_hash_table_lookup(enum_type->table.value_to_quark_set,
+       array = g_hash_table_lookup(enum_declaration->table.value_to_quark_set,
                                    (gconstpointer) v);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE, sizeof(GQuark), 1);
                g_array_set_size(array, 1);
                g_array_index(array, GQuark, array->len - 1) = q;
-               g_hash_table_insert(enum_type->table.value_to_quark_set,
+               g_hash_table_insert(enum_declaration->table.value_to_quark_set,
                                    (gpointer) v, array);
        } else {
                g_array_set_size(array, array->len + 1);
@@ -240,47 +241,47 @@ void enum_unsigned_insert_value_to_quark_set(struct type_enum *enum_type,
 }
 #endif /* __WORDSIZE != 32 */
 
-GArray *enum_quark_to_range_set(const struct type_enum *enum_type,
+GArray *enum_quark_to_range_set(const struct declaration_enum *enum_declaration,
                                GQuark q)
 {
-       return g_hash_table_lookup(enum_type->table.quark_to_range_set,
+       return g_hash_table_lookup(enum_declaration->table.quark_to_range_set,
                                   (gconstpointer) (unsigned long) q);
 }
 
 static
-void enum_signed_insert_range_to_quark(struct type_enum *enum_type,
+void enum_signed_insert_range_to_quark(struct declaration_enum *enum_declaration,
                         int64_t start, int64_t end, GQuark q)
 {
        struct enum_range_to_quark *rtoq;
 
        rtoq = g_new(struct enum_range_to_quark, 1);
-       cds_list_add(&rtoq->node, &enum_type->table.range_to_quark);
+       cds_list_add(&rtoq->node, &enum_declaration->table.range_to_quark);
        rtoq->range.start._signed = start;
        rtoq->range.end._signed = end;
        rtoq->quark = q;
 }
 
 static
-void enum_unsigned_insert_range_to_quark(struct type_enum *enum_type,
+void enum_unsigned_insert_range_to_quark(struct declaration_enum *enum_declaration,
                         uint64_t start, uint64_t end, GQuark q)
 {
        struct enum_range_to_quark *rtoq;
 
        rtoq = g_new(struct enum_range_to_quark, 1);
-       cds_list_add(&rtoq->node, &enum_type->table.range_to_quark);
+       cds_list_add(&rtoq->node, &enum_declaration->table.range_to_quark);
        rtoq->range.start._unsigned = start;
        rtoq->range.end._unsigned = end;
        rtoq->quark = q;
 }
 
-void enum_signed_insert(struct type_enum *enum_type,
+void enum_signed_insert(struct declaration_enum *enum_declaration,
                         int64_t start, int64_t end, GQuark q)
 {
        GArray *array;
        struct enum_range *range;
 
        if (start == end) {
-               enum_signed_insert_value_to_quark_set(enum_type, start, q);
+               enum_signed_insert_value_to_quark_set(enum_declaration, start, q);
        } else {
                if (start > end) {
                        uint64_t tmp;
@@ -289,15 +290,15 @@ void enum_signed_insert(struct type_enum *enum_type,
                        start = end;
                        end = tmp;
                }
-               enum_signed_insert_range_to_quark(enum_type, start, end, q);
+               enum_signed_insert_range_to_quark(enum_declaration, start, end, q);
        }
 
-       array = g_hash_table_lookup(enum_type->table.quark_to_range_set,
+       array = g_hash_table_lookup(enum_declaration->table.quark_to_range_set,
                                    (gconstpointer) (unsigned long) q);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE,
                                          sizeof(struct enum_range), 1);
-               g_hash_table_insert(enum_type->table.quark_to_range_set,
+               g_hash_table_insert(enum_declaration->table.quark_to_range_set,
                                    (gpointer) (unsigned long) q,
                                    array);
        }
@@ -307,7 +308,7 @@ void enum_signed_insert(struct type_enum *enum_type,
        range->end._signed = end;
 }
 
-void enum_unsigned_insert(struct type_enum *enum_type,
+void enum_unsigned_insert(struct declaration_enum *enum_declaration,
                          uint64_t start, uint64_t end, GQuark q)
 {
        GArray *array;
@@ -315,7 +316,7 @@ void enum_unsigned_insert(struct type_enum *enum_type,
 
 
        if (start == end) {
-               enum_unsigned_insert_value_to_quark_set(enum_type, start, q);
+               enum_unsigned_insert_value_to_quark_set(enum_declaration, start, q);
        } else {
                if (start > end) {
                        uint64_t tmp;
@@ -324,15 +325,15 @@ void enum_unsigned_insert(struct type_enum *enum_type,
                        start = end;
                        end = tmp;
                }
-               enum_unsigned_insert_range_to_quark(enum_type, start, end, q);
+               enum_unsigned_insert_range_to_quark(enum_declaration, start, end, q);
        }
 
-       array = g_hash_table_lookup(enum_type->table.quark_to_range_set,
+       array = g_hash_table_lookup(enum_declaration->table.quark_to_range_set,
                                    (gconstpointer) (unsigned long) q);
        if (!array) {
                array = g_array_sized_new(FALSE, TRUE,
                                          sizeof(struct enum_range), 1);
-               g_hash_table_insert(enum_type->table.quark_to_range_set,
+               g_hash_table_insert(enum_declaration->table.quark_to_range_set,
                                    (gpointer) (unsigned long) q,
                                    array);
        }
@@ -342,9 +343,9 @@ void enum_unsigned_insert(struct type_enum *enum_type,
        range->end._unsigned = end;
 }
 
-size_t enum_get_nr_enumerators(struct type_enum *enum_type)
+size_t enum_get_nr_enumerators(struct declaration_enum *enum_declaration)
 {
-       return g_hash_table_size(enum_type->table.quark_to_range_set);
+       return g_hash_table_size(enum_declaration->table.quark_to_range_set);
 }
 
 void enum_copy(struct stream_pos *dest, const struct format *fdest, 
@@ -353,11 +354,11 @@ void enum_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_enum *_enum =
                container_of(definition, struct definition_enum, p);
-       struct type_enum *enum_type= _enum->type;
+       struct declaration_enum *enum_declaration= _enum->declaration;
        GArray *array;
        GQuark v;
 
-       array = fsrc->enum_read(src, enum_type);
+       array = fsrc->enum_read(src, enum_declaration);
        assert(array);
        /* unref previous array */
        if (_enum->value)
@@ -365,76 +366,76 @@ void enum_copy(struct stream_pos *dest, const struct format *fdest,
        _enum->value = array;
        /*
         * Arbitrarily choose the first one.
-        * TODO: use direct underlying type read/write intead. Not doing it for
+        * TODO: use direct underlying declaration read/write intead. Not doing it for
         * now to test enum read and write code.
         */
        v = g_array_index(array, GQuark, 0);
-       return fdest->enum_write(dest, enum_type, v);
+       return fdest->enum_write(dest, enum_declaration, v);
 }
 
 static
-void _enum_type_free(struct type *type)
+void _enum_declaration_free(struct declaration *declaration)
 {
-       struct type_enum *enum_type =
-               container_of(type, struct type_enum, p);
+       struct declaration_enum *enum_declaration =
+               container_of(declaration, struct declaration_enum, p);
        struct enum_range_to_quark *iter, *tmp;
 
-       g_hash_table_destroy(enum_type->table.value_to_quark_set);
-       cds_list_for_each_entry_safe(iter, tmp, &enum_type->table.range_to_quark, node) {
+       g_hash_table_destroy(enum_declaration->table.value_to_quark_set);
+       cds_list_for_each_entry_safe(iter, tmp, &enum_declaration->table.range_to_quark, node) {
                cds_list_del(&iter->node);
                g_free(iter);
        }
-       g_hash_table_destroy(enum_type->table.quark_to_range_set);
-       type_unref(&enum_type->integer_type->p);
-       g_free(enum_type);
+       g_hash_table_destroy(enum_declaration->table.quark_to_range_set);
+       declaration_unref(&enum_declaration->integer_declaration->p);
+       g_free(enum_declaration);
 }
 
-struct type_enum *
-       _enum_type_new(const char *name, struct type_integer *integer_type)
+struct declaration_enum *
+       _enum_declaration_new(const char *name, struct declaration_integer *integer_declaration)
 {
-       struct type_enum *enum_type;
+       struct declaration_enum *enum_declaration;
 
-       enum_type = g_new(struct type_enum, 1);
+       enum_declaration = g_new(struct declaration_enum, 1);
 
-       enum_type->table.value_to_quark_set = g_hash_table_new_full(enum_val_hash,
+       enum_declaration->table.value_to_quark_set = g_hash_table_new_full(enum_val_hash,
                                                            enum_val_equal,
                                                            enum_val_free,
                                                            enum_range_set_free);
-       CDS_INIT_LIST_HEAD(&enum_type->table.range_to_quark);
-       enum_type->table.quark_to_range_set = g_hash_table_new_full(g_int_hash,
+       CDS_INIT_LIST_HEAD(&enum_declaration->table.range_to_quark);
+       enum_declaration->table.quark_to_range_set = g_hash_table_new_full(g_int_hash,
                                                        g_int_equal,
                                                        NULL, enum_range_set_free);
-       type_ref(&integer_type->p);
-       enum_type->integer_type = integer_type;
-       enum_type->p.id = CTF_TYPE_ENUM;
-       enum_type->p.name = g_quark_from_string(name);
-       enum_type->p.alignment = 1;
-       enum_type->p.copy = enum_copy;
-       enum_type->p.type_free = _enum_type_free;
-       enum_type->p.definition_new = _enum_definition_new;
-       enum_type->p.definition_free = _enum_definition_free;
-       enum_type->p.ref = 1;
-       return enum_type;
+       declaration_ref(&integer_declaration->p);
+       enum_declaration->integer_declaration = integer_declaration;
+       enum_declaration->p.id = CTF_TYPE_ENUM;
+       enum_declaration->p.name = g_quark_from_string(name);
+       enum_declaration->p.alignment = 1;
+       enum_declaration->p.copy = enum_copy;
+       enum_declaration->p.declaration_free = _enum_declaration_free;
+       enum_declaration->p.definition_new = _enum_definition_new;
+       enum_declaration->p.definition_free = _enum_definition_free;
+       enum_declaration->p.ref = 1;
+       return enum_declaration;
 }
 
 static
 struct definition *
-       _enum_definition_new(struct type *type,
+       _enum_definition_new(struct declaration *declaration,
                             struct definition_scope *parent_scope)
 {
-       struct type_enum *enum_type =
-               container_of(type, struct type_enum, p);
+       struct declaration_enum *enum_declaration =
+               container_of(declaration, struct declaration_enum, p);
        struct definition_enum *_enum;
        struct definition *definition_integer_parent;
 
        _enum = g_new(struct definition_enum, 1);
-       type_ref(&enum_type->p);
-       _enum->p.type = type;
-       _enum->type = enum_type;
+       declaration_ref(&enum_declaration->p);
+       _enum->p.declaration = declaration;
+       _enum->declaration = enum_declaration;
        _enum->p.ref = 1;
        _enum->value = NULL;
        definition_integer_parent =
-               enum_type->integer_type->p.definition_new(&enum_type->integer_type->p,
+               enum_declaration->integer_declaration->p.definition_new(&enum_declaration->integer_declaration->p,
                                                           parent_scope);
        _enum->integer = container_of(definition_integer_parent,
                                      struct definition_integer, p);
@@ -448,7 +449,7 @@ void _enum_definition_free(struct definition *definition)
                container_of(definition, struct definition_enum, p);
 
        definition_unref(&_enum->integer->p);
-       type_unref(_enum->p.type);
+       declaration_unref(_enum->p.declaration);
        if (_enum->value)
                g_array_unref(_enum->value);
        g_free(_enum);
index c120ae3a756a2ec5f626f0a67f7c6b0742232dbd..b12cf6be06d85241d5f9970e1f84ee1502d3f8b8 100644 (file)
@@ -20,7 +20,7 @@
 #include <babeltrace/format.h>
 
 static
-struct definition *_float_definition_new(struct type *type,
+struct definition *_float_definition_new(struct declaration *declaration,
                                   struct definition_scope *parent_scope);
 static
 void _float_definition_free(struct definition *definition);
@@ -33,71 +33,71 @@ void float_copy(struct stream_pos *destp,
 {
        struct definition_float *_float =
                container_of(definition, struct definition_float, p);
-       struct type_float *float_type = _float->type;
+       struct declaration_float *float_declaration = _float->declaration;
 
        if (fsrc->float_copy == fdest->float_copy) {
-               fsrc->float_copy(destp, srcp, float_type);
+               fsrc->float_copy(destp, srcp, float_declaration);
        } else {
                double v;
 
-               v = fsrc->double_read(srcp, float_type);
-               fdest->double_write(destp, float_type, v);
+               v = fsrc->double_read(srcp, float_declaration);
+               fdest->double_write(destp, float_declaration, v);
        }
 }
 
 static
-void _float_type_free(struct type *type)
+void _float_declaration_free(struct declaration *declaration)
 {
-       struct type_float *float_type =
-               container_of(type, struct type_float, p);
+       struct declaration_float *float_declaration =
+               container_of(declaration, struct declaration_float, p);
 
-       type_unref(&float_type->exp->p);
-       type_unref(&float_type->mantissa->p);
-       type_unref(&float_type->sign->p);
-       g_free(float_type);
+       declaration_unref(&float_declaration->exp->p);
+       declaration_unref(&float_declaration->mantissa->p);
+       declaration_unref(&float_declaration->sign->p);
+       g_free(float_declaration);
 }
 
-struct type_float *
-       float_type_new(const char *name, size_t mantissa_len,
+struct declaration_float *
+       float_declaration_new(const char *name, size_t mantissa_len,
                       size_t exp_len, int byte_order, size_t alignment)
 {
-       struct type_float *float_type;
-       struct type *type;
+       struct declaration_float *float_declaration;
+       struct declaration *declaration;
 
-       float_type = g_new(struct type_float, 1);
-       type = &float_type->p;
-       type->id = CTF_TYPE_FLOAT;
-       type->name = g_quark_from_string(name);
-       type->alignment = alignment;
-       type->copy = float_copy;
-       type->type_free = _float_type_free;
-       type->definition_new = _float_definition_new;
-       type->definition_free = _float_definition_free;
-       type->ref = 1;
-       float_type->byte_order = byte_order;
+       float_declaration = g_new(struct declaration_float, 1);
+       declaration = &float_declaration->p;
+       declaration->id = CTF_TYPE_FLOAT;
+       declaration->name = g_quark_from_string(name);
+       declaration->alignment = alignment;
+       declaration->copy = float_copy;
+       declaration->declaration_free = _float_declaration_free;
+       declaration->definition_new = _float_definition_new;
+       declaration->definition_free = _float_definition_free;
+       declaration->ref = 1;
+       float_declaration->byte_order = byte_order;
 
-       float_type->sign = integer_type_new(NULL, 1,
+       float_declaration->sign = integer_declaration_new(NULL, 1,
                                            byte_order, false, 1);
-       float_type->mantissa = integer_type_new(NULL, mantissa_len - 1,
+       float_declaration->mantissa = integer_declaration_new(NULL, mantissa_len - 1,
                                                byte_order, false, 1);
-       float_type->exp = integer_type_new(NULL, exp_len,
+       float_declaration->exp = integer_declaration_new(NULL, exp_len,
                                           byte_order, true, 1);
-       return float_type;
+       return float_declaration;
 }
 
 static
 struct definition *
-       _float_definition_new(struct type *type,
+       _float_definition_new(struct declaration *declaration,
                              struct definition_scope *parent_scope)
 {
-       struct type_float *float_type =
-               container_of(type, struct type_float, p);
+       struct declaration_float *float_declaration =
+               container_of(declaration, struct declaration_float, p);
        struct definition_float *_float;
 
        _float = g_new(struct definition_float, 1);
-       type_ref(&float_type->p);
-       _float->p.type= type;
-       _float->type= float_type;
+       declaration_ref(&float_declaration->p);
+       _float->p.declaration= declaration;
+       _float->declaration= float_declaration;
        _float->p.ref = 1;
        _float->value = 0.0;
        return &_float->p;
@@ -109,6 +109,6 @@ void _float_definition_free(struct definition *definition)
        struct definition_float *_float =
                container_of(definition, struct definition_float, p);
 
-       type_unref(_float->p.type);
+       declaration_unref(_float->p.declaration);
        g_free(_float);
 }
index 41dd7751febf1065cb24b407de55c7f492841c49..c207079defc661876225e38977fe1c0fcc7bb230 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdint.h>
 
 static
-struct definition *_integer_definition_new(struct type *type,
+struct definition *_integer_definition_new(struct declaration *declaration,
                               struct definition_scope *parent_scope);
 static
 void _integer_definition_free(struct definition *definition);
@@ -33,63 +33,63 @@ void integer_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_integer *integer =
                container_of(definition, struct definition_integer, p);
-       struct type_integer *integer_type = integer->type;
+       struct declaration_integer *integer_declaration = integer->declaration;
 
-       if (!integer_type->signedness) {
+       if (!integer_declaration->signedness) {
                uint64_t v;
 
-               v = fsrc->uint_read(src, integer_type);
-               fdest->uint_write(dest, integer_type, v);
+               v = fsrc->uint_read(src, integer_declaration);
+               fdest->uint_write(dest, integer_declaration, v);
        } else {
                int64_t v;
 
-               v = fsrc->int_read(src, integer_type);
-               fdest->int_write(dest, integer_type, v);
+               v = fsrc->int_read(src, integer_declaration);
+               fdest->int_write(dest, integer_declaration, v);
        }
 }
 
 static
-void _integer_type_free(struct type *type)
+void _integer_declaration_free(struct declaration *declaration)
 {
-       struct type_integer *integer_type =
-               container_of(type, struct type_integer, p);
-       g_free(integer_type);
+       struct declaration_integer *integer_declaration =
+               container_of(declaration, struct declaration_integer, p);
+       g_free(integer_declaration);
 }
 
-struct type_integer *
-       integer_type_new(const char *name, size_t len, int byte_order,
+struct declaration_integer *
+       integer_declaration_new(const char *name, size_t len, int byte_order,
                         int signedness, size_t alignment)
 {
-       struct type_integer *integer_type;
+       struct declaration_integer *integer_declaration;
 
-       integer_type = g_new(struct type_integer, 1);
-       integer_type->p.id = CTF_TYPE_INTEGER;
-       integer_type->p.name = g_quark_from_string(name);
-       integer_type->p.alignment = alignment;
-       integer_type->p.copy = integer_copy;
-       integer_type->p.type_free = _integer_type_free;
-       integer_type->p.definition_free = _integer_definition_free;
-       integer_type->p.definition_new = _integer_definition_new;
-       integer_type->p.ref = 1;
-       integer_type->len = len;
-       integer_type->byte_order = byte_order;
-       integer_type->signedness = signedness;
-       return integer_type;
+       integer_declaration = g_new(struct declaration_integer, 1);
+       integer_declaration->p.id = CTF_TYPE_INTEGER;
+       integer_declaration->p.name = g_quark_from_string(name);
+       integer_declaration->p.alignment = alignment;
+       integer_declaration->p.copy = integer_copy;
+       integer_declaration->p.declaration_free = _integer_declaration_free;
+       integer_declaration->p.definition_free = _integer_definition_free;
+       integer_declaration->p.definition_new = _integer_definition_new;
+       integer_declaration->p.ref = 1;
+       integer_declaration->len = len;
+       integer_declaration->byte_order = byte_order;
+       integer_declaration->signedness = signedness;
+       return integer_declaration;
 }
 
 static
 struct definition *
-       _integer_definition_new(struct type *type,
+       _integer_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope)
 {
-       struct type_integer *integer_type =
-               container_of(type, struct type_integer, p);
+       struct declaration_integer *integer_declaration =
+               container_of(declaration, struct declaration_integer, p);
        struct definition_integer *integer;
 
        integer = g_new(struct definition_integer, 1);
-       type_ref(&integer_type->p);
-       integer->p.type = type;
-       integer->type = integer_type;
+       declaration_ref(&integer_declaration->p);
+       integer->p.declaration = declaration;
+       integer->declaration = integer_declaration;
        integer->p.ref = 1;
        integer->value._unsigned = 0;
        return &integer->p;
@@ -101,6 +101,6 @@ void _integer_definition_free(struct definition *definition)
        struct definition_integer *integer =
                container_of(definition, struct definition_integer, p);
 
-       type_unref(integer->p.type);
+       declaration_unref(integer->p.declaration);
        g_free(integer);
 }
index d455dff337e7469ecb1fdf7ddfb0b7f35d78e82e..8db1ee0466b66b2bb7d661bb6245e4f2db3f9f3f 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 static
-struct definition *_sequence_definition_new(struct type *type,
+struct definition *_sequence_definition_new(struct declaration *declaration,
                                        struct definition_scope *parent_scope);
 static
 void _sequence_definition_free(struct definition *definition);
@@ -35,84 +35,84 @@ void sequence_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_sequence *sequence =
                container_of(definition, struct definition_sequence, p);
-       struct type_sequence *sequence_type = sequence->type;
+       struct declaration_sequence *sequence_declaration = sequence->declaration;
        uint64_t i;
 
-       fsrc->sequence_begin(src, sequence_type);
-       fdest->sequence_begin(dest, sequence_type);
+       fsrc->sequence_begin(src, sequence_declaration);
+       fdest->sequence_begin(dest, sequence_declaration);
 
-       sequence->len->p.type->copy(dest, fdest, src, fsrc,
+       sequence->len->p.declaration->copy(dest, fdest, src, fsrc,
                                    &sequence->len->p);
 
        for (i = 0; i < sequence->len->value._unsigned; i++) {
                struct definition *elem =
                        sequence->current_element.definition;
-               elem->type->copy(dest, fdest, src, fsrc, elem);
+               elem->declaration->copy(dest, fdest, src, fsrc, elem);
        }
-       fsrc->sequence_end(src, sequence_type);
-       fdest->sequence_end(dest, sequence_type);
+       fsrc->sequence_end(src, sequence_declaration);
+       fdest->sequence_end(dest, sequence_declaration);
 }
 
 static
-void _sequence_type_free(struct type *type)
+void _sequence_declaration_free(struct declaration *declaration)
 {
-       struct type_sequence *sequence_type =
-               container_of(type, struct type_sequence, p);
+       struct declaration_sequence *sequence_declaration =
+               container_of(declaration, struct declaration_sequence, p);
 
-       free_type_scope(sequence_type->scope);
-       type_unref(&sequence_type->len_type->p);
-       type_unref(sequence_type->elem);
-       g_free(sequence_type);
+       free_declaration_scope(sequence_declaration->scope);
+       declaration_unref(&sequence_declaration->len_declaration->p);
+       declaration_unref(sequence_declaration->elem);
+       g_free(sequence_declaration);
 }
 
-struct type_sequence *
-       sequence_type_new(const char *name, struct type_integer *len_type,
-                         struct type *elem_type,
-                         struct type_scope *parent_scope)
+struct declaration_sequence *
+       sequence_declaration_new(const char *name, struct declaration_integer *len_declaration,
+                         struct declaration *elem_declaration,
+                         struct declaration_scope *parent_scope)
 {
-       struct type_sequence *sequence_type;
-       struct type *type;
+       struct declaration_sequence *sequence_declaration;
+       struct declaration *declaration;
 
-       sequence_type = g_new(struct type_sequence, 1);
-       type = &sequence_type->p;
-       assert(!len_type->signedness);
-       type_ref(&len_type->p);
-       sequence_type->len_type = len_type;
-       type_ref(elem_type);
-       sequence_type->elem = elem_type;
-       sequence_type->scope = new_type_scope(parent_scope);
-       type->id = CTF_TYPE_SEQUENCE;
-       type->name = g_quark_from_string(name);
-       type->alignment = max(len_type->p.alignment, elem_type->alignment);
-       type->copy = sequence_copy;
-       type->type_free = _sequence_type_free;
-       type->definition_new = _sequence_definition_new;
-       type->definition_free = _sequence_definition_free;
-       type->ref = 1;
-       return sequence_type;
+       sequence_declaration = g_new(struct declaration_sequence, 1);
+       declaration = &sequence_declaration->p;
+       assert(!len_declaration->signedness);
+       declaration_ref(&len_declaration->p);
+       sequence_declaration->len_declaration = len_declaration;
+       declaration_ref(elem_declaration);
+       sequence_declaration->elem = elem_declaration;
+       sequence_declaration->scope = new_declaration_scope(parent_scope);
+       declaration->id = CTF_TYPE_SEQUENCE;
+       declaration->name = g_quark_from_string(name);
+       declaration->alignment = max(len_declaration->p.alignment, elem_declaration->alignment);
+       declaration->copy = sequence_copy;
+       declaration->declaration_free = _sequence_declaration_free;
+       declaration->definition_new = _sequence_definition_new;
+       declaration->definition_free = _sequence_definition_free;
+       declaration->ref = 1;
+       return sequence_declaration;
 }
 
 static
-struct definition *_sequence_definition_new(struct type *type,
+struct definition *_sequence_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope)
 {
-       struct type_sequence *sequence_type =
-               container_of(type, struct type_sequence, p);
+       struct declaration_sequence *sequence_declaration =
+               container_of(declaration, struct declaration_sequence, p);
        struct definition_sequence *sequence;
        struct definition *len_parent;
 
        sequence = g_new(struct definition_sequence, 1);
-       type_ref(&sequence_type->p);
-       sequence->p.type = type;
-       sequence->type = sequence_type;
+       declaration_ref(&sequence_declaration->p);
+       sequence->p.declaration = declaration;
+       sequence->declaration = sequence_declaration;
        sequence->p.ref = 1;
        sequence->scope = new_definition_scope(parent_scope);
-       len_parent = sequence_type->len_type->p.definition_new(&sequence_type->len_type->p,
+       len_parent = sequence_declaration->len_declaration->p.definition_new(&sequence_declaration->len_declaration->p,
                                                                parent_scope);
        sequence->len =
                container_of(len_parent, struct definition_integer, p);
        sequence->current_element.definition =
-               sequence_type->elem->definition_new(sequence_type->elem,
+               sequence_declaration->elem->definition_new(sequence_declaration->elem,
                                                     parent_scope);
        return &sequence->p;
 }
@@ -126,9 +126,9 @@ void _sequence_definition_free(struct definition *definition)
        struct definition *elem_definition =
                sequence->current_element.definition;
 
-       len_definition->type->definition_free(len_definition);
-       elem_definition->type->definition_free(elem_definition);
+       len_definition->declaration->definition_free(len_definition);
+       elem_definition->declaration->definition_free(elem_definition);
        free_definition_scope(sequence->scope);
-       type_unref(sequence->p.type);
+       declaration_unref(sequence->p.declaration);
        g_free(sequence);
 }
index 71b9f8232a73e3135551be939e5bc0a731bcd267..5796bf441483352def4791d7c147b21b414833c6 100644 (file)
@@ -21,7 +21,7 @@
 #include <babeltrace/format.h>
 
 static
-struct definition *_string_definition_new(struct type *type,
+struct definition *_string_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope);
 static
 void _string_definition_free(struct definition *definition);
@@ -32,56 +32,56 @@ void string_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_string *string =
                container_of(definition, struct definition_string, p);
-       struct type_string *string_type = string->type;
+       struct declaration_string *string_declaration = string->declaration;
 
        if (fsrc->string_copy == fdest->string_copy) {
-               fsrc->string_copy(dest, src, string_type);
+               fsrc->string_copy(dest, src, string_declaration);
        } else {
                char *tmp = NULL;
 
-               fsrc->string_read(&tmp, src, string_type);
-               fdest->string_write(dest, tmp, string_type);
+               fsrc->string_read(&tmp, src, string_declaration);
+               fdest->string_write(dest, tmp, string_declaration);
                fsrc->string_free_temp(tmp);
        }
 }
 
 static
-void _string_type_free(struct type *type)
+void _string_declaration_free(struct declaration *declaration)
 {
-       struct type_string *string_type =
-               container_of(type, struct type_string, p);
-       g_free(string_type);
+       struct declaration_string *string_declaration =
+               container_of(declaration, struct declaration_string, p);
+       g_free(string_declaration);
 }
 
-struct type_string *string_type_new(const char *name)
+struct declaration_string *string_declaration_new(const char *name)
 {
-       struct type_string *string_type;
+       struct declaration_string *string_declaration;
 
-       string_type = g_new(struct type_string, 1);
-       string_type->p.id = CTF_TYPE_STRING;
-       string_type->p.name = g_quark_from_string(name);
-       string_type->p.alignment = CHAR_BIT;
-       string_type->p.copy = string_copy;
-       string_type->p.type_free = _string_type_free;
-       string_type->p.definition_new = _string_definition_new;
-       string_type->p.definition_free = _string_definition_free;
-       string_type->p.ref = 1;
-       return string_type;
+       string_declaration = g_new(struct declaration_string, 1);
+       string_declaration->p.id = CTF_TYPE_STRING;
+       string_declaration->p.name = g_quark_from_string(name);
+       string_declaration->p.alignment = CHAR_BIT;
+       string_declaration->p.copy = string_copy;
+       string_declaration->p.declaration_free = _string_declaration_free;
+       string_declaration->p.definition_new = _string_definition_new;
+       string_declaration->p.definition_free = _string_definition_free;
+       string_declaration->p.ref = 1;
+       return string_declaration;
 }
 
 static
 struct definition *
-       _string_definition_new(struct type *type,
+       _string_definition_new(struct declaration *declaration,
                               struct definition_scope *parent_scope)
 {
-       struct type_string *string_type =
-               container_of(type, struct type_string, p);
+       struct declaration_string *string_declaration =
+               container_of(declaration, struct declaration_string, p);
        struct definition_string *string;
 
        string = g_new(struct definition_string, 1);
-       type_ref(&string_type->p);
-       string->p.type = type;
-       string->type = string_type;
+       declaration_ref(&string_declaration->p);
+       string->p.declaration = declaration;
+       string->declaration = string_declaration;
        string->p.ref = 1;
        string->value = NULL;
        return &string->p;
@@ -93,7 +93,7 @@ void _string_definition_free(struct definition *definition)
        struct definition_string *string =
                container_of(definition, struct definition_string, p);
 
-       type_unref(string->p.type);
+       declaration_unref(string->p.declaration);
        g_free(string->value);
        g_free(string);
 }
index 062874784f05165439f9109a387f201a0bf8860a..03c92ea4093bff548ea398cf955a7f687fe3a862 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 static
-struct definition *_struct_definition_new(struct type *type,
+struct definition *_struct_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope);
 static
 void _struct_definition_free(struct definition *definition);
@@ -35,100 +35,100 @@ void struct_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_struct *_struct =
                container_of(definition, struct definition_struct, p);
-       struct type_struct *struct_type = _struct->type;
+       struct declaration_struct *struct_declaration = _struct->declaration;
        unsigned long i;
 
-       fsrc->struct_begin(src, struct_type);
-       fdest->struct_begin(dest, struct_type);
+       fsrc->struct_begin(src, struct_declaration);
+       fdest->struct_begin(dest, struct_declaration);
 
        for (i = 0; i < _struct->fields->len; i++) {
                struct field *field = &g_array_index(_struct->fields,
                                                     struct field, i);
-               struct type *field_type = field->definition->type;
+               struct declaration *field_declaration = field->definition->declaration;
 
-               field_type->copy(dest, fdest, src, fsrc, field->definition);
+               field_declaration->copy(dest, fdest, src, fsrc, field->definition);
 
        }
-       fsrc->struct_end(src, struct_type);
-       fdest->struct_end(dest, struct_type);
+       fsrc->struct_end(src, struct_declaration);
+       fdest->struct_end(dest, struct_declaration);
 }
 
 static
-void _struct_type_free(struct type *type)
+void _struct_declaration_free(struct declaration *declaration)
 {
-       struct type_struct *struct_type =
-               container_of(type, struct type_struct, p);
+       struct declaration_struct *struct_declaration =
+               container_of(declaration, struct declaration_struct, p);
        unsigned long i;
 
-       free_type_scope(struct_type->scope);
-       g_hash_table_destroy(struct_type->fields_by_name);
+       free_declaration_scope(struct_declaration->scope);
+       g_hash_table_destroy(struct_declaration->fields_by_name);
 
-       for (i = 0; i < struct_type->fields->len; i++) {
-               struct type_field *type_field =
-                       &g_array_index(struct_type->fields,
-                                      struct type_field, i);
-               type_unref(type_field->type);
+       for (i = 0; i < struct_declaration->fields->len; i++) {
+               struct declaration_field *declaration_field =
+                       &g_array_index(struct_declaration->fields,
+                                      struct declaration_field, i);
+               declaration_unref(declaration_field->declaration);
        }
-       g_array_free(struct_type->fields, true);
-       g_free(struct_type);
+       g_array_free(struct_declaration->fields, true);
+       g_free(struct_declaration);
 }
 
-struct type_struct *struct_type_new(const char *name,
-                                   struct type_scope *parent_scope)
+struct declaration_struct *struct_declaration_new(const char *name,
+                                   struct declaration_scope *parent_scope)
 {
-       struct type_struct *struct_type;
-       struct type *type;
+       struct declaration_struct *struct_declaration;
+       struct declaration *declaration;
 
-       struct_type = g_new(struct type_struct, 1);
-       type = &struct_type->p;
-       struct_type->fields_by_name = g_hash_table_new(g_direct_hash,
+       struct_declaration = g_new(struct declaration_struct, 1);
+       declaration = &struct_declaration->p;
+       struct_declaration->fields_by_name = g_hash_table_new(g_direct_hash,
                                                       g_direct_equal);
-       struct_type->fields = g_array_sized_new(FALSE, TRUE,
-                                               sizeof(struct type_field),
+       struct_declaration->fields = g_array_sized_new(FALSE, TRUE,
+                                               sizeof(struct declaration_field),
                                                DEFAULT_NR_STRUCT_FIELDS);
-       struct_type->scope = new_type_scope(parent_scope);
-       type->id = CTF_TYPE_STRUCT;
-       type->name = g_quark_from_string(name);
-       type->alignment = 1;
-       type->copy = struct_copy;
-       type->type_free = _struct_type_free;
-       type->definition_new = _struct_definition_new;
-       type->definition_free = _struct_definition_free;
-       type->ref = 1;
-       return struct_type;
+       struct_declaration->scope = new_declaration_scope(parent_scope);
+       declaration->id = CTF_TYPE_STRUCT;
+       declaration->name = g_quark_from_string(name);
+       declaration->alignment = 1;
+       declaration->copy = struct_copy;
+       declaration->declaration_free = _struct_declaration_free;
+       declaration->definition_new = _struct_definition_new;
+       declaration->definition_free = _struct_definition_free;
+       declaration->ref = 1;
+       return struct_declaration;
 }
 
 static
 struct definition *
-       _struct_definition_new(struct type *type,
+       _struct_definition_new(struct declaration *declaration,
                               struct definition_scope *parent_scope)
 {
-       struct type_struct *struct_type =
-               container_of(type, struct type_struct, p);
+       struct declaration_struct *struct_declaration =
+               container_of(declaration, struct declaration_struct, p);
        struct definition_struct *_struct;
        unsigned long i;
        int ret;
 
        _struct = g_new(struct definition_struct, 1);
-       type_ref(&struct_type->p);
-       _struct->p.type = type;
-       _struct->type = struct_type;
+       declaration_ref(&struct_declaration->p);
+       _struct->p.declaration = declaration;
+       _struct->declaration = struct_declaration;
        _struct->p.ref = 1;
        _struct->scope = new_definition_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);
+       g_array_set_size(_struct->fields, struct_declaration->fields->len);
+       for (i = 0; i < struct_declaration->fields->len; i++) {
+               struct declaration_field *declaration_field =
+                       &g_array_index(struct_declaration->fields,
+                                      struct declaration_field, i);
                struct field *field = &g_array_index(_struct->fields,
                                                     struct field, i);
 
-               field->name = type_field->name;
+               field->name = declaration_field->name;
                field->definition =
-                       type_field->type->definition_new(type_field->type,
+                       declaration_field->declaration->definition_new(declaration_field->declaration,
                                                          _struct->scope);
                ret = register_field_definition(field->name,
                                                field->definition,
@@ -145,49 +145,49 @@ void _struct_definition_free(struct definition *definition)
                container_of(definition, struct definition_struct, p);
        unsigned long i;
 
-       assert(_struct->fields->len == _struct->type->fields->len);
+       assert(_struct->fields->len == _struct->declaration->fields->len);
        for (i = 0; i < _struct->fields->len; i++) {
                struct field *field = &g_array_index(_struct->fields,
                                                     struct field, i);
                definition_unref(field->definition);
        }
        free_definition_scope(_struct->scope);
-       type_unref(_struct->p.type);
+       declaration_unref(_struct->p.declaration);
        g_free(_struct);
 }
 
-void struct_type_add_field(struct type_struct *struct_type,
+void struct_declaration_add_field(struct declaration_struct *struct_declaration,
                           const char *field_name,
-                          struct type *field_type)
+                          struct declaration *field_declaration)
 {
-       struct type_field *field;
+       struct declaration_field *field;
        unsigned long index;
 
-       g_array_set_size(struct_type->fields, struct_type->fields->len + 1);
-       index = struct_type->fields->len - 1;   /* last field (new) */
-       field = &g_array_index(struct_type->fields, struct type_field, index);
+       g_array_set_size(struct_declaration->fields, struct_declaration->fields->len + 1);
+       index = struct_declaration->fields->len - 1;    /* last field (new) */
+       field = &g_array_index(struct_declaration->fields, struct declaration_field, index);
        field->name = g_quark_from_string(field_name);
-       type_ref(field_type);
-       field->type = field_type;
+       declaration_ref(field_declaration);
+       field->declaration = field_declaration;
        /* Keep index in hash rather than pointer, because array can relocate */
-       g_hash_table_insert(struct_type->fields_by_name,
+       g_hash_table_insert(struct_declaration->fields_by_name,
                            (gpointer) (unsigned long) field->name,
                            (gpointer) index);
        /*
-        * Alignment of structure is the max alignment of types contained
+        * Alignment of structure is the max alignment of declarations contained
         * therein.
         */
-       struct_type->p.alignment = max(struct_type->p.alignment,
-                                      field_type->alignment);
+       struct_declaration->p.alignment = max(struct_declaration->p.alignment,
+                                      field_declaration->alignment);
 }
 
 unsigned long
-       struct_type_lookup_field_index(struct type_struct *struct_type,
+       struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
                                       GQuark field_name)
 {
        unsigned long index;
 
-       index = (unsigned long) g_hash_table_lookup(struct_type->fields_by_name,
+       index = (unsigned long) g_hash_table_lookup(struct_declaration->fields_by_name,
                                                    (gconstpointer) (unsigned long) field_name);
        return index;
 }
@@ -195,11 +195,11 @@ unsigned long
 /*
  * field returned only valid as long as the field structure is not appended to.
  */
-struct type_field *
-       struct_type_get_field_from_index(struct type_struct *struct_type,
+struct declaration_field *
+       struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
                                         unsigned long index)
 {
-       return &g_array_index(struct_type->fields, struct type_field, index);
+       return &g_array_index(struct_declaration->fields, struct declaration_field, index);
 }
 
 /*
index e36c7a1f5221ba7f016b2105763564689722d37a..90720e2bed988b69be1bb820201fa60cf11bc06a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * types.c
+ * declarations.c
  *
  * BabelTrace - Converter
  *
 
 static
 struct definition *
-       lookup_type_definition_scope(GQuark type_name, struct type_scope *scope)
+       lookup_typedef_declaration_scope(GQuark declaration_name,
+               struct declaration_scope *scope)
 {
-       return g_hash_table_lookup(scope->type_definitions,
-                                  (gconstpointer) (unsigned long) type_name);
+       return g_hash_table_lookup(scope->typedef_declarations,
+                                  (gconstpointer) (unsigned long) declaration_name);
 }
 
-struct definition *lookup_type_definition(GQuark type_name, struct type_scope *scope)
+struct definition *lookup_typedef_declaration(GQuark declaration_name,
+               struct declaration_scope *scope)
 {
        struct definition *definition;
 
        while (scope) {
-               definition = lookup_type_definition_scope(type_name, scope);
+               definition = lookup_typedef_declaration_scope(declaration_name,
+                                                             scope);
                if (definition)
                        return definition;
                scope = scope->parent_scope;
@@ -43,33 +46,35 @@ struct definition *lookup_type_definition(GQuark type_name, struct type_scope *s
        return NULL;
 }
 
-int register_type_definition(GQuark name, struct definition *definition,
-                            struct type_scope *scope)
+int register_typedef_declaration(GQuark name, struct declaration *declaration,
+               struct declaration_scope *scope)
 {
        if (!name)
                return -EPERM;
 
        /* Only lookup in local scope */
-       if (lookup_type_definition_scope(name, scope))
+       if (lookup_typedef_declaration_scope(name, scope))
                return -EEXIST;
 
-       g_hash_table_insert(scope->type_definitions,
+       g_hash_table_insert(scope->typedef_declarations,
                            (gpointer) (unsigned long) name,
-                           definition);
-       definition_ref(definition);
+                           declaration);
+       declaration_ref(declaration);
        return 0;
 }
 
 static
 struct definition *
-       lookup_field_definition_scope(GQuark field_name, struct definition_scope *scope)
+       lookup_field_definition_scope(GQuark field_name,
+               struct definition_scope *scope)
 {
        return g_hash_table_lookup(scope->definitions,
                                   (gconstpointer) (unsigned long) field_name);
 }
 
 struct definition *
-       lookup_field_definition(GQuark field_name, struct definition_scope *scope)
+       lookup_field_definition(GQuark field_name,
+               struct definition_scope *scope)
 {
        struct definition *definition;
 
@@ -83,7 +88,7 @@ struct definition *
 }
 
 int register_field_definition(GQuark field_name, struct definition *definition,
-                             struct definition_scope *scope)
+               struct definition_scope *scope)
 {
        if (!field_name)
                return -EPERM;
@@ -99,15 +104,15 @@ int register_field_definition(GQuark field_name, struct definition *definition,
        return 0;
 }
 
-void type_ref(struct type *type)
+void declaration_ref(struct declaration *declaration)
 {
-       type->ref++;
+       declaration->ref++;
 }
 
-void type_unref(struct type *type)
+void declaration_unref(struct declaration *declaration)
 {
-       if (!--type->ref)
-               type->type_free(type);
+       if (!--declaration->ref)
+               declaration->declaration_free(declaration);
 }
 
 void definition_ref(struct definition *definition)
@@ -118,154 +123,160 @@ void definition_ref(struct definition *definition)
 void definition_unref(struct definition *definition)
 {
        if (!--definition->ref)
-               definition->type->definition_free(definition);
+               definition->declaration->definition_free(definition);
 }
 
-struct type_scope *
-       new_type_scope(struct type_scope *parent_scope)
+struct declaration_scope *
+       new_declaration_scope(struct declaration_scope *parent_scope)
 {
-       struct type_scope *scope = g_new(struct type_scope, 1);
+       struct declaration_scope *scope = g_new(struct declaration_scope, 1);
 
-       scope->type_definitions = g_hash_table_new_full(g_direct_hash,
+       scope->typedef_declarations = g_hash_table_new_full(g_direct_hash,
                                        g_direct_equal, NULL,
                                        (GDestroyNotify) definition_unref);
-       scope->struct_types = g_hash_table_new_full(g_direct_hash,
+       scope->struct_declarations = g_hash_table_new_full(g_direct_hash,
                                        g_direct_equal, NULL,
-                                       (GDestroyNotify) type_unref);
-       scope->variant_types = g_hash_table_new_full(g_direct_hash,
+                                       (GDestroyNotify) declaration_unref);
+       scope->variant_declarations = g_hash_table_new_full(g_direct_hash,
                                        g_direct_equal, NULL,
-                                       (GDestroyNotify) type_unref);
-       scope->enum_types = g_hash_table_new_full(g_direct_hash,
+                                       (GDestroyNotify) declaration_unref);
+       scope->enum_declarations = g_hash_table_new_full(g_direct_hash,
                                        g_direct_equal, NULL,
-                                       (GDestroyNotify) type_unref);
+                                       (GDestroyNotify) declaration_unref);
        scope->parent_scope = parent_scope;
        return scope;
 }
 
-void free_type_scope(struct type_scope *scope)
+void free_declaration_scope(struct declaration_scope *scope)
 {
-       g_hash_table_destroy(scope->enum_types);
-       g_hash_table_destroy(scope->variant_types);
-       g_hash_table_destroy(scope->struct_types);
-       g_hash_table_destroy(scope->type_definitions);
+       g_hash_table_destroy(scope->enum_declarations);
+       g_hash_table_destroy(scope->variant_declarations);
+       g_hash_table_destroy(scope->struct_declarations);
+       g_hash_table_destroy(scope->typedef_declarations);
        g_free(scope);
 }
 
 static
-struct type_struct *lookup_struct_type_scope(GQuark struct_name,
-                                            struct type_scope *scope)
+struct declaration_struct *lookup_struct_declaration_scope(GQuark struct_name,
+                                            struct declaration_scope *scope)
 {
-       return g_hash_table_lookup(scope->struct_types,
+       return g_hash_table_lookup(scope->struct_declarations,
                                   (gconstpointer) (unsigned long) struct_name);
 }
 
-struct type_struct *lookup_struct_type(GQuark struct_name,
-                                      struct type_scope *scope)
+struct declaration_struct *lookup_struct_declaration(GQuark struct_name,
+                                      struct declaration_scope *scope)
 {
-       struct type_struct *type;
+       struct declaration_struct *declaration;
 
        while (scope) {
-               type = lookup_struct_type_scope(struct_name, scope);
-               if (type)
-                       return type;
+               declaration = lookup_struct_declaration_scope(struct_name, scope);
+               if (declaration)
+                       return declaration;
                scope = scope->parent_scope;
        }
        return NULL;
 }
 
-int register_struct_type(GQuark struct_name, struct type_struct *struct_type,
-                        struct type_scope *scope)
+int register_struct_declaration(GQuark struct_name,
+       struct declaration_struct *struct_declaration,
+       struct declaration_scope *scope)
 {
        if (!struct_name)
                return -EPERM;
 
        /* Only lookup in local scope */
-       if (lookup_struct_type_scope(struct_name, scope))
+       if (lookup_struct_declaration_scope(struct_name, scope))
                return -EEXIST;
 
-       g_hash_table_insert(scope->struct_types,
+       g_hash_table_insert(scope->struct_declarations,
                            (gpointer) (unsigned long) struct_name,
-                           struct_type);
-       type_ref(&struct_type->p);
+                           struct_declaration);
+       declaration_ref(&struct_declaration->p);
        return 0;
 }
 
 static
-struct type_variant *lookup_variant_type_scope(GQuark variant_name,
-                                              struct type_scope *scope)
+struct declaration_variant *
+       lookup_variant_declaration_scope(GQuark variant_name,
+               struct declaration_scope *scope)
 {
-       return g_hash_table_lookup(scope->variant_types,
+       return g_hash_table_lookup(scope->variant_declarations,
                                   (gconstpointer) (unsigned long) variant_name);
 }
 
-struct type_variant *lookup_variant_type(GQuark variant_name,
-                                        struct type_scope *scope)
+struct declaration_variant *
+       lookup_variant_declaration(GQuark variant_name,
+               struct declaration_scope *scope)
 {
-       struct type_variant *type;
+       struct declaration_variant *declaration;
 
        while (scope) {
-               type = lookup_variant_type_scope(variant_name, scope);
-               if (type)
-                       return type;
+               declaration = lookup_variant_declaration_scope(variant_name, scope);
+               if (declaration)
+                       return declaration;
                scope = scope->parent_scope;
        }
        return NULL;
 }
 
-int register_variant_type(GQuark variant_name,
-                         struct type_variant *variant_type,
-                         struct type_scope *scope)
+int register_variant_declaration(GQuark variant_name,
+               struct declaration_variant *variant_declaration,
+               struct declaration_scope *scope)
 {
        if (!variant_name)
                return -EPERM;
 
        /* Only lookup in local scope */
-       if (lookup_variant_type_scope(variant_name, scope))
+       if (lookup_variant_declaration_scope(variant_name, scope))
                return -EEXIST;
 
-       g_hash_table_insert(scope->variant_types,
+       g_hash_table_insert(scope->variant_declarations,
                            (gpointer) (unsigned long) variant_name,
-                           variant_type);
-       type_ref(&variant_type->p);
+                           variant_declaration);
+       declaration_ref(&variant_declaration->p);
        return 0;
 }
 
 static
-struct type_enum *lookup_enum_type_scope(GQuark enum_name,
-                                        struct type_scope *scope)
+struct declaration_enum *
+       lookup_enum_declaration_scope(GQuark enum_name,
+               struct declaration_scope *scope)
 {
-       return g_hash_table_lookup(scope->enum_types,
+       return g_hash_table_lookup(scope->enum_declarations,
                                   (gconstpointer) (unsigned long) enum_name);
 }
 
-struct type_enum *lookup_enum_type(GQuark enum_name,
-                                  struct type_scope *scope)
+struct declaration_enum *
+       lookup_enum_declaration(GQuark enum_name,
+               struct declaration_scope *scope)
 {
-       struct type_enum *type;
+       struct declaration_enum *declaration;
 
        while (scope) {
-               type = lookup_enum_type_scope(enum_name, scope);
-               if (type)
-                       return type;
+               declaration = lookup_enum_declaration_scope(enum_name, scope);
+               if (declaration)
+                       return declaration;
                scope = scope->parent_scope;
        }
        return NULL;
 }
 
-int register_enum_type(GQuark enum_name, struct type_enum *enum_type,
-                      struct type_scope *scope)
+int register_enum_declaration(GQuark enum_name,
+               struct declaration_enum *enum_declaration,
+               struct declaration_scope *scope)
 {
        if (!enum_name)
                return -EPERM;
 
        /* Only lookup in local scope */
-       if (lookup_enum_type_scope(enum_name, scope))
+       if (lookup_enum_declaration_scope(enum_name, scope))
                return -EEXIST;
 
-       g_hash_table_insert(scope->enum_types,
+       g_hash_table_insert(scope->enum_declarations,
                            (gpointer) (unsigned long) enum_name,
-                           enum_type);
-       type_ref(&enum_type->p);
+                           enum_declaration);
+       declaration_ref(&enum_declaration->p);
        return 0;
 }
 
index 66c8f59f7051a0378360a2b947e61f6062bb11cb..e522621be346e13cfe6cde920f74b7ae179f654d 100644 (file)
@@ -21,7 +21,7 @@
 #include <errno.h>
 
 static
-struct definition *_variant_definition_new(struct type *type,
+struct definition *_variant_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope);
 static
 void _variant_definition_free(struct definition *definition);
@@ -32,96 +32,96 @@ void variant_copy(struct stream_pos *dest, const struct format *fdest,
 {
        struct definition_variant *variant =
                container_of(definition, struct definition_variant, p);
-       struct type_variant *variant_type = variant->type;
+       struct declaration_variant *variant_declaration = variant->declaration;
        struct field *field;
-       struct type *field_type;
+       struct declaration *field_declaration;
 
-       fsrc->variant_begin(src, variant_type);
-       fdest->variant_begin(dest, variant_type);
+       fsrc->variant_begin(src, variant_declaration);
+       fdest->variant_begin(dest, variant_declaration);
 
        field = variant_get_current_field(variant);
-       field_type = field->definition->type;
-       field_type->copy(dest, fdest, src, fsrc, field->definition);
+       field_declaration = field->definition->declaration;
+       field_declaration->copy(dest, fdest, src, fsrc, field->definition);
 
-       fsrc->variant_end(src, variant_type);
-       fdest->variant_end(dest, variant_type);
+       fsrc->variant_end(src, variant_declaration);
+       fdest->variant_end(dest, variant_declaration);
 }
 
 static
-void _variant_type_free(struct type *type)
+void _variant_declaration_free(struct declaration *declaration)
 {
-       struct type_variant *variant_type =
-               container_of(type, struct type_variant, p);
+       struct declaration_variant *variant_declaration =
+               container_of(declaration, struct declaration_variant, p);
        unsigned long i;
 
-       free_type_scope(variant_type->scope);
-       g_hash_table_destroy(variant_type->fields_by_tag);
+       free_declaration_scope(variant_declaration->scope);
+       g_hash_table_destroy(variant_declaration->fields_by_tag);
 
-       for (i = 0; i < variant_type->fields->len; i++) {
-               struct type_field *type_field =
-                       &g_array_index(variant_type->fields,
-                                      struct type_field, i);
-               type_unref(type_field->type);
+       for (i = 0; i < variant_declaration->fields->len; i++) {
+               struct declaration_field *declaration_field =
+                       &g_array_index(variant_declaration->fields,
+                                      struct declaration_field, i);
+               declaration_unref(declaration_field->declaration);
        }
-       g_array_free(variant_type->fields, true);
-       g_free(variant_type);
+       g_array_free(variant_declaration->fields, true);
+       g_free(variant_declaration);
 }
 
-struct type_variant *variant_type_new(const char *name,
-                                     struct type_scope *parent_scope)
+struct declaration_variant *variant_declaration_new(const char *name,
+                                     struct declaration_scope *parent_scope)
 {
-       struct type_variant *variant_type;
-       struct type *type;
+       struct declaration_variant *variant_declaration;
+       struct declaration *declaration;
 
-       variant_type = g_new(struct type_variant, 1);
-       type = &variant_type->p;
-       variant_type->fields_by_tag = g_hash_table_new(g_direct_hash,
+       variant_declaration = g_new(struct declaration_variant, 1);
+       declaration = &variant_declaration->p;
+       variant_declaration->fields_by_tag = g_hash_table_new(g_direct_hash,
                                                       g_direct_equal);
-       variant_type->fields = g_array_sized_new(FALSE, TRUE,
-                                                sizeof(struct type_field),
+       variant_declaration->fields = g_array_sized_new(FALSE, TRUE,
+                                                sizeof(struct declaration_field),
                                                 DEFAULT_NR_STRUCT_FIELDS);
-       variant_type->scope = new_type_scope(parent_scope);
-       type->id = CTF_TYPE_VARIANT;
-       type->name = g_quark_from_string(name);
-       type->alignment = 1;
-       type->copy = variant_copy;
-       type->type_free = _variant_type_free;
-       type->definition_new = _variant_definition_new;
-       type->definition_free = _variant_definition_free;
-       type->ref = 1;
-       return variant_type;
+       variant_declaration->scope = new_declaration_scope(parent_scope);
+       declaration->id = CTF_TYPE_VARIANT;
+       declaration->name = g_quark_from_string(name);
+       declaration->alignment = 1;
+       declaration->copy = variant_copy;
+       declaration->declaration_free = _variant_declaration_free;
+       declaration->definition_new = _variant_definition_new;
+       declaration->definition_free = _variant_definition_free;
+       declaration->ref = 1;
+       return variant_declaration;
 }
 
 static
 struct definition *
-       _variant_definition_new(struct type *type,
+       _variant_definition_new(struct declaration *declaration,
                                struct definition_scope *parent_scope)
 {
-       struct type_variant *variant_type =
-               container_of(type, struct type_variant, p);
+       struct declaration_variant *variant_declaration =
+               container_of(declaration, struct declaration_variant, p);
        struct definition_variant *variant;
        unsigned long i;
 
        variant = g_new(struct definition_variant, 1);
-       type_ref(&variant_type->p);
-       variant->p.type = type;
-       variant->type = variant_type;
+       declaration_ref(&variant_declaration->p);
+       variant->p.declaration = declaration;
+       variant->declaration = variant_declaration;
        variant->p.ref = 1;
        variant->scope = new_definition_scope(parent_scope);
        variant->fields = g_array_sized_new(FALSE, TRUE,
                                            sizeof(struct field),
                                            DEFAULT_NR_STRUCT_FIELDS);
-       g_array_set_size(variant->fields, variant_type->fields->len);
-       for (i = 0; i < variant_type->fields->len; i++) {
-               struct type_field *type_field =
-                       &g_array_index(variant_type->fields,
-                                      struct type_field, i);
+       g_array_set_size(variant->fields, variant_declaration->fields->len);
+       for (i = 0; i < variant_declaration->fields->len; i++) {
+               struct declaration_field *declaration_field =
+                       &g_array_index(variant_declaration->fields,
+                                      struct declaration_field, i);
                struct field *field = &g_array_index(variant->fields,
                                                     struct field, i);
 
-               field->name = type_field->name;
+               field->name = declaration_field->name;
                field->definition =
-                       type_field->type->definition_new(type_field->type,
+                       declaration_field->declaration->definition_new(declaration_field->declaration,
                                                          variant->scope);
        }
        variant->current_field = NULL;
@@ -135,32 +135,32 @@ void _variant_definition_free(struct definition *definition)
                container_of(definition, struct definition_variant, p);
        unsigned long i;
 
-       assert(variant->fields->len == variant->type->fields->len);
+       assert(variant->fields->len == variant->declaration->fields->len);
        for (i = 0; i < variant->fields->len; i++) {
                struct field *field = &g_array_index(variant->fields,
                                                     struct field, i);
                definition_unref(field->definition);
        }
        free_definition_scope(variant->scope);
-       type_unref(variant->p.type);
+       declaration_unref(variant->p.declaration);
        g_free(variant);
 }
 
-void variant_type_add_field(struct type_variant *variant_type,
+void variant_declaration_add_field(struct declaration_variant *variant_declaration,
                            const char *tag_name,
-                           struct type *tag_type)
+                           struct declaration *tag_declaration)
 {
-       struct type_field *field;
+       struct declaration_field *field;
        unsigned long index;
 
-       g_array_set_size(variant_type->fields, variant_type->fields->len + 1);
-       index = variant_type->fields->len - 1;  /* last field (new) */
-       field = &g_array_index(variant_type->fields, struct type_field, index);
+       g_array_set_size(variant_declaration->fields, variant_declaration->fields->len + 1);
+       index = variant_declaration->fields->len - 1;   /* last field (new) */
+       field = &g_array_index(variant_declaration->fields, struct declaration_field, index);
        field->name = g_quark_from_string(tag_name);
-       type_ref(tag_type);
-       field->type = tag_type;
+       declaration_ref(tag_declaration);
+       field->declaration = tag_declaration;
        /* Keep index in hash rather than pointer, because array can relocate */
-       g_hash_table_insert(variant_type->fields_by_tag,
+       g_hash_table_insert(variant_declaration->fields_by_tag,
                            (gpointer) (unsigned long) field->name,
                            (gpointer) index);
        /*
@@ -170,14 +170,14 @@ void variant_type_add_field(struct type_variant *variant_type,
         */
 }
 
-struct type_field *
-struct_type_get_field_from_tag(struct type_variant *variant_type, GQuark tag)
+struct declaration_field *
+struct_declaration_get_field_from_tag(struct declaration_variant *variant_declaration, GQuark tag)
 {
        unsigned long index;
 
-       index = (unsigned long) g_hash_table_lookup(variant_type->fields_by_tag,
+       index = (unsigned long) g_hash_table_lookup(variant_declaration->fields_by_tag,
                                                    (gconstpointer) (unsigned long) tag);
-       return &g_array_index(variant_type->fields, struct type_field, index);
+       return &g_array_index(variant_declaration->fields, struct declaration_field, index);
 }
 
 /*
@@ -188,7 +188,7 @@ int variant_definition_set_tag(struct definition_variant *variant,
 {
        struct definition_enum *_enum =
                container_of(variant->enum_tag, struct definition_enum, p);
-       struct type_enum *enum_type = _enum->type;
+       struct declaration_enum *enum_declaration = _enum->declaration;
        int missing_field = 0;
        unsigned long i;
 
@@ -198,14 +198,14 @@ int variant_definition_set_tag(struct definition_variant *variant,
         * variant choice map to an enumerator too. We then validate that the
         * number of enumerators equals the number of variant choices.
         */
-       if (variant->type->fields->len != enum_get_nr_enumerators(enum_type))
+       if (variant->declaration->fields->len != enum_get_nr_enumerators(enum_declaration))
                return -EPERM;
 
-       for (i = 0; i < variant->type->fields->len; i++) {
-               struct type_field *field_type =
-                       &g_array_index(variant->type->fields,
-                                      struct type_field, i);
-               if (!enum_quark_to_range_set(enum_type, field_type->name)) {
+       for (i = 0; i < variant->declaration->fields->len; i++) {
+               struct declaration_field *field_declaration =
+                       &g_array_index(variant->declaration->fields,
+                                      struct declaration_field, i);
+               if (!enum_quark_to_range_set(enum_declaration, field_declaration->name)) {
                        missing_field = 1;
                        break;
                }
@@ -218,7 +218,7 @@ int variant_definition_set_tag(struct definition_variant *variant,
         * enumerator tag.
         * TODO: we should also check that each range map to one and only one
         * tag. For the moment, we will simply check this dynamically in
-        * variant_type_get_current_field().
+        * variant_declaration_get_current_field().
         */
 
        /* Set the enum tag field */
@@ -233,7 +233,7 @@ struct field *variant_get_current_field(struct definition_variant *variant)
 {
        struct definition_enum *_enum =
                container_of(variant->enum_tag, struct definition_enum, p);
-       struct type_variant *variant_type = variant->type;
+       struct declaration_variant *variant_declaration = variant->declaration;
        unsigned long index;
        GArray *tag_array;
        GQuark tag;
@@ -245,7 +245,7 @@ struct field *variant_get_current_field(struct definition_variant *variant)
         */
        assert(tag_array->len == 1);
        tag = g_array_index(tag_array, GQuark, 0);
-       index = (unsigned long) g_hash_table_lookup(variant_type->fields_by_tag,
+       index = (unsigned long) g_hash_table_lookup(variant_declaration->fields_by_tag,
                                                    (gconstpointer) (unsigned long) tag);
        variant->current_field = &g_array_index(variant->fields, struct field, index);
        return variant->current_field;
This page took 0.169848 seconds and 4 git commands to generate.