/*
* BabelTrace - CTF IR: Visitor internal
*
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* SOFTWARE.
*/
-#include <babeltrace/ctf-ir/event-types.h>
-#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/visitor.h>
#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-struct ctf_type_stack_frame {
- struct bt_ctf_field_type *type;
- int index;
-};
-
-typedef GPtrArray ctf_type_stack;
+typedef void *(*bt_child_accessor)(void *object, int index);
+typedef int64_t (*bt_child_count_accessor)(void *object);
+typedef int (*bt_child_visitor)(void *object, bt_visitor visitor,
+ void *data);
-struct ctf_type_visitor_context {
- struct bt_ctf_trace *trace;
- struct bt_ctf_stream_class *stream_class;
- struct bt_ctf_event_class *event_class;
- /* Root node being visited */
- enum bt_ctf_node root_node;
- ctf_type_stack *stack;
+struct bt_visitor_object {
+ enum bt_visitor_object_type type;
+ void *object;
};
-typedef int (*ctf_type_visitor_func)(struct bt_ctf_field_type *,
- struct ctf_type_visitor_context *);
-
-BT_HIDDEN
-ctf_type_stack *ctf_type_stack_create(void);
-
-BT_HIDDEN
-void ctf_type_stack_destroy(ctf_type_stack *stack);
-
-BT_HIDDEN
-int ctf_type_stack_push(ctf_type_stack *stack,
- struct ctf_type_stack_frame *entry);
-
-BT_HIDDEN
-struct ctf_type_stack_frame *ctf_type_stack_peek(
- ctf_type_stack *stack);
-
-BT_HIDDEN
-struct ctf_type_stack_frame *ctf_type_stack_pop(ctf_type_stack *stack);
-
-BT_HIDDEN
-int bt_ctf_trace_visit(struct bt_ctf_trace *trace,
- ctf_type_visitor_func func);
-
-BT_HIDDEN
-int bt_ctf_trace_resolve_types(struct bt_ctf_trace *trace);
-
-BT_HIDDEN
-int bt_ctf_stream_class_resolve_types(struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_trace *trace);
-
BT_HIDDEN
-int bt_ctf_event_class_resolve_types(struct bt_ctf_event_class *event_class,
- struct bt_ctf_trace *trace,
- struct bt_ctf_stream_class *stream_class);
+int visitor_helper(struct bt_visitor_object *root,
+ bt_child_count_accessor child_counter,
+ bt_child_accessor child_accessor,
+ bt_child_visitor child_visitor,
+ bt_visitor visitor,
+ void *data);
#endif /* BABELTRACE_CTF_IR_VISITOR_INTERNAL_H */