/*
- * resolve.c
- *
- * Babeltrace - CTF writer: Type resolving internal
+ * SPDX-License-Identifier: MIT
*
* Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2016 Philippe Proulx <pproulx@efficios.com>
*
- * Authors: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Babeltrace - CTF writer: Type resolving internal
*/
#define BT_LOG_TAG "CTF-WRITER/RESOLVE"
#include <limits.h>
#include <stdlib.h>
-#include <babeltrace2/ctf-writer/field-types.h>
-#include <babeltrace2/ctf-writer/object.h>
-#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2-ctf-writer/field-types.h>
+#include <babeltrace2-ctf-writer/object.h>
+#include <babeltrace2-ctf-writer/stream-class.h>
#include <babeltrace2/types.h>
#include "common/macros.h"
* Checks whether or not `stack` is empty.
*/
static
-bt_bool type_stack_empty(type_stack *stack)
+bt_ctf_bool type_stack_empty(type_stack *stack)
{
return stack->len == 0;
}
static
struct type_stack_frame *type_stack_peek(type_stack *stack)
{
- struct type_stack_frame *entry = NULL;
+ BT_ASSERT(stack);
+ BT_ASSERT(!type_stack_empty(stack));
- if (!stack || type_stack_empty(stack)) {
- goto end;
- }
-
- entry = g_ptr_array_index(stack, stack->len - 1);
-end:
- return entry;
+ return g_ptr_array_index(stack, stack->len - 1);
}
/*
* Return value is owned by `stack`.
*/
static
-struct type_stack_frame *type_stack_at(type_stack *stack,
- size_t index)
+struct type_stack_frame *type_stack_at(type_stack *stack, size_t index)
{
- struct type_stack_frame *entry = NULL;
+ BT_ASSERT(stack);
+ BT_ASSERT(index < stack->len);
- if (!stack || index >= stack->len) {
- goto end;
- }
-
- entry = g_ptr_array_index(stack, index);
-
-end:
- return entry;
+ return g_ptr_array_index(stack, index);
}
/*
struct bt_ctf_field_type_common *get_type_from_ctx(struct resolve_context *ctx,
enum bt_ctf_scope scope)
{
- BT_ASSERT(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER &&
+ BT_ASSERT_DBG(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER &&
scope <= BT_CTF_SCOPE_EVENT_FIELDS);
return ctx->scopes[scope - BT_CTF_SCOPE_TRACE_PACKET_HEADER];
{
int ret = 0;
GList *cur_ptoken = ptokens;
- bt_bool first_level_done = BT_FALSE;
+ bt_ctf_bool first_level_done = BT_CTF_FALSE;
/* Get our own reference */
bt_ctf_object_get_ref(type);
/* Next path token */
cur_ptoken = g_list_next(cur_ptoken);
- first_level_done = BT_TRUE;
+ first_level_done = BT_CTF_TRUE;
}
/* Create new field path entry */
int tail_field_path_len =
tail_field_path->indexes->len;
- while (BT_TRUE) {
+ while (BT_CTF_TRUE) {
struct bt_ctf_field_type_common *cur_type =
type_stack_at(ctx->type_stack, i)->type;
int index = type_stack_at(
/*
* Start from both roots and find the first mismatch.
*/
- BT_ASSERT(field_path1->root == field_path2->root);
+ BT_ASSERT_DBG(field_path1->root == field_path2->root);
field_path1_len = field_path1->indexes->len;
field_path2_len = field_path2->indexes->len;
- while (BT_TRUE) {
+ while (BT_CTF_TRUE) {
int target_index, ctx_index;
if (lca_index == field_path2_len ||
}
break;
default:
- abort();
+ bt_common_abort();
}
end:
bt_ctf_field_type_common_variant_get_tag_name(type);
break;
default:
- abort();
+ bt_common_abort();
}
if (!pathstr) {
}
break;
default:
- abort();
+ bt_common_abort();
}
end:
{
int ret;
- BT_ASSERT(type_stack_size(ctx->type_stack) == 0);
+ BT_ASSERT_DBG(type_stack_size(ctx->type_stack) == 0);
ctx->root_scope = root_scope;
ret = resolve_type(get_type_from_ctx(ctx, root_scope), ctx);
ctx->root_scope = BT_CTF_SCOPE_UNKNOWN;