Rename bt_ctf_X -> bt_X, maintain backward compat. for pre-2.0 CTF writer
[babeltrace.git] / lib / ctf-ir / validation.c
index 49ae67ed7311bdfba30b9b8578a0a33fed6b8090..dd9a7afdb6e437a3081f2b7b3e55774657058c82 100644 (file)
  */
 static
 int validate_event_class_types(struct bt_value *environment,
-               struct bt_ctf_field_type *packet_header_type,
-               struct bt_ctf_field_type *packet_context_type,
-               struct bt_ctf_field_type *event_header_type,
-               struct bt_ctf_field_type *stream_event_ctx_type,
-               struct bt_ctf_field_type *event_context_type,
-               struct bt_ctf_field_type *event_payload_type)
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type)
 {
        int ret = 0;
 
@@ -67,11 +67,11 @@ int validate_event_class_types(struct bt_value *environment,
                stream_event_ctx_type, event_context_type, event_payload_type);
 
        /* Resolve sequence type lengths and variant type tags first */
-       ret = bt_ctf_resolve_types(environment, packet_header_type,
+       ret = bt_resolve_types(environment, packet_header_type,
                packet_context_type, event_header_type, stream_event_ctx_type,
                event_context_type, event_payload_type,
-               BT_CTF_RESOLVE_FLAG_EVENT_CONTEXT |
-               BT_CTF_RESOLVE_FLAG_EVENT_PAYLOAD);
+               BT_RESOLVE_FLAG_EVENT_CONTEXT |
+               BT_RESOLVE_FLAG_EVENT_PAYLOAD);
        if (ret) {
                BT_LOGW("Cannot resolve event class field types: ret=%d",
                        ret);
@@ -80,7 +80,7 @@ int validate_event_class_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (event_context_type) {
-               ret = bt_ctf_field_type_validate(event_context_type);
+               ret = bt_field_type_validate(event_context_type);
                if (ret) {
                        BT_LOGW("Invalid event class's context field type: "
                                "ret=%d", ret);
@@ -89,7 +89,7 @@ int validate_event_class_types(struct bt_value *environment,
        }
 
        if (event_payload_type) {
-               ret = bt_ctf_field_type_validate(event_payload_type);
+               ret = bt_field_type_validate(event_payload_type);
                if (ret) {
                        BT_LOGW("Invalid event class's payload field type: "
                                "ret=%d", ret);
@@ -111,10 +111,10 @@ end:
  */
 static
 int validate_stream_class_types(struct bt_value *environment,
-               struct bt_ctf_field_type *packet_header_type,
-               struct bt_ctf_field_type *packet_context_type,
-               struct bt_ctf_field_type *event_header_type,
-               struct bt_ctf_field_type *stream_event_ctx_type)
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type)
 {
        int ret = 0;
 
@@ -127,12 +127,12 @@ int validate_stream_class_types(struct bt_value *environment,
                stream_event_ctx_type);
 
        /* Resolve sequence type lengths and variant type tags first */
-       ret = bt_ctf_resolve_types(environment, packet_header_type,
+       ret = bt_resolve_types(environment, packet_header_type,
                packet_context_type, event_header_type, stream_event_ctx_type,
                NULL, NULL,
-               BT_CTF_RESOLVE_FLAG_PACKET_CONTEXT |
-               BT_CTF_RESOLVE_FLAG_EVENT_HEADER |
-               BT_CTF_RESOLVE_FLAG_STREAM_EVENT_CTX);
+               BT_RESOLVE_FLAG_PACKET_CONTEXT |
+               BT_RESOLVE_FLAG_EVENT_HEADER |
+               BT_RESOLVE_FLAG_STREAM_EVENT_CTX);
        if (ret) {
                BT_LOGW("Cannot resolve stream class field types: ret=%d",
                        ret);
@@ -141,7 +141,7 @@ int validate_stream_class_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (packet_context_type) {
-               ret = bt_ctf_field_type_validate(packet_context_type);
+               ret = bt_field_type_validate(packet_context_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's packet context field type: "
                                "ret=%d", ret);
@@ -150,7 +150,7 @@ int validate_stream_class_types(struct bt_value *environment,
        }
 
        if (event_header_type) {
-               ret = bt_ctf_field_type_validate(event_header_type);
+               ret = bt_field_type_validate(event_header_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's event header field type: "
                                "ret=%d", ret);
@@ -159,7 +159,7 @@ int validate_stream_class_types(struct bt_value *environment,
        }
 
        if (stream_event_ctx_type) {
-               ret = bt_ctf_field_type_validate(
+               ret = bt_field_type_validate(
                        stream_event_ctx_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's event context field type: "
@@ -179,7 +179,7 @@ end:
  */
 static
 int validate_trace_types(struct bt_value *environment,
-               struct bt_ctf_field_type *packet_header_type)
+               struct bt_field_type *packet_header_type)
 {
        int ret = 0;
 
@@ -187,9 +187,9 @@ int validate_trace_types(struct bt_value *environment,
                "packet-header-ft-addr=%p", packet_header_type);
 
        /* Resolve sequence type lengths and variant type tags first */
-       ret = bt_ctf_resolve_types(environment, packet_header_type,
+       ret = bt_resolve_types(environment, packet_header_type,
                NULL, NULL, NULL, NULL, NULL,
-               BT_CTF_RESOLVE_FLAG_PACKET_HEADER);
+               BT_RESOLVE_FLAG_PACKET_HEADER);
        if (ret) {
                BT_LOGW("Cannot resolve trace field types: ret=%d",
                        ret);
@@ -198,7 +198,7 @@ int validate_trace_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (packet_header_type) {
-               ret = bt_ctf_field_type_validate(packet_header_type);
+               ret = bt_field_type_validate(packet_header_type);
                if (ret) {
                        BT_LOGW("Invalid trace's packet header field type: "
                                "ret=%d", ret);
@@ -217,21 +217,21 @@ end:
  * `field_type` is owned by the caller.
  */
 static
-int field_type_contains_sequence_or_variant_ft(struct bt_ctf_field_type *type)
+int field_type_contains_sequence_or_variant_ft(struct bt_field_type *type)
 {
        int ret = 0;
-       enum bt_ctf_field_type_id type_id = bt_ctf_field_type_get_type_id(type);
+       enum bt_field_type_id type_id = bt_field_type_get_type_id(type);
 
        switch (type_id) {
-       case BT_CTF_FIELD_TYPE_ID_SEQUENCE:
-       case BT_CTF_FIELD_TYPE_ID_VARIANT:
+       case BT_FIELD_TYPE_ID_SEQUENCE:
+       case BT_FIELD_TYPE_ID_VARIANT:
                ret = 1;
                goto end;
-       case BT_CTF_FIELD_TYPE_ID_ARRAY:
-       case BT_CTF_FIELD_TYPE_ID_STRUCT:
+       case BT_FIELD_TYPE_ID_ARRAY:
+       case BT_FIELD_TYPE_ID_STRUCT:
        {
                int i;
-               int field_count = bt_ctf_field_type_get_field_count(type);
+               int field_count = bt_field_type_get_field_count(type);
 
                if (field_count < 0) {
                        ret = -1;
@@ -239,8 +239,8 @@ int field_type_contains_sequence_or_variant_ft(struct bt_ctf_field_type *type)
                }
 
                for (i = 0; i < field_count; ++i) {
-                       struct bt_ctf_field_type *child_type =
-                               bt_ctf_field_type_get_field_at_index(type, i);
+                       struct bt_field_type *child_type =
+                               bt_field_type_get_field_at_index(type, i);
 
                        ret = field_type_contains_sequence_or_variant_ft(
                                child_type);
@@ -260,16 +260,16 @@ end:
 }
 
 BT_HIDDEN
-int bt_ctf_validate_class_types(struct bt_value *environment,
-               struct bt_ctf_field_type *packet_header_type,
-               struct bt_ctf_field_type *packet_context_type,
-               struct bt_ctf_field_type *event_header_type,
-               struct bt_ctf_field_type *stream_event_ctx_type,
-               struct bt_ctf_field_type *event_context_type,
-               struct bt_ctf_field_type *event_payload_type,
+int bt_validate_class_types(struct bt_value *environment,
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type,
                int trace_valid, int stream_class_valid, int event_class_valid,
-               struct bt_ctf_validation_output *output,
-               enum bt_ctf_validation_flag validate_flags)
+               struct bt_validation_output *output,
+               enum bt_validation_flag validate_flags)
 {
        int ret = 0;
        int contains_seq_var;
@@ -294,15 +294,15 @@ int bt_ctf_validate_class_types(struct bt_value *environment,
 
        /* Set initial valid flags according to valid parameters */
        if (trace_valid) {
-               output->valid_flags |= BT_CTF_VALIDATION_FLAG_TRACE;
+               output->valid_flags |= BT_VALIDATION_FLAG_TRACE;
        }
 
        if (stream_class_valid) {
-               output->valid_flags |= BT_CTF_VALIDATION_FLAG_STREAM;
+               output->valid_flags |= BT_VALIDATION_FLAG_STREAM;
        }
 
        if (event_class_valid) {
-               output->valid_flags |= BT_CTF_VALIDATION_FLAG_EVENT;
+               output->valid_flags |= BT_VALIDATION_FLAG_EVENT;
        }
 
        /* Own the type parameters */
@@ -314,8 +314,8 @@ int bt_ctf_validate_class_types(struct bt_value *environment,
        bt_get(event_payload_type);
 
        /* Validate trace */
-       if ((validate_flags & BT_CTF_VALIDATION_FLAG_TRACE) && !trace_valid) {
-               struct bt_ctf_field_type *packet_header_type_copy = NULL;
+       if ((validate_flags & BT_VALIDATION_FLAG_TRACE) && !trace_valid) {
+               struct bt_field_type *packet_header_type_copy = NULL;
 
                /* Create field type copies */
                if (packet_header_type) {
@@ -334,7 +334,7 @@ int bt_ctf_validate_class_types(struct bt_value *environment,
 
                        BT_LOGV_STR("Copying packet header field type because it contains at least one sequence or variant field type.");
                        packet_header_type_copy =
-                               bt_ctf_field_type_copy(packet_header_type);
+                               bt_field_type_copy(packet_header_type);
                        if (!packet_header_type_copy) {
                                ret = -1;
                                BT_LOGE_STR("Cannot copy packet header field type.");
@@ -346,7 +346,7 @@ int bt_ctf_validate_class_types(struct bt_value *environment,
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(packet_header_type_copy);
+                       bt_field_type_freeze(packet_header_type_copy);
                }
 
 skip_packet_header_type_copy:
@@ -358,16 +358,16 @@ skip_packet_header_type_copy:
                        packet_header_type);
                if (valid_ret == 0) {
                        /* Trace is valid */
-                       output->valid_flags |= BT_CTF_VALIDATION_FLAG_TRACE;
+                       output->valid_flags |= BT_VALIDATION_FLAG_TRACE;
                }
        }
 
        /* Validate stream class */
-       if ((validate_flags & BT_CTF_VALIDATION_FLAG_STREAM) &&
+       if ((validate_flags & BT_VALIDATION_FLAG_STREAM) &&
                        !stream_class_valid) {
-               struct bt_ctf_field_type *packet_context_type_copy = NULL;
-               struct bt_ctf_field_type *event_header_type_copy = NULL;
-               struct bt_ctf_field_type *stream_event_ctx_type_copy = NULL;
+               struct bt_field_type *packet_context_type_copy = NULL;
+               struct bt_field_type *event_header_type_copy = NULL;
+               struct bt_field_type *stream_event_ctx_type_copy = NULL;
 
                if (packet_context_type) {
                        contains_seq_var =
@@ -385,7 +385,7 @@ skip_packet_header_type_copy:
 
                        BT_LOGV_STR("Copying packet context field type because it contains at least one sequence or variant field type.");
                        packet_context_type_copy =
-                               bt_ctf_field_type_copy(packet_context_type);
+                               bt_field_type_copy(packet_context_type);
                        if (!packet_context_type_copy) {
                                BT_LOGE_STR("Cannot copy packet context field type.");
                                goto sc_validation_error;
@@ -396,7 +396,7 @@ skip_packet_header_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(packet_context_type_copy);
+                       bt_field_type_freeze(packet_context_type_copy);
                }
 
 skip_packet_context_type_copy:
@@ -416,7 +416,7 @@ skip_packet_context_type_copy:
 
                        BT_LOGV_STR("Copying event header field type because it contains at least one sequence or variant field type.");
                        event_header_type_copy =
-                               bt_ctf_field_type_copy(event_header_type);
+                               bt_field_type_copy(event_header_type);
                        if (!event_header_type_copy) {
                                BT_LOGE_STR("Cannot copy event header field type.");
                                goto sc_validation_error;
@@ -427,7 +427,7 @@ skip_packet_context_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(event_header_type_copy);
+                       bt_field_type_freeze(event_header_type_copy);
                }
 
 skip_event_header_type_copy:
@@ -448,7 +448,7 @@ skip_event_header_type_copy:
 
                        BT_LOGV_STR("Copying stream event context field type because it contains at least one sequence or variant field type.");
                        stream_event_ctx_type_copy =
-                               bt_ctf_field_type_copy(stream_event_ctx_type);
+                               bt_field_type_copy(stream_event_ctx_type);
                        if (!stream_event_ctx_type_copy) {
                                BT_LOGE_STR("Cannot copy stream event context field type.");
                                goto sc_validation_error;
@@ -459,7 +459,7 @@ skip_event_header_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(stream_event_ctx_type_copy);
+                       bt_field_type_freeze(stream_event_ctx_type_copy);
                }
 
 skip_stream_event_ctx_type_copy:
@@ -474,7 +474,7 @@ skip_stream_event_ctx_type_copy:
                        event_header_type, stream_event_ctx_type);
                if (valid_ret == 0) {
                        /* Stream class is valid */
-                       output->valid_flags |= BT_CTF_VALIDATION_FLAG_STREAM;
+                       output->valid_flags |= BT_VALIDATION_FLAG_STREAM;
                }
 
                goto sc_validation_done;
@@ -489,10 +489,10 @@ sc_validation_error:
 
 sc_validation_done:
        /* Validate event class */
-       if ((validate_flags & BT_CTF_VALIDATION_FLAG_EVENT) &&
+       if ((validate_flags & BT_VALIDATION_FLAG_EVENT) &&
                        !event_class_valid) {
-               struct bt_ctf_field_type *event_context_type_copy = NULL;
-               struct bt_ctf_field_type *event_payload_type_copy = NULL;
+               struct bt_field_type *event_context_type_copy = NULL;
+               struct bt_field_type *event_payload_type_copy = NULL;
 
                if (event_context_type) {
                        contains_seq_var =
@@ -510,7 +510,7 @@ sc_validation_done:
 
                        BT_LOGV_STR("Copying event context field type because it contains at least one sequence or variant field type.");
                        event_context_type_copy =
-                               bt_ctf_field_type_copy(event_context_type);
+                               bt_field_type_copy(event_context_type);
                        if (!event_context_type_copy) {
                                BT_LOGE_STR("Cannot copy event context field type.");
                                goto ec_validation_error;
@@ -521,7 +521,7 @@ sc_validation_done:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(event_context_type_copy);
+                       bt_field_type_freeze(event_context_type_copy);
                }
 
 skip_event_context_type_copy:
@@ -541,7 +541,7 @@ skip_event_context_type_copy:
 
                        BT_LOGV_STR("Copying event payload field type because it contains at least one sequence or variant field type.");
                        event_payload_type_copy =
-                               bt_ctf_field_type_copy(event_payload_type);
+                               bt_field_type_copy(event_payload_type);
                        if (!event_payload_type_copy) {
                                BT_LOGE_STR("Cannot copy event payload field type.");
                                goto ec_validation_error;
@@ -552,7 +552,7 @@ skip_event_context_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_ctf_field_type_freeze(event_payload_type_copy);
+                       bt_field_type_freeze(event_payload_type_copy);
                }
 
 skip_event_payload_type_copy:
@@ -567,7 +567,7 @@ skip_event_payload_type_copy:
                        event_context_type, event_payload_type);
                if (valid_ret == 0) {
                        /* Event class is valid */
-                       output->valid_flags |= BT_CTF_VALIDATION_FLAG_EVENT;
+                       output->valid_flags |= BT_VALIDATION_FLAG_EVENT;
                }
 
                goto ec_validation_done;
@@ -604,21 +604,21 @@ error:
 }
 
 BT_HIDDEN
-void bt_ctf_validation_replace_types(struct bt_ctf_trace *trace,
-               struct bt_ctf_stream_class *stream_class,
-               struct bt_ctf_event_class *event_class,
-               struct bt_ctf_validation_output *output,
-               enum bt_ctf_validation_flag replace_flags)
+void bt_validation_replace_types(struct bt_trace *trace,
+               struct bt_stream_class *stream_class,
+               struct bt_event_class *event_class,
+               struct bt_validation_output *output,
+               enum bt_validation_flag replace_flags)
 {
-       if ((replace_flags & BT_CTF_VALIDATION_FLAG_TRACE) && trace) {
-               bt_ctf_field_type_freeze(trace->packet_header_type);
+       if ((replace_flags & BT_VALIDATION_FLAG_TRACE) && trace) {
+               bt_field_type_freeze(trace->packet_header_type);
                BT_MOVE(trace->packet_header_type, output->packet_header_type);
        }
 
-       if ((replace_flags & BT_CTF_VALIDATION_FLAG_STREAM) && stream_class) {
-               bt_ctf_field_type_freeze(stream_class->packet_context_type);
-               bt_ctf_field_type_freeze(stream_class->event_header_type);
-               bt_ctf_field_type_freeze(stream_class->event_context_type);
+       if ((replace_flags & BT_VALIDATION_FLAG_STREAM) && stream_class) {
+               bt_field_type_freeze(stream_class->packet_context_type);
+               bt_field_type_freeze(stream_class->event_header_type);
+               bt_field_type_freeze(stream_class->event_context_type);
                BT_MOVE(stream_class->packet_context_type,
                        output->packet_context_type);
                BT_MOVE(stream_class->event_header_type,
@@ -627,17 +627,17 @@ void bt_ctf_validation_replace_types(struct bt_ctf_trace *trace,
                        output->stream_event_ctx_type);
        }
 
-       if ((replace_flags & BT_CTF_VALIDATION_FLAG_EVENT) && event_class) {
-               bt_ctf_field_type_freeze(event_class->context);
-               bt_ctf_field_type_freeze(event_class->fields);
+       if ((replace_flags & BT_VALIDATION_FLAG_EVENT) && event_class) {
+               bt_field_type_freeze(event_class->context);
+               bt_field_type_freeze(event_class->fields);
                BT_MOVE(event_class->context, output->event_context_type);
                BT_MOVE(event_class->fields, output->event_payload_type);
        }
 }
 
 BT_HIDDEN
-void bt_ctf_validation_output_put_types(
-               struct bt_ctf_validation_output *output)
+void bt_validation_output_put_types(
+               struct bt_validation_output *output)
 {
        BT_PUT(output->packet_header_type);
        BT_PUT(output->packet_context_type);
This page took 0.047509 seconds and 4 git commands to generate.