#include <stdint.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/ctf-writer/values-internal.h>
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_create(void);
+struct bt_ctf_private_value *bt_ctf_attributes_create(void);
BT_HIDDEN
-void bt_ctf_attributes_destroy(struct bt_private_value *attr_obj);
+void bt_ctf_attributes_destroy(struct bt_ctf_private_value *attr_obj);
BT_HIDDEN
-int64_t bt_ctf_attributes_get_count(struct bt_private_value *attr_obj);
+int64_t bt_ctf_attributes_get_count(struct bt_ctf_private_value *attr_obj);
BT_HIDDEN
-const char *bt_ctf_attributes_get_field_name(struct bt_private_value *attr_obj,
+const char *bt_ctf_attributes_get_field_name(struct bt_ctf_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_borrow_field_value(struct bt_private_value *attr_obj,
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value(struct bt_ctf_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-int bt_ctf_attributes_set_field_value(struct bt_private_value *attr_obj,
- const char *name, struct bt_private_value *value_obj);
+int bt_ctf_attributes_set_field_value(struct bt_ctf_private_value *attr_obj,
+ const char *name, struct bt_ctf_private_value *value_obj);
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_borrow_field_value_by_name(
- struct bt_private_value *attr_obj, const char *name);
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value_by_name(
+ struct bt_ctf_private_value *attr_obj, const char *name);
BT_HIDDEN
-int bt_ctf_attributes_freeze(struct bt_private_value *attr_obj);
+int bt_ctf_attributes_freeze(struct bt_ctf_private_value *attr_obj);
#ifdef __cplusplus
}
* SOFTWARE.
*/
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-pool-internal.h>
#include <babeltrace/compat/uuid-internal.h>
#include <glib.h>
struct bt_ctf_clock_class {
- struct bt_object base;
+ struct bt_ctf_object base;
GString *name;
GString *description;
uint64_t frequency;
#include <babeltrace/ctf-writer/clock.h>
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <glib.h>
#include <babeltrace/compat/uuid-internal.h>
struct bt_ctf_clock {
- struct bt_object base;
+ struct bt_ctf_object base;
struct bt_ctf_clock_class *clock_class;
uint64_t value; /* Current clock value */
};
*/
#include <stdint.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/types.h>
#ifdef __cplusplus
static inline
void bt_ctf_clock_get(struct bt_ctf_clock *clock)
{
- bt_object_get_ref(clock);
+ bt_ctf_object_get_ref(clock);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_clock_put(struct bt_ctf_clock *clock)
{
- bt_object_put_ref(clock);
+ bt_ctf_object_put_ref(clock);
}
extern struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
#include <babeltrace/ctf-writer/stream-class.h>
#include <babeltrace/ctf-writer/stream.h>
#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/values.h>
#include <glib.h>
struct bt_ctf_event_class_common {
- struct bt_object base;
+ struct bt_ctf_object base;
struct bt_ctf_field_type_common *context_field_type;
struct bt_ctf_field_type_common *payload_field_type;
int frozen;
struct bt_ctf_event_class_common *event_class)
{
BT_ASSERT(event_class);
- return (void *) bt_object_borrow_parent(&event_class->base);
+ return (void *) bt_ctf_object_borrow_parent(&event_class->base);
}
typedef struct bt_ctf_field_type_common *(*bt_ctf_field_type_structure_create_func)();
BT_HIDDEN
int bt_ctf_event_class_common_initialize(struct bt_ctf_event_class_common *event_class,
- const char *name, bt_object_release_func release_func,
+ const char *name, bt_ctf_object_release_func release_func,
bt_ctf_field_type_structure_create_func ft_struct_create_func);
BT_HIDDEN
-void bt_ctf_event_class_common_finalize(struct bt_object *obj);
+void bt_ctf_event_class_common_finalize(struct bt_ctf_object *obj);
BT_HIDDEN
int bt_ctf_event_class_common_validate_single_clock_class(
goto end;
}
- bt_object_put_ref(event_class->context_field_type);
- event_class->context_field_type = bt_object_get_ref(context_ft);
+ bt_ctf_object_put_ref(event_class->context_field_type);
+ event_class->context_field_type = context_ft;
+ bt_ctf_object_get_ref(event_class->context_field_type);
BT_LOGV("Set event class's context field type: "
"event-class-addr=%p, event-class-name=\"%s\", "
"event-class-id=%" PRId64 ", context-ft-addr=%p",
goto end;
}
- bt_object_put_ref(event_class->payload_field_type);
- event_class->payload_field_type = bt_object_get_ref(payload_ft);
+ bt_ctf_object_put_ref(event_class->payload_field_type);
+ event_class->payload_field_type = payload_ft;
+ bt_ctf_object_get_ref(event_class->payload_field_type);
BT_LOGV("Set event class's payload field type: "
"event-class-addr=%p, event-class-name=\"%s\", "
"event-class-id=%" PRId64 ", payload-ft-addr=%p",
* http://www.efficios.com/ctf
*/
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/ctf-writer/field-types.h>
#include <babeltrace/ctf-writer/fields.h>
* bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
* field's reference count.
*
- * You may also use bt_object_get_ref() and bt_object_put_ref() with field objects.
+ * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field objects.
*
* These functions ensure that the field won't be destroyed when it
* is in use. The same number of get and put (plus one extra put to
static inline
void bt_ctf_field_get(struct bt_ctf_field *field)
{
- bt_object_get_ref(field);
+ bt_ctf_object_get_ref(field);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_field_put(struct bt_ctf_field *field)
{
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
}
#ifdef __cplusplus
#include <babeltrace/ctf-writer/stream-internal.h>
#include <babeltrace/ctf-writer/stream.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/values.h>
struct bt_ctf_stream_class;
struct metadata_context;
struct bt_ctf_event_common {
- struct bt_object base;
+ struct bt_ctf_object base;
struct bt_ctf_event_class_common *class;
struct bt_ctf_field_wrapper *header_field;
struct bt_ctf_field_common *stream_event_context_field;
int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event,
struct bt_ctf_event_class_common *event_class,
struct bt_ctf_clock_class *init_expected_clock_class,
- bool is_shared_with_parent, bt_object_release_func release_func,
+ bool is_shared_with_parent, bt_ctf_object_release_func release_func,
bt_ctf_validation_flag_copy_field_type_func field_type_copy_func,
bool must_be_in_trace,
int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
}
static inline
-void bt_ctf_event_common_finalize(struct bt_object *obj,
+void bt_ctf_event_common_finalize(struct bt_ctf_object *obj,
void (*field_release_func)(void *),
void (*header_field_release_func)(void *, struct bt_ctf_event_common *))
{
* common ancestor with it to guarantee they would both have the
* same lifetime.
*/
- bt_object_put_ref(event->class);
+ bt_ctf_object_put_ref(event->class);
}
}
* http://www.efficios.com/ctf
*/
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/ctf-writer/field-types.h>
#ifdef __cplusplus
* bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
* the field type's reference count.
*
- * You may also use bt_object_get_ref() and bt_object_put_ref() with field type objects.
+ * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field type objects.
*
* These functions ensure that the field type won't be destroyed while it
* is in use. The same number of get and put (plus one extra put to
static inline
void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
{
- bt_object_get_ref(type);
+ bt_ctf_object_get_ref(type);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_field_type_put(struct bt_ctf_field_type *type)
{
- bt_object_put_ref(type);
+ bt_ctf_object_put_ref(type);
}
#ifdef __cplusplus
* http://www.efficios.com/ctf
*/
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#ifdef __cplusplus
extern "C" {
static inline
void bt_ctf_event_get(struct bt_ctf_event *event)
{
- bt_object_get_ref(event);
+ bt_ctf_object_get_ref(event);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_event_put(struct bt_ctf_event *event)
{
- bt_object_put_ref(event);
+ bt_ctf_object_put_ref(event);
}
extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
static inline
void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class)
{
- bt_object_get_ref(event_class);
+ bt_ctf_object_get_ref(event_class);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class)
{
- bt_object_put_ref(event_class);
+ bt_ctf_object_put_ref(event_class);
}
#ifdef __cplusplus
*/
#include <babeltrace/common-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/ctf-writer/field-types.h>
#include <glib.h>
struct bt_ctf_field_path {
- struct bt_object base;
+ struct bt_ctf_object base;
enum bt_ctf_scope root;
/*
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/field-types.h>
#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/types.h>
#define BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(_ft, _type_id, _name) \
};
struct bt_ctf_field_type_common {
- struct bt_object base;
+ struct bt_ctf_object base;
enum bt_ctf_field_type_id id;
unsigned int alignment;
};
struct bt_ctf_field_type_enumeration_mapping_iterator {
- struct bt_object base;
+ struct bt_ctf_object base;
/* Owned by this */
struct bt_ctf_field_type_common_enumeration *enumeration_ft;
BT_HIDDEN
void bt_ctf_field_type_common_initialize(struct bt_ctf_field_type_common *ft,
- bool init_bo, bt_object_release_func release_func,
+ bool init_bo, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_integer_initialize(
struct bt_ctf_field_type_common *ft,
- unsigned int size, bt_object_release_func release_func,
+ unsigned int size, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_floating_point_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_enumeration_initialize(
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *container_ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_string_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_structure_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
void bt_ctf_field_type_common_array_initialize(
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *element_ft,
- unsigned int length, bt_object_release_func release_func,
+ unsigned int length, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *element_ft,
const char *length_field_name,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *tag_ft,
const char *tag_name,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods);
BT_HIDDEN
-void bt_ctf_field_type_common_integer_destroy(struct bt_object *obj);
+void bt_ctf_field_type_common_integer_destroy(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_floating_point_destroy(struct bt_object *obj);
+void bt_ctf_field_type_common_floating_point_destroy(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_object *obj);
+void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_string_destroy(struct bt_object *obj);
+void bt_ctf_field_type_common_string_destroy(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_object *obj);
+void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_array_destroy_recursive(struct bt_object *obj);
+void bt_ctf_field_type_common_array_destroy_recursive(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_object *obj);
+void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_ctf_object *obj);
BT_HIDDEN
-void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_object *obj);
+void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_ctf_object *obj);
BT_HIDDEN
int bt_ctf_field_type_common_integer_validate(struct bt_ctf_field_type_common *ft);
*/
#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-pool-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
struct bt_ctf_field_wrapper {
- struct bt_object base;
+ struct bt_ctf_object base;
/* Owned by this */
struct bt_ctf_field_common *field;
BT_HIDDEN
struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
- struct bt_object_pool *pool, struct bt_ctf_field_type *ft);
+ struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft);
#endif /* BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H */
#include <babeltrace/ctf-writer/fields.h>
#include <babeltrace/ctf-writer/serialize-internal.h>
#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/types.h>
#include <glib.h>
#include <inttypes.h>
};
struct bt_ctf_field_common {
- struct bt_object base;
+ struct bt_ctf_object base;
struct bt_ctf_field_type_common *type;
struct bt_ctf_field_common_methods *methods;
bool payload_set;
BT_HIDDEN
int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func);
BT_HIDDEN
int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_destroy_func);
BT_HIDDEN
int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
GDestroyNotify field_destroy_func);
BT_HIDDEN
int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func);
BT_HIDDEN
int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods);
BT_HIDDEN
static inline
void bt_ctf_field_common_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *ft, bool is_shared,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods)
{
BT_ASSERT(field);
BT_ASSERT(ft);
- bt_object_init(&field->base, is_shared, release_func);
+ bt_ctf_object_init(&field->base, is_shared, release_func);
field->methods = methods;
- field->type = bt_object_get_ref(ft);
+ field->type = (void *) bt_ctf_object_get_ref(ft);
}
static inline
{
BT_ASSERT(field);
BT_LOGD_STR("Putting field's type.");
- bt_object_put_ref(field->type);
+ bt_ctf_object_put_ref(field->type);
}
static inline
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
+
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <stdbool.h>
+
+struct bt_ctf_object;
+
+typedef void (*bt_ctf_object_release_func)(struct bt_ctf_object *);
+typedef void (*bt_ctf_object_parent_is_owner_listener_func)(
+ struct bt_ctf_object *);
+
+static inline
+void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj);
+
+static inline
+void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj);
+
+/*
+ * Babeltrace object base.
+ *
+ * All objects publicly exposed by Babeltrace APIs must contain this
+ * object as their first member.
+ */
+struct bt_ctf_object {
+ /*
+ * True if this object is shared, that is, it has a reference
+ * count.
+ */
+ bool is_shared;
+
+ /*
+ * Current reference count.
+ */
+ unsigned long long ref_count;
+
+ /*
+ * Release function called when the object's reference count
+ * falls to zero. For an object with a parent, this function is
+ * bt_ctf_object_with_parent_release_func(), which calls
+ * `spec_release_func` below if there's no current parent.
+ */
+ bt_ctf_object_release_func release_func;
+
+ /*
+ * Specific release function called by
+ * bt_ctf_object_with_parent_release_func() or directly by a
+ * parent object.
+ */
+ bt_ctf_object_release_func spec_release_func;
+
+ /*
+ * Optional callback for an object with a parent, called by
+ * bt_ctf_object_with_parent_release_func() to indicate to the
+ * object that its parent is its owner.
+ */
+ bt_ctf_object_parent_is_owner_listener_func
+ parent_is_owner_listener_func;
+
+ /*
+ * Optional parent object.
+ */
+ struct bt_ctf_object *parent;
+};
+
+static inline
+unsigned long long bt_ctf_object_get_ref_count(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->ref_count;
+}
+
+static inline
+struct bt_ctf_object *bt_ctf_object_borrow_parent(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->parent;
+}
+
+static inline
+struct bt_ctf_object *bt_ctf_object_get_parent(struct bt_ctf_object *obj)
+{
+ struct bt_ctf_object *parent = bt_ctf_object_borrow_parent(obj);
+
+ if (parent) {
+ bt_ctf_object_get_no_null_check(parent);
+ }
+
+ return parent;
+}
+
+static inline
+void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object *parent)
+{
+ BT_ASSERT(child);
+ BT_ASSERT(child->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p",
+ child, parent);
+#endif
+
+ /*
+ * It is assumed that a "child" having a parent is publicly
+ * reachable. Therefore, a reference to its parent must be
+ * taken. The reference to the parent will be released once the
+ * object's reference count falls to zero.
+ */
+ if (parent) {
+ BT_ASSERT(!child->parent);
+ child->parent = parent;
+ bt_ctf_object_get_no_null_check(parent);
+ } else {
+ if (child->parent) {
+ bt_ctf_object_put_no_null_check(child->parent);
+ }
+
+ child->parent = NULL;
+ }
+}
+
+static inline
+void bt_ctf_object_try_spec_release(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+
+ if (bt_ctf_object_get_ref_count(obj) == 0) {
+ obj->spec_release_func(obj);
+ }
+}
+
+static inline
+void bt_ctf_object_with_parent_release_func(struct bt_ctf_object *obj)
+{
+ if (obj->parent) {
+ /*
+ * Keep our own copy of the parent address because `obj`
+ * could be destroyed in
+ * obj->parent_is_owner_listener_func().
+ */
+ struct bt_ctf_object *parent = obj->parent;
+
+#ifdef BT_LOGV
+ BT_LOGV("Releasing parented object: addr=%p, ref-count=%llu, "
+ "parent-addr=%p, parent-ref-count=%llu",
+ obj, obj->ref_count,
+ parent, parent->ref_count);
+#endif
+
+ if (obj->parent_is_owner_listener_func) {
+ /*
+ * Object has a chance to destroy itself here
+ * under certain conditions and notify its
+ * parent. At this point the parent is
+ * guaranteed to exist because it's not put yet.
+ */
+ obj->parent_is_owner_listener_func(obj);
+ }
+
+ /* The release function will be invoked by the parent. */
+ bt_ctf_object_put_no_null_check(parent);
+ } else {
+ bt_ctf_object_try_spec_release(obj);
+ }
+}
+
+static inline
+void bt_ctf_object_init(struct bt_ctf_object *obj, bool is_shared,
+ bt_ctf_object_release_func release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(!is_shared || release_func);
+ obj->is_shared = is_shared;
+ obj->release_func = release_func;
+ obj->parent_is_owner_listener_func = NULL;
+ obj->spec_release_func = NULL;
+ obj->parent = NULL;
+ obj->ref_count = 1;
+}
+
+static inline
+void bt_ctf_object_init_shared(struct bt_ctf_object *obj,
+ bt_ctf_object_release_func release_func)
+{
+ bt_ctf_object_init(obj, true, release_func);
+}
+
+static inline
+void bt_ctf_object_init_unique(struct bt_ctf_object *obj)
+{
+ bt_ctf_object_init(obj, false, NULL);
+}
+
+static inline
+void bt_ctf_object_init_shared_with_parent(struct bt_ctf_object *obj,
+ bt_ctf_object_release_func spec_release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(spec_release_func);
+ bt_ctf_object_init_shared(obj, bt_ctf_object_with_parent_release_func);
+ obj->spec_release_func = spec_release_func;
+}
+
+static inline
+void bt_ctf_object_set_parent_is_owner_listener_func(struct bt_ctf_object *obj,
+ bt_ctf_object_parent_is_owner_listener_func func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+ ((struct bt_ctf_object *) obj)->parent_is_owner_listener_func = func;
+}
+
+static inline
+void bt_ctf_object_inc_ref_count(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ obj->ref_count++;
+ BT_ASSERT(obj->ref_count != 0);
+}
+
+static inline
+void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_ctf_object_inc_ref_count(obj);
+ return obj;
+}
+
+static inline
+void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+ if (unlikely(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) {
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's parent's reference count: "
+ "addr=%p, parent-addr=%p", obj, obj->parent);
+#endif
+
+ bt_ctf_object_get_no_null_check(obj->parent);
+ }
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_ctf_object_inc_ref_count(obj);
+ return obj;
+}
+
+static inline
+void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->ref_count > 0);
+
+#ifdef BT_LOGV
+ BT_LOGV("Decrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count - 1,
+ obj, obj->ref_count, obj->ref_count - 1);
+#endif
+
+ obj->ref_count--;
+
+ if (obj->ref_count == 0) {
+ BT_ASSERT(obj->release_func);
+ obj->release_func(obj);
+ }
+}
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 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.
+ */
+
+/*
+ * This is a generic object pool to avoid memory allocation/deallocation
+ * for objects of which the lifespan is typically short, but which are
+ * created a lot.
+ *
+ * The object pool, thanks to two user functions, knows how to allocate
+ * a brand new object in memory when the pool is empty and how to
+ * destroy an object when we destroy the pool.
+ *
+ * The object pool's user is responsible for:
+ *
+ * * Setting whatever references the object needs to keep and reset some
+ * properties _after_ calling bt_ctf_object_pool_create_object(). This is
+ * typically done in the bt_*_create() function which calls
+ * bt_ctf_object_pool_create_object() (which could call the user-provided
+ * allocation function if the pool is empty) and then sets the
+ * appropriate properties on the possibly recycled object.
+ *
+ * * Releasing whatever references the object keeps _before_ calling
+ * bt_ctf_object_pool_recycle_object(). This is typically done in a custom
+ * bt_*_recycle() function which does the necessary before calling
+ * bt_ctf_object_pool_recycle_object() with an object ready to be reused
+ * at any time.
+ */
+
+#include <glib.h>
+#include <babeltrace/ctf-writer/object-internal.h>
+
+typedef void *(*bt_ctf_object_pool_new_object_func)(void *data);
+typedef void *(*bt_ctf_object_pool_destroy_object_func)(void *obj, void *data);
+
+struct bt_ctf_object_pool {
+ /*
+ * Container of recycled objects, owned by this. The array's size
+ * is the pool's capacity.
+ */
+ GPtrArray *objects;
+
+ /*
+ * Pool's size, that is, number of elements in the array above,
+ * starting at index 0, which exist as recycled objects.
+ */
+ size_t size;
+
+ /* User functions */
+ struct {
+ /* Allocate a new object in memory */
+ bt_ctf_object_pool_new_object_func new_object;
+
+ /* Free direct and indirect memory occupied by object */
+ bt_ctf_object_pool_destroy_object_func destroy_object;
+ } funcs;
+
+ /* User data passed to user functions */
+ void *data;
+};
+
+/*
+ * Initializes an object pool which is already allocated.
+ */
+int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool,
+ bt_ctf_object_pool_new_object_func new_object_func,
+ bt_ctf_object_pool_destroy_object_func destroy_object_func,
+ void *data);
+
+/*
+ * Finalizes an object pool without deallocating it.
+ */
+void bt_ctf_object_pool_finalize(struct bt_ctf_object_pool *pool);
+
+/*
+ * Creates an object from an object pool. If the pool is empty, this
+ * function calls the "new" user function to allocate a new object
+ * before returning it. Otherwise this function returns a recycled
+ * object, removing it from the pool.
+ *
+ * The returned object is owned by the caller.
+ */
+static inline
+void *bt_ctf_object_pool_create_object(struct bt_ctf_object_pool *pool)
+{
+ struct bt_ctf_object *obj;
+
+ BT_ASSERT(pool);
+
+#ifdef BT_LOGV
+ BT_LOGV("Creating object from pool: pool-addr=%p, pool-size=%zu, pool-cap=%u",
+ pool, pool->size, pool->objects->len);
+#endif
+
+ if (pool->size > 0) {
+ /* Pick one from the pool */
+ pool->size--;
+ obj = pool->objects->pdata[pool->size];
+ pool->objects->pdata[pool->size] = NULL;
+ goto end;
+ }
+
+ /* Pool is empty: create a brand new object */
+#ifdef BT_LOGV
+ BT_LOGV("Pool is empty: allocating new object: pool-addr=%p",
+ pool);
+#endif
+
+ obj = pool->funcs.new_object(pool->data);
+
+end:
+#ifdef BT_LOGV
+ BT_LOGV("Created one object from pool: pool-addr=%p, obj-addr=%p",
+ pool, obj);
+#endif
+
+ return obj;
+}
+
+/*
+ * Recycles an object, that is, puts it back into the pool.
+ *
+ * The pool becomes the sole owner of the object to recycle.
+ */
+static inline
+void bt_ctf_object_pool_recycle_object(struct bt_ctf_object_pool *pool, void *obj)
+{
+ struct bt_ctf_object *bt_obj = obj;
+
+ BT_ASSERT(pool);
+ BT_ASSERT(obj);
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycling object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+
+ if (pool->size == pool->objects->len) {
+ /* Backing array is full: make place for recycled object */
+#ifdef BT_LOGV
+ BT_LOGV("Object pool is full: increasing object pool capacity: "
+ "pool-addr=%p, old-pool-cap=%u, new-pool-cap=%u",
+ pool, pool->objects->len, pool->objects->len + 1);
+#endif
+ g_ptr_array_set_size(pool->objects, pool->size + 1);
+ }
+
+ /* Reset reference count to 1 since it could be 0 now */
+ bt_obj->ref_count = 1;
+
+ /* Back to the pool */
+ pool->objects->pdata[pool->size] = obj;
+ pool->size++;
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycled object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+}
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_H
+#define BABELTRACE_CTF_WRITER_OBJECT_H
+
+/*
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
+ * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup refs Reference counting management
+@ingroup apiref
+@brief Common reference counting management for all Babeltrace objects.
+
+@code
+#include <babeltrace/ctf-writer/object.h>
+@endcode
+
+The macros and functions of this module are everything that is needed
+to handle the <strong><em>reference counting</em></strong> of
+Babeltrace objects.
+
+Any Babeltrace object can be shared by multiple owners thanks to
+<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
+counting</a>.
+
+The Babeltrace C API complies with the following key principles:
+
+1. When you call an API function which accepts a Babeltrace object
+ pointer as a parameter, the API function <strong>borrows the
+ reference</strong> for the <strong>duration of the function</strong>.
+
+ @image html ref-count-user-calls.png
+
+ The API function can also get a new reference if the system needs a
+ more persistent reference, but the ownership is <strong>never
+ transferred</strong> from the caller to the API function.
+
+ In other words, the caller still owns the object after calling any
+ API function: no function "steals" the user's reference (except
+ bt_ctf_object_put_ref()).
+
+2. An API function which \em returns a Babeltrace object pointer to the
+ user returns a <strong>new reference</strong>. The caller becomes an
+ owner of the object.
+
+ @image html ref-count-api-returns.png
+
+ It is your responsibility to discard the object when you don't
+ need it anymore with bt_ctf_object_put_ref().
+
+ For example, see bt_ctf_value_array_get().
+
+3. A Babeltrace object pointer received as a parameter in a user
+ function called back from an API function is a
+ <strong>borrowed</strong>, or <strong>weak reference</strong>: if you
+ need a reference which is more persistent than the duration of the
+ user function, call bt_ctf_object_get_ref() on the pointer.
+
+ @image html ref-count-callback.png
+
+ For example, see bt_ctf_value_map_foreach_entry().
+
+The two macros BT_CTF_OBJECT_PUT_REF_AND_RESET() and BT_CTF_OBJECT_MOVE_REF() operate on \em variables rather
+than pointer values. You should use BT_CTF_OBJECT_PUT_REF_AND_RESET() instead of bt_ctf_object_put_ref() when
+possible to avoid "double puts". For the same reason, you should use use
+BT_CTF_OBJECT_MOVE_REF() instead of performing manual reference moves between
+variables.
+
+@file
+@brief Reference counting management macros and functions.
+@sa refs
+
+@addtogroup refs
+@{
+*/
+
+/**
+@brief Calls bt_ctf_object_put_ref() on a variable named \p _var, then
+ sets \p _var to \c NULL.
+
+Using this macro is considered safer than calling bt_ctf_object_put_ref() because it
+makes sure that the variable which used to contain a reference to a
+Babeltrace object is set to \c NULL so that a future BT_CTF_OBJECT_PUT_REF_AND_RESET() or
+bt_ctf_object_put_ref() call will not cause another, unwanted reference decrementation.
+
+@param[in,out] _var Name of a variable containing a
+ Babeltrace object's address (this address
+ can be \c NULL).
+
+@post <strong>If \p _var does not contain \p NULL</strong>,
+ its reference count is decremented.
+@post \p _var contains \c NULL.
+
+@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
+ variable to another.
+*/
+#define BT_CTF_OBJECT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_ctf_object_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+/**
+@brief Transfers the ownership of a Babeltrace object from a variable
+ named \p _var_src to a variable named \p _var_dst.
+
+This macro implements the following common pattern:
+
+ 1. Call bt_ctf_object_put_ref() on \p _var_dst to make sure the previous reference
+ held by \p _var_dst is discarded.
+ 2. Assign \p _var_src to \p _var_dst.
+ 3. Set \p _var_src to \c NULL to avoid future, unwanted reference
+ decrementation of \p _var_src.
+
+@warning
+You must \em not use this macro when both \p _var_dst and
+\p _var_src contain the same Babeltrace object address and the reference
+count of this object is 1. The initial call to bt_ctf_object_put_ref() on \p _var_dst
+would destroy the object and leave a dangling pointer in \p _var_dst.
+
+@param[in,out] _var_dst Name of the destination variable, containing
+ either the address of a Babeltrace object to
+ put first, or \c NULL.
+@param[in,out] _var_src Name of the source variable, containing
+ either the address of a Babeltrace object to
+ move, or \c NULL.
+
+@pre <strong>If \p _var_dst and \p _var_src contain the same
+ value which is not \c NULL</strong>, this object's reference
+ count is greater than 1.
+@post <strong>If \c _var_dst is not \c NULL</strong>, its reference
+ count is decremented.
+@post \p _var_dst is equal to the value of \p _var_src \em before
+ you called this macro.
+@post \p _var_src is \c NULL.
+
+@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
+*/
+#define BT_CTF_OBJECT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_ctf_object_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+/**
+@brief Increments the reference count of the Babeltrace object \p obj.
+
+@param[in] obj Babeltrace object of which to get a new reference
+ (can be \c NULL).
+@returns \p obj
+
+@post <strong>If \c obj is not \c NULL</strong>, its reference
+ count is incremented.
+
+@sa bt_ctf_object_put_ref(): Decrements the reference count of a Babeltrace object.
+*/
+void *bt_ctf_object_get_ref(void *obj);
+
+/**
+@brief Decrements the reference count of the Babeltrace object
+ \p obj.
+
+When the object's reference count reaches 0, the object can no longer
+be accessed and is considered \em destroyed.
+
+@remarks
+You should use the BT_CTF_OBJECT_PUT_REF_AND_RESET() macro instead of calling bt_ctf_object_put_ref() since the
+former is generally safer.
+
+@param[in] obj Babeltrace object of which to drop a reference
+ (can be \c NULL).
+
+@post <strong>If \c obj is not \c NULL</strong>, its reference
+ count is decremented.
+
+@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
+@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
+ variable to another.
+@sa bt_ctf_object_get_ref(): Increments the reference count of a Babeltrace object.
+*/
+void bt_ctf_object_put_ref(void *obj);
+
+/**
+@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_H */
#include <babeltrace/ctf-writer/field-types.h>
#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/ctf-writer/values-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <glib.h>
* All parameters are owned by the caller.
*/
BT_HIDDEN
-int bt_ctf_resolve_types(struct bt_private_value *environment,
+int bt_ctf_resolve_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
#include <babeltrace/ctf-writer/utils-internal.h>
#include <babeltrace/ctf-writer/validation-internal.h>
#include <babeltrace/ctf-writer/visitor.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <inttypes.h>
struct bt_ctf_stream_class_common {
- struct bt_object base;
+ struct bt_ctf_object base;
GString *name;
/* Array of pointers to event class addresses */
BT_HIDDEN
int bt_ctf_stream_class_common_initialize(struct bt_ctf_stream_class_common *stream_class,
- const char *name, bt_object_release_func release_func);
+ const char *name, bt_ctf_object_release_func release_func);
BT_HIDDEN
void bt_ctf_stream_class_common_finalize(struct bt_ctf_stream_class_common *stream_class);
struct bt_ctf_stream_class_common *stream_class)
{
BT_ASSERT(stream_class);
- return (void *) bt_object_borrow_parent(&stream_class->base);
+ return (void *) bt_ctf_object_borrow_parent(&stream_class->base);
}
static inline
goto end;
}
- bt_object_put_ref(stream_class->packet_context_field_type);
- bt_object_get_ref(packet_context_type);
+ bt_ctf_object_put_ref(stream_class->packet_context_field_type);
stream_class->packet_context_field_type = packet_context_type;
+ bt_ctf_object_get_ref(stream_class->packet_context_field_type);
BT_LOGV("Set stream class's packet context field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"packet-context-ft-addr=%p",
goto end;
}
- bt_object_put_ref(stream_class->event_header_field_type);
- stream_class->event_header_field_type = bt_object_get_ref(event_header_type);
+ bt_ctf_object_put_ref(stream_class->event_header_field_type);
+ stream_class->event_header_field_type = event_header_type;
+ bt_ctf_object_get_ref(stream_class->event_header_field_type);
BT_LOGV("Set stream class's event header field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"event-header-ft-addr=%p",
goto end;
}
- bt_object_put_ref(stream_class->event_context_field_type);
- stream_class->event_context_field_type = bt_object_get_ref(event_context_type);
+ bt_ctf_object_put_ref(stream_class->event_context_field_type);
+ stream_class->event_context_field_type = event_context_type;
+ bt_ctf_object_get_ref(stream_class->event_context_field_type);
BT_LOGV("Set stream class's event context field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"event-context-ft-addr=%p",
* http://www.efficios.com/ctf
*/
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#ifdef __cplusplus
extern "C" {
static inline
void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
{
- bt_object_get_ref(stream_class);
+ bt_ctf_object_get_ref(stream_class);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
{
- bt_object_put_ref(stream_class);
+ bt_ctf_object_put_ref(stream_class);
}
#ifdef __cplusplus
#include <babeltrace/ctf-writer/stream-internal.h>
#include <babeltrace/ctf-writer/stream.h>
#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <stdint.h>
struct bt_ctf_stream_common;
struct bt_ctf_stream_common {
- struct bt_object base;
+ struct bt_ctf_object base;
int64_t id;
struct bt_ctf_stream_class_common *stream_class;
GString *name;
int bt_ctf_stream_common_initialize(
struct bt_ctf_stream_common *stream,
struct bt_ctf_stream_class_common *stream_class, const char *name,
- uint64_t id, bt_object_release_func release_func);
+ uint64_t id, bt_ctf_object_release_func release_func);
BT_HIDDEN
void bt_ctf_stream_common_finalize(struct bt_ctf_stream_common *stream);
static inline
void bt_ctf_stream_get(struct bt_ctf_stream *stream)
{
- bt_object_get_ref(stream);
+ bt_ctf_object_get_ref(stream);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_stream_put(struct bt_ctf_stream *stream)
{
- bt_object_put_ref(stream);
+ bt_ctf_object_put_ref(stream);
}
#ifdef __cplusplus
#include <babeltrace/ctf-writer/stream-class-internal.h>
#include <babeltrace/ctf-writer/trace.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/types.h>
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/values-internal.h>
#include <glib.h>
#include <sys/types.h>
struct bt_ctf_trace_common {
- struct bt_object base;
+ struct bt_ctf_object base;
GString *name;
int frozen;
unsigned char uuid[BABELTRACE_UUID_LEN];
bt_bool uuid_set;
enum bt_ctf_byte_order native_byte_order;
- struct bt_private_value *environment;
+ struct bt_ctf_private_value *environment;
GPtrArray *clock_classes; /* Array of pointers to bt_ctf_clock_class */
GPtrArray *stream_classes; /* Array of ptrs to bt_ctf_stream_class_common */
GPtrArray *streams; /* Array of ptrs to bt_ctf_stream_common */
BT_HIDDEN
int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace,
- bt_object_release_func release_func);
+ bt_ctf_object_release_func release_func);
BT_HIDDEN
void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace);
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
- const char *name, struct bt_private_value *value);
+ const char *name, struct bt_ctf_private_value *value);
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common *trace,
}
static inline
-struct bt_private_value *
+struct bt_ctf_private_value *
bt_ctf_trace_common_borrow_environment_field_value_by_index(
struct bt_ctf_trace_common *trace, uint64_t index)
{
}
static inline
-struct bt_private_value *
+struct bt_ctf_private_value *
bt_ctf_trace_common_borrow_environment_field_value_by_name(
struct bt_ctf_trace_common *trace, const char *name)
{
int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace,
struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int64_t bt_ctf_trace_get_environment_field_count(
+ struct bt_ctf_trace *trace);
+
+BT_HIDDEN
+const char *bt_ctf_trace_get_environment_field_name_by_index(
+ struct bt_ctf_trace *trace, uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_value *
+bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace,
+ uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_value *
+bt_ctf_trace_get_environment_field_value_by_name(
+ struct bt_ctf_trace *trace, const char *name);
+
#endif /* BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H */
extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
const unsigned char *uuid);
-extern int64_t bt_ctf_trace_get_environment_field_count(
- struct bt_ctf_trace *trace);
-
-extern const char *
-bt_ctf_trace_get_environment_field_name_by_index(
- struct bt_ctf_trace *trace, uint64_t index);
-
-extern struct bt_value *
-bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace,
- uint64_t index);
-
-extern struct bt_value *
-bt_ctf_trace_get_environment_field_value_by_name(
- struct bt_ctf_trace *trace, const char *name);
-
extern int bt_ctf_trace_set_environment_field_integer(
struct bt_ctf_trace *trace, const char *name,
int64_t value);
* SOFTWARE.
*/
-#include <babeltrace/private-values.h>
#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/values-internal.h>
struct bt_ctf_trace_common;
struct bt_ctf_stream_class_common;
* All parameters are owned by the caller.
*/
BT_HIDDEN
-int bt_ctf_validate_class_types(struct bt_private_value *environment,
+int bt_ctf_validate_class_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
+
+/*
+ * Copyright (c) 2015-2017 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-2017 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.
+ */
+
+#include <babeltrace/babeltrace-internal.h>
+
+struct bt_ctf_value;
+struct bt_ctf_private_value;
+
+/**
+@brief Status codes.
+*/
+enum bt_ctf_value_status {
+ /// Operation canceled.
+ BT_CTF_VALUE_STATUS_CANCELED = 125,
+
+ /// Cannot allocate memory.
+ BT_CTF_VALUE_STATUS_NOMEM = -12,
+
+ /// Okay, no error.
+ BT_CTF_VALUE_STATUS_OK = 0,
+};
+
+BT_HIDDEN
+enum bt_ctf_value_status _bt_ctf_value_freeze(struct bt_ctf_value *object);
+
+#ifdef BT_DEV_MODE
+# define bt_ctf_value_freeze _bt_ctf_value_freeze
+#else
+# define bt_ctf_value_freeze(_value)
+#endif /* BT_DEV_MODE */
+
+struct bt_ctf_value *bt_ctf_value_null;
+
+enum bt_ctf_value_type {
+ /// Null value object.
+ BT_CTF_VALUE_TYPE_NULL = 0,
+
+ /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
+ BT_CTF_VALUE_TYPE_BOOL = 1,
+
+ /// Integer value object (holds a signed 64-bit integer raw value).
+ BT_CTF_VALUE_TYPE_INTEGER = 2,
+
+ /// Floating point number value object (holds a \c double raw value).
+ BT_CTF_VALUE_TYPE_REAL = 3,
+
+ /// String value object.
+ BT_CTF_VALUE_TYPE_STRING = 4,
+
+ /// Array value object.
+ BT_CTF_VALUE_TYPE_ARRAY = 5,
+
+ /// Map value object.
+ BT_CTF_VALUE_TYPE_MAP = 6,
+};
+
+BT_HIDDEN
+enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object);
+
+static inline
+bt_bool bt_ctf_value_is_null(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_NULL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_bool(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_BOOL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_integer(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_INTEGER;
+}
+
+static inline
+bt_bool bt_ctf_value_is_real(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_REAL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_string(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_STRING;
+}
+
+static inline
+bt_bool bt_ctf_value_is_array(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_ARRAY;
+}
+
+static inline
+bt_bool bt_ctf_value_is_map(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_MAP;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy,
+ const struct bt_ctf_value *object);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj);
+
+BT_HIDDEN
+int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj);
+
+BT_HIDDEN
+double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj);
+
+BT_HIDDEN
+const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj);
+
+BT_HIDDEN
+uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj);
+
+static inline
+bt_bool bt_ctf_value_array_is_empty(const struct bt_ctf_value *array_obj)
+{
+ return bt_ctf_value_array_get_size(array_obj) == 0;
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
+ const struct bt_ctf_value *array_obj, uint64_t index);
+
+BT_HIDDEN
+uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj);
+
+static inline
+bt_bool bt_ctf_value_map_is_empty(const struct bt_ctf_value *map_obj)
+{
+ return bt_ctf_value_map_get_size(map_obj) == 0;
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(
+ const struct bt_ctf_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_ctf_value_map_foreach_entry_cb)(const char *key,
+ struct bt_ctf_value *object, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(
+ const struct bt_ctf_value *map_obj,
+ bt_ctf_value_map_foreach_entry_cb cb, void *data);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj,
+ const char *key);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_extend(
+ struct bt_ctf_private_value **extended_map_obj,
+ const struct bt_ctf_value *base_map_obj,
+ const struct bt_ctf_value *extension_map_obj);
+
+
+struct bt_ctf_value;
+struct bt_ctf_private_value;
+
+struct bt_ctf_private_value *bt_ctf_private_value_null;
+
+static inline
+struct bt_ctf_value *bt_ctf_private_value_as_value(
+ struct bt_ctf_private_value *priv_value)
+{
+ return (void *) priv_value;
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create_init(bt_bool val);
+
+BT_HIDDEN
+void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj,
+ bt_bool val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create_init(
+ int64_t val);
+
+BT_HIDDEN
+void bt_ctf_private_value_integer_set(
+ struct bt_ctf_private_value *integer_obj, int64_t val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create_init(double val);
+
+BT_HIDDEN
+void bt_ctf_private_value_real_set(
+ struct bt_ctf_private_value *real_obj, double val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create_init(
+ const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_string_set(
+ struct bt_ctf_private_value *string_obj,
+ const char *val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
+ const struct bt_ctf_private_value *array_obj, uint64_t index);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
+ struct bt_ctf_private_value *array_obj,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
+ struct bt_ctf_private_value *array_obj,
+ bt_bool val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
+ struct bt_ctf_private_value *array_obj,
+ int64_t val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
+ struct bt_ctf_private_value *array_obj,
+ double val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
+ struct bt_ctf_private_value *array_obj, const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
+ struct bt_ctf_private_value *array_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
+ struct bt_ctf_private_value *array_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
+ struct bt_ctf_private_value *array_obj, uint64_t index,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value(
+ const struct bt_ctf_private_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_ctf_private_value_map_foreach_entry_cb)(const char *key,
+ struct bt_ctf_private_value *object, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_foreach_entry(
+ const struct bt_ctf_private_value *map_obj,
+ bt_ctf_private_value_map_foreach_entry_cb cb, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
+ struct bt_ctf_private_value *map_obj, const char *key,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, bt_bool val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, int64_t val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, double val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
+ struct bt_ctf_private_value *map_obj, const char *key,
+ const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
+ struct bt_ctf_private_value *map_obj, const char *key);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
+ struct bt_ctf_private_value *map_obj, const char *key);
+
+#endif /* BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H */
*/
/**
-@struct bt_object
+@struct bt_ctf_object
@brief A CTF IR object wrapper.
This structure wraps both a CTF IR object and its type
-(see #bt_object_type). It is used in the visiting function.
+(see #bt_ctf_object_type). It is used in the visiting function.
-You can use the bt_object_get_type() and
-bt_object_get_object() accessors to get the type and wrapped
+You can use the bt_ctf_object_get_type() and
+bt_ctf_object_get_object() accessors to get the type and wrapped
CTF IR object of a CTF IR object wrapper.
A CTF IR object wrapper has <strong>no reference count</strong>: do \em
-not use bt_object_put_ref() or bt_object_get_ref() on it.
+not use bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
@sa ctfirvisitor
*/
\p object.
\p object has <strong>no reference count</strong>: do \em not use
-bt_object_put_ref() or bt_object_get_ref() on it.
+bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
@param[in] object Currently visited CTF IR object wrapper.
@param[in] data User data.
wrapper \p object.
The reference count of \p object is \em not incremented by this
-function. On success, you must call bt_object_get_ref() on the return value to
+function. On success, you must call bt_ctf_object_get_ref() on the return value to
have your own reference.
@param[in] object Object wrapper of which to get the wrapped
#include <dirent.h>
#include <sys/types.h>
#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
struct metadata_context {
GString *string;
};
struct bt_ctf_writer {
- struct bt_object base;
+ struct bt_ctf_object base;
int frozen; /* Protects attributes that can't be changed mid-trace */
struct bt_ctf_trace *trace;
GString *path;
static inline
void bt_ctf_writer_get(struct bt_ctf_writer *writer)
{
- bt_object_get_ref(writer);
+ bt_ctf_object_get_ref(writer);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_writer_put(struct bt_ctf_writer *writer)
{
- bt_object_put_ref(writer);
+ bt_ctf_object_put_ref(writer);
}
#ifdef __cplusplus
field-types.c \
field-wrapper.c \
functor.c \
+ object.c \
+ object-pool.c \
resolve.c \
serialize.c \
stream.c \
trace.c \
utils.c \
validation.c \
+ values.c \
visitor.c \
writer.c
#include <babeltrace/assert-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compat/string-internal.h>
-#include <babeltrace/object.h>
-#include <babeltrace/values-internal.h>
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace/ctf-writer/values-internal.h>
#include <inttypes.h>
#define BT_CTF_ATTR_NAME_INDEX 0
#define BT_CTF_ATTR_VALUE_INDEX 1
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_create(void)
+struct bt_ctf_private_value *bt_ctf_attributes_create(void)
{
- struct bt_private_value *attr_obj;
+ struct bt_ctf_private_value *attr_obj;
/*
* Attributes: array value object of array value objects, each one
* ]
*/
BT_LOGD_STR("Creating attributes object.");
- attr_obj = bt_private_value_array_create();
+ attr_obj = bt_ctf_private_value_array_create();
if (!attr_obj) {
BT_LOGE_STR("Failed to create array value.");
} else {
}
BT_HIDDEN
-void bt_ctf_attributes_destroy(struct bt_private_value *attr_obj)
+void bt_ctf_attributes_destroy(struct bt_ctf_private_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
- bt_object_put_ref(attr_obj);
+ bt_ctf_object_put_ref(attr_obj);
}
BT_HIDDEN
-int64_t bt_ctf_attributes_get_count(struct bt_private_value *attr_obj)
+int64_t bt_ctf_attributes_get_count(struct bt_ctf_private_value *attr_obj)
{
- return bt_value_array_get_size(bt_private_value_as_value(attr_obj));
+ return bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj));
}
BT_HIDDEN
-const char *bt_ctf_attributes_get_field_name(struct bt_private_value *attr_obj,
+const char *bt_ctf_attributes_get_field_name(struct bt_ctf_private_value *attr_obj,
uint64_t index)
{
const char *ret = NULL;
- struct bt_private_value *attr_field_obj = NULL;
- struct bt_private_value *attr_field_name_obj = NULL;
+ struct bt_ctf_private_value *attr_field_obj = NULL;
+ struct bt_ctf_private_value *attr_field_name_obj = NULL;
if (!attr_obj) {
BT_LOGW_STR("Invalid parameter: attributes object is NULL.");
goto end;
}
- if (index >= bt_value_array_get_size(bt_private_value_as_value(attr_obj))) {
+ if (index >= bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(bt_private_value_as_value(attr_obj)));
+ index, bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj)));
goto end;
}
- attr_field_obj = bt_private_value_array_borrow_element_by_index(
+ attr_field_obj = bt_ctf_private_value_array_borrow_element_by_index(
attr_obj, index);
if (!attr_field_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
}
attr_field_name_obj =
- bt_private_value_array_borrow_element_by_index(
+ bt_ctf_private_value_array_borrow_element_by_index(
attr_field_obj, BT_CTF_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
goto end;
}
- ret = bt_value_string_get(
- bt_private_value_as_value(attr_field_name_obj));
+ ret = bt_ctf_value_string_get(
+ bt_ctf_private_value_as_value(attr_field_name_obj));
end:
return ret;
}
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_borrow_field_value(struct bt_private_value *attr_obj,
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value(struct bt_ctf_private_value *attr_obj,
uint64_t index)
{
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_ctf_private_value *value_obj = NULL;
+ struct bt_ctf_private_value *attr_field_obj = NULL;
if (!attr_obj) {
BT_LOGW_STR("Invalid parameter: attributes object is NULL.");
goto end;
}
- if (index >= bt_value_array_get_size(bt_private_value_as_value(attr_obj))) {
+ if (index >= bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(bt_private_value_as_value(attr_obj)));
+ index, bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj)));
goto end;
}
- attr_field_obj = bt_private_value_array_borrow_element_by_index(
+ attr_field_obj = bt_ctf_private_value_array_borrow_element_by_index(
attr_obj, index);
if (!attr_field_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
goto end;
}
- value_obj = bt_private_value_array_borrow_element_by_index(attr_field_obj,
+ value_obj = bt_ctf_private_value_array_borrow_element_by_index(attr_field_obj,
BT_CTF_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
}
static
-struct bt_private_value *bt_ctf_attributes_borrow_field_by_name(
- struct bt_private_value *attr_obj, const char *name)
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_by_name(
+ struct bt_ctf_private_value *attr_obj, const char *name)
{
uint64_t i;
int64_t attr_size;
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_name_obj = NULL;
+ struct bt_ctf_private_value *value_obj = NULL;
+ struct bt_ctf_private_value *attr_field_name_obj = NULL;
- attr_size = bt_value_array_get_size(bt_private_value_as_value(attr_obj));
+ attr_size = bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj));
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
for (i = 0; i < attr_size; ++i) {
const char *field_name;
- value_obj = bt_private_value_array_borrow_element_by_index(attr_obj, i);
+ value_obj = bt_ctf_private_value_array_borrow_element_by_index(attr_obj, i);
if (!value_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_obj, i);
goto error;
}
- attr_field_name_obj = bt_private_value_array_borrow_element_by_index(value_obj,
+ attr_field_name_obj = bt_ctf_private_value_array_borrow_element_by_index(value_obj,
BT_CTF_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
goto error;
}
- field_name = bt_value_string_get(
- bt_private_value_as_value(attr_field_name_obj));
+ field_name = bt_ctf_value_string_get(
+ bt_ctf_private_value_as_value(attr_field_name_obj));
if (!strcmp(field_name, name)) {
break;
}
BT_HIDDEN
-int bt_ctf_attributes_set_field_value(struct bt_private_value *attr_obj,
- const char *name, struct bt_private_value *value_obj)
+int bt_ctf_attributes_set_field_value(struct bt_ctf_private_value *attr_obj,
+ const char *name, struct bt_ctf_private_value *value_obj)
{
int ret = 0;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_ctf_private_value *attr_field_obj = NULL;
if (!attr_obj || !name || !value_obj) {
BT_LOGW("Invalid parameter: attributes object, name, or value object is NULL: "
attr_field_obj = bt_ctf_attributes_borrow_field_by_name(attr_obj, name);
if (attr_field_obj) {
- ret = bt_private_value_array_set_element_by_index(
+ ret = bt_ctf_private_value_array_set_element_by_index(
attr_field_obj, BT_CTF_ATTR_VALUE_INDEX,
- bt_private_value_as_value(value_obj));
+ bt_ctf_private_value_as_value(value_obj));
attr_field_obj = NULL;
goto end;
}
- attr_field_obj = bt_private_value_array_create();
+ attr_field_obj = bt_ctf_private_value_array_create();
if (!attr_field_obj) {
BT_LOGE_STR("Failed to create empty array value.");
ret = -1;
goto end;
}
- ret = bt_private_value_array_append_string_element(attr_field_obj, name);
- ret |= bt_private_value_array_append_element(attr_field_obj,
- bt_private_value_as_value(value_obj));
+ ret = bt_ctf_private_value_array_append_string_element(attr_field_obj, name);
+ ret |= bt_ctf_private_value_array_append_element(attr_field_obj,
+ bt_ctf_private_value_as_value(value_obj));
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
goto end;
}
- ret = bt_private_value_array_append_element(attr_obj,
- bt_private_value_as_value(attr_field_obj));
+ ret = bt_ctf_private_value_array_append_element(attr_obj,
+ bt_ctf_private_value_as_value(attr_field_obj));
if (ret) {
BT_LOGE("Cannot append element to array value: "
"array-value-addr=%p, element-value-addr=%p",
}
end:
- bt_object_put_ref(attr_field_obj);
+ bt_ctf_object_put_ref(attr_field_obj);
return ret;
}
BT_HIDDEN
-struct bt_private_value *bt_ctf_attributes_borrow_field_value_by_name(
- struct bt_private_value *attr_obj, const char *name)
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value_by_name(
+ struct bt_ctf_private_value *attr_obj, const char *name)
{
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_ctf_private_value *value_obj = NULL;
+ struct bt_ctf_private_value *attr_field_obj = NULL;
if (!attr_obj || !name) {
BT_LOGW("Invalid parameter: attributes object or name is NULL: "
goto end;
}
- value_obj = bt_private_value_array_borrow_element_by_index(attr_field_obj,
+ value_obj = bt_ctf_private_value_array_borrow_element_by_index(attr_field_obj,
BT_CTF_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
}
BT_HIDDEN
-int bt_ctf_attributes_freeze(struct bt_private_value *attr_obj)
+int bt_ctf_attributes_freeze(struct bt_ctf_private_value *attr_obj)
{
uint64_t i;
int64_t count;
}
BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj);
- count = bt_value_array_get_size(bt_private_value_as_value(attr_obj));
+ count = bt_ctf_value_array_get_size(bt_ctf_private_value_as_value(attr_obj));
BT_ASSERT(count >= 0);
/*
* attribute is frozen one by one.
*/
for (i = 0; i < count; ++i) {
- struct bt_private_value *obj = NULL;
+ struct bt_ctf_private_value *obj = NULL;
obj = bt_ctf_attributes_borrow_field_value(attr_obj, i);
if (!obj) {
goto end;
}
- bt_value_freeze(bt_private_value_as_value(obj));
+ bt_ctf_value_freeze(bt_ctf_private_value_as_value(obj));
}
end:
#include <babeltrace/compat/uuid-internal.h>
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/compat/string-internal.h>
#include <inttypes.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <babeltrace/assert-internal.h>
static
-void bt_ctf_clock_class_destroy(struct bt_object *obj);
+void bt_ctf_clock_class_destroy(struct bt_ctf_object *obj);
BT_HIDDEN
bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class)
clock_class->precision = 1;
clock_class->frequency = freq;
- bt_object_init_shared(&clock_class->base, bt_ctf_clock_class_destroy);
+ bt_ctf_object_init_shared(&clock_class->base, bt_ctf_clock_class_destroy);
if (name) {
ret = bt_ctf_clock_class_set_name(clock_class, name);
clock_class, name);
return clock_class;
error:
- BT_OBJECT_PUT_REF_AND_RESET(clock_class);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(clock_class);
return clock_class;
}
}
static
-void bt_ctf_clock_class_destroy(struct bt_object *obj)
+void bt_ctf_clock_class_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_clock_class *clock_class;
#include <babeltrace/ctf-writer/clock-internal.h>
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace/ctf-writer/object.h>
#include <inttypes.h>
static
-void bt_ctf_clock_destroy(struct bt_object *obj);
+void bt_ctf_clock_destroy(struct bt_ctf_object *obj);
struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
{
goto error;
}
- bt_object_init_shared(&clock->base, bt_ctf_clock_destroy);
+ bt_ctf_object_init_shared(&clock->base, bt_ctf_clock_destroy);
clock->value = 0;
/* Pre-2.0.0 backward compatibility: default frequency is 1 GHz */
return clock;
error:
- BT_OBJECT_PUT_REF_AND_RESET(clock);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(clock);
return clock;
}
}
static
-void bt_ctf_clock_destroy(struct bt_object *obj)
+void bt_ctf_clock_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_clock *clock;
clock = container_of(obj, struct bt_ctf_clock, base);
- bt_object_put_ref(clock->clock_class);
+ bt_ctf_object_put_ref(clock->clock_class);
g_free(clock);
}
#include <babeltrace/ctf-writer/validation-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/types.h>
-#include <babeltrace/values-internal.h>
+#include <babeltrace/ctf-writer/values-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <inttypes.h>
#include <stdlib.h>
BT_HIDDEN
-void bt_ctf_event_class_common_finalize(struct bt_object *obj)
+void bt_ctf_event_class_common_finalize(struct bt_ctf_object *obj)
{
struct bt_ctf_event_class_common *event_class;
}
BT_LOGD_STR("Putting context field type.");
- bt_object_put_ref(event_class->context_field_type);
+ bt_ctf_object_put_ref(event_class->context_field_type);
BT_LOGD_STR("Putting payload field type.");
- bt_object_put_ref(event_class->payload_field_type);
+ bt_ctf_object_put_ref(event_class->payload_field_type);
}
BT_HIDDEN
int bt_ctf_event_class_common_initialize(struct bt_ctf_event_class_common *event_class,
- const char *name, bt_object_release_func release_func,
+ const char *name, bt_ctf_object_release_func release_func,
bt_ctf_field_type_structure_create_func ft_struct_create_func)
{
int ret = 0;
BT_LOGD("Initializing common event class object: name=\"%s\"",
name);
- bt_object_init_shared_with_parent(&event_class->base, release_func);
+ bt_ctf_object_init_shared_with_parent(&event_class->base, release_func);
event_class->payload_field_type = ft_struct_create_func();
if (!event_class->payload_field_type) {
BT_LOGE_STR("Cannot create event class's initial payload field type object.");
}
static
-void bt_ctf_event_class_destroy(struct bt_object *obj)
+void bt_ctf_event_class_destroy(struct bt_ctf_object *obj)
{
bt_ctf_event_class_common_finalize(obj);
g_free(obj);
goto end;
error:
- bt_object_put_ref(ctf_event_class);
+ bt_ctf_object_put_ref(ctf_event_class);
end:
return ctf_event_class;
struct bt_ctf_event_class *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return bt_object_get_ref(bt_ctf_event_class_common_borrow_stream_class(
+ return bt_ctf_object_get_ref(bt_ctf_event_class_common_borrow_stream_class(
BT_CTF_TO_COMMON(event_class)));
}
struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type(
struct bt_ctf_event_class *event_class)
{
- return bt_object_get_ref(bt_ctf_event_class_common_borrow_payload_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_event_class_common_borrow_payload_field_type(
BT_CTF_TO_COMMON(event_class)));
}
struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type(
struct bt_ctf_event_class *event_class)
{
- return bt_object_get_ref(bt_ctf_event_class_common_borrow_context_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_event_class_common_borrow_context_field_type(
BT_CTF_TO_COMMON(event_class)));
}
struct metadata_context *context)
{
int ret = 0;
- struct bt_value *attr_value = NULL;
+ struct bt_ctf_value *attr_value = NULL;
BT_ASSERT(event_class);
BT_ASSERT(context);
end:
context->current_indentation_level = 0;
- BT_OBJECT_PUT_REF_AND_RESET(attr_value);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(attr_value);
return ret;
}
* No need to increment field_type's reference count since getting it
* from the structure already does.
*/
- field_type = bt_object_get_ref(
+ field_type = bt_ctf_object_get_ref(
bt_ctf_field_type_common_structure_borrow_field_type_by_name(
event_class->common.payload_field_type, name));
#include <babeltrace/ctf-writer/trace.h>
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <inttypes.h>
static
struct bt_ctf_field_type_common *event_context_type = NULL;
struct bt_ctf_field_type_common *event_payload_type = NULL;
int trace_valid = 0;
- struct bt_private_value *environment = NULL;
+ struct bt_ctf_private_value *environment = NULL;
stream_class = bt_ctf_event_class_common_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event,
struct bt_ctf_event_class_common *event_class,
struct bt_ctf_clock_class *init_expected_clock_class,
- bool is_shared_with_parent, bt_object_release_func release_func,
+ bool is_shared_with_parent, bt_ctf_object_release_func release_func,
bt_ctf_validation_flag_copy_field_type_func field_type_copy_func,
bool must_be_in_trace,
int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
struct bt_ctf_field_common *event_payload = NULL;
struct bt_ctf_validation_output validation_output = { 0 };
struct bt_ctf_clock_class *expected_clock_class =
- init_expected_clock_class ? bt_object_get_ref(init_expected_clock_class) :
+ init_expected_clock_class ? bt_ctf_object_get_ref(init_expected_clock_class) :
NULL;
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
* destroy it.
*/
if (is_shared_with_parent) {
- bt_object_init_shared_with_parent(&event->base, release_func);
+ bt_ctf_object_init_shared_with_parent(&event->base, release_func);
} else {
- bt_object_init_unique(&event->base);
+ bt_ctf_object_init_unique(&event->base);
}
if (!stream_class->frozen) {
* from that point, the event and its class will share the same
* lifetime.
*/
- event->class = bt_object_get_ref(event_class);
+ event->class = bt_ctf_object_get_ref(event_class);
ret = bt_ctf_event_common_create_fields(stream_class,
&validation_output,
* now because the stream class is frozen.
*/
if (expected_clock_class) {
- BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
+ BT_CTF_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
/*
error:
bt_ctf_validation_output_put_types(&validation_output);
- bt_object_put_ref(expected_clock_class);
+ bt_ctf_object_put_ref(expected_clock_class);
if (event_header) {
release_header_field_func(event_header, stream_class);
void destroy_event_header_field(struct bt_ctf_field_wrapper *field_wrapper)
{
BT_ASSERT(field_wrapper);
- bt_object_put_ref(field_wrapper->field);
+ bt_ctf_object_put_ref(field_wrapper->field);
bt_ctf_field_wrapper_destroy(field_wrapper);
}
goto end;
error:
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (field_wrapper) {
destroy_event_header_field(field_wrapper);
struct bt_ctf_event_common *event_common)
{
BT_ASSERT(field_wrapper);
- BT_OBJECT_PUT_REF_AND_RESET(field_wrapper->field);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(field_wrapper->field);
bt_ctf_field_wrapper_destroy(field_wrapper);
}
static
-void bt_ctf_event_destroy(struct bt_object *obj)
+void bt_ctf_event_destroy(struct bt_ctf_object *obj)
{
- bt_ctf_event_common_finalize(obj, (void *) bt_object_put_ref,
+ bt_ctf_event_common_finalize(obj, (void *) bt_ctf_object_put_ref,
(void *) release_event_header_field);
g_free(obj);
}
bt_ctf_field_type_copy,
false, map_clock_classes_func,
(create_field_func) bt_ctf_field_create,
- (release_field_func) bt_object_put_ref,
+ (release_field_func) bt_ctf_object_put_ref,
(create_header_field_func) create_event_header_field,
(release_header_field_func) destroy_event_header_field);
if (ret) {
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(event);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event);
end:
return event;
struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_object_get_ref(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event)));
+ return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event)));
}
BT_HIDDEN
{
BT_ASSERT(event);
return (struct bt_ctf_stream *)
- bt_object_borrow_parent(&BT_CTF_TO_COMMON(event)->base);
+ bt_ctf_object_borrow_parent(&BT_CTF_TO_COMMON(event)->base);
}
struct bt_ctf_stream *bt_ctf_event_get_stream(struct bt_ctf_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_object_get_ref(bt_ctf_event_borrow_stream(event));
+ return bt_ctf_object_get_ref(bt_ctf_event_borrow_stream(event));
}
int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name,
BT_CTF_FROM_COMMON(event->common.payload_field), name);
} else {
field = BT_CTF_FROM_COMMON(event->common.payload_field);
- bt_object_get_ref(field);
+ bt_ctf_object_get_ref(field);
}
return field;
struct bt_ctf_field *bt_ctf_event_get_payload_field(
struct bt_ctf_event *event)
{
- return bt_object_get_ref(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event)));
+ return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_header(struct bt_ctf_event *event)
{
- return bt_object_get_ref(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event)));
+ return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_context(struct bt_ctf_event *event)
{
- return bt_object_get_ref(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event)));
+ return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
struct bt_ctf_event *event)
{
- return bt_object_get_ref(bt_ctf_event_common_borrow_stream_event_context(
+ return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_stream_event_context(
BT_CTF_TO_COMMON(event)));
}
bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type);
}
- bt_object_put_ref(event->common.header_field->field);
- event->common.header_field->field = bt_object_get_ref(header);
+ bt_ctf_object_put_ref(event->common.header_field->field);
+ event->common.header_field->field = bt_ctf_object_get_ref(header);
BT_LOGV("Set event's header field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"header-field-addr=%p",
event, event->common.class->payload_field_type);
}
- bt_object_put_ref(event->common.payload_field);
- event->common.payload_field = bt_object_get_ref(payload);
+ bt_ctf_object_put_ref(event->common.payload_field);
+ event->common.payload_field = bt_ctf_object_get_ref(payload);
BT_LOGV("Set event's payload field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"payload-field-addr=%p",
event, event->common.class->context_field_type);
}
- bt_object_put_ref(event->common.context_field);
- event->common.context_field = bt_object_get_ref(context);
+ bt_ctf_object_put_ref(event->common.context_field);
+ event->common.context_field = bt_ctf_object_get_ref(context);
BT_LOGV("Set event's context field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"context-field-addr=%p",
bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type);
}
- bt_object_put_ref(event->common.stream_event_context_field);
- event->common.stream_event_context_field = bt_object_get_ref(stream_event_context);
+ bt_ctf_object_put_ref(event->common.stream_event_context_field);
+ event->common.stream_event_context_field = bt_ctf_object_get_ref(stream_event_context);
BT_LOGV("Set event's stream event context field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"stream-event-context-field-addr=%p",
#include <stdint.h>
static
-void field_path_destroy(struct bt_object *obj)
+void field_path_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_field_path *field_path = (struct bt_ctf_field_path *) obj;
goto error;
}
- bt_object_init_shared(&field_path->base, field_path_destroy);
+ bt_ctf_object_init_shared(&field_path->base, field_path_destroy);
field_path->root = BT_CTF_SCOPE_UNKNOWN;
field_path->indexes = g_array_new(TRUE, FALSE, sizeof(int));
if (!field_path->indexes) {
return field_path;
error:
- BT_OBJECT_PUT_REF_AND_RESET(field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(field_path);
return NULL;
}
#include <babeltrace/ctf-writer/utils-internal.h>
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace/ctf-writer/object.h>
#include <float.h>
#include <inttypes.h>
#include <stdlib.h>
BT_HIDDEN
void bt_ctf_field_type_common_initialize(struct bt_ctf_field_type_common *ft,
- bool init_bo, bt_object_release_func release_func,
+ bool init_bo, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
BT_ASSERT(ft && (ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN) &&
(ft->id < BT_CTF_FIELD_TYPE_ID_NR));
- bt_object_init_shared(&ft->base, release_func);
+ bt_ctf_object_init_shared(&ft->base, release_func);
ft->methods = methods;
if (init_bo) {
BT_HIDDEN
void bt_ctf_field_type_common_integer_initialize(
struct bt_ctf_field_type_common *ft,
- unsigned int size, bt_object_release_func release_func,
+ unsigned int size, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft);
BT_HIDDEN
void bt_ctf_field_type_common_floating_point_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_floating_point *flt_ft = BT_CTF_FROM_COMMON(ft);
void bt_ctf_field_type_common_enumeration_initialize(
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *container_ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_enumeration *enum_ft = BT_CTF_FROM_COMMON(ft);
BT_LOGD("Initializing common enumeration field type object: int-ft-addr=%p",
container_ft);
ft->id = BT_CTF_FIELD_TYPE_ID_ENUM;
- enum_ft->container_ft = bt_object_get_ref(container_ft);
+ enum_ft->container_ft = bt_ctf_object_get_ref(container_ft);
enum_ft->entries = g_ptr_array_new_with_free_func(
(GDestroyNotify) destroy_enumeration_mapping);
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_HIDDEN
void bt_ctf_field_type_common_string_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_string *string_ft = BT_CTF_FROM_COMMON(ft);
BT_HIDDEN
void bt_ctf_field_type_common_structure_initialize(
struct bt_ctf_field_type_common *ft,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_structure *struct_ft = BT_CTF_FROM_COMMON(ft);
void bt_ctf_field_type_common_array_initialize(
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *element_ft,
- unsigned int length, bt_object_release_func release_func,
+ unsigned int length, bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_array *array_ft = BT_CTF_FROM_COMMON(ft);
BT_LOGD("Initializing common array field type object: element-ft-addr=%p, "
"length=%u", element_ft, length);
ft->id = BT_CTF_FIELD_TYPE_ID_ARRAY;
- array_ft->element_ft = bt_object_get_ref(element_ft);
+ array_ft->element_ft = bt_ctf_object_get_ref(element_ft);
array_ft->length = length;
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_LOGD("Initialized common array field type object: addr=%p, "
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *element_ft,
const char *length_field_name,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_sequence *seq_ft = BT_CTF_FROM_COMMON(ft);
BT_LOGD("Initializing common sequence field type object: element-ft-addr=%p, "
"length-field-name=\"%s\"", element_ft, length_field_name);
ft->id = BT_CTF_FIELD_TYPE_ID_SEQUENCE;
- seq_ft->element_ft = bt_object_get_ref(element_ft);
+ seq_ft->element_ft = bt_ctf_object_get_ref(element_ft);
seq_ft->length_field_name = g_string_new(length_field_name);
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_LOGD("Initialized common sequence field type object: addr=%p, "
struct bt_ctf_field_type_common *ft,
struct bt_ctf_field_type_common *tag_ft,
const char *tag_name,
- bt_object_release_func release_func,
+ bt_ctf_object_release_func release_func,
struct bt_ctf_field_type_common_methods *methods)
{
struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft);
sizeof(struct bt_ctf_field_type_common_variant_choice));
if (tag_ft) {
- var_ft->tag_ft = bt_object_get_ref(tag_ft);
+ var_ft->tag_ft = bt_ctf_object_get_ref(tag_ft);
}
bt_ctf_field_type_common_initialize(ft, true, release_func, methods);
}
BT_HIDDEN
-void bt_ctf_field_type_common_integer_destroy(struct bt_object *obj)
+void bt_ctf_field_type_common_integer_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_integer *ft = (void *) obj;
BT_LOGD("Destroying integer field type object: addr=%p", ft);
BT_LOGD_STR("Putting mapped clock class.");
- bt_object_put_ref(ft->mapped_clock_class);
+ bt_ctf_object_put_ref(ft->mapped_clock_class);
g_free(ft);
}
BT_HIDDEN
-void bt_ctf_field_type_common_floating_point_destroy(struct bt_object *obj)
+void bt_ctf_field_type_common_floating_point_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_floating_point *ft = (void *) obj;
}
BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_object *obj)
+void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_enumeration *ft = (void *) obj;
BT_LOGD("Destroying enumeration field type object: addr=%p", ft);
g_ptr_array_free(ft->entries, TRUE);
BT_LOGD_STR("Putting container field type.");
- bt_object_put_ref(ft->container_ft);
+ bt_ctf_object_put_ref(ft->container_ft);
g_free(ft);
}
BT_HIDDEN
-void bt_ctf_field_type_common_string_destroy(struct bt_object *obj)
+void bt_ctf_field_type_common_string_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_string *ft = (void *) obj;
"addr=%p, field-ft-addr=%p, field-name=\"%s\"",
field, field->type, g_quark_to_string(field->name));
BT_LOGD_STR("Putting field type.");
- bt_object_put_ref(field->type);
+ bt_ctf_object_put_ref(field->type);
}
BT_HIDDEN
-void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_object *obj)
+void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_structure *ft = (void *) obj;
uint64_t i;
}
BT_HIDDEN
-void bt_ctf_field_type_common_array_destroy_recursive(struct bt_object *obj)
+void bt_ctf_field_type_common_array_destroy_recursive(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_array *ft = (void *) obj;
BT_LOGD("Destroying array field type object: addr=%p", ft);
BT_LOGD_STR("Putting element field type.");
- bt_object_put_ref(ft->element_ft);
+ bt_ctf_object_put_ref(ft->element_ft);
g_free(ft);
}
BT_HIDDEN
-void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_object *obj)
+void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_sequence *ft = (void *) obj;
BT_LOGD("Destroying sequence field type object: addr=%p", ft);
BT_LOGD_STR("Putting element field type.");
- bt_object_put_ref(ft->element_ft);
+ bt_ctf_object_put_ref(ft->element_ft);
g_string_free(ft->length_field_name, TRUE);
BT_LOGD_STR("Putting length field path.");
- bt_object_put_ref(ft->length_field_path);
+ bt_ctf_object_put_ref(ft->length_field_path);
g_free(ft);
}
"addr=%p, field-ft-addr=%p, field-name=\"%s\"",
choice, choice->type, g_quark_to_string(choice->name));
BT_LOGD_STR("Putting field type.");
- bt_object_put_ref(choice->type);
+ bt_ctf_object_put_ref(choice->type);
if (choice->ranges) {
g_array_free(choice->ranges, TRUE);
}
BT_HIDDEN
-void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_object *obj)
+void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_common_variant *ft = (void *) obj;
uint64_t i;
}
BT_LOGD_STR("Putting tag field type.");
- bt_object_put_ref(ft->tag_ft);
+ bt_ctf_object_put_ref(ft->tag_ft);
BT_LOGD_STR("Putting tag field path.");
- bt_object_put_ref(ft->tag_field_path);
+ bt_ctf_object_put_ref(ft->tag_field_path);
g_free(ft);
}
}
*member_name = name_quark;
- *member_ft = bt_object_get_ref(field_type);
+ *member_ft = bt_ctf_object_get_ref(field_type);
g_hash_table_insert(field_name_to_index,
GUINT_TO_POINTER(name_quark),
GUINT_TO_POINTER(members->len - 1));
}
static
-void bt_ctf_field_type_enum_iter_destroy(struct bt_object *obj)
+void bt_ctf_field_type_enum_iter_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_field_type_enumeration_mapping_iterator *iter =
container_of(obj,
BT_LOGD("Destroying enumeration field type mapping iterator: addr=%p",
obj);
BT_LOGD_STR("Putting parent enumeration field type.");
- bt_object_put_ref(iter->enumeration_ft);
+ bt_ctf_object_put_ref(iter->enumeration_ft);
g_free(iter);
}
goto end;
}
- bt_object_init_shared(&iter->base, bt_ctf_field_type_enum_iter_destroy);
- iter->enumeration_ft = bt_object_get_ref(ft);
+ bt_ctf_object_init_shared(&iter->base, bt_ctf_field_type_enum_iter_destroy);
+ iter->enumeration_ft = bt_ctf_object_get_ref(ft);
iter->index = -1;
iter->type = iterator_type;
return iter;
error:
- bt_object_put_ref(iter);
+ bt_ctf_object_put_ref(iter);
return NULL;
}
return iter;
error:
- bt_object_put_ref(iter);
+ bt_ctf_object_put_ref(iter);
return NULL;
}
return iter;
error:
- bt_object_put_ref(iter);
+ bt_ctf_object_put_ref(iter);
return NULL;
}
goto end;
}
- bt_object_put_ref(int_ft->mapped_clock_class);
- int_ft->mapped_clock_class = bt_object_get_ref(clock_class);
+ bt_ctf_object_put_ref(int_ft->mapped_clock_class);
+ int_ft->mapped_clock_class = bt_ctf_object_get_ref(clock_class);
BT_LOGV("Set integer field type's mapped clock class: ft-addr=%p, "
"clock-class-addr=%p, clock-class-name=\"%s\"",
ft, clock_class, bt_ctf_clock_class_get_name(clock_class));
BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i);
if (field->name == name_quark) {
- bt_object_put_ref(field->type);
- field->type = bt_object_get_ref(field_type);
+ bt_ctf_object_put_ref(field->type);
+ field->type = bt_ctf_object_get_ref(field_type);
}
}
}
if (array_ft->element_ft) {
- BT_OBJECT_PUT_REF_AND_RESET(array_ft->element_ft);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(array_ft->element_ft);
}
- array_ft->element_ft = bt_object_get_ref(element_ft);
+ array_ft->element_ft = bt_ctf_object_get_ref(element_ft);
BT_LOGV("Set array field type's element field type: array-ft-addr=%p, "
"element-ft-addr=%p", ft, element_ft);
}
if (seq_ft->element_ft) {
- BT_OBJECT_PUT_REF_AND_RESET(seq_ft->element_ft);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(seq_ft->element_ft);
}
seq_ft->element_ft = element_ft;
- bt_object_get_ref(seq_ft->element_ft);
+ bt_ctf_object_get_ref(seq_ft->element_ft);
BT_LOGV("Set sequence field type's element field type: sequence-ft-addr=%p, "
"element-ft-addr=%p", ft, element_ft);
goto end;
}
- bt_object_get_ref(path);
- BT_OBJECT_MOVE_REF(seq_ft->length_field_path, path);
+ bt_ctf_object_get_ref(path);
+ BT_CTF_OBJECT_MOVE_REF(seq_ft->length_field_path, path);
BT_LOGV("Set sequence field type's length field path: ft-addr=%p, "
"field-path-addr=%p", ft, path);
goto end;
}
- bt_object_get_ref(path);
- BT_OBJECT_MOVE_REF(var_ft->tag_field_path, path);
+ bt_ctf_object_get_ref(path);
+ BT_CTF_OBJECT_MOVE_REF(var_ft->tag_field_path, path);
BT_LOGV("Set variant field type's tag field path: ft-addr=%p, "
"field-path-addr=%p", ft, path);
goto end;
}
- bt_object_put_ref(var_ft->tag_ft);
- var_ft->tag_ft = bt_object_get_ref(tag_ft);
+ bt_ctf_object_put_ref(var_ft->tag_ft);
+ var_ft->tag_ft = bt_ctf_object_get_ref(tag_ft);
BT_LOGV("Set variant field type's tag field type: variant-ft-addr=%p, "
"tag-ft-addr=%p", ft, tag_ft);
g_array_append_val(choice->ranges, range);
}
- bt_object_put_ref(iter);
+ bt_ctf_object_put_ref(iter);
}
var_ft->choices_up_to_date = true;
if (!*expected_clock_class) {
/* Move reference to output parameter */
- *expected_clock_class = bt_object_get_ref(mapped_clock_class);
+ *expected_clock_class = bt_ctf_object_get_ref(mapped_clock_class);
mapped_clock_class = NULL;
BT_LOGV("Setting expected clock class: "
"expected-clock-class-addr=%p",
bt_ctf_clock_class_get_name(mapped_clock_class),
*expected_clock_class,
bt_ctf_clock_class_get_name(*expected_clock_class));
- bt_object_put_ref(mapped_clock_class);
+ bt_ctf_object_put_ref(mapped_clock_class);
ret = -1;
goto end;
}
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(integer);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(integer);
end:
return (void *) integer;
struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
struct bt_ctf_field_type *ft)
{
- return bt_object_get_ref(bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
(void *) ft));
}
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(enumeration);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(enumeration);
end:
return (void *) enumeration;
struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_field_type_common_enumeration_borrow_container_field_type(
(void *) ft));
}
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(structure);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(structure);
end:
return (void *) structure;
(void *) ft, field_name, (void *) field_type, index);
if (ret == 0 && field_type) {
- bt_object_get_ref(*field_type);
+ bt_ctf_object_get_ref(*field_type);
}
return ret;
struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
struct bt_ctf_field_type *ft, const char *name)
{
- return bt_object_get_ref(bt_ctf_field_type_common_structure_borrow_field_type_by_name(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_structure_borrow_field_type_by_name(
(void *) ft, name));
}
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(var_ft);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(var_ft);
end:
return (void *) var_ft;
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_tag_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_variant_borrow_tag_field_type(
(void *) ft));
}
struct bt_ctf_field_type *ft,
const char *field_name)
{
- return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_field_type_by_name(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_variant_borrow_field_type_by_name(
(void *) ft, field_name));
}
(void *) ft, field_name, (void *) field_type, index);
if (ret == 0 && field_type) {
- bt_object_get_ref(*field_type);
+ bt_ctf_object_get_ref(*field_type);
}
return ret;
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(array);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(array);
end:
return (void *) array;
struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_object_get_ref(bt_ctf_field_type_common_array_borrow_element_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_array_borrow_element_field_type(
(void *) ft));
}
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(sequence);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(sequence);
end:
return (void *) sequence;
struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_object_get_ref(bt_ctf_field_type_common_sequence_borrow_element_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_field_type_common_sequence_borrow_element_field_type(
(void *) ft));
}
goto end;
}
- copy_ft->mapped_clock_class = bt_object_get_ref(int_ft->mapped_clock_class);
+ copy_ft->mapped_clock_class = bt_ctf_object_get_ref(int_ft->mapped_clock_class);
copy_ft->user_byte_order = int_ft->user_byte_order;
copy_ft->is_signed = int_ft->is_signed;
copy_ft->size = int_ft->size;
ft, copy_ft);
end:
- bt_object_put_ref(container_copy_ft);
+ bt_ctf_object_put_ref(container_copy_ft);
return (void *) copy_ft;
error:
- bt_object_put_ref(container_copy_ft);
- BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
+ bt_ctf_object_put_ref(container_copy_ft);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_ft);
return (void *) copy_ft;
}
return (void *) copy_ft;
error:
- BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
ft, copy_ft);
end:
- bt_object_put_ref(tag_ft_copy);
+ bt_ctf_object_put_ref(tag_ft_copy);
return (void *) copy_ft;
error:
- bt_object_put_ref(tag_ft_copy);
- BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
+ bt_ctf_object_put_ref(tag_ft_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
ft, copy_ft);
end:
- bt_object_put_ref(container_ft_copy);
+ bt_ctf_object_put_ref(container_ft_copy);
return (void *) copy_ft;
}
ft, copy_ft);
end:
- bt_object_put_ref(container_ft_copy);
+ bt_ctf_object_put_ref(container_ft_copy);
return (void *) copy_ft;
error:
- bt_object_put_ref(container_ft_copy);
- BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
+ bt_ctf_object_put_ref(container_ft_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
#include <babeltrace/ctf-writer/field-wrapper-internal.h>
#include <babeltrace/ctf-writer/fields-internal.h>
#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-writer/object-internal.h>
#include <glib.h>
BT_HIDDEN
goto end;
}
- bt_object_init_unique(&field_wrapper->base);
+ bt_ctf_object_init_unique(&field_wrapper->base);
BT_LOGD("Created empty field wrapper object: addr=%p",
field_wrapper);
BT_HIDDEN
struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
- struct bt_object_pool *pool, struct bt_ctf_field_type *ft)
+ struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft)
{
struct bt_ctf_field_wrapper *field_wrapper = NULL;
BT_ASSERT(pool);
BT_ASSERT(ft);
- field_wrapper = bt_object_pool_create_object(pool);
+ field_wrapper = bt_ctf_object_pool_create_object(pool);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one field wrapper from field wrapper pool: "
"%![pool-]+o", pool);
#include <babeltrace/ctf-writer/fields-internal.h>
#include <babeltrace/ctf-writer/serialize-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace/ctf-writer/object.h>
#include <float.h>
#include <inttypes.h>
#include <inttypes.h>
BT_HIDDEN
int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func)
BT_HIDDEN
int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func)
BT_HIDDEN
int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods)
{
int ret = 0;
BT_HIDDEN
int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_destroy_func)
BT_HIDDEN
int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
GDestroyNotify field_destroy_func)
{
BT_LOGD("Destroying CTF writer enumeration field object: addr=%p",
field);
BT_LOGD_STR("Putting container field.");
- bt_object_put_ref(enumeration->container);
+ bt_ctf_object_put_ref(enumeration->container);
bt_ctf_field_common_finalize((void *) field);
g_free(field);
}
BT_LOGD("Destroying CTF writer variant field object: addr=%p", field);
BT_LOGD_STR("Putting tag field.");
- bt_object_put_ref(variant->tag);
+ bt_ctf_object_put_ref(variant->tag);
bt_ctf_field_common_variant_finalize_recursive((void *) field);
g_free(field);
}
}
end:
- bt_object_put_ref(character);
- bt_object_put_ref(character_type);
+ bt_ctf_object_put_ref(character);
+ bt_ctf_object_put_ref(character_type);
return ret;
}
struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field)
{
- return bt_object_get_ref(bt_ctf_field_common_borrow_type((void *) field));
+ return bt_ctf_object_get_ref(bt_ctf_field_common_borrow_type((void *) field));
}
enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field)
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index(
(void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
struct bt_ctf_field *field, const char *name)
{
- return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name(
(void *) field, name));
}
struct bt_ctf_field *bt_ctf_field_array_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_field_common_array_borrow_field((void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_sequence_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_field_common_sequence_borrow_field((void *) field, index));
}
goto end;
}
- bt_object_put_ref(variant_field->tag);
- variant_field->tag = bt_object_get_ref(tag_field);
+ bt_ctf_object_put_ref(variant_field->tag);
+ variant_field->tag = bt_ctf_object_get_ref(tag_field);
current_field = bt_ctf_field_variant_get_current_field(field);
BT_ASSERT(current_field);
struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
struct bt_ctf_field *variant_field)
{
- return bt_object_get_ref(bt_ctf_field_common_variant_borrow_current_field(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_variant_borrow_current_field(
(void *) variant_field));
}
struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
struct bt_ctf_field *field)
{
- return bt_object_get_ref(bt_ctf_field_enumeration_borrow_container(field));
+ return bt_ctf_object_get_ref(bt_ctf_field_enumeration_borrow_container(field));
}
int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field,
if (integer) {
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(integer), (void *) type,
true,
- (bt_object_release_func) bt_ctf_field_integer_destroy,
+ (bt_ctf_object_release_func) bt_ctf_field_integer_destroy,
&bt_ctf_field_integer_methods);
integer->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_integer_serialize;
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(enumeration),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_enumeration_destroy_recursive,
&bt_ctf_field_enumeration_methods);
enumeration->container = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(enum_ft->container_ft));
if (!enumeration->container) {
- BT_OBJECT_PUT_REF_AND_RESET(enumeration);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(enumeration);
goto end;
}
if (floating_point) {
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(floating_point),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_floating_point_destroy,
&bt_ctf_field_floating_point_methods);
floating_point->common.spec.writer.serialize_func =
iret = bt_ctf_field_common_structure_initialize(BT_CTF_TO_COMMON(structure),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_structure_destroy_recursive,
&bt_ctf_field_structure_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_object_put_ref);
+ (GDestroyNotify) bt_ctf_object_put_ref);
structure->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_structure_serialize_recursive;
if (iret) {
- BT_OBJECT_PUT_REF_AND_RESET(structure);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(structure);
goto end;
}
bt_ctf_field_common_variant_initialize(BT_CTF_TO_COMMON(BT_CTF_TO_COMMON(variant)),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_variant_destroy_recursive,
&bt_ctf_field_variant_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_object_put_ref);
+ (GDestroyNotify) bt_ctf_object_put_ref);
variant->tag = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(var_ft->tag_ft));
variant->common.common.spec.writer.serialize_func =
ret = bt_ctf_field_common_array_initialize(BT_CTF_TO_COMMON(array),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_array_destroy_recursive,
&bt_ctf_field_array_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_object_put_ref);
+ (GDestroyNotify) bt_ctf_object_put_ref);
array->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_array_serialize_recursive;
if (ret) {
- BT_OBJECT_PUT_REF_AND_RESET(array);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(array);
goto end;
}
if (sequence) {
bt_ctf_field_common_sequence_initialize(BT_CTF_TO_COMMON(sequence),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_sequence_destroy_recursive,
&bt_ctf_field_sequence_methods,
- (GDestroyNotify) bt_object_put_ref);
+ (GDestroyNotify) bt_ctf_object_put_ref);
sequence->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_sequence_serialize_recursive;
BT_LOGD("Created CTF writer sequence field object: addr=%p, ft-addr=%p",
if (string) {
bt_ctf_field_common_string_initialize(BT_CTF_TO_COMMON(string),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_string_destroy,
&bt_ctf_field_string_methods);
string->common.spec.writer.serialize_func =
ret = -1;
goto end;
}
- bt_object_get_ref(value);
- BT_OBJECT_MOVE_REF(structure->fields->pdata[index], value);
+ bt_ctf_object_get_ref(value);
+ BT_CTF_OBJECT_MOVE_REF(structure->fields->pdata[index], value);
end:
return ret;
--- /dev/null
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 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.
+ */
+
+#define BT_LOG_TAG "OBJECT-POOL"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <stdint.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/ctf-writer/object-pool-internal.h>
+
+int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool,
+ bt_ctf_object_pool_new_object_func new_object_func,
+ bt_ctf_object_pool_destroy_object_func destroy_object_func,
+ void *data)
+{
+ int ret = 0;
+
+ BT_ASSERT(new_object_func);
+ BT_ASSERT(destroy_object_func);
+ BT_LOGD("Initializing object pool: addr=%p, data-addr=%p",
+ pool, data);
+ pool->objects = g_ptr_array_new();
+ if (!pool->objects) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ pool->funcs.new_object = new_object_func;
+ pool->funcs.destroy_object = destroy_object_func;
+ pool->data = data;
+ pool->size = 0;
+ BT_LIB_LOGD("Initialized object pool: %!+o", pool);
+ goto end;
+
+error:
+ if (pool) {
+ bt_ctf_object_pool_finalize(pool);
+ }
+
+ ret = -1;
+
+end:
+ return ret;
+}
+
+void bt_ctf_object_pool_finalize(struct bt_ctf_object_pool *pool)
+{
+ uint64_t i;
+
+ BT_ASSERT(pool);
+ BT_LIB_LOGD("Finalizing object pool: %!+o", pool);
+
+ if (pool->objects) {
+ for (i = 0; i < pool->size; i++) {
+ void *obj = pool->objects->pdata[i];
+
+ if (obj) {
+ pool->funcs.destroy_object(obj, pool->data);
+ }
+ }
+
+ g_ptr_array_free(pool->objects, TRUE);
+ pool->objects = NULL;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#include <babeltrace/ctf-writer/object-internal.h>
+
+void *bt_ctf_object_get_ref(void *obj)
+{
+ if (unlikely(!obj)) {
+ goto end;
+ }
+
+ bt_ctf_object_get_no_null_check(obj);
+
+end:
+ return obj;
+}
+
+void bt_ctf_object_put_ref(void *obj)
+{
+ if (unlikely(!obj)) {
+ return;
+ }
+
+ bt_ctf_object_put_no_null_check(obj);
+}
#include <babeltrace/ctf-writer/resolve-internal.h>
#include <babeltrace/ctf-writer/stream-class.h>
#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/types.h>
-#include <babeltrace/values.h>
+#include <babeltrace/ctf-writer/values-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <limits.h>
* * Event payload
*/
struct resolve_context {
- struct bt_private_value *environment;
+ struct bt_ctf_private_value *environment;
struct bt_ctf_field_type_common *scopes[6];
/* Root scope being visited */
{
struct type_stack_frame *frame = data;
- BT_OBJECT_PUT_REF_AND_RESET(frame->type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(frame->type);
g_free(frame);
}
BT_LOGV("Pushing field type on context's stack: "
"ft-addr=%p, stack-size-before=%u", type, stack->len);
- frame->type = bt_object_get_ref(type);
+ frame->type = bt_ctf_object_get_ref(type);
g_ptr_array_add(stack, frame);
end:
bt_bool first_level_done = BT_FALSE;
/* Get our own reference */
- bt_object_get_ref(type);
+ bt_ctf_object_get_ref(type);
/* Locate target */
while (cur_ptoken) {
}
/* Move child type to current type */
- bt_object_get_ref(child_type);
- BT_OBJECT_MOVE_REF(type, child_type);
+ bt_ctf_object_get_ref(child_type);
+ BT_CTF_OBJECT_MOVE_REF(type, child_type);
}
end:
- bt_object_put_ref(type);
+ bt_ctf_object_put_ref(type);
return ret;
}
}
end:
- BT_OBJECT_PUT_REF_AND_RESET(tail_field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(tail_field_path);
return ret;
}
end:
if (ret) {
- BT_OBJECT_PUT_REF_AND_RESET(field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(field_path);
}
ptokens_destroy(ptokens);
/* Start with root type */
type = get_type_from_ctx(ctx, field_path->root);
- bt_object_get_ref(type);
+ bt_ctf_object_get_ref(type);
if (!type) {
/* Error: root type is not available */
BT_LOGW("Root field type is not available: root-scope=%s",
}
/* Move child type to current type */
- bt_object_get_ref(child_type);
- BT_OBJECT_MOVE_REF(type, child_type);
+ bt_ctf_object_get_ref(child_type);
+ BT_CTF_OBJECT_MOVE_REF(type, child_type);
}
return type;
error:
- BT_OBJECT_PUT_REF_AND_RESET(type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(type);
return type;
}
return field_path;
error:
- BT_OBJECT_PUT_REF_AND_RESET(field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(field_path);
return field_path;
}
}
end:
- BT_OBJECT_PUT_REF_AND_RESET(ctx_field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(ctx_field_path);
return ret;
}
g_string_free(target_field_path_pretty, TRUE);
}
- BT_OBJECT_PUT_REF_AND_RESET(target_field_path);
- BT_OBJECT_PUT_REF_AND_RESET(target_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(target_field_path);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(target_type);
return ret;
}
BT_HIDDEN
int bt_ctf_resolve_types(
- struct bt_private_value *environment,
+ struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
#include <babeltrace/ctf-writer/visitor-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
BT_HIDDEN
int bt_ctf_stream_class_common_initialize(struct bt_ctf_stream_class_common *stream_class,
- const char *name, bt_object_release_func release_func)
+ const char *name, bt_ctf_object_release_func release_func)
{
BT_LOGD("Initializing common stream class object: name=\"%s\"", name);
- bt_object_init_shared_with_parent(&stream_class->base, release_func);
+ bt_ctf_object_init_shared_with_parent(&stream_class->base, release_func);
stream_class->name = g_string_new(name);
stream_class->event_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_try_spec_release);
+ (GDestroyNotify) bt_ctf_object_try_spec_release);
if (!stream_class->event_classes) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
goto error;
BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64,
stream_class, bt_ctf_stream_class_common_get_name(stream_class),
bt_ctf_stream_class_common_get_id(stream_class));
- bt_object_put_ref(stream_class->clock_class);
+ bt_ctf_object_put_ref(stream_class->clock_class);
if (stream_class->event_classes_ht) {
g_hash_table_destroy(stream_class->event_classes_ht);
}
BT_LOGD_STR("Putting event header field type.");
- bt_object_put_ref(stream_class->event_header_field_type);
+ bt_ctf_object_put_ref(stream_class->event_header_field_type);
BT_LOGD_STR("Putting packet context field type.");
- bt_object_put_ref(stream_class->packet_context_field_type);
+ bt_ctf_object_put_ref(stream_class->packet_context_field_type);
BT_LOGD_STR("Putting event context field type.");
- bt_object_put_ref(stream_class->event_context_field_type);
+ bt_ctf_object_put_ref(stream_class->event_context_field_type);
}
static
* context) could change before the next call to one of
* those two functions.
*/
- expected_clock_class = bt_object_get_ref(stream_class->clock_class);
+ expected_clock_class = bt_ctf_object_get_ref(stream_class->clock_class);
/*
* At this point, `expected_clock_class` can be NULL,
*event_id = stream_class->next_event_id;
}
- bt_object_set_parent(&event_class->base, &stream_class->base);
+ bt_ctf_object_set_parent(&event_class->base, &stream_class->base);
if (trace) {
/*
if (stream_class->frozen && expected_clock_class) {
BT_ASSERT(!stream_class->clock_class ||
stream_class->clock_class == expected_clock_class);
- BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
+ BT_CTF_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
BT_LOGD("Added event class to stream class: "
end:
bt_ctf_validation_output_put_types(&validation_output);
- bt_object_put_ref(expected_clock_class);
+ bt_ctf_object_put_ref(expected_clock_class);
g_free(event_id);
return ret;
}
goto end;
}
- bt_object_put_ref(stream_class->common.event_header_field_type);
+ bt_ctf_object_put_ref(stream_class->common.event_header_field_type);
stream_class->common.event_header_field_type =
(void *) event_header_type;
event_header_type = NULL;
end:
if (ret) {
- bt_object_put_ref(event_header_type);
+ bt_ctf_object_put_ref(event_header_type);
}
- bt_object_put_ref(_uint32_t);
- bt_object_put_ref(_uint64_t);
+ bt_ctf_object_put_ref(_uint32_t);
+ bt_ctf_object_put_ref(_uint64_t);
return ret;
}
goto end;
}
- bt_object_put_ref(stream_class->common.packet_context_field_type);
+ bt_ctf_object_put_ref(stream_class->common.packet_context_field_type);
stream_class->common.packet_context_field_type =
(void *) packet_context_type;
packet_context_type = NULL;
end:
if (ret) {
- bt_object_put_ref(packet_context_type);
+ bt_ctf_object_put_ref(packet_context_type);
goto end;
}
- bt_object_put_ref(_uint64_t);
- bt_object_put_ref(ts_begin_end_uint64_t);
+ bt_ctf_object_put_ref(_uint64_t);
+ bt_ctf_object_put_ref(ts_begin_end_uint64_t);
return ret;
}
static
-void bt_ctf_stream_class_destroy(struct bt_object *obj)
+void bt_ctf_stream_class_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_stream_class *stream_class;
stream_class, bt_ctf_stream_class_get_name(stream_class),
bt_ctf_stream_class_get_id(stream_class));
bt_ctf_stream_class_common_finalize(BT_CTF_TO_COMMON(stream_class));
- bt_object_put_ref(stream_class->clock);
+ bt_ctf_object_put_ref(stream_class->clock);
g_free(stream_class);
}
return stream_class;
error:
- BT_OBJECT_PUT_REF_AND_RESET(stream_class);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(stream_class);
return stream_class;
}
ret = bt_ctf_field_type_common_structure_replace_field(
(void *) parent_ft, field_name, (void *) ft_copy);
- bt_object_put_ref(ft_copy);
+ bt_ctf_object_put_ref(ft_copy);
BT_LOGV("Automatically mapped field type to stream class's clock class: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64 ", ft-addr=%p, "
}
end:
- bt_object_put_ref(ft);
- bt_object_put_ref(mapped_clock_class);
+ bt_ctf_object_put_ref(ft);
+ bt_ctf_object_put_ref(mapped_clock_class);
return ret;
}
goto end;
}
- clock = bt_object_get_ref(stream_class->clock);
+ clock = bt_ctf_object_get_ref(stream_class->clock);
end:
return clock;
}
/* Replace the current clock of this stream class. */
- bt_object_put_ref(stream_class->clock);
- stream_class->clock = bt_object_get_ref(clock);
+ bt_ctf_object_put_ref(stream_class->clock);
+ stream_class->clock = bt_ctf_object_get_ref(clock);
BT_LOGV("Set stream class's clock: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"clock-addr=%p, clock-name=\"%s\"",
"\tid = %" PRId64 ";\n",
stream_class->common.id);
}
- bt_object_put_ref(stream_id_type);
+ bt_ctf_object_put_ref(stream_id_type);
}
if (stream_class->common.event_header_field_type) {
BT_LOGD_STR("Serializing stream class's event header field type's metadata.");
}
end:
- bt_object_put_ref(packet_header_type);
+ bt_ctf_object_put_ref(packet_header_type);
context->current_indentation_level = 0;
return ret;
}
struct bt_ctf_trace *bt_ctf_stream_class_get_trace(
struct bt_ctf_stream_class *stream_class)
{
- return bt_object_get_ref(bt_ctf_stream_class_common_borrow_trace(
+ return bt_ctf_object_get_ref(bt_ctf_stream_class_common_borrow_trace(
BT_CTF_TO_COMMON(stream_class)));
}
struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_stream_class_common_borrow_packet_context_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_header_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_stream_class_common_borrow_event_header_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_stream_class_common_borrow_event_context_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
struct bt_ctf_stream_class *stream_class, uint64_t index)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_stream_class_common_borrow_event_class_by_index(
BT_CTF_TO_COMMON(stream_class), index));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
struct bt_ctf_stream_class *stream_class, uint64_t id)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_stream_class_common_borrow_event_class_by_id(
BT_CTF_TO_COMMON(stream_class), id));
}
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/trace.h>
#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <inttypes.h>
#include <stdint.h>
#include <unistd.h>
int bt_ctf_stream_common_initialize(
struct bt_ctf_stream_common *stream,
struct bt_ctf_stream_class_common *stream_class, const char *name,
- uint64_t id, bt_object_release_func release_func)
+ uint64_t id, bt_ctf_object_release_func release_func)
{
int ret = 0;
struct bt_ctf_trace_common *trace = NULL;
- bt_object_init_shared_with_parent(&stream->base, release_func);
+ bt_ctf_object_init_shared_with_parent(&stream->base, release_func);
if (!stream_class) {
BT_LOGW_STR("Invalid parameter: stream class is NULL.");
* Acquire reference to parent since stream will become publicly
* reachable; it needs its parent to remain valid.
*/
- bt_object_set_parent(&stream->base, &trace->base);
+ bt_ctf_object_set_parent(&stream->base, &trace->base);
stream->stream_class = stream_class;
stream->id = (int64_t) id;
}
static
-void bt_ctf_stream_destroy(struct bt_object *obj);
+void bt_ctf_stream_destroy(struct bt_ctf_object *obj);
static
int try_set_structure_field_integer(struct bt_ctf_field *, char *, uint64_t);
}
}
end:
- bt_object_put_ref(field_type);
+ bt_ctf_object_put_ref(field_type);
return ret;
}
magic_field, (uint64_t) magic_value);
}
end:
- bt_object_put_ref(magic_field);
+ bt_ctf_object_put_ref(magic_field);
return ret;
}
}
trace = (struct bt_ctf_trace *)
- bt_object_get_parent(&stream->common.base);
+ bt_ctf_object_get_parent(&stream->common.base);
for (i = 0; i < 16; i++) {
struct bt_ctf_field *uuid_element =
ret = bt_ctf_field_integer_unsigned_set_value(
uuid_element, (uint64_t) trace->common.uuid[i]);
- bt_object_put_ref(uuid_element);
+ bt_ctf_object_put_ref(uuid_element);
if (ret) {
BT_LOGW("Cannot set integer field's value (for `uuid` packet header field): "
"stream-addr=%p, stream-name=\"%s\", field-addr=%p, "
stream, bt_ctf_stream_get_name(stream), uuid_field);
end:
- bt_object_put_ref(uuid_field);
- BT_OBJECT_PUT_REF_AND_RESET(trace);
+ bt_ctf_object_put_ref(uuid_field);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(trace);
return ret;
}
static
}
end:
- bt_object_put_ref(stream_id_field);
+ bt_ctf_object_put_ref(stream_id_field);
return ret;
}
}
end:
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
return ret;
}
}
end:
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
return ret;
}
}
end:
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
return ret;
}
goto end;
}
- bt_object_put_ref(cc);
+ bt_ctf_object_put_ref(cc);
val_size = bt_ctf_field_type_integer_get_size(
(void *) field_common->type);
BT_ASSERT(val_size >= 1);
BT_ASSERT(int_field);
ret = visit_field_update_clock_value(int_field, val);
- bt_object_put_ref(int_field);
+ bt_ctf_object_put_ref(int_field);
break;
}
case BT_CTF_FIELD_TYPE_ID_ARRAY:
BT_ASSERT(elem_field);
ret = visit_field_update_clock_value(elem_field, val);
- bt_object_put_ref(elem_field);
+ bt_ctf_object_put_ref(elem_field);
if (ret) {
goto end;
}
BT_ASSERT(elem_field);
ret = visit_field_update_clock_value(elem_field, val);
- bt_object_put_ref(elem_field);
+ bt_ctf_object_put_ref(elem_field);
if (ret) {
goto end;
}
BT_ASSERT(member_field);
ret = visit_field_update_clock_value(member_field, val);
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
if (ret) {
goto end;
}
}
ret = visit_field_update_clock_value(cur_field, val);
- bt_object_put_ref(cur_field);
+ bt_ctf_object_put_ref(cur_field);
break;
}
default:
field = bt_ctf_event_get_header(event);
ret = visit_field_update_clock_value(field, val);
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's header.");
field = bt_ctf_event_get_stream_event_context(event);
ret = visit_field_update_clock_value(field, val);
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's stream event context.");
field = bt_ctf_event_get_context(event);
ret = visit_field_update_clock_value(field, val);
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's context.");
field = bt_ctf_event_get_payload_field(event);
ret = visit_field_update_clock_value(field, val);
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's payload.");
if (strcmp(member_name, "packet_size") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "content_size") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "events_discarded") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "packet_seq_num") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
continue;
}
ret = visit_field_update_clock_value(member_field,
&cur_clock_value);
- bt_object_put_ref(member_field);
+ bt_ctf_object_put_ref(member_field);
if (ret) {
BT_LOGW("Cannot automatically update clock value "
"in stream's packet context: "
}
end:
- bt_object_put_ref(ts_begin_field);
- bt_object_put_ref(ts_end_field);
+ bt_ctf_object_put_ref(ts_begin_field);
+ bt_ctf_object_put_ref(ts_end_field);
return ret;
}
static
void release_event(struct bt_ctf_event *event)
{
- if (bt_object_get_ref_count(&event->common.base)) {
+ if (bt_ctf_object_get_ref_count(&event->common.base)) {
/*
* The event is being orphaned, but it must guarantee the
* existence of its event class for the duration of its
* lifetime.
*/
- bt_object_get_ref(event->common.class);
- BT_OBJECT_PUT_REF_AND_RESET(event->common.base.parent);
+ bt_ctf_object_get_ref(event->common.class);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event->common.base.parent);
} else {
- bt_object_try_spec_release(&event->common.base);
+ bt_ctf_object_try_spec_release(&event->common.base);
}
}
stream->pos.fd = -1;
writer = (struct bt_ctf_writer *)
- bt_object_get_parent(&trace->common.base);
+ bt_ctf_object_get_parent(&trace->common.base);
stream->last_ts_end = -1ULL;
BT_LOGD("CTF writer stream object belongs writer's trace: "
"writer-addr=%p", writer);
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(stream);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(stream);
end:
- bt_object_put_ref(writer);
+ bt_ctf_object_put_ref(writer);
return stream;
}
}
end:
- bt_object_put_ref(events_discarded_field);
+ bt_ctf_object_put_ref(events_discarded_field);
return ret;
}
stream, bt_ctf_stream_get_name(stream), event_count);
end:
- bt_object_put_ref(events_discarded_field);
+ bt_ctf_object_put_ref(events_discarded_field);
}
static int auto_populate_event_header(struct bt_ctf_stream *stream,
stream, bt_ctf_stream_get_name(stream), event);
end:
- bt_object_put_ref(id_field);
- bt_object_put_ref(timestamp_field);
- bt_object_put_ref(mapped_clock_class);
+ bt_ctf_object_put_ref(id_field);
+ bt_ctf_object_put_ref(timestamp_field);
+ bt_ctf_object_put_ref(mapped_clock_class);
return ret;
}
goto end;
}
- bt_object_set_parent(&event->common.base, &stream->common.base);
+ bt_ctf_object_set_parent(&event->common.base, &stream->common.base);
BT_LOGV_STR("Automatically populating the header of the event to append.");
ret = auto_populate_event_header(stream, event);
if (ret) {
* longer needed.
*/
BT_LOGV_STR("Putting the event's class.");
- bt_object_put_ref(event->common.class);
+ bt_ctf_object_put_ref(event->common.class);
BT_LOGV("Appended event to stream: "
"stream-addr=%p, stream-name=\"%s\", event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
* Orphan the event; we were not successful in associating it to
* a stream.
*/
- bt_object_set_parent(&event->common.base, NULL);
+ bt_ctf_object_set_parent(&event->common.base, NULL);
return ret;
}
packet_context = stream->packet_context;
if (packet_context) {
- bt_object_get_ref(packet_context);
+ bt_ctf_object_get_ref(packet_context);
}
end:
return packet_context;
goto end;
}
- bt_object_put_ref(field_type);
- bt_object_put_ref(stream->packet_context);
- stream->packet_context = bt_object_get_ref(field);
+ bt_ctf_object_put_ref(field_type);
+ bt_ctf_object_put_ref(stream->packet_context);
+ stream->packet_context = bt_ctf_object_get_ref(field);
BT_LOGV("Set stream's packet context field: "
"stream-addr=%p, stream-name=\"%s\", "
"packet-context-field-addr=%p",
packet_header = stream->packet_header;
if (packet_header) {
- bt_object_get_ref(packet_header);
+ bt_ctf_object_get_ref(packet_header);
}
end:
return packet_header;
}
trace = (struct bt_ctf_trace *)
- bt_object_get_parent(&stream->common.base);
+ bt_ctf_object_get_parent(&stream->common.base);
if (!field) {
if (trace->common.packet_header_field_type) {
}
skip_validation:
- bt_object_put_ref(stream->packet_header);
- stream->packet_header = bt_object_get_ref(field);
+ bt_ctf_object_put_ref(stream->packet_header);
+ stream->packet_header = bt_ctf_object_get_ref(field);
BT_LOGV("Set stream's packet header field: "
"stream-addr=%p, stream-name=\"%s\", "
"packet-header-field-addr=%p",
stream, bt_ctf_stream_get_name(stream), field);
end:
- BT_OBJECT_PUT_REF_AND_RESET(trace);
- bt_object_put_ref(field_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(trace);
+ bt_ctf_object_put_ref(field_type);
return ret;
}
member = bt_ctf_field_structure_get_field_by_name(structure, name);
if (member) {
bt_ctf_field_common_reset_recursive((void *) member);
- bt_object_put_ref(member);
+ bt_ctf_object_put_ref(member);
}
}
packet_size_field = bt_ctf_field_structure_get_field_by_name(
stream->packet_context, "packet_size");
has_packet_size = (packet_size_field != NULL);
- bt_object_put_ref(packet_size_field);
+ bt_ctf_object_put_ref(packet_size_field);
}
if (stream->flushed_packet_count == 1) {
struct bt_ctf_field *field = bt_ctf_field_structure_get_field_by_name(
stream->packet_context, "content_size");
- bt_object_put_ref(field);
+ bt_ctf_object_put_ref(field);
if (!field) {
if (stream->pos.offset != stream->pos.packet_size) {
BT_LOGW("Stream's packet context's `content_size` field is missing, "
}
static
-void bt_ctf_stream_destroy(struct bt_object *obj)
+void bt_ctf_stream_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_stream *stream = (void *) obj;
}
BT_LOGD_STR("Putting packet header field.");
- bt_object_put_ref(stream->packet_header);
+ bt_ctf_object_put_ref(stream->packet_header);
BT_LOGD_STR("Putting packet context field.");
- bt_object_put_ref(stream->packet_context);
+ bt_ctf_object_put_ref(stream->packet_context);
g_free(stream);
}
}
ret = !ret ? 1 : ret;
end:
- bt_object_put_ref(integer);
- bt_object_put_ref(field_type);
+ bt_ctf_object_put_ref(integer);
+ bt_ctf_object_put_ref(field_type);
return ret;
}
struct bt_ctf_stream_class *bt_ctf_stream_get_class(
struct bt_ctf_stream *stream)
{
- return bt_object_get_ref(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream)));
+ return bt_ctf_object_get_ref(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream)));
}
const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream)
#include <babeltrace/ctf-writer/visitor-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <babeltrace/types.h>
-#include <babeltrace/values-internal.h>
-#include <babeltrace/values.h>
+#include <babeltrace/ctf-writer/values-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
BT_HIDDEN
int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace,
- bt_object_release_func release_func)
+ bt_ctf_object_release_func release_func)
{
int ret = 0;
BT_LOGD_STR("Initializing common trace object.");
trace->native_byte_order = BT_CTF_BYTE_ORDER_UNSPECIFIED;
- bt_object_init_shared_with_parent(&trace->base, release_func);
+ bt_ctf_object_init_shared_with_parent(&trace->base, release_func);
trace->clock_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_put_ref);
+ (GDestroyNotify) bt_ctf_object_put_ref);
if (!trace->clock_classes) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
goto error;
}
trace->streams = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_try_spec_release);
+ (GDestroyNotify) bt_ctf_object_try_spec_release);
if (!trace->streams) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
goto error;
}
trace->stream_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_try_spec_release);
+ (GDestroyNotify) bt_ctf_object_try_spec_release);
if (!trace->stream_classes) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
goto error;
}
BT_LOGD_STR("Putting packet header field type.");
- bt_object_put_ref(trace->packet_header_field_type);
+ bt_ctf_object_put_ref(trace->packet_header_field_type);
}
BT_HIDDEN
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
- const char *name, struct bt_private_value *value)
+ const char *name, struct bt_ctf_private_value *value)
{
int ret = 0;
goto end;
}
- if (!bt_value_is_integer(bt_private_value_as_value(value)) &&
- !bt_value_is_string(bt_private_value_as_value(value))) {
+ if (!bt_ctf_value_is_integer(bt_ctf_private_value_as_value(value)) &&
+ !bt_ctf_value_is_string(bt_ctf_private_value_as_value(value))) {
BT_LOGW("Invalid parameter: environment field's value is not an integer or string value: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\", env-value-type=%s",
trace, bt_ctf_trace_common_get_name(trace), name,
bt_common_value_type_string(
- bt_value_get_type(
- bt_private_value_as_value(value))));
+ bt_ctf_value_get_type(
+ bt_ctf_private_value_as_value(value))));
ret = -1;
goto end;
}
*
* The object passed is frozen like all other attributes.
*/
- struct bt_private_value *attribute =
+ struct bt_ctf_private_value *attribute =
bt_ctf_attributes_borrow_field_value_by_name(
trace->environment, name);
goto end;
}
- bt_value_freeze(bt_private_value_as_value(value));
+ bt_ctf_value_freeze(bt_ctf_private_value_as_value(value));
}
ret = bt_ctf_attributes_set_field_value(trace->environment, name,
const char *name, const char *value)
{
int ret = 0;
- struct bt_private_value *env_value_string_obj = NULL;
+ struct bt_ctf_private_value *env_value_string_obj = NULL;
if (!value) {
BT_LOGW_STR("Invalid parameter: value is NULL.");
goto end;
}
- env_value_string_obj = bt_private_value_string_create_init(value);
+ env_value_string_obj = bt_ctf_private_value_string_create_init(value);
if (!env_value_string_obj) {
BT_LOGE_STR("Cannot create string value object.");
ret = -1;
env_value_string_obj);
end:
- bt_object_put_ref(env_value_string_obj);
+ bt_ctf_object_put_ref(env_value_string_obj);
return ret;
}
struct bt_ctf_trace_common *trace, const char *name, int64_t value)
{
int ret = 0;
- struct bt_private_value *env_value_integer_obj = NULL;
+ struct bt_ctf_private_value *env_value_integer_obj = NULL;
- env_value_integer_obj = bt_private_value_integer_create_init(value);
+ env_value_integer_obj = bt_ctf_private_value_integer_create_init(value);
if (!env_value_integer_obj) {
BT_LOGE_STR("Cannot create integer value object.");
ret = -1;
env_value_integer_obj);
end:
- bt_object_put_ref(env_value_integer_obj);
+ bt_ctf_object_put_ref(env_value_integer_obj);
return ret;
}
goto end;
}
- bt_object_get_ref(clock_class);
+ bt_ctf_object_get_ref(clock_class);
g_ptr_array_add(trace->clock_classes, clock_class);
if (trace->frozen) {
ret = bt_ctf_field_type_common_validate_single_clock_class(
trace->packet_header_field_type,
&clock_class);
- bt_object_put_ref(clock_class);
+ bt_ctf_object_put_ref(clock_class);
if (ret || clock_class) {
BT_LOGW("Trace's packet header field type cannot "
"contain a field type which is mapped to "
int64_t event_class_count;
struct bt_ctf_trace_common *current_parent_trace = NULL;
struct bt_ctf_clock_class *expected_clock_class =
- bt_object_get_ref(init_expected_clock_class);
+ bt_ctf_object_get_ref(init_expected_clock_class);
BT_ASSERT(copy_field_type_func);
}
}
- bt_object_set_parent(&stream_class->base, &trace->base);
+ bt_ctf_object_set_parent(&stream_class->base, &trace->base);
g_ptr_array_add(trace->stream_classes, stream_class);
/*
* now because the stream class is frozen.
*/
if (expected_clock_class) {
- BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
+ BT_CTF_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
BT_LOGD("Added stream class to trace: "
end:
if (ret) {
- bt_object_set_parent(&stream_class->base, NULL);
+ bt_ctf_object_set_parent(&stream_class->base, NULL);
if (ec_validation_outputs) {
for (i = 0; i < event_class_count; i++) {
g_free(ec_validation_outputs);
bt_ctf_validation_output_put_types(&trace_sc_validation_output);
- bt_object_put_ref(expected_clock_class);
+ bt_ctf_object_put_ref(expected_clock_class);
return ret;
}
goto end;
}
- bt_object_put_ref(trace->packet_header_field_type);
- trace->packet_header_field_type = bt_object_get_ref(packet_header_type);
+ bt_ctf_object_put_ref(trace->packet_header_field_type);
+ trace->packet_header_field_type = bt_ctf_object_get_ref(packet_header_type);
BT_LOGV("Set trace's packet header field type: "
"addr=%p, name=\"%s\", packet-context-ft-addr=%p",
trace, bt_ctf_trace_common_get_name(trace), packet_header_type);
}
static
-void bt_ctf_trace_destroy(struct bt_object *obj)
+void bt_ctf_trace_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_trace *trace = (void *) obj;
return trace;
error:
- BT_OBJECT_PUT_REF_AND_RESET(trace);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(trace);
return trace;
}
BT_CTF_TO_COMMON(trace), index);
}
-struct bt_value *bt_ctf_trace_get_environment_field_value_by_index(
+struct bt_ctf_value *bt_ctf_trace_get_environment_field_value_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_index(
BT_CTF_TO_COMMON(trace), index));
}
-struct bt_value *bt_ctf_trace_get_environment_field_value_by_name(
+struct bt_ctf_value *bt_ctf_trace_get_environment_field_value_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_name(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_name(
BT_CTF_TO_COMMON(trace), name));
}
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_clock_class_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_clock_class_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_stream_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
struct bt_ctf_trace *trace, uint64_t id)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_id(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_id(
BT_CTF_TO_COMMON(trace), id));
}
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return bt_object_get_ref(
+ return bt_ctf_object_get_ref(
bt_ctf_trace_common_borrow_clock_class_by_name(BT_CTF_TO_COMMON(trace),
name));
}
g_string_append(context->string, "env {\n");
for (i = 0; i < env_size; i++) {
- struct bt_private_value *env_field_value_obj = NULL;
+ struct bt_ctf_private_value *env_field_value_obj = NULL;
const char *entry_name;
entry_name = bt_ctf_attributes_get_field_name(
BT_ASSERT(entry_name);
BT_ASSERT(env_field_value_obj);
- switch (bt_value_get_type(
- bt_private_value_as_value(env_field_value_obj))) {
- case BT_VALUE_TYPE_INTEGER:
+ switch (bt_ctf_value_get_type(
+ bt_ctf_private_value_as_value(env_field_value_obj))) {
+ case BT_CTF_VALUE_TYPE_INTEGER:
{
int64_t int_value;
- int_value = bt_value_integer_get(
- bt_private_value_as_value(
+ int_value = bt_ctf_value_integer_get(
+ bt_ctf_private_value_as_value(
env_field_value_obj));
g_string_append_printf(context->string,
"\t%s = %" PRId64 ";\n", entry_name,
int_value);
break;
}
- case BT_VALUE_TYPE_STRING:
+ case BT_CTF_VALUE_TYPE_STRING:
{
const char *str_value;
char *escaped_str = NULL;
- str_value = bt_value_string_get(
- bt_private_value_as_value(
+ str_value = bt_ctf_value_string_get(
+ bt_ctf_private_value_as_value(
env_field_value_obj));
escaped_str = g_strescape(str_value, NULL);
if (!escaped_str) {
struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
struct bt_ctf_trace *trace)
{
- return bt_object_get_ref(bt_ctf_trace_common_borrow_packet_header_field_type(
+ return bt_ctf_object_get_ref(bt_ctf_trace_common_borrow_packet_header_field_type(
BT_CTF_TO_COMMON(trace)));
}
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/field-types-internal.h>
#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <glib.h>
#include <stdlib.h>
#include <babeltrace/ctf-writer/stream-class-internal.h>
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/object.h>
-#include <babeltrace/values.h>
+#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace/ctf-writer/values-internal.h>
/*
* This function resolves and validates the field types of an event
* All parameters are owned by the caller.
*/
static
-int validate_event_class_types(struct bt_private_value *environment,
+int validate_event_class_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
* All parameters are owned by the caller.
*/
static
-int validate_stream_class_types(struct bt_private_value *environment,
+int validate_stream_class_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
* All parameters are owned by the caller.
*/
static
-int validate_trace_types(struct bt_private_value *environment,
+int validate_trace_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type)
{
int ret = 0;
}
BT_HIDDEN
-int bt_ctf_validate_class_types(struct bt_private_value *environment,
+int bt_ctf_validate_class_types(struct bt_ctf_private_value *environment,
struct bt_ctf_field_type_common *packet_header_type,
struct bt_ctf_field_type_common *packet_context_type,
struct bt_ctf_field_type_common *event_header_type,
}
/* Own the type parameters */
- bt_object_get_ref(packet_header_type);
- bt_object_get_ref(packet_context_type);
- bt_object_get_ref(event_header_type);
- bt_object_get_ref(stream_event_ctx_type);
- bt_object_get_ref(event_context_type);
- bt_object_get_ref(event_payload_type);
+ bt_ctf_object_get_ref(packet_header_type);
+ bt_ctf_object_get_ref(packet_context_type);
+ bt_ctf_object_get_ref(event_header_type);
+ bt_ctf_object_get_ref(stream_event_ctx_type);
+ bt_ctf_object_get_ref(event_context_type);
+ bt_ctf_object_get_ref(event_payload_type);
/* Validate trace */
if ((validate_flags & BT_CTF_VALIDATION_FLAG_TRACE) && !trace_valid) {
} else if (!contains_seq_var) {
/* No copy is needed */
packet_header_type_copy = packet_header_type;
- bt_object_get_ref(packet_header_type_copy);
+ bt_ctf_object_get_ref(packet_header_type_copy);
goto skip_packet_header_type_copy;
}
skip_packet_header_type_copy:
/* Put original reference and move copy */
- BT_OBJECT_MOVE_REF(packet_header_type, packet_header_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(packet_header_type, packet_header_type_copy);
/* Validate trace field types */
valid_ret = validate_trace_types(environment,
} else if (!contains_seq_var) {
/* No copy is needed */
packet_context_type_copy = packet_context_type;
- bt_object_get_ref(packet_context_type_copy);
+ bt_ctf_object_get_ref(packet_context_type_copy);
goto skip_packet_context_type_copy;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_header_type_copy = event_header_type;
- bt_object_get_ref(event_header_type_copy);
+ bt_ctf_object_get_ref(event_header_type_copy);
goto skip_event_header_type_copy;
}
/* No copy is needed */
stream_event_ctx_type_copy =
stream_event_ctx_type;
- bt_object_get_ref(stream_event_ctx_type_copy);
+ bt_ctf_object_get_ref(stream_event_ctx_type_copy);
goto skip_stream_event_ctx_type_copy;
}
skip_stream_event_ctx_type_copy:
/* Put original references and move copies */
- BT_OBJECT_MOVE_REF(packet_context_type, packet_context_type_copy);
- BT_OBJECT_MOVE_REF(event_header_type, event_header_type_copy);
- BT_OBJECT_MOVE_REF(stream_event_ctx_type, stream_event_ctx_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(packet_context_type, packet_context_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(event_header_type, event_header_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(stream_event_ctx_type, stream_event_ctx_type_copy);
/* Validate stream class field types */
valid_ret = validate_stream_class_types(environment,
goto sc_validation_done;
sc_validation_error:
- BT_OBJECT_PUT_REF_AND_RESET(packet_context_type_copy);
- BT_OBJECT_PUT_REF_AND_RESET(event_header_type_copy);
- BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(packet_context_type_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_header_type_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type_copy);
ret = -1;
goto error;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_context_type_copy = event_context_type;
- bt_object_get_ref(event_context_type_copy);
+ bt_ctf_object_get_ref(event_context_type_copy);
goto skip_event_context_type_copy;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_payload_type_copy = event_payload_type;
- bt_object_get_ref(event_payload_type_copy);
+ bt_ctf_object_get_ref(event_payload_type_copy);
goto skip_event_payload_type_copy;
}
skip_event_payload_type_copy:
/* Put original references and move copies */
- BT_OBJECT_MOVE_REF(event_context_type, event_context_type_copy);
- BT_OBJECT_MOVE_REF(event_payload_type, event_payload_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(event_context_type, event_context_type_copy);
+ BT_CTF_OBJECT_MOVE_REF(event_payload_type, event_payload_type_copy);
/* Validate event class field types */
valid_ret = validate_event_class_types(environment,
goto ec_validation_done;
ec_validation_error:
- BT_OBJECT_PUT_REF_AND_RESET(event_context_type_copy);
- BT_OBJECT_PUT_REF_AND_RESET(event_payload_type_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_context_type_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_payload_type_copy);
ret = -1;
goto error;
}
* to validate (and that were possibly altered by the validation
* process) to the output values.
*/
- BT_OBJECT_MOVE_REF(output->packet_header_type, packet_header_type);
- BT_OBJECT_MOVE_REF(output->packet_context_type, packet_context_type);
- BT_OBJECT_MOVE_REF(output->event_header_type, event_header_type);
- BT_OBJECT_MOVE_REF(output->stream_event_ctx_type, stream_event_ctx_type);
- BT_OBJECT_MOVE_REF(output->event_context_type, event_context_type);
- BT_OBJECT_MOVE_REF(output->event_payload_type, event_payload_type);
+ BT_CTF_OBJECT_MOVE_REF(output->packet_header_type, packet_header_type);
+ BT_CTF_OBJECT_MOVE_REF(output->packet_context_type, packet_context_type);
+ BT_CTF_OBJECT_MOVE_REF(output->event_header_type, event_header_type);
+ BT_CTF_OBJECT_MOVE_REF(output->stream_event_ctx_type, stream_event_ctx_type);
+ BT_CTF_OBJECT_MOVE_REF(output->event_context_type, event_context_type);
+ BT_CTF_OBJECT_MOVE_REF(output->event_payload_type, event_payload_type);
return ret;
error:
- BT_OBJECT_PUT_REF_AND_RESET(packet_header_type);
- BT_OBJECT_PUT_REF_AND_RESET(packet_context_type);
- BT_OBJECT_PUT_REF_AND_RESET(event_header_type);
- BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type);
- BT_OBJECT_PUT_REF_AND_RESET(event_context_type);
- BT_OBJECT_PUT_REF_AND_RESET(event_payload_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(packet_header_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(packet_context_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_header_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_context_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(event_payload_type);
return ret;
}
{
if ((replace_flags & BT_CTF_VALIDATION_FLAG_TRACE) && trace) {
bt_ctf_field_type_common_freeze(trace->packet_header_field_type);
- BT_OBJECT_MOVE_REF(trace->packet_header_field_type,
+ BT_CTF_OBJECT_MOVE_REF(trace->packet_header_field_type,
output->packet_header_type);
}
bt_ctf_field_type_common_freeze(stream_class->packet_context_field_type);
bt_ctf_field_type_common_freeze(stream_class->event_header_field_type);
bt_ctf_field_type_common_freeze(stream_class->event_context_field_type);
- BT_OBJECT_MOVE_REF(stream_class->packet_context_field_type,
+ BT_CTF_OBJECT_MOVE_REF(stream_class->packet_context_field_type,
output->packet_context_type);
- BT_OBJECT_MOVE_REF(stream_class->event_header_field_type,
+ BT_CTF_OBJECT_MOVE_REF(stream_class->event_header_field_type,
output->event_header_type);
- BT_OBJECT_MOVE_REF(stream_class->event_context_field_type,
+ BT_CTF_OBJECT_MOVE_REF(stream_class->event_context_field_type,
output->stream_event_ctx_type);
}
if ((replace_flags & BT_CTF_VALIDATION_FLAG_EVENT) && event_class) {
bt_ctf_field_type_common_freeze(event_class->context_field_type);
bt_ctf_field_type_common_freeze(event_class->payload_field_type);
- BT_OBJECT_MOVE_REF(event_class->context_field_type, output->event_context_type);
- BT_OBJECT_MOVE_REF(event_class->payload_field_type, output->event_payload_type);
+ BT_CTF_OBJECT_MOVE_REF(event_class->context_field_type, output->event_context_type);
+ BT_CTF_OBJECT_MOVE_REF(event_class->payload_field_type, output->event_payload_type);
}
}
void bt_ctf_validation_output_put_types(
struct bt_ctf_validation_output *output)
{
- BT_OBJECT_PUT_REF_AND_RESET(output->packet_header_type);
- BT_OBJECT_PUT_REF_AND_RESET(output->packet_context_type);
- BT_OBJECT_PUT_REF_AND_RESET(output->event_header_type);
- BT_OBJECT_PUT_REF_AND_RESET(output->stream_event_ctx_type);
- BT_OBJECT_PUT_REF_AND_RESET(output->event_context_type);
- BT_OBJECT_PUT_REF_AND_RESET(output->event_payload_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->packet_header_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->packet_context_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->event_header_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->stream_event_ctx_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->event_context_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(output->event_payload_type);
}
--- /dev/null
+/*
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015 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.
+ */
+
+#define BT_LOG_TAG "CTF-WRITER-VALUES"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <string.h>
+#include <inttypes.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/common-internal.h>
+#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace/compat/glib-internal.h>
+#include <babeltrace/types.h>
+#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace/assert-internal.h>
+#include <babeltrace/assert-pre-internal.h>
+
+#define BT_CTF_VALUE_FROM_CONCRETE(_concrete) ((struct bt_ctf_value *) (_concrete))
+#define BT_CTF_VALUE_TO_BOOL(_base) ((struct bt_ctf_value_bool *) (_base))
+#define BT_CTF_VALUE_TO_INTEGER(_base) ((struct bt_ctf_value_integer *) (_base))
+#define BT_CTF_VALUE_TO_REAL(_base) ((struct bt_ctf_value_real *) (_base))
+#define BT_CTF_VALUE_TO_STRING(_base) ((struct bt_ctf_value_string *) (_base))
+#define BT_CTF_VALUE_TO_ARRAY(_base) ((struct bt_ctf_value_array *) (_base))
+#define BT_CTF_VALUE_TO_MAP(_base) ((struct bt_ctf_value_map *) (_base))
+
+#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \
+ BT_ASSERT_PRE(((struct bt_ctf_value *) (_value))->type == (_type), \
+ "Value has the wrong type ID: expected-type=%d, " \
+ "%![value-]+v", (_type), \
+ (_value))
+
+#define BT_ASSERT_PRE_VALUE_HOT(_value, _name) \
+ BT_ASSERT_PRE_HOT(((struct bt_ctf_value *) (_value)), (_name), \
+ ": %!+v", (_value))
+
+#define BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(_index, _count) \
+ BT_ASSERT_PRE((_index) < (_count), \
+ "Index is out of bound: " \
+ "index=%" PRIu64 ", count=%u", (_index), (_count));
+
+struct bt_ctf_value {
+ struct bt_ctf_object base;
+ enum bt_ctf_value_type type;
+ bt_bool frozen;
+};
+
+static
+void bt_ctf_value_null_instance_release_func(struct bt_ctf_object *obj)
+{
+ BT_LOGW("Releasing the null value singleton: addr=%p", obj);
+}
+
+static
+struct bt_ctf_value bt_ctf_value_null_instance = {
+ .base = {
+ .is_shared = true,
+ .ref_count = 1,
+ .release_func = bt_ctf_value_null_instance_release_func,
+ .spec_release_func = NULL,
+ .parent_is_owner_listener_func = NULL,
+ .parent = NULL,
+ },
+ .type = BT_CTF_VALUE_TYPE_NULL,
+ .frozen = BT_TRUE,
+};
+
+struct bt_ctf_value *bt_ctf_value_null = &bt_ctf_value_null_instance;
+struct bt_ctf_private_value *bt_ctf_private_value_null =
+ (void *) &bt_ctf_value_null_instance;
+
+struct bt_ctf_value_bool {
+ struct bt_ctf_value base;
+ bt_bool value;
+};
+
+struct bt_ctf_value_integer {
+ struct bt_ctf_value base;
+ int64_t value;
+};
+
+struct bt_ctf_value_real {
+ struct bt_ctf_value base;
+ double value;
+};
+
+struct bt_ctf_value_string {
+ struct bt_ctf_value base;
+ GString *gstr;
+};
+
+struct bt_ctf_value_array {
+ struct bt_ctf_value base;
+ GPtrArray *garray;
+};
+
+struct bt_ctf_value_map {
+ struct bt_ctf_value base;
+ GHashTable *ght;
+};
+
+static
+void bt_ctf_value_destroy(struct bt_ctf_object *obj);
+
+static
+void bt_ctf_value_string_destroy(struct bt_ctf_value *object)
+{
+ g_string_free(BT_CTF_VALUE_TO_STRING(object)->gstr, TRUE);
+ BT_CTF_VALUE_TO_STRING(object)->gstr = NULL;
+}
+
+static
+void bt_ctf_value_array_destroy(struct bt_ctf_value *object)
+{
+ /*
+ * Pointer array's registered value destructor will take care
+ * of putting each contained object.
+ */
+ g_ptr_array_free(BT_CTF_VALUE_TO_ARRAY(object)->garray, TRUE);
+ BT_CTF_VALUE_TO_ARRAY(object)->garray = NULL;
+}
+
+static
+void bt_ctf_value_map_destroy(struct bt_ctf_value *object)
+{
+ /*
+ * Hash table's registered value destructor will take care of
+ * putting each contained object. Keys are GQuarks and cannot
+ * be destroyed anyway.
+ */
+ g_hash_table_destroy(BT_CTF_VALUE_TO_MAP(object)->ght);
+ BT_CTF_VALUE_TO_MAP(object)->ght = NULL;
+}
+
+static
+void (* const destroy_funcs[])(struct bt_ctf_value *) = {
+ [BT_CTF_VALUE_TYPE_NULL] = NULL,
+ [BT_CTF_VALUE_TYPE_BOOL] = NULL,
+ [BT_CTF_VALUE_TYPE_INTEGER] = NULL,
+ [BT_CTF_VALUE_TYPE_REAL] = NULL,
+ [BT_CTF_VALUE_TYPE_STRING] = bt_ctf_value_string_destroy,
+ [BT_CTF_VALUE_TYPE_ARRAY] = bt_ctf_value_array_destroy,
+ [BT_CTF_VALUE_TYPE_MAP] = bt_ctf_value_map_destroy,
+};
+
+static
+struct bt_ctf_private_value *bt_ctf_value_null_copy(const struct bt_ctf_value *null_obj)
+{
+ return (void *) bt_ctf_value_null;
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_bool_copy(const struct bt_ctf_value *bool_obj)
+{
+ return bt_ctf_private_value_bool_create_init(
+ BT_CTF_VALUE_TO_BOOL(bool_obj)->value);
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_integer_copy(
+ const struct bt_ctf_value *integer_obj)
+{
+ return bt_ctf_private_value_integer_create_init(
+ BT_CTF_VALUE_TO_INTEGER(integer_obj)->value);
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_real_copy(const struct bt_ctf_value *real_obj)
+{
+ return bt_ctf_private_value_real_create_init(
+ BT_CTF_VALUE_TO_REAL(real_obj)->value);
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_string_copy(const struct bt_ctf_value *string_obj)
+{
+ return bt_ctf_private_value_string_create_init(
+ BT_CTF_VALUE_TO_STRING(string_obj)->gstr->str);
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_array_copy(const struct bt_ctf_value *array_obj)
+{
+ int i;
+ int ret;
+ struct bt_ctf_private_value *copy_obj;
+ struct bt_ctf_value_array *typed_array_obj;
+
+ BT_LOGD("Copying array value: addr=%p", array_obj);
+ typed_array_obj = BT_CTF_VALUE_TO_ARRAY(array_obj);
+ copy_obj = bt_ctf_private_value_array_create();
+ if (!copy_obj) {
+ BT_LOGE_STR("Cannot create empty array value.");
+ goto end;
+ }
+
+ for (i = 0; i < typed_array_obj->garray->len; ++i) {
+ struct bt_ctf_private_value *element_obj_copy = NULL;
+ struct bt_ctf_value *element_obj =
+ bt_ctf_value_array_borrow_element_by_index(
+ array_obj, i);
+
+ BT_ASSERT(element_obj);
+ BT_LOGD("Copying array value's element: element-addr=%p, "
+ "index=%d", element_obj, i);
+ ret = bt_ctf_value_copy(&element_obj_copy, element_obj);
+ if (ret) {
+ BT_LOGE("Cannot copy array value's element: "
+ "array-addr=%p, index=%d",
+ array_obj, i);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_obj);
+ goto end;
+ }
+
+ BT_ASSERT(element_obj_copy);
+ ret = bt_ctf_private_value_array_append_element(copy_obj,
+ (void *) element_obj_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
+ if (ret) {
+ BT_LOGE("Cannot append to array value: addr=%p",
+ array_obj);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_obj);
+ goto end;
+ }
+ }
+
+ BT_LOGD("Copied array value: original-addr=%p, copy-addr=%p",
+ array_obj, copy_obj);
+
+end:
+ return copy_obj;
+}
+
+static
+struct bt_ctf_private_value *bt_ctf_value_map_copy(const struct bt_ctf_value *map_obj)
+{
+ int ret;
+ GHashTableIter iter;
+ gpointer key, element_obj;
+ struct bt_ctf_private_value *copy_obj;
+ struct bt_ctf_private_value *element_obj_copy = NULL;
+ struct bt_ctf_value_map *typed_map_obj;
+
+ BT_LOGD("Copying map value: addr=%p", map_obj);
+ typed_map_obj = BT_CTF_VALUE_TO_MAP(map_obj);
+ copy_obj = bt_ctf_private_value_map_create();
+ if (!copy_obj) {
+ goto end;
+ }
+
+ g_hash_table_iter_init(&iter, typed_map_obj->ght);
+
+ while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
+ const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
+
+ BT_ASSERT(key_str);
+ BT_LOGD("Copying map value's element: element-addr=%p, "
+ "key=\"%s\"", element_obj, key_str);
+ ret = bt_ctf_value_copy(&element_obj_copy, element_obj);
+ if (ret) {
+ BT_LOGE("Cannot copy map value's element: "
+ "map-addr=%p, key=\"%s\"",
+ map_obj, key_str);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_obj);
+ goto end;
+ }
+
+ BT_ASSERT(element_obj_copy);
+ ret = bt_ctf_private_value_map_insert_entry(copy_obj, key_str,
+ (void *) element_obj_copy);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
+ if (ret) {
+ BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
+ map_obj, key_str);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(copy_obj);
+ goto end;
+ }
+ }
+
+ BT_LOGD("Copied map value: addr=%p", map_obj);
+
+end:
+ return copy_obj;
+}
+
+static
+struct bt_ctf_private_value *(* const copy_funcs[])(const struct bt_ctf_value *) = {
+ [BT_CTF_VALUE_TYPE_NULL] = bt_ctf_value_null_copy,
+ [BT_CTF_VALUE_TYPE_BOOL] = bt_ctf_value_bool_copy,
+ [BT_CTF_VALUE_TYPE_INTEGER] = bt_ctf_value_integer_copy,
+ [BT_CTF_VALUE_TYPE_REAL] = bt_ctf_value_real_copy,
+ [BT_CTF_VALUE_TYPE_STRING] = bt_ctf_value_string_copy,
+ [BT_CTF_VALUE_TYPE_ARRAY] = bt_ctf_value_array_copy,
+ [BT_CTF_VALUE_TYPE_MAP] = bt_ctf_value_map_copy,
+};
+
+static
+bt_bool bt_ctf_value_null_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ /*
+ * Always BT_TRUE since bt_ctf_value_compare() already checks if both
+ * object_a and object_b have the same type, and in the case of
+ * null value objects, they're always the same if it is so.
+ */
+ return BT_TRUE;
+}
+
+static
+bt_bool bt_ctf_value_bool_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ if (BT_CTF_VALUE_TO_BOOL(object_a)->value !=
+ BT_CTF_VALUE_TO_BOOL(object_b)->value) {
+ BT_LOGV("Boolean value objects are different: "
+ "bool-a-val=%d, bool-b-val=%d",
+ BT_CTF_VALUE_TO_BOOL(object_a)->value,
+ BT_CTF_VALUE_TO_BOOL(object_b)->value);
+ return BT_FALSE;
+ }
+
+ return BT_TRUE;
+}
+
+static
+bt_bool bt_ctf_value_integer_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ if (BT_CTF_VALUE_TO_INTEGER(object_a)->value !=
+ BT_CTF_VALUE_TO_INTEGER(object_b)->value) {
+ BT_LOGV("Integer value objects are different: "
+ "int-a-val=%" PRId64 ", int-b-val=%" PRId64,
+ BT_CTF_VALUE_TO_INTEGER(object_a)->value,
+ BT_CTF_VALUE_TO_INTEGER(object_b)->value);
+ return BT_FALSE;
+ }
+
+ return BT_TRUE;
+}
+
+static
+bt_bool bt_ctf_value_real_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ if (BT_CTF_VALUE_TO_REAL(object_a)->value !=
+ BT_CTF_VALUE_TO_REAL(object_b)->value) {
+ BT_LOGV("Real number value objects are different: "
+ "real-a-val=%f, real-b-val=%f",
+ BT_CTF_VALUE_TO_REAL(object_a)->value,
+ BT_CTF_VALUE_TO_REAL(object_b)->value);
+ return BT_FALSE;
+ }
+
+ return BT_TRUE;
+}
+
+static
+bt_bool bt_ctf_value_string_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ if (strcmp(BT_CTF_VALUE_TO_STRING(object_a)->gstr->str,
+ BT_CTF_VALUE_TO_STRING(object_b)->gstr->str) != 0) {
+ BT_LOGV("String value objects are different: "
+ "string-a-val=\"%s\", string-b-val=\"%s\"",
+ BT_CTF_VALUE_TO_STRING(object_a)->gstr->str,
+ BT_CTF_VALUE_TO_STRING(object_b)->gstr->str);
+ return BT_FALSE;
+ }
+
+ return BT_TRUE;
+}
+
+static
+bt_bool bt_ctf_value_array_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ int i;
+ bt_bool ret = BT_TRUE;
+ const struct bt_ctf_value_array *array_obj_a =
+ BT_CTF_VALUE_TO_ARRAY(object_a);
+
+ if (bt_ctf_value_array_get_size(object_a) !=
+ bt_ctf_value_array_get_size(object_b)) {
+ BT_LOGV("Array values are different: size mismatch "
+ "value-a-addr=%p, value-b-addr=%p, "
+ "value-a-size=%" PRId64 ", value-b-size=%" PRId64,
+ object_a, object_b,
+ bt_ctf_value_array_get_size(object_a),
+ bt_ctf_value_array_get_size(object_b));
+ ret = BT_FALSE;
+ goto end;
+ }
+
+ for (i = 0; i < array_obj_a->garray->len; ++i) {
+ struct bt_ctf_value *element_obj_a;
+ struct bt_ctf_value *element_obj_b;
+
+ element_obj_a = bt_ctf_value_array_borrow_element_by_index(
+ object_a, i);
+ element_obj_b = bt_ctf_value_array_borrow_element_by_index(
+ object_b, i);
+
+ if (!bt_ctf_value_compare(element_obj_a, element_obj_b)) {
+ BT_LOGV("Array values's elements are different: "
+ "value-a-addr=%p, value-b-addr=%p, index=%d",
+ element_obj_a, element_obj_b, i);
+ ret = BT_FALSE;
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
+static
+bt_bool bt_ctf_value_map_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ bt_bool ret = BT_TRUE;
+ GHashTableIter iter;
+ gpointer key, element_obj_a;
+ const struct bt_ctf_value_map *map_obj_a = BT_CTF_VALUE_TO_MAP(object_a);
+
+ if (bt_ctf_value_map_get_size(object_a) !=
+ bt_ctf_value_map_get_size(object_b)) {
+ BT_LOGV("Map values are different: size mismatch "
+ "value-a-addr=%p, value-b-addr=%p, "
+ "value-a-size=%" PRId64 ", value-b-size=%" PRId64,
+ object_a, object_b,
+ bt_ctf_value_map_get_size(object_a),
+ bt_ctf_value_map_get_size(object_b));
+ ret = BT_FALSE;
+ goto end;
+ }
+
+ g_hash_table_iter_init(&iter, map_obj_a->ght);
+
+ while (g_hash_table_iter_next(&iter, &key, &element_obj_a)) {
+ struct bt_ctf_value *element_obj_b;
+ const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
+
+ element_obj_b = bt_ctf_value_map_borrow_entry_value(object_b,
+ key_str);
+
+ if (!bt_ctf_value_compare(element_obj_a, element_obj_b)) {
+ BT_LOGV("Map values's elements are different: "
+ "value-a-addr=%p, value-b-addr=%p, key=\"%s\"",
+ element_obj_a, element_obj_b, key_str);
+ ret = BT_FALSE;
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
+static
+bt_bool (* const compare_funcs[])(const struct bt_ctf_value *,
+ const struct bt_ctf_value *) = {
+ [BT_CTF_VALUE_TYPE_NULL] = bt_ctf_value_null_compare,
+ [BT_CTF_VALUE_TYPE_BOOL] = bt_ctf_value_bool_compare,
+ [BT_CTF_VALUE_TYPE_INTEGER] = bt_ctf_value_integer_compare,
+ [BT_CTF_VALUE_TYPE_REAL] = bt_ctf_value_real_compare,
+ [BT_CTF_VALUE_TYPE_STRING] = bt_ctf_value_string_compare,
+ [BT_CTF_VALUE_TYPE_ARRAY] = bt_ctf_value_array_compare,
+ [BT_CTF_VALUE_TYPE_MAP] = bt_ctf_value_map_compare,
+};
+
+static
+void bt_ctf_value_null_freeze(struct bt_ctf_value *object)
+{
+}
+
+static
+void bt_ctf_value_generic_freeze(struct bt_ctf_value *object)
+{
+ object->frozen = BT_TRUE;
+}
+
+static
+void bt_ctf_value_array_freeze(struct bt_ctf_value *object)
+{
+ int i;
+ struct bt_ctf_value_array *typed_array_obj =
+ BT_CTF_VALUE_TO_ARRAY(object);
+
+ for (i = 0; i < typed_array_obj->garray->len; ++i) {
+ bt_ctf_value_freeze(g_ptr_array_index(typed_array_obj->garray, i));
+ }
+
+ bt_ctf_value_generic_freeze(object);
+}
+
+static
+void bt_ctf_value_map_freeze(struct bt_ctf_value *object)
+{
+ GHashTableIter iter;
+ gpointer key, element_obj;
+ const struct bt_ctf_value_map *map_obj = BT_CTF_VALUE_TO_MAP(object);
+
+ g_hash_table_iter_init(&iter, map_obj->ght);
+
+ while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
+ bt_ctf_value_freeze(element_obj);
+ }
+
+ bt_ctf_value_generic_freeze(object);
+}
+
+static
+void (* const freeze_funcs[])(struct bt_ctf_value *) = {
+ [BT_CTF_VALUE_TYPE_NULL] = bt_ctf_value_null_freeze,
+ [BT_CTF_VALUE_TYPE_BOOL] = bt_ctf_value_generic_freeze,
+ [BT_CTF_VALUE_TYPE_INTEGER] = bt_ctf_value_generic_freeze,
+ [BT_CTF_VALUE_TYPE_REAL] = bt_ctf_value_generic_freeze,
+ [BT_CTF_VALUE_TYPE_STRING] = bt_ctf_value_generic_freeze,
+ [BT_CTF_VALUE_TYPE_ARRAY] = bt_ctf_value_array_freeze,
+ [BT_CTF_VALUE_TYPE_MAP] = bt_ctf_value_map_freeze,
+};
+
+static
+void bt_ctf_value_destroy(struct bt_ctf_object *obj)
+{
+ struct bt_ctf_value *value;
+
+ value = container_of(obj, struct bt_ctf_value, base);
+ BT_LOGD("Destroying value: addr=%p", value);
+
+ if (bt_ctf_value_is_null(value)) {
+ BT_LOGD_STR("Not destroying the null value singleton.");
+ return;
+ }
+
+ if (destroy_funcs[value->type]) {
+ destroy_funcs[value->type](value);
+ }
+
+ g_free(value);
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status _bt_ctf_value_freeze(struct bt_ctf_value *object)
+{
+ enum bt_ctf_value_status ret = BT_CTF_VALUE_STATUS_OK;
+
+ BT_ASSERT(object);
+
+ if (object->frozen) {
+ goto end;
+ }
+
+ BT_LOGD("Freezing value: addr=%p", object);
+ freeze_funcs[object->type](object);
+
+end:
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object)
+{
+ BT_ASSERT_PRE_NON_NULL(object, "Value object");
+ return object->type;
+}
+
+static
+struct bt_ctf_value bt_ctf_value_create_base(enum bt_ctf_value_type type)
+{
+ struct bt_ctf_value value;
+
+ value.type = type;
+ value.frozen = BT_FALSE;
+ bt_ctf_object_init_shared(&value.base, bt_ctf_value_destroy);
+ return value;
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create_init(bt_bool val)
+{
+ struct bt_ctf_value_bool *bool_obj;
+
+ BT_LOGD("Creating boolean value object: val=%d", val);
+ bool_obj = g_new0(struct bt_ctf_value_bool, 1);
+ if (!bool_obj) {
+ BT_LOGE_STR("Failed to allocate one boolean value object.");
+ goto end;
+ }
+
+ bool_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_BOOL);
+ bool_obj->value = val;
+ BT_LOGD("Created boolean value object: addr=%p", bool_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(bool_obj);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create(void)
+{
+ return bt_ctf_private_value_bool_create_init(BT_FALSE);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create_init(int64_t val)
+{
+ struct bt_ctf_value_integer *integer_obj;
+
+ BT_LOGD("Creating integer value object: val=%" PRId64, val);
+ integer_obj = g_new0(struct bt_ctf_value_integer, 1);
+ if (!integer_obj) {
+ BT_LOGE_STR("Failed to allocate one integer value object.");
+ goto end;
+ }
+
+ integer_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_INTEGER);
+ integer_obj->value = val;
+ BT_LOGD("Created integer value object: addr=%p",
+ integer_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(integer_obj);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create(void)
+{
+ return bt_ctf_private_value_integer_create_init(0);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create_init(double val)
+{
+ struct bt_ctf_value_real *real_obj;
+
+ BT_LOGD("Creating real number value object: val=%f", val);
+ real_obj = g_new0(struct bt_ctf_value_real, 1);
+ if (!real_obj) {
+ BT_LOGE_STR("Failed to allocate one real number value object.");
+ goto end;
+ }
+
+ real_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_REAL);
+ real_obj->value = val;
+ BT_LOGD("Created real number value object: addr=%p",
+ real_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(real_obj);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create(void)
+{
+ return bt_ctf_private_value_real_create_init(0.);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create_init(const char *val)
+{
+ struct bt_ctf_value_string *string_obj = NULL;
+
+ if (!val) {
+ BT_LOGW_STR("Invalid parameter: value is NULL.");
+ goto end;
+ }
+
+ BT_LOGD("Creating string value object: val-len=%zu", strlen(val));
+ string_obj = g_new0(struct bt_ctf_value_string, 1);
+ if (!string_obj) {
+ BT_LOGE_STR("Failed to allocate one string object.");
+ goto end;
+ }
+
+ string_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_STRING);
+ string_obj->gstr = g_string_new(val);
+ if (!string_obj->gstr) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ g_free(string_obj);
+ string_obj = NULL;
+ goto end;
+ }
+
+ BT_LOGD("Created string value object: addr=%p",
+ string_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(string_obj);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create(void)
+{
+ return bt_ctf_private_value_string_create_init("");
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_create(void)
+{
+ struct bt_ctf_value_array *array_obj;
+
+ BT_LOGD_STR("Creating empty array value object.");
+ array_obj = g_new0(struct bt_ctf_value_array, 1);
+ if (!array_obj) {
+ BT_LOGE_STR("Failed to allocate one array object.");
+ goto end;
+ }
+
+ array_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_ARRAY);
+ array_obj->garray = bt_g_ptr_array_new_full(0,
+ (GDestroyNotify) bt_ctf_object_put_ref);
+ if (!array_obj->garray) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ g_free(array_obj);
+ array_obj = NULL;
+ goto end;
+ }
+
+ BT_LOGD("Created array value object: addr=%p",
+ array_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(array_obj);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_create(void)
+{
+ struct bt_ctf_value_map *map_obj;
+
+ BT_LOGD_STR("Creating empty map value object.");
+ map_obj = g_new0(struct bt_ctf_value_map, 1);
+ if (!map_obj) {
+ BT_LOGE_STR("Failed to allocate one map object.");
+ goto end;
+ }
+
+ map_obj->base = bt_ctf_value_create_base(BT_CTF_VALUE_TYPE_MAP);
+ map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+ NULL, (GDestroyNotify) bt_ctf_object_put_ref);
+ if (!map_obj->ght) {
+ BT_LOGE_STR("Failed to allocate a GHashTable.");
+ g_free(map_obj);
+ map_obj = NULL;
+ goto end;
+ }
+
+ BT_LOGD("Created map value object: addr=%p",
+ map_obj);
+
+end:
+ return (void *) BT_CTF_VALUE_FROM_CONCRETE(map_obj);
+}
+
+BT_HIDDEN
+bt_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL);
+ return BT_CTF_VALUE_TO_BOOL(bool_obj)->value;
+}
+
+BT_HIDDEN
+void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj, bt_bool val)
+{
+ BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL);
+ BT_ASSERT_PRE_VALUE_HOT(bool_obj, "Value object");
+ BT_CTF_VALUE_TO_BOOL(bool_obj)->value = val;
+ BT_LOGV("Set boolean value's raw value: value-addr=%p, value=%d",
+ bool_obj, val);
+}
+
+BT_HIDDEN
+int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER);
+ return BT_CTF_VALUE_TO_INTEGER(integer_obj)->value;
+}
+
+BT_HIDDEN
+void bt_ctf_private_value_integer_set(struct bt_ctf_private_value *integer_obj,
+ int64_t val)
+{
+ BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER);
+ BT_ASSERT_PRE_VALUE_HOT(integer_obj, "Value object");
+ BT_CTF_VALUE_TO_INTEGER(integer_obj)->value = val;
+ BT_LOGV("Set integer value's raw value: value-addr=%p, value=%" PRId64,
+ integer_obj, val);
+}
+
+BT_HIDDEN
+double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL);
+ return BT_CTF_VALUE_TO_REAL(real_obj)->value;
+}
+
+BT_HIDDEN
+void bt_ctf_private_value_real_set(struct bt_ctf_private_value *real_obj, double val)
+{
+ BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL);
+ BT_ASSERT_PRE_VALUE_HOT(real_obj, "Value object");
+ BT_CTF_VALUE_TO_REAL(real_obj)->value = val;
+ BT_LOGV("Set real number value's raw value: value-addr=%p, value=%f",
+ real_obj, val);
+}
+
+BT_HIDDEN
+const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING);
+ return BT_CTF_VALUE_TO_STRING(string_obj)->gstr->str;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_string_set(
+ struct bt_ctf_private_value *string_obj, const char *val)
+{
+ BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING);
+ BT_ASSERT_PRE_VALUE_HOT(string_obj, "Value object");
+ g_string_assign(BT_CTF_VALUE_TO_STRING(string_obj)->gstr, val);
+ BT_LOGV("Set string value's raw value: value-addr=%p, raw-value-addr=%p",
+ string_obj, val);
+ return BT_CTF_VALUE_STATUS_OK;
+}
+
+BT_HIDDEN
+uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(array_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY);
+ return (uint64_t) BT_CTF_VALUE_TO_ARRAY(array_obj)->garray->len;
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
+ const struct bt_ctf_value *array_obj,
+ uint64_t index)
+{
+ struct bt_ctf_value_array *typed_array_obj =
+ BT_CTF_VALUE_TO_ARRAY(array_obj);
+
+ BT_ASSERT_PRE_NON_NULL(array_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY);
+ BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
+ typed_array_obj->garray->len);
+ return g_ptr_array_index(typed_array_obj->garray, index);
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
+ const struct bt_ctf_private_value *array_obj,
+ uint64_t index)
+{
+ return (void *) bt_ctf_value_array_borrow_element_by_index(
+ (void *) array_obj, index);
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
+ struct bt_ctf_private_value *array_obj,
+ struct bt_ctf_value *element_obj)
+{
+ struct bt_ctf_value_array *typed_array_obj =
+ BT_CTF_VALUE_TO_ARRAY(array_obj);
+
+ BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
+ BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY);
+ BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
+ g_ptr_array_add(typed_array_obj->garray, element_obj);
+ bt_ctf_object_get_ref(element_obj);
+ BT_LOGV("Appended element to array value: array-value-addr=%p, "
+ "element-value-addr=%p, new-size=%u",
+ array_obj, element_obj, typed_array_obj->garray->len);
+ return BT_CTF_VALUE_STATUS_OK;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
+ struct bt_ctf_private_value *array_obj, bt_bool val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *bool_obj = NULL;
+
+ bool_obj = bt_ctf_private_value_bool_create_init(val);
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) bool_obj);
+ bt_ctf_object_put_ref(bool_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
+ struct bt_ctf_private_value *array_obj, int64_t val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *integer_obj = NULL;
+
+ integer_obj = bt_ctf_private_value_integer_create_init(val);
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) integer_obj);
+ bt_ctf_object_put_ref(integer_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
+ struct bt_ctf_private_value *array_obj, double val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *real_obj = NULL;
+
+ real_obj = bt_ctf_private_value_real_create_init(val);
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) real_obj);
+ bt_ctf_object_put_ref(real_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
+ struct bt_ctf_private_value *array_obj, const char *val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *string_obj = NULL;
+
+ string_obj = bt_ctf_private_value_string_create_init(val);
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) string_obj);
+ bt_ctf_object_put_ref(string_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
+ struct bt_ctf_private_value *array_obj)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *empty_array_obj = NULL;
+
+ empty_array_obj = bt_ctf_private_value_array_create();
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) empty_array_obj);
+ bt_ctf_object_put_ref(empty_array_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
+ struct bt_ctf_private_value *array_obj)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *map_obj = NULL;
+
+ map_obj = bt_ctf_private_value_map_create();
+ ret = bt_ctf_private_value_array_append_element(array_obj,
+ (void *) map_obj);
+ bt_ctf_object_put_ref(map_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
+ struct bt_ctf_private_value *array_obj, uint64_t index,
+ struct bt_ctf_value *element_obj)
+{
+ struct bt_ctf_value_array *typed_array_obj =
+ BT_CTF_VALUE_TO_ARRAY(array_obj);
+
+ BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
+ BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY);
+ BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
+ BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
+ typed_array_obj->garray->len);
+ bt_ctf_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index));
+ g_ptr_array_index(typed_array_obj->garray, index) = element_obj;
+ bt_ctf_object_get_ref(element_obj);
+ BT_LOGV("Set array value's element: array-value-addr=%p, "
+ "index=%" PRIu64 ", element-value-addr=%p",
+ array_obj, index, element_obj);
+ return BT_CTF_VALUE_STATUS_OK;
+}
+
+BT_HIDDEN
+uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP);
+ return (uint64_t) g_hash_table_size(BT_CTF_VALUE_TO_MAP(map_obj)->ght);
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(const struct bt_ctf_value *map_obj,
+ const char *key)
+{
+ BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
+ BT_ASSERT_PRE_NON_NULL(key, "Key");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP);
+ return g_hash_table_lookup(BT_CTF_VALUE_TO_MAP(map_obj)->ght,
+ GUINT_TO_POINTER(g_quark_from_string(key)));
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value(
+ const struct bt_ctf_private_value *map_obj, const char *key)
+{
+ return (void *) bt_ctf_value_map_borrow_entry_value((void *) map_obj, key);
+}
+
+BT_HIDDEN
+bt_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj, const char *key)
+{
+ BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
+ BT_ASSERT_PRE_NON_NULL(key, "Key");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP);
+ return bt_g_hash_table_contains(BT_CTF_VALUE_TO_MAP(map_obj)->ght,
+ GUINT_TO_POINTER(g_quark_from_string(key)));
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
+ struct bt_ctf_private_value *map_obj,
+ const char *key, struct bt_ctf_value *element_obj)
+{
+ BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object");
+ BT_ASSERT_PRE_NON_NULL(key, "Key");
+ BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP);
+ BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object");
+ g_hash_table_insert(BT_CTF_VALUE_TO_MAP(map_obj)->ght,
+ GUINT_TO_POINTER(g_quark_from_string(key)), element_obj);
+ bt_ctf_object_get_ref(element_obj);
+ BT_LOGV("Inserted value into map value: map-value-addr=%p, "
+ "key=\"%s\", element-value-addr=%p",
+ map_obj, key, element_obj);
+ return BT_CTF_VALUE_STATUS_OK;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, bt_bool val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *bool_obj = NULL;
+
+ bool_obj = bt_ctf_private_value_bool_create_init(val);
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) bool_obj);
+ bt_ctf_object_put_ref(bool_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, int64_t val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *integer_obj = NULL;
+
+ integer_obj = bt_ctf_private_value_integer_create_init(val);
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) integer_obj);
+ bt_ctf_object_put_ref(integer_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, double val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *real_obj = NULL;
+
+ real_obj = bt_ctf_private_value_real_create_init(val);
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) real_obj);
+ bt_ctf_object_put_ref(real_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
+ struct bt_ctf_private_value *map_obj, const char *key,
+ const char *val)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *string_obj = NULL;
+
+ string_obj = bt_ctf_private_value_string_create_init(val);
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) string_obj);
+ bt_ctf_object_put_ref(string_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
+ struct bt_ctf_private_value *map_obj, const char *key)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *array_obj = NULL;
+
+ array_obj = bt_ctf_private_value_array_create();
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) array_obj);
+ bt_ctf_object_put_ref(array_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
+ struct bt_ctf_private_value *map_obj, const char *key)
+{
+ enum bt_ctf_value_status ret;
+ struct bt_ctf_private_value *empty_map_obj = NULL;
+
+ empty_map_obj = bt_ctf_private_value_map_create();
+ ret = bt_ctf_private_value_map_insert_entry(map_obj, key,
+ (void *) empty_map_obj);
+ bt_ctf_object_put_ref(empty_map_obj);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(const struct bt_ctf_value *map_obj,
+ bt_ctf_value_map_foreach_entry_cb cb, void *data)
+{
+ enum bt_ctf_value_status ret = BT_CTF_VALUE_STATUS_OK;
+ gpointer key, element_obj;
+ GHashTableIter iter;
+ struct bt_ctf_value_map *typed_map_obj = BT_CTF_VALUE_TO_MAP(map_obj);
+
+ BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
+ BT_ASSERT_PRE_NON_NULL(cb, "Callback");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP);
+ g_hash_table_iter_init(&iter, typed_map_obj->ght);
+
+ while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
+ const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
+
+ if (!cb(key_str, element_obj, data)) {
+ BT_LOGV("User canceled the loop: key=\"%s\", "
+ "value-addr=%p, data=%p",
+ key_str, element_obj, data);
+ ret = BT_CTF_VALUE_STATUS_CANCELED;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_foreach_entry(
+ const struct bt_ctf_private_value *map_obj,
+ bt_ctf_private_value_map_foreach_entry_cb cb, void *data)
+{
+ return bt_ctf_value_map_foreach_entry((void *) map_obj,
+ (bt_ctf_value_map_foreach_entry_cb) cb, data);
+}
+
+struct extend_map_element_data {
+ struct bt_ctf_private_value *extended_obj;
+ enum bt_ctf_value_status status;
+};
+
+static
+bt_bool extend_map_element(const char *key,
+ struct bt_ctf_value *extension_obj_elem, void *data)
+{
+ bt_bool ret = BT_TRUE;
+ struct extend_map_element_data *extend_data = data;
+ struct bt_ctf_private_value *extension_obj_elem_copy = NULL;
+
+ /* Copy object which is to replace the current one */
+ extend_data->status = bt_ctf_value_copy(&extension_obj_elem_copy,
+ extension_obj_elem);
+ if (extend_data->status) {
+ BT_LOGE("Cannot copy map element: addr=%p",
+ extension_obj_elem);
+ goto error;
+ }
+
+ BT_ASSERT(extension_obj_elem_copy);
+
+ /* Replace in extended object */
+ extend_data->status = bt_ctf_private_value_map_insert_entry(
+ extend_data->extended_obj, key,
+ (void *) extension_obj_elem_copy);
+ if (extend_data->status) {
+ BT_LOGE("Cannot replace value in extended value: key=\"%s\", "
+ "extended-value-addr=%p, element-value-addr=%p",
+ key, extend_data->extended_obj,
+ extension_obj_elem_copy);
+ goto error;
+ }
+
+ goto end;
+
+error:
+ BT_ASSERT(extend_data->status != BT_CTF_VALUE_STATUS_OK);
+ ret = BT_FALSE;
+
+end:
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy);
+ return ret;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_extend(
+ struct bt_ctf_private_value **extended_map_obj,
+ const struct bt_ctf_value *base_map_obj,
+ const struct bt_ctf_value *extension_obj)
+{
+ struct extend_map_element_data extend_data = {
+ .extended_obj = NULL,
+ .status = BT_CTF_VALUE_STATUS_OK,
+ };
+
+ BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
+ BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
+ BT_ASSERT_PRE_NON_NULL(extended_map_obj,
+ "Extended value object (output)");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_CTF_VALUE_TYPE_MAP);
+ BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_CTF_VALUE_TYPE_MAP);
+ BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
+ base_map_obj, extension_obj);
+ *extended_map_obj = NULL;
+
+ /* Create copy of base map object to start with */
+ extend_data.status = bt_ctf_value_copy(extended_map_obj, base_map_obj);
+ if (extend_data.status) {
+ BT_LOGE("Cannot copy base value: base-value-addr=%p",
+ base_map_obj);
+ goto error;
+ }
+
+ BT_ASSERT(extended_map_obj);
+
+ /*
+ * For each key in the extension map object, replace this key
+ * in the copied map object.
+ */
+ extend_data.extended_obj = *extended_map_obj;
+
+ if (bt_ctf_value_map_foreach_entry(extension_obj, extend_map_element,
+ &extend_data)) {
+ BT_LOGE("Cannot iterate on the extension object's elements: "
+ "extension-value-addr=%p", extension_obj);
+ goto error;
+ }
+
+ if (extend_data.status) {
+ BT_LOGE("Failed to successfully iterate on the extension object's elements: "
+ "extension-value-addr=%p", extension_obj);
+ goto error;
+ }
+
+ BT_LOGD("Extended map value: extended-value-addr=%p",
+ *extended_map_obj);
+ goto end;
+
+error:
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(*extended_map_obj);
+ *extended_map_obj = NULL;
+
+end:
+ return extend_data.status;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy_obj,
+ const struct bt_ctf_value *object)
+{
+ enum bt_ctf_value_status status = BT_CTF_VALUE_STATUS_OK;
+
+ BT_ASSERT_PRE_NON_NULL(object, "Value object");
+ BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)");
+ BT_LOGD("Copying value object: addr=%p", object);
+ *copy_obj = copy_funcs[object->type](object);
+ if (*copy_obj) {
+ BT_LOGD("Copied value object: copy-value-addr=%p",
+ copy_obj);
+ } else {
+ status = BT_CTF_VALUE_STATUS_NOMEM;
+ *copy_obj = NULL;
+ BT_LOGE_STR("Failed to copy value object.");
+ }
+
+ return status;
+}
+
+BT_HIDDEN
+bt_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b)
+{
+ bt_bool ret = BT_FALSE;
+
+ BT_ASSERT_PRE_NON_NULL(object_a, "Value object A");
+ BT_ASSERT_PRE_NON_NULL(object_b, "Value object B");
+
+ if (object_a->type != object_b->type) {
+ BT_LOGV("Values are different: type mismatch: "
+ "value-a-addr=%p, value-b-addr=%p, "
+ "value-a-type=%d, value-b-type=%d",
+ object_a, object_b, object_a->type, object_b->type);
+ goto end;
+ }
+
+ ret = compare_funcs[object_a->type](object_a, object_b);
+
+end:
+ return ret;
+}
*/
#include <babeltrace/ctf-writer/visitor-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
BT_HIDDEN
int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root,
goto end;
}
ret = child_visitor(child, visitor, data);
- BT_OBJECT_PUT_REF_AND_RESET(child);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(child);
if (ret) {
goto end;
}
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/object.h>
+#include <babeltrace/ctf-writer/object.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <unistd.h>
static
-void bt_ctf_writer_destroy(struct bt_object *obj);
+void bt_ctf_writer_destroy(struct bt_ctf_object *obj);
static
int init_trace_packet_header(struct bt_ctf_trace *trace)
goto end;
}
end:
- bt_object_put_ref(uuid_array_type);
- bt_object_put_ref(_uint32_t);
- bt_object_put_ref(_uint8_t);
- bt_object_put_ref(trace_packet_header_type);
+ bt_ctf_object_put_ref(uuid_array_type);
+ bt_ctf_object_put_ref(_uint32_t);
+ bt_ctf_object_put_ref(_uint8_t);
+ bt_ctf_object_put_ref(trace_packet_header_type);
return ret;
}
metadata_path = g_build_filename(path, "metadata", NULL);
- bt_object_init_shared(&writer->base, bt_ctf_writer_destroy);
+ bt_ctf_object_init_shared(&writer->base, bt_ctf_writer_destroy);
writer->path = g_string_new(path);
if (!writer->path) {
goto error_destroy;
goto error_destroy;
}
- bt_object_set_parent(&writer->trace->common.base, &writer->base);
- bt_object_put_ref(writer->trace);
+ bt_ctf_object_set_parent(&writer->trace->common.base, &writer->base);
+ bt_ctf_object_put_ref(writer->trace);
/* Default to little-endian */
ret = bt_ctf_writer_set_byte_order(writer, BT_CTF_BYTE_ORDER_NATIVE);
return writer;
error_destroy:
- BT_OBJECT_PUT_REF_AND_RESET(writer);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(writer);
error:
g_free(metadata_path);
return writer;
}
-void bt_ctf_writer_destroy(struct bt_object *obj)
+void bt_ctf_writer_destroy(struct bt_ctf_object *obj)
{
struct bt_ctf_writer *writer;
}
}
- bt_object_try_spec_release(&writer->trace->common.base);
+ bt_ctf_object_try_spec_release(&writer->trace->common.base);
g_free(writer);
}
}
trace = writer->trace;
- bt_object_get_ref(trace);
+ bt_ctf_object_get_ref(trace);
end:
return trace;
}
stream_class_found = BT_TRUE;
}
- BT_OBJECT_PUT_REF_AND_RESET(existing_stream_class);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(existing_stream_class);
if (stream_class_found) {
break;
return stream;
error:
- BT_OBJECT_PUT_REF_AND_RESET(stream);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(stream);
return stream;
}
field_type = bt_ctf_field_type_integer_create(size);
ret = bt_ctf_field_type_set_alignment(field_type, alignment);
if (ret) {
- BT_OBJECT_PUT_REF_AND_RESET(field_type);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(field_type);
}
end:
return field_type;
#define DEFAULT_CLOCK_TIME 0
#define DEFAULT_CLOCK_VALUE 0
-#define NR_TESTS 335
+#define NR_TESTS 325
struct bt_utsname {
char sysname[BABELTRACE_HOST_NAME_MAX];
struct bt_ctf_field *packet_header, *packet_header_field;
struct bt_ctf_trace *trace;
int ret;
- int64_t ret_int64_t;
- struct bt_value *obj;
if (argc < 2) {
printf("Usage: tests-ctf-writer path_to_babeltrace\n");
"oh yeah"),
"bt_ctf_trace_set_environment_field_string succeeds");
- /* Test bt_ctf_trace_get_environment_field_count */
- ok(bt_ctf_trace_get_environment_field_count(trace) == 3,
- "bt_ctf_trace_get_environment_field_count returns a correct number of environment fields");
-
- /* Test bt_ctf_trace_get_environment_field_name */
- ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 0);
- ok(ret_string && !strcmp(ret_string, "host"),
- "bt_ctf_trace_get_environment_field_name returns a correct field name");
- ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 1);
- ok(ret_string && !strcmp(ret_string, "test_env_int"),
- "bt_ctf_trace_get_environment_field_name returns a correct field name");
- ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 2);
- ok(ret_string && !strcmp(ret_string, "test_env_str"),
- "bt_ctf_trace_get_environment_field_name returns a correct field name");
-
- /* Test bt_ctf_trace_get_environment_field_value */
- obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 1);
- ret_int64_t = bt_value_integer_get(obj);
- ok(ret_int64_t == -164973,
- "bt_ctf_trace_get_environment_field_value succeeds in getting an integer value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 2);
- ret_string = bt_value_string_get(obj);
- ok(ret_string && !strcmp(ret_string, "oh yeah"),
- "bt_ctf_trace_get_environment_field_value succeeds in getting a string value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
-
- /* Test bt_ctf_trace_get_environment_field_value_by_name */
- ok(!bt_ctf_trace_get_environment_field_value_by_name(trace, "oh oh"),
- "bt_ctf_trace_get_environment_field_value_by_name returns NULL or an unknown field name");
- obj = bt_ctf_trace_get_environment_field_value_by_name(trace,
- "test_env_str");
- ret_string = bt_value_string_get(obj);
- ok(ret_string && !strcmp(ret_string, "oh yeah"),
- "bt_ctf_trace_get_environment_field_value_by_name succeeds in getting an existing field");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
-
/* Test environment field replacement */
ok(!bt_ctf_trace_set_environment_field_integer(trace, "test_env_int",
654321),
"bt_ctf_trace_set_environment_field_integer succeeds with an existing name");
- ok(bt_ctf_trace_get_environment_field_count(trace) == 3,
- "bt_ctf_trace_set_environment_field_integer with an existing key does not increase the environment size");
- obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 1);
- ret_int64_t = bt_value_integer_get(obj);
- ok(ret_int64_t == 654321,
- "bt_ctf_trace_get_environment_field_value successfully replaces an existing field");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
ok(bt_ctf_writer_add_environment_field(writer, "sysname", name.sysname)
== 0, "Add sysname (%s) environment field to writer instance",