X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fevent.c;h=82499417477c977ae949bae9180219686e8e0ba7;hb=dac5c838a2e15f0da9acd223a119ae7962dbc79a;hp=586b69b6ba8f316bde944cb15f7831c53bc80278;hpb=286a2840a9fec9d0b65d07dc94154a9f9d4d51f9;p=babeltrace.git diff --git a/formats/ctf/ir/event.c b/formats/ctf/ir/event.c index 586b69b6..82499417 100644 --- a/formats/ctf/ir/event.c +++ b/formats/ctf/ir/event.c @@ -36,20 +36,22 @@ #include #include #include +#include +#include #include #include static -void bt_ctf_event_class_destroy(struct bt_ctf_ref *ref); +void bt_ctf_event_class_destroy(struct bt_ref *ref); static -void bt_ctf_event_destroy(struct bt_ctf_ref *ref); +void bt_ctf_event_destroy(struct bt_ref *ref); static int set_integer_field_value(struct bt_ctf_field *field, uint64_t value); struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) { int ret; - struct bt_object *obj = NULL; + struct bt_value *obj = NULL; struct bt_ctf_event_class *event_class = NULL; if (bt_ctf_validate_identifier(name)) { @@ -61,7 +63,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) goto error; } - bt_ctf_ref_init(&event_class->ref_count); + bt_ctf_base_init(event_class, bt_ctf_event_class_destroy); event_class->fields = bt_ctf_field_type_structure_create(); if (!event_class->fields) { goto error; @@ -72,7 +74,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) goto error; } - obj = bt_object_integer_create_init(-1); + obj = bt_value_integer_create_init(-1); if (!obj) { goto error; } @@ -83,9 +85,9 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) goto error; } - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); - obj = bt_object_string_create_init(name); + obj = bt_value_string_create_init(name); if (!obj) { goto error; } @@ -96,7 +98,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) goto error; } - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return event_class; @@ -105,14 +107,14 @@ error: bt_ctf_event_class_put(event_class); } - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return NULL; } const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class) { - struct bt_object *obj = NULL; + struct bt_value *obj = NULL; const char *name = NULL; if (!event_class) { @@ -125,19 +127,19 @@ const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class) goto end; } - if (bt_object_string_get(obj, &name)) { + if (bt_value_string_get(obj, &name)) { name = NULL; } end: - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return name; } int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) { - struct bt_object *obj = NULL; + struct bt_value *obj = NULL; int64_t ret = 0; if (!event_class) { @@ -151,7 +153,7 @@ int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) goto end; } - if (bt_object_integer_get(obj, &ret)) { + if (bt_value_integer_get(obj, &ret)) { ret = -1; } @@ -162,7 +164,7 @@ int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) } end: - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return ret; } @@ -171,7 +173,7 @@ int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, uint32_t id) { int ret = 0; - struct bt_object *obj = NULL; + struct bt_value *obj = NULL; if (!event_class) { ret = -1; @@ -193,20 +195,20 @@ int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, goto end; } - if (bt_object_integer_set(obj, id)) { + if (bt_value_integer_set(obj, id)) { ret = -1; goto end; } end: - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return ret; } int bt_ctf_event_class_set_attribute( struct bt_ctf_event_class *event_class, const char *name, - struct bt_object *value) + struct bt_value *value) { int ret = 0; @@ -216,12 +218,12 @@ int bt_ctf_event_class_set_attribute( } if (!strcmp(name, "id") || !strcmp(name, "loglevel")) { - if (!bt_object_is_integer(value)) { + if (!bt_value_is_integer(value)) { ret = -1; goto end; } } else if (!strcmp(name, "name") || !strcmp(name, "model.emf.uri")) { - if (!bt_object_is_string(value)) { + if (!bt_value_is_string(value)) { ret = -1; goto end; } @@ -235,7 +237,7 @@ int bt_ctf_event_class_set_attribute( if (!strcmp(name, "id")) { int64_t val; - ret = bt_object_integer_get(value, &val); + ret = bt_value_integer_get(value, &val); if (ret) { goto end; @@ -287,11 +289,11 @@ end: return ret; } -struct bt_object * +struct bt_value * bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class *event_class, int index) { - struct bt_object *ret; + struct bt_value *ret; if (!event_class) { ret = NULL; @@ -304,11 +306,11 @@ end: return ret; } -struct bt_object * +struct bt_value * bt_ctf_event_class_get_attribute_value_by_name( struct bt_ctf_event_class *event_class, const char *name) { - struct bt_object *ret; + struct bt_value *ret; if (!event_class || !name) { ret = NULL; @@ -510,20 +512,12 @@ end: void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class) { - if (!event_class) { - return; - } - - bt_ctf_ref_get(&event_class->ref_count); + bt_ctf_get(event_class); } void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class) { - if (!event_class) { - return; - } - - bt_ctf_ref_put(&event_class->ref_count, bt_ctf_event_class_destroy); + bt_ctf_put(event_class); } BT_HIDDEN @@ -531,9 +525,9 @@ int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class, uint32_t stream_id) { int ret = 0; - struct bt_object *obj; + struct bt_value *obj; - obj = bt_object_integer_create_init(stream_id); + obj = bt_value_integer_create_init(stream_id); if (!obj) { ret = -1; @@ -544,7 +538,7 @@ int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class, "stream_id", obj); end: - BT_OBJECT_PUT(obj); + BT_VALUE_PUT(obj); return ret; } @@ -572,7 +566,7 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) goto end; } - bt_ctf_ref_init(&event->ref_count); + bt_ctf_base_init(event, bt_ctf_event_destroy); bt_ctf_event_class_get(event_class); bt_ctf_event_class_freeze(event_class); event->event_class = event_class; @@ -603,7 +597,7 @@ end: return event; error_destroy: if (event) { - bt_ctf_event_destroy(&event->ref_count); + bt_ctf_event_destroy(&event->base.ref_count); } return NULL; @@ -884,26 +878,19 @@ end: void bt_ctf_event_get(struct bt_ctf_event *event) { - if (!event) { - return; - } - - bt_ctf_ref_get(&event->ref_count); + bt_ctf_get(event); } void bt_ctf_event_put(struct bt_ctf_event *event) { - if (!event) { - return; - } - - bt_ctf_ref_put(&event->ref_count, bt_ctf_event_destroy); + bt_ctf_put(event); } static -void bt_ctf_event_class_destroy(struct bt_ctf_ref *ref) +void bt_ctf_event_class_destroy(struct bt_ref *ref) { struct bt_ctf_event_class *event_class; + struct bt_ctf_base *base; if (!ref) { return; @@ -913,7 +900,8 @@ void bt_ctf_event_class_destroy(struct bt_ctf_ref *ref) * Don't call put() on the stream class. See comment in * bt_ctf_event_class_set_stream_class for explanation. */ - event_class = container_of(ref, struct bt_ctf_event_class, ref_count); + base = container_of(ref, struct bt_ctf_base, ref_count); + event_class = container_of(base, struct bt_ctf_event_class, base); if (event_class->attributes) { bt_ctf_attributes_destroy(event_class->attributes); } @@ -927,16 +915,17 @@ void bt_ctf_event_class_destroy(struct bt_ctf_ref *ref) } static -void bt_ctf_event_destroy(struct bt_ctf_ref *ref) +void bt_ctf_event_destroy(struct bt_ref *ref) { struct bt_ctf_event *event; + struct bt_ctf_base *base; if (!ref) { return; } - event = container_of(ref, struct bt_ctf_event, - ref_count); + base = container_of(ref, struct bt_ctf_base, ref_count); + event = container_of(base, struct bt_ctf_event, base); if (event->event_class) { bt_ctf_event_class_put(event->event_class); } @@ -1042,7 +1031,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, int i; int count; int ret = 0; - struct bt_object *attr_value = NULL; + struct bt_value *attr_value = NULL; assert(event_class); assert(context); @@ -1070,12 +1059,12 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, goto end; } - switch (bt_object_get_type(attr_value)) { - case BT_OBJECT_TYPE_INTEGER: + switch (bt_value_get_type(attr_value)) { + case BT_VALUE_TYPE_INTEGER: { int64_t value; - ret = bt_object_integer_get(attr_value, &value); + ret = bt_value_integer_get(attr_value, &value); if (ret) { goto end; @@ -1086,11 +1075,11 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, break; } - case BT_OBJECT_TYPE_STRING: + case BT_VALUE_TYPE_STRING: { const char *value; - ret = bt_object_string_get(attr_value, &value); + ret = bt_value_string_get(attr_value, &value); if (ret) { goto end; @@ -1107,7 +1096,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, break; } - BT_OBJECT_PUT(attr_value); + BT_VALUE_PUT(attr_value); } if (event_class->context) { @@ -1132,7 +1121,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, g_string_append(context->string, "};\n\n"); end: context->current_indentation_level = 0; - BT_OBJECT_PUT(attr_value); + BT_VALUE_PUT(attr_value); return ret; } @@ -1292,7 +1281,7 @@ struct bt_ctf_event *bt_ctf_event_copy(struct bt_ctf_event *event) goto error; } - bt_ctf_ref_init(©->ref_count); + bt_ctf_base_init(copy, bt_ctf_event_destroy); copy->event_class = event->event_class; bt_ctf_event_class_get(copy->event_class); copy->stream = event->stream;