*/
#define BT_LOG_TAG "LIB/FIELD-CLASS"
-#include "lib/lib-logging.h"
+#include "lib/logging.h"
#include "lib/assert-pre.h"
#include <babeltrace2/trace-ir/field-class.h>
#include "field.h"
#include "field-path.h"
#include "utils.h"
+#include "lib/func-status.h"
enum bt_field_class_type bt_field_class_get_type(
const struct bt_field_class *fc)
bt_common_field_class_type_string(type));
int_fc = g_new0(struct bt_field_class_integer, 1);
if (!int_fc) {
- BT_LOGE_STR("Failed to allocate one integer field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one integer field class.");
goto error;
}
bt_common_field_class_type_string(type));
enum_fc = g_new0(struct bt_field_class_enumeration, 1);
if (!enum_fc) {
- BT_LOGE_STR("Failed to allocate one enumeration field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one enumeration field class.");
goto error;
}
enum_fc->mappings = g_array_new(FALSE, TRUE,
sizeof(struct bt_field_class_enumeration_mapping));
if (!enum_fc->mappings) {
- BT_LOGE_STR("Failed to allocate a GArray.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
goto error;
}
enum_fc->label_buf = g_ptr_array_new();
if (!enum_fc->label_buf) {
- BT_LOGE_STR("Failed to allocate a GArray.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
goto error;
}
(uint64_t *) lower, (uint64_t *) upper);
}
-enum bt_field_class_status
+enum bt_field_class_enumeration_get_mapping_labels_by_value_status
bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
const struct bt_field_class *fc, uint64_t value,
bt_field_class_enumeration_mapping_label_array *label_array,
*label_array = (void *) enum_fc->label_buf->pdata;
*count = (uint64_t) enum_fc->label_buf->len;
- return BT_FIELD_CLASS_STATUS_OK;
+ return BT_FUNC_STATUS_OK;
}
-enum bt_field_class_status
+enum bt_field_class_enumeration_get_mapping_labels_by_value_status
bt_field_class_signed_enumeration_get_mapping_labels_by_value(
const struct bt_field_class *fc, int64_t value,
bt_field_class_enumeration_mapping_label_array *label_array,
*label_array = (void *) enum_fc->label_buf->pdata;
*count = (uint64_t) enum_fc->label_buf->len;
- return BT_FIELD_CLASS_STATUS_OK;
+ return BT_FUNC_STATUS_OK;
}
static inline
-enum bt_field_class_status add_mapping_to_enumeration_field_class(
+enum bt_field_class_enumeration_map_range_status
+add_mapping_to_enumeration_field_class(
struct bt_field_class *fc,
const char *label, uint64_t lower, uint64_t upper)
{
- int ret = BT_FIELD_CLASS_STATUS_OK;
+ int ret = BT_FUNC_STATUS_OK;
uint64_t i;
struct bt_field_class_enumeration *enum_fc = (void *) fc;
struct bt_field_class_enumeration_mapping *mapping = NULL;
finalize_enumeration_field_class_mapping(mapping);
g_array_set_size(enum_fc->mappings,
enum_fc->mappings->len - 1);
- ret = BT_FIELD_CLASS_STATUS_NOMEM;
+ ret = BT_FUNC_STATUS_MEMORY_ERROR;
goto end;
}
finalize_enumeration_field_class_mapping(mapping);
g_array_set_size(enum_fc->mappings,
enum_fc->mappings->len - 1);
- ret = BT_FIELD_CLASS_STATUS_NOMEM;
+ ret = BT_FUNC_STATUS_MEMORY_ERROR;
goto end;
}
}
return ret;
}
-enum bt_field_class_status bt_field_class_unsigned_enumeration_map_range(
+enum bt_field_class_enumeration_map_range_status bt_field_class_unsigned_enumeration_map_range(
struct bt_field_class *fc, const char *label,
uint64_t range_lower, uint64_t range_upper)
{
range_upper);
}
-enum bt_field_class_status bt_field_class_signed_enumeration_map_range(
+enum bt_field_class_enumeration_map_range_status bt_field_class_signed_enumeration_map_range(
struct bt_field_class *fc, const char *label,
int64_t range_lower, int64_t range_upper)
{
BT_LOGD_STR("Creating default real field class object.");
real_fc = g_new0(struct bt_field_class_real, 1);
if (!real_fc) {
- BT_LOGE_STR("Failed to allocate one real field class.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one real field class.");
goto error;
}
fc->named_fcs = g_array_new(FALSE, TRUE,
sizeof(struct bt_named_field_class));
if (!fc->named_fcs) {
- BT_LOGE_STR("Failed to allocate a GArray.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
ret = -1;
goto end;
}
fc->name_to_index = g_hash_table_new(g_str_hash, g_str_equal);
if (!fc->name_to_index) {
- BT_LOGE_STR("Failed to allocate a GHashTable.");
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GHashTable.");
ret = -1;
goto end;
}
BT_LOGD_STR("Creating default structure field class object.");
struct_fc = g_new0(struct bt_field_class_structure, 1);
if (!struct_fc) {
- BT_LOGE_STR("Failed to allocate one structure field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one structure field class.");
goto error;
}
}
static
-enum bt_field_class_status append_named_field_class_to_container_field_class(
+int append_named_field_class_to_container_field_class(
struct bt_field_class_named_field_class_container *container_fc,
const char *name, struct bt_field_class *fc)
{
- int ret = BT_FIELD_CLASS_STATUS_OK;
+ int ret = BT_FUNC_STATUS_OK;
struct bt_named_field_class *named_fc;
GString *name_str;
"%![container-fc-]+F, name=\"%s\"", container_fc, name);
name_str = g_string_new(name);
if (!name_str) {
- BT_LOGE_STR("Failed to allocate a GString.");
- ret = BT_FIELD_CLASS_STATUS_NOMEM;
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
+ ret = BT_FUNC_STATUS_MEMORY_ERROR;
goto end;
}
return ret;
}
-enum bt_field_class_status bt_field_class_structure_append_member(
+enum bt_field_class_structure_append_member_status
+bt_field_class_structure_append_member(
struct bt_field_class *fc, const char *name,
struct bt_field_class *member_fc)
{
BT_LOGD_STR("Creating default variant field class object.");
var_fc = g_new0(struct bt_field_class_variant, 1);
if (!var_fc) {
- BT_LOGE_STR("Failed to allocate one variant field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one variant field class.");
goto error;
}
return (void *) var_fc;
}
-enum bt_field_class_status bt_field_class_variant_set_selector_field_class(
+enum bt_field_class_variant_set_selector_field_class_status
+bt_field_class_variant_set_selector_field_class(
struct bt_field_class *fc,
struct bt_field_class *selector_fc)
{
var_fc->selector_fc = selector_fc;
bt_object_get_no_null_check(selector_fc);
bt_field_class_freeze(selector_fc);
- return BT_FIELD_CLASS_STATUS_OK;
+ return BT_FUNC_STATUS_OK;
}
-enum bt_field_class_status bt_field_class_variant_append_option(
+enum bt_field_class_variant_append_option_status
+bt_field_class_variant_append_option(
struct bt_field_class *fc,
const char *name, struct bt_field_class *option_fc)
{
BT_LOGD_STR("Creating default static array field class object.");
array_fc = g_new0(struct bt_field_class_static_array, 1);
if (!array_fc) {
- BT_LOGE_STR("Failed to allocate one static array field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one static array field class.");
goto error;
}
BT_LOGD_STR("Creating default dynamic array field class object.");
array_fc = g_new0(struct bt_field_class_dynamic_array, 1);
if (!array_fc) {
- BT_LOGE_STR("Failed to allocate one dynamic array field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one dynamic array field class.");
goto error;
}
return (void *) array_fc;
}
-enum bt_field_class_status bt_field_class_dynamic_array_set_length_field_class(
+enum bt_field_class_dynamic_array_set_length_field_class_status
+bt_field_class_dynamic_array_set_length_field_class(
struct bt_field_class *fc,
struct bt_field_class *length_fc)
{
array_fc->length_fc = length_fc;
bt_object_get_no_null_check(length_fc);
bt_field_class_freeze(length_fc);
- return BT_FIELD_CLASS_STATUS_OK;
+ return BT_FUNC_STATUS_OK;
}
const struct bt_field_path *
BT_LOGD_STR("Creating default string field class object.");
string_fc = g_new0(struct bt_field_class_string, 1);
if (!string_fc) {
- BT_LOGE_STR("Failed to allocate one string field class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate one string field class.");
goto error;
}