#include <stdlib.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/common-internal.h>
#include "babeltrace-cfg.h"
#include "babeltrace-cfg-cli-args-connect.h"
{
size_t i;
int ret = 0;
- struct bt_value *connected_components = bt_value_map_create();
+ struct bt_private_value *connected_components =
+ bt_private_value_map_create();
if (!connected_components) {
ret = -1;
struct bt_config_connection *connection =
g_ptr_array_index(cfg->cmd_data.run.connections, i);
- ret = bt_value_map_insert_entry(connected_components,
+ ret = bt_private_value_map_insert_entry(connected_components,
connection->upstream_comp_name->str, bt_value_null);
if (ret) {
goto end;
}
- ret = bt_value_map_insert_entry(connected_components,
+ ret = bt_private_value_map_insert_entry(connected_components,
connection->downstream_comp_name->str, bt_value_null);
if (ret) {
goto end;
}
ret = validate_all_components_connected_in_array(
- cfg->cmd_data.run.sources, connected_components,
+ cfg->cmd_data.run.sources,
+ bt_value_borrow_from_private(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
}
ret = validate_all_components_connected_in_array(
- cfg->cmd_data.run.filters, connected_components,
+ cfg->cmd_data.run.filters,
+ bt_value_borrow_from_private(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
}
ret = validate_all_components_connected_in_array(
- cfg->cmd_data.run.sinks, connected_components,
+ cfg->cmd_data.run.sinks,
+ bt_value_borrow_from_private(connected_components),
error_buf, error_buf_size);
if (ret) {
goto end;
{
size_t i;
int ret = 0;
- struct bt_value *flat_connection_names = bt_value_map_create();
+ struct bt_private_value *flat_connection_names =
+ bt_private_value_map_create();
GString *flat_connection_name = NULL;
if (!flat_connection_names) {
connection->downstream_comp_name->str,
connection->downstream_port_glob->str);
- if (bt_value_map_has_entry(flat_connection_names,
+ if (bt_value_map_has_entry(bt_value_borrow_from_private(
+ flat_connection_names),
flat_connection_name->str)) {
snprintf(error_buf, error_buf_size,
"Duplicate connection:\n %s\n",
goto end;
}
- ret = bt_value_map_insert_entry(flat_connection_names,
+ ret = bt_private_value_map_insert_entry(flat_connection_names,
flat_connection_name->str, bt_value_null);
if (ret) {
goto end;
*/
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include "babeltrace-cfg.h"
#include "babeltrace-cfg-cli-args.h"
#include "babeltrace-cfg-cli-args-default.h"
struct bt_config *bt_config_cli_args_create_with_default(int argc,
const char *argv[], int *retcode)
{
- struct bt_value *initial_plugin_paths;
+ struct bt_private_value *initial_plugin_paths;
struct bt_config *cfg = NULL;
int ret;
- initial_plugin_paths = bt_value_array_create();
+ initial_plugin_paths = bt_private_value_array_create();
if (!initial_plugin_paths) {
goto error;
}
#include <babeltrace/babeltrace.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <popt.h>
#include <glib.h>
#include <sys/types.h>
GScanner *scanner;
/* Output map value object being filled (owned by this) */
- struct bt_value *params;
+ struct bt_private_value *params;
/* Next expected FSM state */
enum ini_parsing_fsm_state expecting;
goto error;
}
- if (bt_value_map_has_entry(state->params, state->last_map_key)) {
+ if (bt_value_map_has_entry(
+ bt_value_borrow_from_private(state->params),
+ state->last_map_key)) {
g_string_append_printf(state->ini_error,
"Duplicate parameter key: `%s`\n",
state->last_map_key);
goto error;
}
- value = bt_value_integer_create_init(
- (int64_t) int_val);
+ value = bt_value_borrow_from_private(
+ bt_private_value_integer_create_init(
+ (int64_t) int_val));
break;
}
case G_TOKEN_FLOAT:
/* Positive floating point number */
- value = bt_value_real_create_init(
- state->scanner->value.v_float);
+ value = bt_value_borrow_from_private(
+ bt_private_value_real_create_init(
+ state->scanner->value.v_float));
break;
case G_TOKEN_STRING:
/* Quoted string */
- value = bt_value_string_create_init(
- state->scanner->value.v_string);
+ value = bt_value_borrow_from_private(
+ bt_private_value_string_create_init(
+ state->scanner->value.v_string));
break;
case G_TOKEN_IDENTIFIER:
{
} else if (!strcmp(id, "true") || !strcmp(id, "TRUE") ||
!strcmp(id, "yes") ||
!strcmp(id, "YES")) {
- value = bt_value_bool_create_init(true);
+ value = bt_value_borrow_from_private(
+ bt_private_value_bool_create_init(true));
} else if (!strcmp(id, "false") ||
!strcmp(id, "FALSE") ||
!strcmp(id, "no") ||
!strcmp(id, "NO")) {
- value = bt_value_bool_create_init(false);
+ value = bt_value_borrow_from_private(
+ bt_private_value_bool_create_init(false));
} else {
- value = bt_value_string_create_init(id);
+ value = bt_value_borrow_from_private(
+ bt_private_value_string_create_init(id));
}
break;
}
goto error;
}
- value = bt_value_integer_create_init(
- -((int64_t) int_val));
+ value = bt_value_borrow_from_private(
+ bt_private_value_integer_create_init(
+ -((int64_t) int_val)));
break;
}
case G_TOKEN_FLOAT:
/* Negative floating point number */
- value = bt_value_real_create_init(
- -state->scanner->value.v_float);
+ value = bt_value_borrow_from_private(
+ bt_private_value_real_create_init(
+ -state->scanner->value.v_float));
break;
default:
/* Unset value variable will trigger the error */
success:
if (value) {
- if (bt_value_map_insert_entry(state->params,
+ if (bt_private_value_map_insert_entry(state->params,
state->last_map_key, value)) {
/* Only override return value on error */
ret = -1;
* Return value is owned by the caller.
*/
static
-struct bt_value *bt_value_from_ini(const char *arg, GString *ini_error)
+struct bt_private_value *bt_private_value_from_ini(const char *arg,
+ GString *ini_error)
{
/* Lexical scanner configuration */
GScannerConfig scanner_config = {
.ini_error = ini_error,
};
- state.params = bt_value_map_create();
+ state.params = bt_private_value_map_create();
if (!state.params) {
goto error;
}
* Return value is owned by the caller.
*/
static
-struct bt_value *bt_value_from_arg(const char *arg)
+struct bt_private_value *bt_private_value_from_arg(const char *arg)
{
- struct bt_value *params = NULL;
+ struct bt_private_value *params = NULL;
GString *ini_error = NULL;
ini_error = g_string_new(NULL);
}
/* Try INI-style parsing */
- params = bt_value_from_ini(arg, ini_error);
+ params = bt_private_value_from_ini(arg, ini_error);
if (!params) {
printf_err("%s", ini_error->str);
goto end;
if (ini_error) {
g_string_free(ini_error, TRUE);
}
+
return params;
}
}
/* Start with empty parameters */
- cfg_component->params = bt_value_map_create();
+ cfg_component->params = bt_private_value_map_create();
if (!cfg_component->params) {
print_err_oom();
goto error;
* Return value is owned by the caller.
*/
static
-struct bt_value *names_from_arg(const char *arg)
+struct bt_private_value *names_from_arg(const char *arg)
{
GScanner *scanner = NULL;
- struct bt_value *names = NULL;
+ struct bt_private_value *names = NULL;
bool found_all = false, found_none = false, found_item = false;
- names = bt_value_array_create();
+ names = bt_private_value_array_create();
if (!names) {
print_err_oom();
goto error;
!strcmp(identifier, "args") ||
!strcmp(identifier, "arg")) {
found_item = true;
- if (bt_value_array_append_string_element(names,
+ if (bt_private_value_array_append_string_element(names,
"payload")) {
goto error;
}
} else if (!strcmp(identifier, "context") ||
!strcmp(identifier, "ctx")) {
found_item = true;
- if (bt_value_array_append_string_element(names,
+ if (bt_private_value_array_append_string_element(names,
"context")) {
goto error;
}
} else if (!strcmp(identifier, "scope") ||
!strcmp(identifier, "header")) {
found_item = true;
- if (bt_value_array_append_string_element(names,
+ if (bt_private_value_array_append_string_element(names,
identifier)) {
goto error;
}
} else if (!strcmp(identifier, "all")) {
found_all = true;
- if (bt_value_array_append_string_element(names,
+ if (bt_private_value_array_append_string_element(names,
identifier)) {
goto error;
}
} else if (!strcmp(identifier, "none")) {
found_none = true;
- if (bt_value_array_append_string_element(names,
+ if (bt_private_value_array_append_string_element(names,
identifier)) {
goto error;
}
* least one item is specified.
*/
if (found_item && !found_none && !found_all) {
- if (bt_value_array_append_string_element(names, "none")) {
+ if (bt_private_value_array_append_string_element(names, "none")) {
goto error;
}
}
* Return value is owned by the caller.
*/
static
-struct bt_value *fields_from_arg(const char *arg)
+struct bt_private_value *fields_from_arg(const char *arg)
{
GScanner *scanner = NULL;
- struct bt_value *fields;
+ struct bt_private_value *fields;
- fields = bt_value_array_create();
+ fields = bt_private_value_array_create();
if (!fields) {
print_err_oom();
goto error;
!strcmp(identifier, "emf") ||
!strcmp(identifier, "callsite") ||
!strcmp(identifier, "all")) {
- if (bt_value_array_append_string_element(fields,
+ if (bt_private_value_array_append_string_element(fields,
identifier)) {
goto error;
}
int add_run_cfg_comp_check_name(struct bt_config *cfg,
struct bt_config_component *cfg_comp,
enum bt_config_component_dest dest,
- struct bt_value *instance_names)
+ struct bt_private_value *instance_names)
{
int ret = 0;
goto end;
}
- if (bt_value_map_has_entry(instance_names, cfg_comp->instance_name->str)) {
+ if (bt_value_map_has_entry(bt_value_borrow_from_private(instance_names),
+ cfg_comp->instance_name->str)) {
printf_err("Duplicate component instance name:\n %s\n",
cfg_comp->instance_name->str);
ret = -1;
goto end;
}
- if (bt_value_map_insert_entry(instance_names,
+ if (bt_private_value_map_insert_entry(instance_names,
cfg_comp->instance_name->str, bt_value_null)) {
print_err_oom();
ret = -1;
}
static
-int append_env_var_plugin_paths(struct bt_value *plugin_paths)
+int append_env_var_plugin_paths(struct bt_private_value *plugin_paths)
{
int ret = 0;
const char *envvar;
}
static
-int append_home_and_system_plugin_paths(struct bt_value *plugin_paths,
+int append_home_and_system_plugin_paths(struct bt_private_value *plugin_paths,
bool omit_system_plugin_path, bool omit_home_plugin_path)
{
int ret;
static
struct bt_config *bt_config_base_create(enum bt_config_command command,
- struct bt_value *initial_plugin_paths, bool needs_plugins)
+ struct bt_private_value *initial_plugin_paths,
+ bool needs_plugins)
{
struct bt_config *cfg;
if (initial_plugin_paths) {
cfg->plugin_paths = bt_object_get_ref(initial_plugin_paths);
} else {
- cfg->plugin_paths = bt_value_array_create();
+ cfg->plugin_paths = bt_private_value_array_create();
if (!cfg->plugin_paths) {
print_err_oom();
goto error;
static
struct bt_config *bt_config_run_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_list_plugins_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_help_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_query_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_print_ctf_metadata_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_print_lttng_live_sessions_create(
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
int bt_config_append_plugin_paths_check_setuid_setgid(
- struct bt_value *plugin_paths, const char *arg)
+ struct bt_private_value *plugin_paths, const char *arg)
{
int ret = 0;
struct bt_config *bt_config_help_from_args(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
poptContext pc = NULL;
char *arg = NULL;
struct bt_config *bt_config_query_from_args(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
poptContext pc = NULL;
char *arg = NULL;
int ret;
struct bt_config *cfg = NULL;
const char *leftover;
- struct bt_value *params = bt_value_null;
+ struct bt_private_value *params = bt_private_value_null;
*retcode = 0;
cfg = bt_config_query_create(initial_plugin_paths);
case OPT_PARAMS:
{
bt_object_put_ref(params);
- params = bt_value_from_arg(arg);
+ params = bt_private_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
arg);
}
BT_ASSERT(params);
- BT_OBJECT_MOVE_REF(cfg->cmd_data.query.cfg_component->params, params);
+ BT_OBJECT_MOVE_REF(cfg->cmd_data.query.cfg_component->params,
+ params);
} else {
print_query_usage(stdout);
*retcode = -1;
struct bt_config *bt_config_list_plugins_from_args(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
poptContext pc = NULL;
char *arg = NULL;
struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
poptContext pc = NULL;
char *arg = NULL;
struct bt_config_component *cur_cfg_comp = NULL;
enum bt_config_component_dest cur_cfg_comp_dest =
BT_CONFIG_COMPONENT_DEST_UNKNOWN;
- struct bt_value *cur_base_params = NULL;
+ struct bt_private_value *cur_base_params = NULL;
int opt, ret = 0;
struct bt_config *cfg = NULL;
- struct bt_value *instance_names = NULL;
- struct bt_value *connection_args = NULL;
+ struct bt_private_value *instance_names = NULL;
+ struct bt_private_value *connection_args = NULL;
GString *cur_param_key = NULL;
char error_buf[256] = { 0 };
long retry_duration = -1;
cfg->cmd_data.run.retry_duration_us = 100000;
cfg->omit_system_plugin_path = force_omit_system_plugin_path;
cfg->omit_home_plugin_path = force_omit_home_plugin_path;
- cur_base_params = bt_value_map_create();
+ cur_base_params = bt_private_value_map_create();
if (!cur_base_params) {
print_err_oom();
goto error;
}
- instance_names = bt_value_map_create();
+ instance_names = bt_private_value_map_create();
if (!instance_names) {
print_err_oom();
goto error;
}
- connection_args = bt_value_array_create();
+ connection_args = bt_private_value_array_create();
if (!connection_args) {
print_err_oom();
goto error;
BT_ASSERT(cur_base_params);
bt_object_put_ref(cur_cfg_comp->params);
- cur_cfg_comp->params = bt_value_copy(cur_base_params);
+ cur_cfg_comp->params = bt_value_copy(
+ bt_value_borrow_from_private(cur_base_params));
if (!cur_cfg_comp->params) {
print_err_oom();
goto error;
}
case OPT_PARAMS:
{
- struct bt_value *params;
- struct bt_value *params_to_set;
+ struct bt_private_value *params;
+ struct bt_private_value *params_to_set;
if (!cur_cfg_comp) {
printf_err("Cannot add parameters to unavailable component:\n %s\n",
goto error;
}
- params = bt_value_from_arg(arg);
+ params = bt_private_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
arg);
goto error;
}
- params_to_set = bt_value_map_extend(cur_cfg_comp->params,
- params);
+ params_to_set = bt_value_map_extend(
+ bt_value_borrow_from_private(cur_cfg_comp->params),
+ bt_value_borrow_from_private(params));
BT_OBJECT_PUT_REF_AND_RESET(params);
if (!params_to_set) {
printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n",
goto error;
}
- if (bt_value_map_insert_string_entry(cur_cfg_comp->params,
+ if (bt_private_value_map_insert_string_entry(cur_cfg_comp->params,
cur_param_key->str, arg)) {
print_err_oom();
goto error;
break;
case OPT_BASE_PARAMS:
{
- struct bt_value *params = bt_value_from_arg(arg);
+ struct bt_private_value *params =
+ bt_private_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --base-params option's argument:\n %s\n",
}
case OPT_RESET_BASE_PARAMS:
BT_OBJECT_PUT_REF_AND_RESET(cur_base_params);
- cur_base_params = bt_value_map_create();
+ cur_base_params = bt_private_value_map_create();
if (!cur_base_params) {
print_err_oom();
goto error;
}
break;
case OPT_CONNECT:
- if (bt_value_array_append_string_element(
+ if (bt_private_value_array_append_string_element(
connection_args, arg)) {
print_err_oom();
goto error;
goto error;
}
- ret = bt_config_cli_args_create_connections(cfg, connection_args,
+ ret = bt_config_cli_args_create_connections(cfg,
+ bt_value_borrow_from_private(connection_args),
error_buf, 256);
if (ret) {
printf_err("Cannot creation connections:\n%s", error_buf);
struct bt_config *bt_config_run_from_args_array(struct bt_value *run_args,
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *cfg = NULL;
const char **argv;
GString *comp_arg;
GString *name_arg;
GString *params_arg;
- struct bt_value *extra_params;
+ struct bt_private_value *extra_params;
};
static
int assign_name_to_implicit_component(struct implicit_component_args *args,
- const char *prefix, struct bt_value *existing_names,
+ const char *prefix, struct bt_private_value *existing_names,
GList **comp_names, bool append_to_comp_names)
{
int ret = 0;
goto end;
}
- name = get_component_auto_name(prefix, existing_names);
+ name = get_component_auto_name(prefix,
+ bt_value_borrow_from_private(existing_names));
if (!name) {
ret = -1;
g_string_assign(args->name_arg, name->str);
- if (bt_value_map_insert_entry(existing_names, name->str,
+ if (bt_private_value_map_insert_entry(existing_names, name->str,
bt_value_null)) {
print_err_oom();
ret = -1;
static
int append_run_args_for_implicit_component(
struct implicit_component_args *impl_args,
- struct bt_value *run_args)
+ struct bt_private_value *run_args)
{
int ret = 0;
size_t i;
goto end;
}
- if (bt_value_array_append_string_element(run_args, "--component")) {
+ if (bt_private_value_array_append_string_element(run_args, "--component")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, impl_args->comp_arg->str)) {
+ if (bt_private_value_array_append_string_element(run_args, impl_args->comp_arg->str)) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--name")) {
+ if (bt_private_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, impl_args->name_arg->str)) {
+ if (bt_private_value_array_append_string_element(run_args, impl_args->name_arg->str)) {
print_err_oom();
goto error;
}
if (impl_args->params_arg->len > 0) {
- if (bt_value_array_append_string_element(run_args, "--params")) {
+ if (bt_private_value_array_append_string_element(run_args, "--params")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
impl_args->params_arg->str)) {
print_err_oom();
goto error;
}
}
- for (i = 0; i < bt_value_array_get_size(impl_args->extra_params); i++) {
+ for (i = 0; i < bt_value_array_get_size(
+ bt_value_borrow_from_private(impl_args->extra_params));
+ i++) {
struct bt_value *elem;
const char *arg;
elem = bt_value_array_borrow_element_by_index(
- impl_args->extra_params, i);
+ bt_value_borrow_from_private(impl_args->extra_params),
+ i);
if (!elem) {
goto error;
}
goto error;
}
- ret = bt_value_array_append_string_element(run_args, arg);
+ ret = bt_private_value_array_append_string_element(run_args, arg);
if (ret) {
print_err_oom();
goto error;
args->comp_arg = g_string_new(comp_arg);
args->name_arg = g_string_new(NULL);
args->params_arg = g_string_new(NULL);
- args->extra_params = bt_value_array_create();
+ args->extra_params = bt_private_value_array_create();
if (!args->comp_arg || !args->name_arg ||
!args->params_arg || !args->extra_params) {
BT_ASSERT(key);
BT_ASSERT(value);
- if (bt_value_array_append_string_element(args->extra_params, "--key")) {
+ if (bt_private_value_array_append_string_element(args->extra_params, "--key")) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_value_array_append_string_element(args->extra_params, key)) {
+ if (bt_private_value_array_append_string_element(args->extra_params, key)) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_value_array_append_string_element(args->extra_params, "--value")) {
+ if (bt_private_value_array_append_string_element(args->extra_params, "--value")) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_value_array_append_string_element(args->extra_params, value)) {
+ if (bt_private_value_array_append_string_element(args->extra_params, value)) {
print_err_oom();
ret = -1;
goto end;
static
int convert_append_name_param(enum bt_config_component_dest dest,
GString *cur_name, GString *cur_name_prefix,
- struct bt_value *run_args, struct bt_value *all_names,
+ struct bt_private_value *run_args,
+ struct bt_private_value *all_names,
GList **source_names, GList **filter_names,
GList **sink_names)
{
* component.
*/
name = get_component_auto_name(cur_name_prefix->str,
- all_names);
+ bt_value_borrow_from_private(all_names));
append_name_opt = true;
} else {
/*
* An explicit name was provided for the user
* component.
*/
- if (bt_value_map_has_entry(all_names,
+ if (bt_value_map_has_entry(
+ bt_value_borrow_from_private(all_names),
cur_name->str)) {
printf_err("Duplicate component instance name:\n %s\n",
cur_name->str);
* Remember this name globally, for the uniqueness of
* all component names.
*/
- if (bt_value_map_insert_entry(all_names, name->str, bt_value_null)) {
+ if (bt_private_value_map_insert_entry(all_names, name->str, bt_value_null)) {
print_err_oom();
goto error;
}
* Append the --name option if necessary.
*/
if (append_name_opt) {
- if (bt_value_array_append_string_element(run_args, "--name")) {
+ if (bt_private_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, name->str)) {
+ if (bt_private_value_array_append_string_element(run_args, name->str)) {
print_err_oom();
goto error;
}
* function.
*/
static
-int append_connect_arg(struct bt_value *run_args,
+int append_connect_arg(struct bt_private_value *run_args,
const char *upstream_name, const char *downstream_name)
{
int ret = 0;
goto end;
}
- ret = bt_value_array_append_string_element(run_args, "--connect");
+ ret = bt_private_value_array_append_string_element(run_args, "--connect");
if (ret) {
print_err_oom();
ret = -1;
g_string_append(arg, e_upstream_name->str);
g_string_append_c(arg, ':');
g_string_append(arg, e_downstream_name->str);
- ret = bt_value_array_append_string_element(run_args, arg->str);
+ ret = bt_private_value_array_append_string_element(run_args, arg->str);
if (ret) {
print_err_oom();
ret = -1;
* Appends the run command's --connect options for the convert command.
*/
static
-int convert_auto_connect(struct bt_value *run_args,
+int convert_auto_connect(struct bt_private_value *run_args,
GList *source_names, GList *filter_names,
GList *sink_names)
{
*/
BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
impl_args->extra_params =
- bt_value_copy(base_implicit_ctf_input_args->extra_params);
+ bt_value_copy(bt_value_borrow_from_private(
+ base_implicit_ctf_input_args->extra_params));
if (!impl_args->extra_params) {
print_err_oom();
destroy_implicit_component_args(impl_args);
struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths, char *log_level)
+ struct bt_private_value *initial_plugin_paths, char *log_level)
{
poptContext pc = NULL;
char *arg = NULL;
bool print_run_args = false;
bool print_run_args_0 = false;
bool print_ctf_metadata = false;
- struct bt_value *run_args = NULL;
- struct bt_value *all_names = NULL;
+ struct bt_private_value *run_args = NULL;
+ struct bt_private_value *all_names = NULL;
GList *source_names = NULL;
GList *filter_names = NULL;
GList *sink_names = NULL;
struct implicit_component_args implicit_debug_info_args = { 0 };
struct implicit_component_args implicit_muxer_args = { 0 };
struct implicit_component_args implicit_trimmer_args = { 0 };
- struct bt_value *plugin_paths = bt_object_get_ref(initial_plugin_paths);
+ struct bt_private_value *plugin_paths =
+ bt_object_get_ref(initial_plugin_paths);
char error_buf[256] = { 0 };
size_t i;
struct bt_common_lttng_live_url_parts lttng_live_url_parts = { 0 };
goto error;
}
- all_names = bt_value_map_create();
+ all_names = bt_private_value_map_create();
if (!all_names) {
print_err_oom();
goto error;
}
- run_args = bt_value_array_create();
+ run_args = bt_private_value_array_create();
if (!run_args) {
print_err_oom();
goto error;
abort();
}
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--component")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--params")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--key")) {
+ if (bt_private_value_array_append_string_element(run_args, "--key")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, "path")) {
+ if (bt_private_value_array_append_string_element(run_args, "path")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--value")) {
+ if (bt_private_value_array_append_string_element(run_args, "--value")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--key")) {
+ if (bt_private_value_array_append_string_element(run_args, "--key")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, "url")) {
+ if (bt_private_value_array_append_string_element(run_args, "url")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--value")) {
+ if (bt_private_value_array_append_string_element(run_args, "--value")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_value_array_append_string_element(run_args, "--name")) {
+ if (bt_private_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
case OPT_OMIT_HOME_PLUGIN_PATH:
force_omit_home_plugin_path = true;
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--omit-home-plugin-path")) {
print_err_oom();
goto error;
}
break;
case OPT_RETRY_DURATION:
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--retry-duration")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
case OPT_OMIT_SYSTEM_PLUGIN_PATH:
force_omit_system_plugin_path = true;
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--omit-system-plugin-path")) {
print_err_oom();
goto error;
goto error;
}
- if (bt_value_array_append_string_element(run_args,
+ if (bt_private_value_array_append_string_element(run_args,
"--plugin-path")) {
print_err_oom();
goto error;
}
- if (bt_value_array_append_string_element(run_args, arg)) {
+ if (bt_private_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
break;
case OPT_FIELDS:
{
- struct bt_value *fields = fields_from_arg(arg);
+ struct bt_private_value *fields = fields_from_arg(arg);
if (!fields) {
goto error;
implicit_text_args.exists = true;
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
- fields, "field");
+ bt_value_borrow_from_private(fields), "field");
bt_object_put_ref(fields);
if (ret) {
goto error;
}
case OPT_NAMES:
{
- struct bt_value *names = names_from_arg(arg);
+ struct bt_private_value *names = names_from_arg(arg);
if (!names) {
goto error;
implicit_text_args.exists = true;
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
- names, "name");
+ bt_value_borrow_from_private(names), "name");
bt_object_put_ref(names);
if (ret) {
goto error;
goto error;
}
- for (i = 0; i < bt_value_array_get_size(run_args); i++) {
+ for (i = 0; i < bt_value_array_get_size(
+ bt_value_borrow_from_private(run_args)); i++) {
struct bt_value *arg_value =
bt_value_array_borrow_element_by_index(
- run_args, i);
+ bt_value_borrow_from_private(run_args),
+ i);
const char *arg;
GString *quoted = NULL;
const char *arg_to_print;
g_string_free(quoted, TRUE);
}
- if (i < bt_value_array_get_size(run_args) - 1) {
+ if (i < bt_value_array_get_size(
+ bt_value_borrow_from_private(run_args)) - 1) {
if (print_run_args) {
putchar(' ');
} else {
goto end;
}
- cfg = bt_config_run_from_args_array(run_args, retcode,
+ cfg = bt_config_run_from_args_array(
+ bt_value_borrow_from_private(run_args), retcode,
force_omit_system_plugin_path, force_omit_home_plugin_path,
initial_plugin_paths);
if (!cfg) {
struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths)
+ struct bt_private_value *initial_plugin_paths)
{
struct bt_config *config = NULL;
int i;
*retcode = -1;
if (!initial_plugin_paths) {
- initial_plugin_paths = bt_value_array_create();
+ initial_plugin_paths = bt_private_value_array_create();
if (!initial_plugin_paths) {
*retcode = 1;
goto end;
struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_value *initial_plugin_paths);
+ struct bt_private_value *initial_plugin_paths);
#endif /* CLI_BABELTRACE_CFG_CLI_ARGS_H */
#include <babeltrace/common-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <glib.h>
#include "babeltrace-cfg.h"
* and appends them to the array value object plugin_paths.
*/
enum bt_value_status bt_config_append_plugin_paths(
- struct bt_value *plugin_paths, const char *arg)
+ struct bt_private_value *plugin_paths, const char *arg)
{
enum bt_value_status status = BT_VALUE_STATUS_OK;
GPtrArray *dirs = g_ptr_array_new_with_free_func(destroy_gstring);
for (i = 0; i < dirs->len; i++) {
GString *dir = g_ptr_array_index(dirs, i);
- status = bt_value_array_append_string_element(plugin_paths, dir->str);
+ status = bt_private_value_array_append_string_element(
+ plugin_paths, dir->str);
if (status != BT_VALUE_STATUS_OK) {
break;
}
enum bt_component_class_type type;
GString *plugin_name;
GString *comp_cls_name;
- struct bt_value *params;
+ struct bt_private_value *params;
GString *instance_name;
};
struct bt_object base;
bool debug;
bool verbose;
- struct bt_value *plugin_paths;
+ struct bt_private_value *plugin_paths;
bool omit_system_plugin_path;
bool omit_home_plugin_path;
bool command_needs_plugins;
}
enum bt_value_status bt_config_append_plugin_paths(
- struct bt_value *plugin_paths, const char *arg);
+ struct bt_private_value *plugin_paths, const char *arg);
void bt_config_connection_destroy(struct bt_config_connection *connection);
#include <babeltrace/babeltrace.h>
#include <babeltrace/common-internal.h>
-#include <babeltrace/values-internal.h>
#include <unistd.h>
#include <stdlib.h>
#include <popt.h>
error:
BT_LOGE("Error printing value of type %s.",
- bt_value_type_string(bt_value_get_type(value)));
+ bt_common_value_type_string(bt_value_get_type(value)));
}
static
}
fprintf(stderr, " Parameters:\n");
- print_value(stderr, bt_config_component->params, 8);
+ print_value(stderr,
+ bt_value_borrow_from_private(bt_config_component->params), 8);
}
static
{
size_t i;
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
fprintf(stderr, " Source component instances:\n");
print_bt_config_components(cfg->cmd_data.run.sources);
static
void print_cfg_list_plugins(struct bt_config *cfg)
{
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
}
static
void print_cfg_help(struct bt_config *cfg)
{
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
}
static
void print_cfg_print_ctf_metadata(struct bt_config *cfg)
{
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
fprintf(stderr, " Path: %s\n",
cfg->cmd_data.print_ctf_metadata.path->str);
}
static
void print_cfg_print_lttng_live_sessions(struct bt_config *cfg)
{
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
fprintf(stderr, " URL: %s\n",
cfg->cmd_data.print_lttng_live_sessions.url->str);
}
static
void print_cfg_query(struct bt_config *cfg)
{
- print_plugin_paths(cfg->plugin_paths);
+ print_plugin_paths(bt_value_borrow_from_private(cfg->plugin_paths));
fprintf(stderr, " Object: `%s`\n", cfg->cmd_data.query.object->str);
fprintf(stderr, " Component class:\n");
print_bt_config_component(cfg->cmd_data.query.cfg_component);
}
ret = query(comp_cls, cfg->cmd_data.query.object->str,
- cfg->cmd_data.query.cfg_component->params, &results,
- &fail_reason);
+ bt_value_borrow_from_private(cfg->cmd_data.query.cfg_component->params),
+ &results, &fail_reason);
if (ret) {
goto failed;
}
int plugins_count, component_classes_count = 0, i;
printf("From the following plugin paths:\n\n");
- print_value(stdout, cfg->plugin_paths, 2);
+ print_value(stdout, bt_value_borrow_from_private(cfg->plugin_paths), 2);
printf("\n");
plugins_count = loaded_plugins->len;
if (plugins_count == 0) {
int ret = 0;
struct bt_component_class *comp_cls = NULL;
struct bt_value *results = NULL;
- struct bt_value *params = NULL;
+ struct bt_private_value *params = NULL;
struct bt_value *map = NULL;
struct bt_value *v = NULL;
static const char * const plugin_name = "ctf";
goto error;
}
- params = bt_value_map_create();
+ params = bt_private_value_map_create();
if (!params) {
goto error;
}
- ret = bt_value_map_insert_string_entry(params, "url",
+ ret = bt_private_value_map_insert_string_entry(params, "url",
cfg->cmd_data.print_lttng_live_sessions.url->str);
if (ret) {
goto error;
}
- ret = query(comp_cls, "sessions", params, &results, &fail_reason);
+ ret = query(comp_cls, "sessions", bt_value_borrow_from_private(params),
+ &results, &fail_reason);
if (ret) {
goto failed;
}
int ret = 0;
struct bt_component_class *comp_cls = NULL;
struct bt_value *results = NULL;
- struct bt_value *params = NULL;
+ struct bt_private_value *params = NULL;
struct bt_value *metadata_text_value = NULL;
const char *metadata_text = NULL;
static const char * const plugin_name = "ctf";
goto end;
}
- params = bt_value_map_create();
+ params = bt_private_value_map_create();
if (!params) {
ret = -1;
goto end;
}
- ret = bt_value_map_insert_string_entry(params, "path",
+ ret = bt_private_value_map_insert_string_entry(params, "path",
cfg->cmd_data.print_ctf_metadata.path->str);
if (ret) {
ret = -1;
goto end;
}
- ret = query(comp_cls, "metadata-info", params, &results, &fail_reason);
+ ret = query(comp_cls, "metadata-info",
+ bt_value_borrow_from_private(params), &results, &fail_reason);
if (ret) {
goto failed;
}
struct bt_port *(*port_by_index_fn)(struct bt_component *, uint64_t);
enum bt_graph_status status = BT_GRAPH_STATUS_ERROR;
bool insert_trimmer = false;
- struct bt_value *trimmer_params = NULL;
+ struct bt_private_value *trimmer_params = NULL;
char *intersection_begin = NULL;
char *intersection_end = NULL;
struct bt_component *trimmer = NULL;
}
insert_trimmer = true;
- trimmer_params = bt_value_map_create();
+ trimmer_params = bt_private_value_map_create();
if (!trimmer_params) {
goto error;
}
- status = bt_value_map_insert_string_entry(
+ status = bt_private_value_map_insert_string_entry(
trimmer_params, "begin", intersection_begin);
if (status != BT_VALUE_STATUS_OK) {
goto error;
}
- status = bt_value_map_insert_string_entry(
+ status = bt_private_value_map_insert_string_entry(
trimmer_params,
"end", intersection_end);
if (status != BT_VALUE_STATUS_OK) {
ctx->connect_ports = false;
graph_status = bt_graph_add_component(ctx->graph,
- trimmer_class, trimmer_name, trimmer_params,
+ trimmer_class, trimmer_name,
+ bt_value_borrow_from_private(trimmer_params),
&trimmer);
free(trimmer_name);
if (graph_status != BT_GRAPH_STATUS_OK) {
enum bt_value_status value_status;
const char *path = NULL;
struct bt_value *component_path_value = NULL;
- struct bt_value *query_params = NULL;
+ struct bt_private_value *query_params = NULL;
struct bt_value *query_result = NULL;
struct bt_value *trace_info = NULL;
struct bt_value *intersection_range = NULL;
struct trace_range *trace_range = NULL;
const char *fail_reason = NULL;
- component_path_value = bt_value_map_borrow_entry_value(cfg_comp->params,
+ component_path_value = bt_value_map_borrow_entry_value(
+ bt_value_borrow_from_private(cfg_comp->params),
"path");
if (component_path_value && !bt_value_is_string(component_path_value)) {
BT_LOGD("Cannot get path parameter: component-name=%s",
goto error;
}
- query_params = bt_value_map_create();
+ query_params = bt_private_value_map_create();
if (!query_params) {
BT_LOGE_STR("Cannot create query parameters.");
ret = -1;
goto error;
}
- value_status = bt_value_map_insert_entry(query_params, "path",
+ value_status = bt_private_value_map_insert_entry(query_params, "path",
component_path_value);
if (value_status != BT_VALUE_STATUS_OK) {
BT_LOGE_STR("Cannot insert path parameter in query parameter map.");
goto error;
}
- ret = query(comp_cls, "trace-info", query_params, &query_result,
+ ret = query(comp_cls, "trace-info",
+ bt_value_borrow_from_private(query_params), &query_result,
&fail_reason);
if (ret) {
BT_LOGD("Component class does not support the `trace-info` query: %s: "
}
ret = bt_graph_add_component(ctx->graph, comp_cls,
- cfg_comp->instance_name->str, cfg_comp->params, &comp);
+ cfg_comp->instance_name->str,
+ bt_value_borrow_from_private(cfg_comp->params), &comp);
if (ret) {
BT_LOGE("Cannot create component: plugin-name=\"%s\", "
"comp-cls-name=\"%s\", comp-cls-type=%d, "
print_cfg(cfg);
if (cfg->command_needs_plugins) {
- ret = load_all_plugins(cfg->plugin_paths);
+ ret = load_all_plugins(
+ bt_value_borrow_from_private(cfg->plugin_paths));
if (ret) {
BT_LOGE("Failed to load plugins: ret=%d", ret);
retcode = 1;
babeltrace/logging.h \
babeltrace/object.h \
babeltrace/types.h \
+ babeltrace/private-values.h \
babeltrace/values.h \
babeltrace/version.h
/* Core API */
#include <babeltrace/logging.h>
#include <babeltrace/object.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
#include <babeltrace/version.h>
#include <babeltrace/trace-ir/field-classes.h>
#include <babeltrace/trace-ir/field-path.h>
#include <babeltrace/trace-ir/event-class.h>
+#include <babeltrace/values.h>
#include <stdarg.h>
#include <inttypes.h>
#include <stdint.h>
}
};
+static inline
+const char *bt_common_value_type_string(enum bt_value_type type)
+{
+ switch (type) {
+ case BT_VALUE_TYPE_NULL:
+ return "BT_VALUE_TYPE_NULL";
+ case BT_VALUE_TYPE_BOOL:
+ return "BT_VALUE_TYPE_BOOL";
+ case BT_VALUE_TYPE_INTEGER:
+ return "BT_VALUE_TYPE_INTEGER";
+ case BT_VALUE_TYPE_REAL:
+ return "BT_VALUE_TYPE_REAL";
+ case BT_VALUE_TYPE_STRING:
+ return "BT_VALUE_TYPE_STRING";
+ case BT_VALUE_TYPE_ARRAY:
+ return "BT_VALUE_TYPE_ARRAY";
+ case BT_VALUE_TYPE_MAP:
+ return "BT_VALUE_TYPE_MAP";
+ default:
+ return "(unknown)";
+ }
+};
+
static inline
GString *bt_field_path_string(struct bt_field_path *path)
{
#include <stdint.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_create(void);
+struct bt_private_value *bt_ctf_attributes_create(void);
BT_HIDDEN
-void bt_ctf_attributes_destroy(struct bt_value *attr_obj);
+void bt_ctf_attributes_destroy(struct bt_private_value *attr_obj);
BT_HIDDEN
-int64_t bt_ctf_attributes_get_count(struct bt_value *attr_obj);
+int64_t bt_ctf_attributes_get_count(struct bt_private_value *attr_obj);
BT_HIDDEN
-const char *bt_ctf_attributes_get_field_name(struct bt_value *attr_obj,
+const char *bt_ctf_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_borrow_field_value(struct bt_value *attr_obj,
+struct bt_private_value *bt_ctf_attributes_borrow_field_value(struct bt_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-int bt_ctf_attributes_set_field_value(struct bt_value *attr_obj,
- const char *name, struct bt_value *value_obj);
+int bt_ctf_attributes_set_field_value(struct bt_private_value *attr_obj,
+ const char *name, struct bt_private_value *value_obj);
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_borrow_field_value_by_name(
- struct bt_value *attr_obj, const char *name);
+struct bt_private_value *bt_ctf_attributes_borrow_field_value_by_name(
+ struct bt_private_value *attr_obj, const char *name);
BT_HIDDEN
-int bt_ctf_attributes_freeze(struct bt_value *attr_obj);
+int bt_ctf_attributes_freeze(struct bt_private_value *attr_obj);
#ifdef __cplusplus
}
#include <babeltrace/ctf-writer/field-types.h>
#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/values.h>
+#include <babeltrace/private-values.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_value *environment,
+int bt_ctf_resolve_types(struct bt_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/object-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <glib.h>
#include <sys/types.h>
unsigned char uuid[BABELTRACE_UUID_LEN];
bt_bool uuid_set;
enum bt_ctf_byte_order native_byte_order;
- struct bt_value *environment;
+ struct bt_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_set_environment_field(struct bt_ctf_trace_common *trace,
- const char *name, struct bt_value *value);
+ const char *name, struct bt_private_value *value);
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common *trace,
}
static inline
-struct bt_value *bt_ctf_trace_common_borrow_environment_field_value_by_index(
+struct bt_private_value *
+bt_ctf_trace_common_borrow_environment_field_value_by_index(
struct bt_ctf_trace_common *trace, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
}
static inline
-struct bt_value *bt_ctf_trace_common_borrow_environment_field_value_by_name(
+struct bt_private_value *
+bt_ctf_trace_common_borrow_environment_field_value_by_name(
struct bt_ctf_trace_common *trace, const char *name)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
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(
- struct bt_ctf_trace *trace, const char *name,
- struct bt_value *value);
-
extern int bt_ctf_trace_set_environment_field_integer(
struct bt_ctf_trace *trace, const char *name,
int64_t value);
* SOFTWARE.
*/
-#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/babeltrace-internal.h>
struct bt_ctf_trace_common;
* All parameters are owned by the caller.
*/
BT_HIDDEN
-int bt_ctf_validate_class_types(struct bt_value *environment,
+int bt_ctf_validate_class_types(struct bt_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_PRIVATE_VALUES_H
+#define BABELTRACE_PRIVATE_VALUES_H
+
+/*
+ * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-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.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* For enum bt_value_status */
+#include <babeltrace/values.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_value;
+struct bt_private_value;
+
+extern struct bt_private_value *bt_private_value_null;
+
+extern struct bt_value *bt_value_borrow_from_private(
+ struct bt_private_value *priv_value);
+
+extern struct bt_private_value *bt_private_value_bool_create(void);
+
+
+extern struct bt_private_value *bt_private_value_bool_create_init(bt_bool val);
+
+extern enum bt_value_status bt_private_value_bool_set(struct bt_private_value *bool_obj,
+ bt_bool val);
+
+extern struct bt_private_value *bt_private_value_integer_create(void);
+
+extern struct bt_private_value *bt_private_value_integer_create_init(int64_t val);
+
+extern enum bt_value_status bt_private_integer_bool_set(
+ struct bt_private_value *integer_obj, int64_t val);
+
+extern struct bt_private_value *bt_private_value_real_create(void);
+
+extern struct bt_private_value *bt_private_value_real_create_init(double val);
+
+extern enum bt_value_status bt_private_value_real_set(
+ struct bt_private_value *real_obj, double val);
+
+extern struct bt_private_value *bt_private_value_string_create(void);
+
+extern struct bt_private_value *bt_private_value_string_create_init(const char *val);
+
+extern enum bt_value_status bt_private_value_string_set(struct bt_private_value *string_obj,
+ const char *val);
+
+extern struct bt_private_value *bt_private_value_array_create(void);
+
+extern struct bt_private_value *bt_private_value_array_borrow_element_by_index(
+ const struct bt_private_value *array_obj, uint64_t index);
+
+extern enum bt_value_status bt_private_value_array_append_element(
+ struct bt_private_value *array_obj, struct bt_value *element_obj);
+
+extern enum bt_value_status bt_private_value_array_append_bool_element(
+ struct bt_private_value *array_obj, bt_bool val);
+
+extern enum bt_value_status bt_private_value_array_append_integer_element(
+ struct bt_private_value *array_obj, int64_t val);
+
+extern enum bt_value_status bt_private_value_array_append_real_element(
+ struct bt_private_value *array_obj, double val);
+
+extern enum bt_value_status bt_private_value_array_append_string_element(
+ struct bt_private_value *array_obj, const char *val);
+
+extern enum bt_value_status bt_private_value_array_append_empty_array_element(
+ struct bt_private_value *array_obj);
+
+extern enum bt_value_status bt_private_value_array_append_empty_map_element(
+ struct bt_private_value *array_obj);
+
+extern enum bt_value_status bt_private_value_array_set_element_by_index(
+ struct bt_private_value *array_obj, uint64_t index,
+ struct bt_value *element_obj);
+
+extern struct bt_private_value *bt_private_value_map_create(void);
+
+extern struct bt_private_value *bt_private_value_map_borrow_entry_value(
+ const struct bt_private_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_private_value_map_foreach_entry_cb)(const char *key,
+ struct bt_private_value *object, void *data);
+
+extern enum bt_value_status bt_private_value_map_foreach_entry(
+ const struct bt_private_value *map_obj,
+ bt_private_value_map_foreach_entry_cb cb, void *data);
+
+extern enum bt_value_status bt_private_value_map_insert_entry(
+ struct bt_private_value *map_obj, const char *key,
+ struct bt_value *element_obj);
+
+extern enum bt_value_status bt_private_value_map_insert_bool_entry(
+ struct bt_private_value *map_obj, const char *key, bt_bool val);
+
+extern enum bt_value_status bt_private_value_map_insert_integer_entry(
+ struct bt_private_value *map_obj, const char *key, int64_t val);
+
+extern enum bt_value_status bt_private_value_map_insert_real_entry(
+ struct bt_private_value *map_obj, const char *key, double val);
+
+extern enum bt_value_status bt_private_value_map_insert_string_entry(
+ struct bt_private_value *map_obj, const char *key, const char *val);
+
+extern enum bt_value_status bt_private_value_map_insert_empty_array_entry(
+ struct bt_private_value *map_obj, const char *key);
+
+extern enum bt_value_status bt_private_value_map_insert_empty_map_entry(
+ struct bt_private_value *map_obj, const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PRIVATE_VALUES_H */
#include <babeltrace/values.h>
BT_HIDDEN
-struct bt_value *bt_attributes_create(void);
+struct bt_private_value *bt_attributes_create(void);
BT_HIDDEN
-void bt_attributes_destroy(struct bt_value *attr_obj);
+void bt_attributes_destroy(struct bt_private_value *attr_obj);
BT_HIDDEN
-int64_t bt_attributes_get_count(struct bt_value *attr_obj);
+int64_t bt_attributes_get_count(struct bt_private_value *attr_obj);
BT_HIDDEN
-const char *bt_attributes_get_field_name(struct bt_value *attr_obj,
+const char *bt_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value(struct bt_value *attr_obj,
+struct bt_private_value *bt_attributes_borrow_field_value(
+ struct bt_private_value *attr_obj,
uint64_t index);
BT_HIDDEN
-int bt_attributes_set_field_value(struct bt_value *attr_obj,
- const char *name, struct bt_value *value_obj);
+int bt_attributes_set_field_value(struct bt_private_value *attr_obj,
+ const char *name, struct bt_private_value *value_obj);
BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value_by_name(
- struct bt_value *attr_obj, const char *name);
+struct bt_private_value *bt_attributes_borrow_field_value_by_name(
+ struct bt_private_value *attr_obj, const char *name);
BT_HIDDEN
-int bt_attributes_freeze(struct bt_value *attr_obj);
+int bt_attributes_freeze(struct bt_private_value *attr_obj);
#ifdef __cplusplus
}
bt_uuid value;
} uuid;
- struct bt_value *environment;
+ struct bt_private_value *environment;
/* Array of `struct bt_stream_class *` */
GPtrArray *stream_classes;
# define bt_value_freeze(_value)
#endif /* BT_DEV_MODE */
-static inline
-const char *bt_value_status_string(enum bt_value_status status)
-{
- switch (status) {
- case BT_VALUE_STATUS_CANCELED:
- return "BT_VALUE_STATUS_CANCELED";
- case BT_VALUE_STATUS_INVAL:
- return "BT_VALUE_STATUS_INVAL";
- case BT_VALUE_STATUS_ERROR:
- return "BT_VALUE_STATUS_ERROR";
- case BT_VALUE_STATUS_OK:
- return "BT_VALUE_STATUS_OK";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_value_type_string(enum bt_value_type type)
-{
- switch (type) {
- case BT_VALUE_TYPE_NULL:
- return "BT_VALUE_TYPE_NULL";
- case BT_VALUE_TYPE_BOOL:
- return "BT_VALUE_TYPE_BOOL";
- case BT_VALUE_TYPE_INTEGER:
- return "BT_VALUE_TYPE_INTEGER";
- case BT_VALUE_TYPE_REAL:
- return "BT_VALUE_TYPE_REAL";
- case BT_VALUE_TYPE_STRING:
- return "BT_VALUE_TYPE_STRING";
- case BT_VALUE_TYPE_ARRAY:
- return "BT_VALUE_TYPE_ARRAY";
- case BT_VALUE_TYPE_MAP:
- return "BT_VALUE_TYPE_MAP";
- default:
- return "(unknown)";
- }
-};
-
#endif /* BABELTRACE_VALUES_INTERNAL_H */
/* For bt_bool */
#include <babeltrace/types.h>
-/* For bt_object_get_ref() */
-#include <babeltrace/object.h>
-
#ifdef __cplusplus
extern "C" {
#endif
-/**
-@defgroup values Value objects
-@ingroup apiref
-@brief Value objects.
-
-@code
-#include <babeltrace/values.h>
-@endcode
-
-This is a set of <strong><em>value objects</em></strong>. With the
-functions documented here, you can create and modify:
-
-- \link bt_value_bool_create() Boolean value objects\endlink.
-- \link bt_value_integer_create() Integer value objects\endlink.
-- \link bt_value_float_create() Floating point number
- value objects\endlink.
-- \link bt_value_string_create() String value objects\endlink.
-- \link bt_value_array_create() Array value objects\endlink,
- containing zero or more value objects.
-- \link bt_value_map_create() Map value objects\endlink, mapping
- string keys to value objects.
-
-As with any Babeltrace object, value objects have
-<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
-counts</a>. When you \link bt_value_array_append_element() append a value object
-to an array value object\endlink, or when you \link bt_value_map_insert_entry()
-insert a value object into a map value object\endlink, its reference
-count is incremented, as well as when you get a value object back from
-those objects. See \ref refs to learn more about the reference counting
-management of Babeltrace objects.
-
-Most functions of this API return a <em>status code</em>, one of the
-values of #bt_value_status.
-
-You can create a deep copy of any value object with bt_value_copy(). You
-can compare two value objects with bt_value_compare().
-
-The following matrix shows some categorized value object functions
-to use for each value object type:
-
-<table>
- <tr>
- <th>Function role →<br>
- Value object type ↓
- <th>Create
- <th>Check type
- <th>Get value
- <th>Set value
- </tr>
- <tr>
- <th>Null
- <td>Use the \ref bt_value_null variable
- <td>bt_value_is_null()
- <td>N/A
- <td>N/A
- </tr>
- <tr>
- <th>Boolean
- <td>bt_value_bool_create()<br>
- bt_value_bool_create_init()
- <td>bt_value_is_bool()
- <td>bt_value_bool_get()
- <td>bt_value_bool_set()
- </tr>
- <tr>
- <th>Integer
- <td>bt_value_integer_create()<br>
- bt_value_integer_create_init()
- <td>bt_value_is_integer()
- <td>bt_value_integer_get()
- <td>bt_value_integer_set()
- </tr>
- <tr>
- <th>Floating point<br>number
- <td>bt_value_float_create()<br>
- bt_value_float_create_init()
- <td>bt_value_is_float()
- <td>bt_value_float_get()
- <td>bt_value_float_set()
- </tr>
- <tr>
- <th>String
- <td>bt_value_string_create()<br>
- bt_value_string_create_init()
- <td>bt_value_is_string()
- <td>bt_value_string_get()
- <td>bt_value_string_set()
- </tr>
- <tr>
- <th>Array
- <td>bt_value_array_create()
- <td>bt_value_is_array()
- <td>bt_value_array_get()
- <td>bt_value_array_append_element()<br>
- bt_value_array_append_bool_element()<br>
- bt_value_array_append_integer_element()<br>
- bt_value_array_append_element_float()<br>
- bt_value_array_append_string_element()<br>
- bt_value_array_append_empty_array_element()<br>
- bt_value_array_append_empty_map_element()<br>
- bt_value_array_set_element_by_index()
- </tr>
- <tr>
- <th>Map
- <td>bt_value_map_create()<br>
- bt_value_map_extend()
- <td>bt_value_is_map()
- <td>bt_value_map_get()<br>
- bt_value_map_foreach_entry()
- <td>bt_value_map_insert_entry()<br>
- bt_value_map_insert_bool_entry()<br>
- bt_value_map_insert_integer_entry()<br>
- bt_value_map_insert_float_entry()<br>
- bt_value_map_insert_string_entry()<br>
- bt_value_map_insert_empty_array_entry()<br>
- bt_value_map_insert_empty_map_entry()
- </tr>
-</table>
-
-@file
-@brief Value object types and functions.
-@sa values
-
-@addtogroup values
-@{
-*/
-
/**
@brief Status codes.
*/
/// Operation canceled.
BT_VALUE_STATUS_CANCELED = -3,
- /* -22 for compatibility with -EINVAL */
- /// Invalid argument.
- BT_VALUE_STATUS_INVAL = -22,
-
/// General error.
BT_VALUE_STATUS_ERROR = -1,
BT_VALUE_STATUS_OK = 0,
};
-/**
-@struct bt_value
-@brief A value object.
-@sa values
-*/
struct bt_value;
+struct bt_private_value;
-/**
-@brief The null value object singleton.
-
-You \em must use this variable when you need the null value object.
-
-The null value object singleton has no reference count: there is only
-one. You can compare any value object address to the null value object
-singleton to check if it's the null value object, or otherwise with
-bt_value_is_null().
-
-You can pass \ref bt_value_null to bt_object_get_ref() or bt_object_put_ref(): it has
-<em>no effect</em>.
-
-The null value object singleton is <em>always frozen</em> (see
-bt_value_is_frozen()).
-
-The functions of this API return this variable when the value object
-is actually the null value object (of type #BT_VALUE_TYPE_NULL),
-whereas \c NULL means an error of some sort.
-*/
extern struct bt_value *bt_value_null;
-/**
-@name Type information
-@{
-*/
-
-/**
-@brief Value object type.
-*/
enum bt_value_type {
/// Null value object.
BT_VALUE_TYPE_NULL = 0,
BT_VALUE_TYPE_MAP = 6,
};
-/**
-@brief Returns the type of the value object \p object.
-
-@param[in] object Value object of which to get the type.
-@returns Type of value object \p object,
- or #BT_VALUE_TYPE_UNKNOWN on error.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa #bt_value_type: Value object types.
-@sa bt_value_is_null(): Returns whether or not a given value object
- is the null value object.
-@sa bt_value_is_bool(): Returns whether or not a given value object
- is a boolean value object.
-@sa bt_value_is_integer(): Returns whether or not a given value
- object is an integer value object.
-@sa bt_value_is_float(): Returns whether or not a given value object
- is a floating point number value object.
-@sa bt_value_is_string(): Returns whether or not a given value object
- is a string value object.
-@sa bt_value_is_array(): Returns whether or not a given value object
- is an array value object.
-@sa bt_value_is_map(): Returns whether or not a given value object
- is a map value object.
-*/
extern enum bt_value_type bt_value_get_type(const struct bt_value *object);
-/**
-@brief Returns whether or not the value object \p object is the null
- value object.
-
-The only valid null value object is \ref bt_value_null.
-
-An alternative to calling this function is to directly compare the value
-object pointer to the \ref bt_value_null variable.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is the null value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_null(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_NULL;
}
-/**
-@brief Returns whether or not the value object \p object is a boolean
- value object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is a boolean value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_bool(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
}
-/**
-@brief Returns whether or not the value object \p object is an integer
- value object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is an integer value object.
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_integer(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_INTEGER;
}
-/**
-@brief Returns whether or not the value object \p object is a floating
- point number value object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is a floating point
- number value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_real(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
}
-/**
-@brief Returns whether or not the value object \p object is a string
- value object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is a string value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_string(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
}
-/**
-@brief Returns whether or not the value object \p object is an array
- value object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is an array value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_array(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
}
-/**
-@brief Returns whether or not the value object \p object is a map value
- object.
-
-@param[in] object Value object to check.
-@returns #BT_TRUE if \p object is a map value object.
-
-@prenotnull{object}
-@postrefcountsame{object}
-
-@sa bt_value_get_type(): Returns the type of a given value object.
-*/
static inline
bt_bool bt_value_is_map(const struct bt_value *object)
{
return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
}
-/** @} */
-
-/**
-@name Common value object functions
-@{
-*/
-
-/**
-@brief Creates a \em deep copy of the value object \p object.
-
-You can copy a frozen value object: the resulting copy is
-<em>not frozen</em>.
-
-@param[in] object Value object to copy.
-@returns Deep copy of \p object on success, or \c NULL
- on error.
-
-@prenotnull{object}
-@post <strong>On success, if the returned value object is not
- \ref bt_value_null</strong>, its reference count is 1.
-@postrefcountsame{object}
-*/
-extern struct bt_value *bt_value_copy(const struct bt_value *object);
-
-/**
-@brief Recursively compares the value objects \p object_a and
- \p object_b and returns #BT_TRUE if they have the same
- \em content (raw values).
+extern struct bt_private_value *bt_value_copy(const struct bt_value *object);
-@param[in] object_a Value object A to compare to \p object_b.
-@param[in] object_b Value object B to compare to \p object_a.
-@returns #BT_TRUE if \p object_a and \p object_b have the
- same \em content, or #BT_FALSE if they differ
- or on error.
-
-@postrefcountsame{object_a}
-@postrefcountsame{object_b}
-*/
extern bt_bool bt_value_compare(const struct bt_value *object_a,
const struct bt_value *object_b);
-/** @} */
-
-/**
-@name Boolean value object functions
-@{
-*/
-
-/**
-@brief Creates a default boolean value object.
-
-The created boolean value object's initial raw value is #BT_FALSE.
-
-@returns Created boolean value object on success, or \c NULL
- on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_bool_create_init(): Creates an initialized boolean
- value object.
-*/
-extern struct bt_value *bt_value_bool_create(void);
-
-/**
-@brief Creates a boolean value object with its initial raw value set to
- \p val.
-
-@param[in] val Initial raw value.
-@returns Created boolean value object on success, or
- \c NULL on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_bool_create(): Creates a default boolean value object.
-*/
-extern struct bt_value *bt_value_bool_create_init(bt_bool val);
-
-/**
-@brief Returns the boolean raw value of the boolean value object
- \p bool_obj.
-
-@param[in] bool_obj Boolean value object of which to get the
- raw value.
-@param[out] val Returned boolean raw value.
-@returns Status code.
-
-@prenotnull{bool_obj}
-@prenotnull{val}
-@pre \p bool_obj is a boolean value object.
-@postrefcountsame{bool_obj}
-
-@sa bt_value_bool_set(): Sets the raw value of a boolean value object.
-*/
extern enum bt_value_status bt_value_bool_get(
const struct bt_value *bool_obj, bt_bool *val);
-/**
-@brief Sets the boolean raw value of the boolean value object
- \p bool_obj to \p val.
-
-@param[in] bool_obj Boolean value object of which to set
- the raw value.
-@param[in] val New boolean raw value.
-@returns Status code.
-
-@prenotnull{bool_obj}
-@pre \p bool_obj is a boolean value object.
-@prehot{bool_obj}
-@postrefcountsame{bool_obj}
-
-@sa bt_value_bool_get(): Returns the raw value of a given boolean
- value object.
-*/
-extern enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj,
- bt_bool val);
-
-/** @} */
-
-/**
-@name Integer value object functions
-@{
-*/
-
-/**
-@brief Creates a default integer value object.
-
-The created integer value object's initial raw value is 0.
-
-@returns Created integer value object on success, or \c NULL
- on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_integer_create_init(): Creates an initialized integer
- value object.
-*/
-extern struct bt_value *bt_value_integer_create(void);
-
-/**
-@brief Creates an integer value object with its initial raw value set to
- \p val.
-
-@param[in] val Initial raw value.
-@returns Created integer value object on success, or
- \c NULL on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_integer_create(): Creates a default integer
- value object.
-*/
-extern struct bt_value *bt_value_integer_create_init(int64_t val);
-
-/**
-@brief Returns the integer raw value of the integer value object
- \p integer_obj.
-
-@param[in] integer_obj Integer value object of which to get the
- raw value.
-@param[out] val Returned integer raw value.
-@returns Status code.
-
-@prenotnull{integer_obj}
-@prenotnull{val}
-@pre \p integer_obj is an integer value object.
-@postrefcountsame{integer_obj}
-
-@sa bt_value_integer_set(): Sets the raw value of an integer value
- object.
-*/
extern enum bt_value_status bt_value_integer_get(
const struct bt_value *integer_obj, int64_t *val);
-/**
-@brief Sets the integer raw value of the integer value object
- \p integer_obj to \p val.
-
-@param[in] integer_obj Integer value object of which to set
- the raw value.
-@param[in] val New integer raw value.
-@returns Status code.
-
-@prenotnull{integer_obj}
-@pre \p integer_obj is an integer value object.
-@prehot{integer_obj}
-@postrefcountsame{integer_obj}
-
-@sa bt_value_integer_get(): Returns the raw value of a given integer
- value object.
-*/
-extern enum bt_value_status bt_value_integer_set(
- struct bt_value *integer_obj, int64_t val);
-
-/** @} */
-
-/**
-@name Floating point number value object functions
-@{
-*/
-
-/**
-@brief Creates a default floating point number value object.
-
-The created floating point number value object's initial raw value is 0.
-
-@returns Created floating point number value object on success,
- or \c NULL on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_float_create_init(): Creates an initialized floating
- point number value object.
-*/
-extern struct bt_value *bt_value_real_create(void);
-
-/**
-@brief Creates a floating point number value object with its initial raw
- value set to \p val.
-
-@param[in] val Initial raw value.
-@returns Created floating point number value object on
- success, or \c NULL on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_float_create(): Creates a default floating point number
- value object.
-*/
-extern struct bt_value *bt_value_real_create_init(double val);
-
-/**
-@brief Returns the floating point number raw value of the floating point
- number value object \p float_obj.
-
-@param[in] float_obj Floating point number value object of which to
- get the raw value.
-@param[out] val Returned floating point number raw value
-@returns Status code.
-
-@prenotnull{float_obj}
-@prenotnull{val}
-@pre \p float_obj is a floating point number value object.
-@postrefcountsame{float_obj}
-
-@sa bt_value_float_set(): Sets the raw value of a given floating
- point number value object.
-*/
extern enum bt_value_status bt_value_real_get(
const struct bt_value *real_obj, double *val);
-/**
-@brief Sets the floating point number raw value of the floating point
- number value object \p float_obj to \p val.
-
-@param[in] float_obj Floating point number value object of which to set
- the raw value.
-@param[in] val New floating point number raw value.
-@returns Status code.
-
-@prenotnull{float_obj}
-@pre \p float_obj is a floating point number value object.
-@prehot{float_obj}
-@postrefcountsame{float_obj}
-
-@sa bt_value_float_get(): Returns the raw value of a floating point
- number value object.
-*/
-extern enum bt_value_status bt_value_real_set(
- struct bt_value *real_obj, double val);
-
-/** @} */
-
-/**
-@name String value object functions
-@{
-*/
-
-/**
-@brief Creates a default string value object.
-
-The string value object is initially empty.
-
-@returns Created string value object on success, or \c NULL
- on error.
-
-@postsuccessrefcountret1
-
-@sa bt_value_string_create_init(): Creates an initialized string
- value object.
-*/
-extern struct bt_value *bt_value_string_create(void);
-
-/**
-@brief Creates a string value object with its initial raw value set to
- \p val.
-
-On success, \p val is copied.
-
-@param[in] val Initial raw value (copied on success).
-@returns Created string value object on success, or
- \c NULL on error.
-
-@prenotnull{val}
-@postsuccessrefcountret1
-
-@sa bt_value_float_create(): Creates a default string value object.
-*/
-extern struct bt_value *bt_value_string_create_init(const char *val);
-
-/**
-@brief Returns the string raw value of the string value object
- \p string_obj.
-
-The returned string is placed in \p *val. It is valid as long as this
-value object exists and is \em not modified. The ownership of the
-returned string is \em not transferred to the caller.
-
-@param[in] string_obj String value object of which to get the
- raw value.
-@param[out] val Returned string raw value.
-@returns Status code.
-
-@prenotnull{string_obj}
-@prenotnull{val}
-@pre \p string_obj is a string value object.
-@postrefcountsame{string_obj}
-
-@sa bt_value_string_set(): Sets the raw value of a string
- value object.
-*/
extern enum bt_value_status bt_value_string_get(
const struct bt_value *string_obj, const char **val);
-/**
-@brief Sets the string raw value of the string value object
- \p string_obj to \p val.
-
-On success, \p val is copied.
-
-@param[in] string_obj String value object of which to set
- the raw value.
-@param[in] val New string raw value (copied on success).
-@returns Status code.
-
-@prenotnull{string_obj}
-@prenotnull{val}
-@pre \p string_obj is a string value object.
-@prehot{string_obj}
-@postrefcountsame{string_obj}
-
-@sa bt_value_string_get(): Returns the raw value of a given string
- value object.
-*/
-extern enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
- const char *val);
-
-/**
- * @}
- */
-
-/**
- * @name Array value object functions
- * @{
- */
-
-/**
-@brief Creates an empty array value object.
-
-@returns Created array value object on success, or \c NULL
- on error.
-
-@postsuccessrefcountret1
-*/
-extern struct bt_value *bt_value_array_create(void);
-
-/**
-@brief Returns the size of the array value object \p array_obj, that is,
- the number of value objects contained in \p array_obj.
-
-@param[in] array_obj Array value object of which to get the size.
-@returns Number of value objects contained in
- \p array_obj if the return value is 0 (empty)
- or a positive value, or one of
- #bt_value_status negative values otherwise.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_is_empty(): Checks whether or not a given array
- value object is empty.
-*/
extern int64_t bt_value_array_get_size(const struct bt_value *array_obj);
-/**
-@brief Checks whether or not the array value object \p array_obj
- is empty.
-
-@param[in] array_obj Array value object to check.
-@returns #BT_TRUE if \p array_obj is empty.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_get_size(): Returns the size of a given array value
- object.
-*/
extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
extern struct bt_value *bt_value_array_borrow_element_by_index(
const struct bt_value *array_obj, uint64_t index);
-/**
-@brief Appends the value object \p element_obj to the array value
- object \p array_obj.
-
-@param[in] array_obj Array value object in which to append
- \p element_obj.
-@param[in] element_obj Value object to append.
-@returns Status code.
-
-@prenotnull{array_obj}
-@prenotnull{element_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@post <strong>On success, if \p element_obj is not
- \ref bt_value_null</strong>, its reference count is incremented.
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_bool_element(): Appends a boolean raw value to a
- given array value object.
-@sa bt_value_array_append_integer_element(): Appends an integer raw value
- to a given array value object.
-@sa bt_value_array_append_element_float(): Appends a floating point number
- raw value to a given array value object.
-@sa bt_value_array_append_string_element(): Appends a string raw value to a
- given array value object.
-@sa bt_value_array_append_empty_array_element(): Appends an empty array value
- object to a given array value object.
-@sa bt_value_array_append_empty_map_element(): Appends an empty map value
- object to a given array value object.
-*/
-extern enum bt_value_status bt_value_array_append_element(
- struct bt_value *array_obj, struct bt_value *element_obj);
-
-/**
-@brief Appends the boolean raw value \p val to the array value object
- \p array_obj.
-
-This is a convenience function which creates the underlying boolean
-value object before appending it.
-
-@param[in] array_obj Array value object in which to append \p val.
-@param[in] val Boolean raw value to append to \p array_obj.
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_bool_element(
- struct bt_value *array_obj, bt_bool val);
-
-/**
-@brief Appends the integer raw value \p val to the array value object
- \p array_obj.
-
-This is a convenience function which creates the underlying integer
-value object before appending it.
-
-@param[in] array_obj Array value object in which to append \p val.
-@param[in] val Integer raw value to append to \p array_obj.
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_integer_element(
- struct bt_value *array_obj, int64_t val);
-
-/**
-@brief Appends the floating point number raw value \p val to the array
- value object \p array_obj.
-
-This is a convenience function which creates the underlying floating
-point number value object before appending it.
-
-@param[in] array_obj Array value object in which to append \p val.
-@param[in] val Floating point number raw value to append
- to \p array_obj.
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_real_element(
- struct bt_value *array_obj, double val);
-
-/**
-@brief Appends the string raw value \p val to the array value object
- \p array_obj.
-
-This is a convenience function which creates the underlying string value
-object before appending it.
-
-On success, \p val is copied.
-
-@param[in] array_obj Array value object in which to append \p val.
-@param[in] val String raw value to append to \p array_obj
- (copied on success).
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prenotnull{val}
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_string_element(
- struct bt_value *array_obj, const char *val);
-
-/**
-@brief Appends an empty array value object to the array value object
- \p array_obj.
-
-This is a convenience function which creates the underlying array value
-object before appending it.
-
-@param[in] array_obj Array value object in which to append an
- empty array value object
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_empty_array_element(
- struct bt_value *array_obj);
-
-/**
-@brief Appends an empty map value object to the array value object
- \p array_obj.
-
-This is a convenience function which creates the underlying map value
-object before appending it.
-
-@param[in] array_obj Array value object in which to append an empty
- map value object.
-@returns Status code.
-
-@prenotnull{array_obj}
-@pre \p array_obj is an array value object.
-@prehot{array_obj}
-@postrefcountsame{array_obj}
-
-@sa bt_value_array_append_element(): Appends a value object to a given
- array value object.
-*/
-extern enum bt_value_status bt_value_array_append_empty_map_element(
- struct bt_value *array_obj);
-
-/**
-@brief Replaces the value object contained in the array value object
- \p array_obj at the index \p index by \p element_obj.
-
-@param[in] array_obj Array value object in which to replace
- an element.
-@param[in] index Index of value object to replace in
- \p array_obj.
-@param[in] element_obj New value object at position \p index of
- \p array_obj.
-@returns Status code.
-
-@prenotnull{array_obj}
-@prenotnull{element_obj}
-@pre \p array_obj is an array value object.
-@pre \p index is lesser than the size of \p array_obj (see
- bt_value_array_get_size()).
-@prehot{array_obj}
-@post <strong>On success, if the replaced value object is not
- \ref bt_value_null</strong>, its reference count is decremented.
-@post <strong>On success, if \p element_obj is not
- \ref bt_value_null</strong>, its reference count is incremented.
-@postrefcountsame{array_obj}
-*/
-extern enum bt_value_status bt_value_array_set_element_by_index(
- struct bt_value *array_obj, uint64_t index,
- struct bt_value *element_obj);
-
-/** @} */
-
-/**
-@name Map value object functions
-@{
-*/
-
-/**
-@brief Creates an empty map value object.
-
-@returns Created map value object on success, or \c NULL on error.
-
-@postsuccessrefcountret1
-*/
-extern struct bt_value *bt_value_map_create(void);
-
-/**
-@brief Returns the size of the map value object \p map_obj, that is, the
- number of entries contained in \p map_obj.
-
-@param[in] map_obj Map value object of which to get the size.
-@returns Number of entries contained in \p map_obj if the
- return value is 0 (empty) or a positive value,
- or one of #bt_value_status negative values
- otherwise.
-
-@prenotnull{map_obj}
-@pre \p map_obj is a map value object.
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_is_empty(): Checks whether or not a given map value
- object is empty.
-*/
extern int64_t bt_value_map_get_size(const struct bt_value *map_obj);
-/**
-@brief Checks whether or not the map value object \p map_obj is empty.
-
-@param[in] map_obj Map value object to check.
-@returns #BT_TRUE if \p map_obj is empty.
-
-@prenotnull{map_obj}
-@pre \p map_obj is a map value object.
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_get_size(): Returns the size of a given map value object.
-*/
extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
extern struct bt_value *bt_value_map_borrow_entry_value(
const struct bt_value *map_obj, const char *key);
-/**
-@brief User function type to use with bt_value_map_foreach_entry().
-
-\p object is a <em>weak reference</em>: you \em must pass it to bt_object_get_ref()
-if you need to keep a reference after this function returns.
-
-This function \em must return #BT_TRUE to continue the map value object
-traversal, or #BT_FALSE to break it.
-
-@param[in] key Key of map entry.
-@param[in] object Value object of map entry (weak reference).
-@param[in] data User data.
-@returns #BT_TRUE to continue the loop, or #BT_FALSE to break it.
-
-@prenotnull{key}
-@prenotnull{object}
-@post The reference count of \p object is not lesser than what it is
- when the function is called.
-*/
typedef bt_bool (* bt_value_map_foreach_entry_cb)(const char *key,
struct bt_value *object, void *data);
-/**
-@brief Calls a provided user function \p cb for each value object of the
- map value object \p map_obj.
-
-The value object passed to the user function is a <b>weak reference</b>:
-you \em must pass it to bt_object_get_ref() if you need to keep a persistent
-reference after the user function returns.
-
-The key passed to the user function is only valid in the scope of
-this user function call.
-
-The user function \em must return #BT_TRUE to continue the traversal of
-\p map_obj, or #BT_FALSE to break it.
-
-@param[in] map_obj Map value object on which to iterate.
-@param[in] cb User function to call back.
-@param[in] data User data passed to the user function.
-@returns Status code. More
- specifically, #BT_VALUE_STATUS_CANCELED is
- returned if the loop was canceled by the user
- function.
-
-@prenotnull{map_obj}
-@prenotnull{cb}
-@pre \p map_obj is a map value object.
-@postrefcountsame{map_obj}
-*/
extern enum bt_value_status bt_value_map_foreach_entry(
const struct bt_value *map_obj,
bt_value_map_foreach_entry_cb cb, void *data);
-/**
-@brief Returns whether or not the map value object \p map_obj contains
- an entry mapped to the key \p key.
-
-@param[in] map_obj Map value object to check.
-@param[in] key Key to check.
-@returns #BT_TRUE if \p map_obj has an entry mapped to the
- key \p key, or #BT_FALSE if it does not or
- on error.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@postrefcountsame{map_obj}
-*/
extern bt_bool bt_value_map_has_entry(const struct bt_value *map_obj,
const char *key);
-/**
-@brief Inserts the value object \p element_obj mapped to the key
- \p key into the map value object \p map_obj.
-
-If a value object is already mapped to \p key in \p map_obj, the
-associated value object is first put, and then replaced by
-\p element_obj.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert
- \p element_obj.
-@param[in] key Key (copied on success) to which the
- value object to insert is mapped.
-@param[in] element_obj Value object to insert, mapped to the
- key \p key.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@prenotnull{element_obj}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@post <strong>On success, if \p element_obj is not
- \ref bt_value_null</strong>, its reference count is incremented.
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_bool_entry(): Inserts a boolean raw value into a
- given map value object.
-@sa bt_value_map_insert_integer_entry(): Inserts an integer raw value into
- a given map value object.
-@sa bt_value_map_insert_float_entry(): Inserts a floating point number raw
- value into a given map value object.
-@sa bt_value_map_insert_string_entry(): Inserts a string raw value into a
- given map value object.
-@sa bt_value_map_insert_empty_array_entry(): Inserts an empty array value
- object into a given map value object.
-@sa bt_value_map_insert_empty_map_entry(): Inserts an empty map value
- object into a given map value object.
-*/
-extern enum bt_value_status bt_value_map_insert_entry(
- struct bt_value *map_obj, const char *key,
- struct bt_value *element_obj);
-
-/**
-@brief Inserts the boolean raw value \p val mapped to the key \p key
- into the map value object \p map_obj.
-
-This is a convenience function which creates the underlying boolean
-value object before inserting it.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert \p val.
-@param[in] key Key (copied on success) to which the boolean
- value object to insert is mapped.
-@param[in] val Boolean raw value to insert, mapped to
- the key \p key.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_bool_entry(
- struct bt_value *map_obj, const char *key, bt_bool val);
-
-/**
-@brief Inserts the integer raw value \p val mapped to the key \p key
- into the map value object \p map_obj.
-
-This is a convenience function which creates the underlying integer
-value object before inserting it.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert \p val.
-@param[in] key Key (copied on success) to which the integer
- value object to insert is mapped.
-@param[in] val Integer raw value to insert, mapped to
- the key \p key.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_integer_entry(
- struct bt_value *map_obj, const char *key, int64_t val);
-
-/**
-@brief Inserts the floating point number raw value \p val mapped to
- the key \p key into the map value object \p map_obj.
-
-This is a convenience function which creates the underlying floating
-point number value object before inserting it.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert \p val.
-@param[in] key Key (copied on success) to which the floating
- point number value object to insert is mapped.
-@param[in] val Floating point number raw value to insert,
- mapped to the key \p key.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_real_entry(
- struct bt_value *map_obj, const char *key, double val);
-
-/**
-@brief Inserts the string raw value \p val mapped to the key \p key
- into the map value object \p map_obj.
-
-This is a convenience function which creates the underlying string value
-object before inserting it.
-
-On success, \p val and \p key are copied.
-
-@param[in] map_obj Map value object in which to insert \p val.
-@param[in] key Key (copied on success) to which the string
- value object to insert is mapped.
-@param[in] val String raw value to insert (copied on success),
- mapped to the key \p key.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@prenotnull{val}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_string_entry(
- struct bt_value *map_obj, const char *key, const char *val);
-
-/**
-@brief Inserts an empty array value object mapped to the key \p key
- into the map value object \p map_obj.
-
-This is a convenience function which creates the underlying array value
-object before inserting it.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert an empty
- array value object.
-@param[in] key Key (copied on success) to which the empty array
- value object to insert is mapped.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_empty_array_entry(
- struct bt_value *map_obj, const char *key);
-
-/**
-@brief Inserts an empty map value object mapped to the key \p key into
- the map value object \p map_obj.
-
-This is a convenience function which creates the underlying map value
-object before inserting it.
-
-On success, \p key is copied.
-
-@param[in] map_obj Map value object in which to insert an empty
- map object.
-@param[in] key Key (copied on success) to which the empty map
- value object to insert is mapped.
-@returns Status code.
-
-@prenotnull{map_obj}
-@prenotnull{key}
-@pre \p map_obj is a map value object.
-@prehot{map_obj}
-@postrefcountsame{map_obj}
-
-@sa bt_value_map_insert_entry(): Inserts a value object into a given map
- value object.
-*/
-extern enum bt_value_status bt_value_map_insert_empty_map_entry(
- struct bt_value *map_obj, const char *key);
-
-/**
-@brief Creates a copy of the base map value object \p base_map_obj
- superficially extended with the entries of the extension map
- value object \p extension_map_obj.
-
-This function creates a superficial extension of \p base_map_obj with
-\p extension_map_obj by adding new entries to it and replacing the
-ones that share the keys in the extension object. The extension is
-\em superficial because it does not merge internal array and map
-value objects.
-
-For example, consider the following \p base_map_obj (JSON representation):
-
-@verbatim
-{
- "hello": 23,
- "code": -17,
- "em": false,
- "return": [5, 6, null]
-}
-@endverbatim
-
-and the following \p extension_map_obj (JSON representation):
-
-@verbatim
-{
- "comma": ",",
- "code": 22,
- "return": 17.88
-}
-@endverbatim
-
-The extended object is (JSON representation):
-
-@verbatim
-{
- "hello": 23,
- "code": 22,
- "em": false,
- "return": 17.88,
- "comma": ","
-}
-@endverbatim
-
-@param[in] base_map_obj Base map value object with initial
- entries.
-@param[in] extension_map_obj Extension map value object containing
- the entries to add to or replace in
- \p base_map_obj.
-@returns Created extended map value object, or
- \c NULL on error.
-
-@prenotnull{base_map_obj}
-@prenotnull{extension_map_obj}
-@pre \p base_map_obj is a map value object.
-@pre \p extension_map_obj is a map value object.
-@postrefcountsame{base_map_obj}
-@postrefcountsame{extension_map_obj}
-@postsuccessrefcountret1
-*/
-extern struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj,
+extern struct bt_private_value *bt_value_map_extend(
+ struct bt_value *base_map_obj,
struct bt_value *extension_map_obj);
-/** @} */
-
-/** @} */
-
#ifdef __cplusplus
}
#endif
#include <babeltrace/object.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <inttypes.h>
#define BT_CTF_ATTR_NAME_INDEX 0
#define BT_CTF_ATTR_VALUE_INDEX 1
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_create(void)
+struct bt_private_value *bt_ctf_attributes_create(void)
{
- struct bt_value *attr_obj;
+ struct bt_private_value *attr_obj;
/*
* Attributes: array value object of array value objects, each one
* ]
*/
BT_LOGD_STR("Creating attributes object.");
- attr_obj = bt_value_array_create();
+ attr_obj = bt_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_value *attr_obj)
+void bt_ctf_attributes_destroy(struct bt_private_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
bt_object_put_ref(attr_obj);
}
BT_HIDDEN
-int64_t bt_ctf_attributes_get_count(struct bt_value *attr_obj)
+int64_t bt_ctf_attributes_get_count(struct bt_private_value *attr_obj)
{
- return bt_value_array_get_size(attr_obj);
+ return bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
}
BT_HIDDEN
-const char *bt_ctf_attributes_get_field_name(struct bt_value *attr_obj,
+const char *bt_ctf_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index)
{
int rc;
const char *ret = NULL;
- struct bt_value *attr_field_obj = NULL;
- struct bt_value *attr_field_name_obj = NULL;
+ struct bt_private_value *attr_field_obj = NULL;
+ struct bt_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(attr_obj)) {
+ if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(attr_obj));
+ index, bt_value_array_get_size(bt_value_borrow_from_private(attr_obj)));
goto end;
}
- attr_field_obj = bt_value_array_borrow_element_by_index(attr_obj, index);
+ attr_field_obj = bt_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: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- attr_field_name_obj = bt_value_array_borrow_element_by_index(attr_field_obj,
- BT_CTF_ATTR_NAME_INDEX);
+ attr_field_name_obj =
+ bt_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: "
"value-addr=%p, index=%" PRIu64, attr_field_obj,
goto end;
}
- rc = bt_value_string_get(attr_field_name_obj, &ret);
+ rc = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj), &ret);
if (rc) {
BT_LOGE("Cannot get raw value from string value: value-addr=%p",
attr_field_name_obj);
}
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_borrow_field_value(struct bt_value *attr_obj,
+struct bt_private_value *bt_ctf_attributes_borrow_field_value(struct bt_private_value *attr_obj,
uint64_t index)
{
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_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(attr_obj)) {
+ if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(attr_obj));
+ index, bt_value_array_get_size(bt_value_borrow_from_private(attr_obj)));
goto end;
}
- attr_field_obj = bt_value_array_borrow_element_by_index(attr_obj, index);
+ attr_field_obj = bt_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: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- value_obj = bt_value_array_borrow_element_by_index(attr_field_obj,
+ value_obj = bt_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_value *bt_ctf_attributes_borrow_field_by_name(
- struct bt_value *attr_obj, const char *name)
+struct bt_private_value *bt_ctf_attributes_borrow_field_by_name(
+ struct bt_private_value *attr_obj, const char *name)
{
uint64_t i;
int64_t attr_size;
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_name_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_private_value *attr_field_name_obj = NULL;
- attr_size = bt_value_array_get_size(attr_obj);
+ attr_size = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
int ret;
const char *field_name;
- value_obj = bt_value_array_borrow_element_by_index(attr_obj, i);
+ value_obj = bt_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_value_array_borrow_element_by_index(value_obj,
+ attr_field_name_obj = bt_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;
}
- ret = bt_value_string_get(attr_field_name_obj, &field_name);
+ ret = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj),
+ &field_name);
if (ret) {
BT_LOGE("Cannot get raw value from string value: value-addr=%p",
attr_field_name_obj);
}
BT_HIDDEN
-int bt_ctf_attributes_set_field_value(struct bt_value *attr_obj,
- const char *name, struct bt_value *value_obj)
+int bt_ctf_attributes_set_field_value(struct bt_private_value *attr_obj,
+ const char *name, struct bt_private_value *value_obj)
{
int ret = 0;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_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_value_array_set_element_by_index(attr_field_obj,
- BT_CTF_ATTR_VALUE_INDEX, value_obj);
+ ret = bt_private_value_array_set_element_by_index(
+ attr_field_obj, BT_CTF_ATTR_VALUE_INDEX,
+ bt_value_borrow_from_private(value_obj));
attr_field_obj = NULL;
goto end;
}
- attr_field_obj = bt_value_array_create();
+ attr_field_obj = bt_private_value_array_create();
if (!attr_field_obj) {
BT_LOGE_STR("Failed to create empty array value.");
ret = -1;
goto end;
}
- ret = bt_value_array_append_string_element(attr_field_obj, name);
- ret |= bt_value_array_append_element(attr_field_obj, value_obj);
+ ret = bt_private_value_array_append_string_element(attr_field_obj, name);
+ ret |= bt_private_value_array_append_element(attr_field_obj,
+ bt_value_borrow_from_private(value_obj));
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
goto end;
}
- ret = bt_value_array_append_element(attr_obj, attr_field_obj);
+ ret = bt_private_value_array_append_element(attr_obj,
+ bt_value_borrow_from_private(attr_field_obj));
if (ret) {
BT_LOGE("Cannot append element to array value: "
"array-value-addr=%p, element-value-addr=%p",
}
BT_HIDDEN
-struct bt_value *bt_ctf_attributes_borrow_field_value_by_name(
- struct bt_value *attr_obj, const char *name)
+struct bt_private_value *bt_ctf_attributes_borrow_field_value_by_name(
+ struct bt_private_value *attr_obj, const char *name)
{
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_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_value_array_borrow_element_by_index(attr_field_obj,
+ value_obj = bt_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_value *attr_obj)
+int bt_ctf_attributes_freeze(struct bt_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(attr_obj);
+ count = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
BT_ASSERT(count >= 0);
/*
* attribute is frozen one by one.
*/
for (i = 0; i < count; ++i) {
- struct bt_value *obj = NULL;
+ struct bt_private_value *obj = NULL;
obj = bt_ctf_attributes_borrow_field_value(attr_obj, i);
if (!obj) {
goto end;
}
- bt_value_freeze(obj);
+ bt_value_freeze(bt_value_borrow_from_private(obj));
}
end:
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_value *environment = NULL;
+ struct bt_private_value *environment = NULL;
stream_class = bt_ctf_event_class_common_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
* * Event payload
*/
struct resolve_context {
- struct bt_value *environment;
+ struct bt_private_value *environment;
struct bt_ctf_field_type_common *scopes[6];
/* Root scope being visited */
BT_HIDDEN
int bt_ctf_resolve_types(
- struct bt_value *environment,
+ struct bt_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,
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
- const char *name, struct bt_value *value)
+ const char *name, struct bt_private_value *value)
{
int ret = 0;
goto end;
}
- if (!bt_value_is_integer(value) && !bt_value_is_string(value)) {
+ if (!bt_value_is_integer(bt_value_borrow_from_private(value)) &&
+ !bt_value_is_string(bt_value_borrow_from_private(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_value_type_string(bt_value_get_type(value)));
+ bt_common_value_type_string(
+ bt_value_get_type(
+ bt_value_borrow_from_private(value))));
ret = -1;
goto end;
}
*
* The object passed is frozen like all other attributes.
*/
- struct bt_value *attribute =
+ struct bt_private_value *attribute =
bt_ctf_attributes_borrow_field_value_by_name(
trace->environment, name);
goto end;
}
- bt_value_freeze(value);
+ bt_value_freeze(bt_value_borrow_from_private(value));
}
ret = bt_ctf_attributes_set_field_value(trace->environment, name,
const char *name, const char *value)
{
int ret = 0;
- struct bt_value *env_value_string_obj = NULL;
+ struct bt_private_value *env_value_string_obj = NULL;
if (!value) {
BT_LOGW_STR("Invalid parameter: value is NULL.");
goto end;
}
- env_value_string_obj = bt_value_string_create_init(value);
+ env_value_string_obj = bt_private_value_string_create_init(value);
if (!env_value_string_obj) {
BT_LOGE_STR("Cannot create string value object.");
ret = -1;
struct bt_ctf_trace_common *trace, const char *name, int64_t value)
{
int ret = 0;
- struct bt_value *env_value_integer_obj = NULL;
+ struct bt_private_value *env_value_integer_obj = NULL;
- env_value_integer_obj = bt_value_integer_create_init(value);
+ env_value_integer_obj = bt_private_value_integer_create_init(value);
if (!env_value_integer_obj) {
BT_LOGE_STR("Cannot create integer value object.");
ret = -1;
return bt_ctf_trace_common_set_uuid(BT_CTF_TO_COMMON(trace), uuid);
}
-int bt_ctf_trace_set_environment_field(struct bt_ctf_trace *trace,
- const char *name, struct bt_value *value)
-{
- return bt_ctf_trace_common_set_environment_field(BT_CTF_TO_COMMON(trace),
- name, value);
-}
-
int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace,
const char *name, const char *value)
{
g_string_append(context->string, "env {\n");
for (i = 0; i < env_size; i++) {
- struct bt_value *env_field_value_obj = NULL;
+ struct bt_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(env_field_value_obj)) {
+ switch (bt_value_get_type(
+ bt_value_borrow_from_private(env_field_value_obj))) {
case BT_VALUE_TYPE_INTEGER:
{
int ret;
int64_t int_value;
- ret = bt_value_integer_get(env_field_value_obj,
- &int_value);
+ ret = bt_value_integer_get(
+ bt_value_borrow_from_private(
+ env_field_value_obj), &int_value);
BT_ASSERT(ret == 0);
g_string_append_printf(context->string,
"\t%s = %" PRId64 ";\n", entry_name,
const char *str_value;
char *escaped_str = NULL;
- ret = bt_value_string_get(env_field_value_obj,
- &str_value);
+ ret = bt_value_string_get(
+ bt_value_borrow_from_private(
+ env_field_value_obj), &str_value);
BT_ASSERT(ret == 0);
escaped_str = g_strescape(str_value, NULL);
if (!escaped_str) {
* All parameters are owned by the caller.
*/
static
-int validate_event_class_types(struct bt_value *environment,
+int validate_event_class_types(struct bt_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_value *environment,
+int validate_stream_class_types(struct bt_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_value *environment,
+int validate_trace_types(struct bt_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_value *environment,
+int bt_ctf_validate_class_types(struct bt_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/graph/notification-event-internal.h>
#include <babeltrace/graph/notification-packet-internal.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/common-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
if (!bt_value_is_map(params)) {
BT_LOGW("Invalid parameter: initialization parameters must be a map value: "
"type=%s",
- bt_value_type_string(bt_value_get_type(params)));
+ bt_common_value_type_string(
+ bt_value_get_type(params)));
graph_status = BT_GRAPH_STATUS_INVALID;
goto end;
}
} else {
- params = bt_value_map_create();
+ params = bt_value_borrow_from_private(
+ bt_private_value_map_create());
if (!params) {
BT_LOGE_STR("Cannot create map value object.");
graph_status = BT_GRAPH_STATUS_NOMEM;
const char *prefix, struct bt_value *value)
{
BUF_APPEND(", %stype=%s",
- PRFIELD(bt_value_type_string(bt_value_get_type(value))));
+ PRFIELD(bt_common_value_type_string(bt_value_get_type(value))));
if (!extended) {
return;
#include <babeltrace/object.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/values-internal.h>
#include <inttypes.h>
#include <babeltrace/compat/string-internal.h>
#define BT_ATTR_VALUE_INDEX 1
BT_HIDDEN
-struct bt_value *bt_attributes_create(void)
+struct bt_private_value *bt_attributes_create(void)
{
- struct bt_value *attr_obj;
+ struct bt_private_value *attr_obj;
/*
* Attributes: array value object of array value objects, each one
* ]
*/
BT_LOGD_STR("Creating attributes object.");
- attr_obj = bt_value_array_create();
+ attr_obj = bt_private_value_array_create();
if (!attr_obj) {
BT_LOGE_STR("Failed to create array value.");
} else {
}
BT_HIDDEN
-void bt_attributes_destroy(struct bt_value *attr_obj)
+void bt_attributes_destroy(struct bt_private_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
bt_object_put_ref(attr_obj);
}
BT_HIDDEN
-int64_t bt_attributes_get_count(struct bt_value *attr_obj)
+int64_t bt_attributes_get_count(struct bt_private_value *attr_obj)
{
- return bt_value_array_get_size(attr_obj);
+ return bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
}
BT_HIDDEN
-const char *bt_attributes_get_field_name(struct bt_value *attr_obj,
+const char *bt_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index)
{
int rc;
const char *ret = NULL;
- struct bt_value *attr_field_obj = NULL;
- struct bt_value *attr_field_name_obj = NULL;
+ struct bt_private_value *attr_field_obj = NULL;
+ struct bt_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(attr_obj)) {
+ if (index >= bt_value_array_get_size(
+ bt_value_borrow_from_private(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(attr_obj));
+ index, bt_value_array_get_size(
+ bt_value_borrow_from_private(attr_obj)));
goto end;
}
- attr_field_obj = bt_value_array_borrow_element_by_index(attr_obj, index);
+ attr_field_obj = bt_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: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- attr_field_name_obj = bt_value_array_borrow_element_by_index(attr_field_obj,
- BT_ATTR_NAME_INDEX);
+ attr_field_name_obj =
+ bt_private_value_array_borrow_element_by_index(attr_field_obj,
+ BT_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_field_obj,
goto end;
}
- rc = bt_value_string_get(attr_field_name_obj, &ret);
+ rc = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj), &ret);
if (rc) {
BT_LOGE("Cannot get raw value from string value: value-addr=%p",
attr_field_name_obj);
}
BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value(struct bt_value *attr_obj,
- uint64_t index)
+struct bt_private_value *bt_attributes_borrow_field_value(
+ struct bt_private_value *attr_obj, uint64_t index)
{
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_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(attr_obj)) {
+ if (index >= bt_value_array_get_size(bt_value_borrow_from_private(attr_obj))) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(attr_obj));
+ index, bt_value_array_get_size(
+ bt_value_borrow_from_private(attr_obj)));
goto end;
}
- attr_field_obj = bt_value_array_borrow_element_by_index(attr_obj, index);
+ attr_field_obj =
+ bt_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: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- value_obj = bt_value_array_borrow_element_by_index(attr_field_obj,
- BT_ATTR_VALUE_INDEX);
+ value_obj = bt_private_value_array_borrow_element_by_index(
+ attr_field_obj, BT_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_field_obj,
}
static
-struct bt_value *bt_attributes_borrow_field_by_name(
- struct bt_value *attr_obj, const char *name)
+struct bt_private_value *bt_attributes_borrow_field_by_name(
+ struct bt_private_value *attr_obj, const char *name)
{
uint64_t i;
int64_t attr_size;
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_name_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_private_value *attr_field_name_obj = NULL;
- attr_size = bt_value_array_get_size(attr_obj);
+ attr_size = bt_value_array_get_size(
+ bt_value_borrow_from_private(attr_obj));
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
int ret;
const char *field_name;
- value_obj = bt_value_array_borrow_element_by_index(attr_obj, i);
+ value_obj = bt_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_value_array_borrow_element_by_index(value_obj,
- BT_ATTR_NAME_INDEX);
+ attr_field_name_obj =
+ bt_private_value_array_borrow_element_by_index(
+ value_obj, BT_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
"value-addr=%p, index=%" PRIu64,
goto error;
}
- ret = bt_value_string_get(attr_field_name_obj, &field_name);
+ ret = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj),
+ &field_name);
if (ret) {
BT_LOGE("Cannot get raw value from string value: value-addr=%p",
attr_field_name_obj);
}
BT_HIDDEN
-int bt_attributes_set_field_value(struct bt_value *attr_obj,
- const char *name, struct bt_value *value_obj)
+int bt_attributes_set_field_value(struct bt_private_value *attr_obj,
+ const char *name, struct bt_private_value *value_obj)
{
int ret = 0;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_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_attributes_borrow_field_by_name(attr_obj, name);
if (attr_field_obj) {
- ret = bt_value_array_set_element_by_index(attr_field_obj,
- BT_ATTR_VALUE_INDEX, value_obj);
+ ret = bt_private_value_array_set_element_by_index(
+ attr_field_obj, BT_ATTR_VALUE_INDEX,
+ bt_value_borrow_from_private(value_obj));
attr_field_obj = NULL;
goto end;
}
- attr_field_obj = bt_value_array_create();
+ attr_field_obj = bt_private_value_array_create();
if (!attr_field_obj) {
BT_LOGE_STR("Failed to create empty array value.");
ret = -1;
goto end;
}
- ret = bt_value_array_append_string_element(attr_field_obj, name);
- ret |= bt_value_array_append_element(attr_field_obj, value_obj);
+ ret = bt_private_value_array_append_string_element(attr_field_obj,
+ name);
+ ret |= bt_private_value_array_append_element(attr_field_obj,
+ bt_value_borrow_from_private(value_obj));
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
goto end;
}
- ret = bt_value_array_append_element(attr_obj, attr_field_obj);
+ ret = bt_private_value_array_append_element(attr_obj,
+ bt_value_borrow_from_private(attr_field_obj));
if (ret) {
BT_LOGE("Cannot append element to array value: "
"array-value-addr=%p, element-value-addr=%p",
}
BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value_by_name(
- struct bt_value *attr_obj, const char *name)
+struct bt_private_value *bt_attributes_borrow_field_value_by_name(
+ struct bt_private_value *attr_obj, const char *name)
{
- struct bt_value *value_obj = NULL;
- struct bt_value *attr_field_obj = NULL;
+ struct bt_private_value *value_obj = NULL;
+ struct bt_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_value_array_borrow_element_by_index(attr_field_obj,
- BT_ATTR_VALUE_INDEX);
+ value_obj = bt_private_value_array_borrow_element_by_index(
+ attr_field_obj, BT_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_field_obj,
}
BT_HIDDEN
-int bt_attributes_freeze(struct bt_value *attr_obj)
+int bt_attributes_freeze(struct bt_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(attr_obj);
+ count = bt_value_array_get_size(bt_value_borrow_from_private(attr_obj));
BT_ASSERT(count >= 0);
/*
* attribute is frozen one by one.
*/
for (i = 0; i < count; ++i) {
- struct bt_value *obj = NULL;
+ struct bt_private_value *obj = NULL;
obj = bt_attributes_borrow_field_value(attr_obj, i);
if (!obj) {
goto end;
}
- bt_value_freeze(obj);
+ bt_value_freeze(bt_value_borrow_from_private(obj));
}
end:
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/types.h>
static
bool trace_has_environment_entry(struct bt_trace *trace, const char *name)
{
- struct bt_value *attribute;
-
BT_ASSERT(trace);
- attribute = bt_attributes_borrow_field_value_by_name(
- trace->environment, name);
- return attribute != NULL;
+ return bt_attributes_borrow_field_value_by_name(
+ trace->environment, name) != NULL;
}
static
int set_environment_entry(struct bt_trace *trace, const char *name,
- struct bt_value *value)
+ struct bt_private_value *value)
{
int ret;
"%![trace-]+t, entry-name=\"%s\"", trace, name);
ret = bt_attributes_set_field_value(trace->environment, name,
value);
- bt_value_freeze(value);
+ bt_value_freeze(bt_value_borrow_from_private(value));
if (ret) {
BT_LIB_LOGE("Cannot set trace's environment entry: "
"%![trace-]+t, entry-name=\"%s\"", trace, name);
const char *name, const char *value)
{
int ret;
- struct bt_value *value_obj;
+ struct bt_private_value *value_obj;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
BT_ASSERT_PRE_NON_NULL(value, "Value");
- value_obj = bt_value_string_create_init(value);
+ value_obj = bt_private_value_string_create_init(value);
if (!value_obj) {
BT_LOGE_STR("Cannot create a string value object.");
ret = -1;
struct bt_trace *trace, const char *name, int64_t value)
{
int ret;
- struct bt_value *value_obj;
+ struct bt_private_value *value_obj;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- value_obj = bt_value_integer_create_init(value);
+ value_obj = bt_private_value_integer_create_init(value);
if (!value_obj) {
BT_LOGE_STR("Cannot create an integer value object.");
ret = -1;
BT_ASSERT_PRE_NON_NULL(value, "Value");
BT_ASSERT_PRE_VALID_INDEX(index,
bt_attributes_get_count(trace->environment));
- *value = bt_attributes_borrow_field_value(trace->environment, index);
+ *value = bt_value_borrow_from_private(
+ bt_attributes_borrow_field_value(trace->environment, index));
BT_ASSERT(*value);
*name = bt_attributes_get_field_name(trace->environment, index);
BT_ASSERT(*name);
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_attributes_borrow_field_value_by_name(trace->environment,
- name);
+ return bt_value_borrow_from_private(
+ bt_attributes_borrow_field_value_by_name(trace->environment,
+ name));
}
uint64_t bt_trace_get_stream_count(struct bt_trace *trace)
#include <string.h>
#include <inttypes.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/common-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/compat/glib-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/object-internal.h>
#define BT_VALUE_TO_MAP(_base) ((struct bt_value_map *) (_base))
#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \
- BT_ASSERT_PRE((_value)->type == (_type), \
+ BT_ASSERT_PRE(((struct bt_value *) (_value))->type == (_type), \
"Value has the wrong type ID: expected-type=%s, " \
- "%![value-]+v", bt_value_type_string(_type), \
+ "%![value-]+v", bt_common_value_type_string(_type), \
(_value))
#define BT_ASSERT_PRE_VALUE_HOT(_value, _name) \
- BT_ASSERT_PRE_HOT((_value), (_name), ": %!+v", (_value))
+ BT_ASSERT_PRE_HOT(((struct bt_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_value {
struct bt_object base;
enum bt_value_type type;
};
struct bt_value *bt_value_null = &bt_value_null_instance;
+struct bt_private_value *bt_private_value_null = (void *) &bt_value_null_instance;
struct bt_value_bool {
struct bt_value base;
};
static
-struct bt_value *bt_value_null_copy(const struct bt_value *null_obj)
+struct bt_private_value *bt_value_null_copy(const struct bt_value *null_obj)
{
- return bt_value_null;
+ return (void *) bt_value_null;
}
static
-struct bt_value *bt_value_bool_copy(const struct bt_value *bool_obj)
+struct bt_private_value *bt_value_bool_copy(const struct bt_value *bool_obj)
{
- return bt_value_bool_create_init(BT_VALUE_TO_BOOL(bool_obj)->value);
+ return bt_private_value_bool_create_init(BT_VALUE_TO_BOOL(bool_obj)->value);
}
static
-struct bt_value *bt_value_integer_copy(const struct bt_value *integer_obj)
+struct bt_private_value *bt_value_integer_copy(
+ const struct bt_value *integer_obj)
{
- return bt_value_integer_create_init(
+ return bt_private_value_integer_create_init(
BT_VALUE_TO_INTEGER(integer_obj)->value);
}
static
-struct bt_value *bt_value_real_copy(const struct bt_value *real_obj)
+struct bt_private_value *bt_value_real_copy(const struct bt_value *real_obj)
{
- return bt_value_real_create_init(
+ return bt_private_value_real_create_init(
BT_VALUE_TO_REAL(real_obj)->value);
}
static
-struct bt_value *bt_value_string_copy(const struct bt_value *string_obj)
+struct bt_private_value *bt_value_string_copy(const struct bt_value *string_obj)
{
- return bt_value_string_create_init(
+ return bt_private_value_string_create_init(
BT_VALUE_TO_STRING(string_obj)->gstr->str);
}
static
-struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
+struct bt_private_value *bt_value_array_copy(const struct bt_value *array_obj)
{
int i;
int ret;
- struct bt_value *copy_obj;
+ struct bt_private_value *copy_obj;
struct bt_value_array *typed_array_obj;
BT_LOGD("Copying array value: addr=%p", array_obj);
typed_array_obj = BT_VALUE_TO_ARRAY(array_obj);
- copy_obj = bt_value_array_create();
+ copy_obj = bt_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_value *element_obj_copy;
+ struct bt_private_value *element_obj_copy;
struct bt_value *element_obj = bt_value_array_borrow_element_by_index(
array_obj, i);
goto end;
}
- ret = bt_value_array_append_element(copy_obj, element_obj_copy);
+ ret = bt_private_value_array_append_element(copy_obj,
+ (void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot append to array value: addr=%p",
}
static
-struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
+struct bt_private_value *bt_value_map_copy(const struct bt_value *map_obj)
{
int ret;
GHashTableIter iter;
gpointer key, element_obj;
- struct bt_value *copy_obj;
- struct bt_value *element_obj_copy;
+ struct bt_private_value *copy_obj;
+ struct bt_private_value *element_obj_copy;
struct bt_value_map *typed_map_obj;
BT_LOGD("Copying map value: addr=%p", map_obj);
typed_map_obj = BT_VALUE_TO_MAP(map_obj);
- copy_obj = bt_value_map_create();
+ copy_obj = bt_private_value_map_create();
if (!copy_obj) {
goto end;
}
goto end;
}
- ret = bt_value_map_insert_entry(copy_obj, key_str, element_obj_copy);
+ ret = bt_private_value_map_insert_entry(copy_obj, key_str,
+ (void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
}
static
-struct bt_value *(* const copy_funcs[])(const struct bt_value *) = {
+struct bt_private_value *(* const copy_funcs[])(const struct bt_value *) = {
[BT_VALUE_TYPE_NULL] = bt_value_null_copy,
[BT_VALUE_TYPE_BOOL] = bt_value_bool_copy,
[BT_VALUE_TYPE_INTEGER] = bt_value_integer_copy,
const struct bt_value_array *array_obj_a =
BT_VALUE_TO_ARRAY(object_a);
- if (bt_value_array_get_size(object_a) != bt_value_array_get_size(object_b)) {
+ if (bt_value_array_get_size(object_a) !=
+ bt_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,
struct bt_value *element_obj_a;
struct bt_value *element_obj_b;
- element_obj_a = bt_value_array_borrow_element_by_index(object_a, i);
- element_obj_b = bt_value_array_borrow_element_by_index(object_b, i);
+ element_obj_a = bt_value_array_borrow_element_by_index(
+ object_a, i);
+ element_obj_b = bt_value_array_borrow_element_by_index(
+ object_b, i);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
BT_LOGV("Array values's elements are different: "
struct bt_value *element_obj_b;
const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
- element_obj_b = bt_value_map_borrow_entry_value(object_b, key_str);
+ element_obj_b = bt_value_map_borrow_entry_value(object_b,
+ key_str);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
BT_LOGV("Map values's elements are different: "
return value;
}
-struct bt_value *bt_value_bool_create_init(bt_bool val)
+struct bt_private_value *bt_private_value_bool_create_init(bt_bool val)
{
struct bt_value_bool *bool_obj;
BT_LOGD("Created boolean value object: addr=%p", bool_obj);
end:
- return BT_VALUE_FROM_CONCRETE(bool_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(bool_obj);
}
-struct bt_value *bt_value_bool_create(void)
+struct bt_private_value *bt_private_value_bool_create(void)
{
- return bt_value_bool_create_init(BT_FALSE);
+ return bt_private_value_bool_create_init(BT_FALSE);
}
-struct bt_value *bt_value_integer_create_init(int64_t val)
+struct bt_private_value *bt_private_value_integer_create_init(int64_t val)
{
struct bt_value_integer *integer_obj;
integer_obj);
end:
- return BT_VALUE_FROM_CONCRETE(integer_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(integer_obj);
}
-struct bt_value *bt_value_integer_create(void)
+struct bt_private_value *bt_private_value_integer_create(void)
{
- return bt_value_integer_create_init(0);
+ return bt_private_value_integer_create_init(0);
}
-struct bt_value *bt_value_real_create_init(double val)
+struct bt_private_value *bt_private_value_real_create_init(double val)
{
struct bt_value_real *real_obj;
real_obj);
end:
- return BT_VALUE_FROM_CONCRETE(real_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(real_obj);
}
-struct bt_value *bt_value_real_create(void)
+struct bt_private_value *bt_private_value_real_create(void)
{
- return bt_value_real_create_init(0.);
+ return bt_private_value_real_create_init(0.);
}
-struct bt_value *bt_value_string_create_init(const char *val)
+struct bt_private_value *bt_private_value_string_create_init(const char *val)
{
struct bt_value_string *string_obj = NULL;
string_obj);
end:
- return BT_VALUE_FROM_CONCRETE(string_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(string_obj);
}
-struct bt_value *bt_value_string_create(void)
+struct bt_private_value *bt_private_value_string_create(void)
{
- return bt_value_string_create_init("");
+ return bt_private_value_string_create_init("");
}
-struct bt_value *bt_value_array_create(void)
+struct bt_private_value *bt_private_value_array_create(void)
{
struct bt_value_array *array_obj;
array_obj);
end:
- return BT_VALUE_FROM_CONCRETE(array_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(array_obj);
}
-struct bt_value *bt_value_map_create(void)
+struct bt_private_value *bt_private_value_map_create(void)
{
struct bt_value_map *map_obj;
map_obj);
end:
- return BT_VALUE_FROM_CONCRETE(map_obj);
+ return (void *) BT_VALUE_FROM_CONCRETE(map_obj);
}
enum bt_value_status bt_value_bool_get(const struct bt_value *bool_obj,
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
+enum bt_value_status bt_private_value_bool_set(struct bt_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_VALUE_TYPE_BOOL);
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_integer_set(struct bt_value *integer_obj,
+enum bt_value_status bt_private_integer_bool_set(struct bt_private_value *integer_obj,
int64_t val)
{
BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_real_set(struct bt_value *real_obj,
+enum bt_value_status bt_private_value_real_set(struct bt_private_value *real_obj,
double val)
{
BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
+enum bt_value_status bt_private_value_string_set(struct bt_private_value *string_obj,
const char *val)
{
BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
return bt_value_array_get_size(array_obj) == 0;
}
-struct bt_value *bt_value_array_borrow_element_by_index(const struct bt_value *array_obj,
+struct bt_value *bt_value_array_borrow_element_by_index(
+ const struct bt_value *array_obj,
uint64_t index)
{
struct bt_value_array *typed_array_obj =
return g_ptr_array_index(typed_array_obj->garray, index);
}
-enum bt_value_status bt_value_array_append_element(struct bt_value *array_obj,
+struct bt_private_value *bt_private_value_array_borrow_element_by_index(
+ const struct bt_private_value *array_obj,
+ uint64_t index)
+{
+ return (void *) bt_value_array_borrow_element_by_index(
+ (void *) array_obj, index);
+}
+
+enum bt_value_status bt_private_value_array_append_element(
+ struct bt_private_value *array_obj,
struct bt_value *element_obj)
{
struct bt_value_array *typed_array_obj =
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_array_append_bool_element(struct bt_value *array_obj,
- bt_bool val)
+enum bt_value_status bt_private_value_array_append_bool_element(
+ struct bt_private_value *array_obj, bt_bool val)
{
enum bt_value_status ret;
- struct bt_value *bool_obj = NULL;
+ struct bt_private_value *bool_obj = NULL;
- bool_obj = bt_value_bool_create_init(val);
- ret = bt_value_array_append_element(array_obj, bool_obj);
+ bool_obj = bt_private_value_bool_create_init(val);
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) bool_obj);
bt_object_put_ref(bool_obj);
return ret;
}
-enum bt_value_status bt_value_array_append_integer_element(
- struct bt_value *array_obj, int64_t val)
+enum bt_value_status bt_private_value_array_append_integer_element(
+ struct bt_private_value *array_obj, int64_t val)
{
enum bt_value_status ret;
- struct bt_value *integer_obj = NULL;
+ struct bt_private_value *integer_obj = NULL;
- integer_obj = bt_value_integer_create_init(val);
- ret = bt_value_array_append_element(array_obj, integer_obj);
+ integer_obj = bt_private_value_integer_create_init(val);
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) integer_obj);
bt_object_put_ref(integer_obj);
return ret;
}
-enum bt_value_status bt_value_array_append_real_element(struct bt_value *array_obj,
- double val)
+enum bt_value_status bt_private_value_array_append_real_element(
+ struct bt_private_value *array_obj, double val)
{
enum bt_value_status ret;
- struct bt_value *real_obj = NULL;
+ struct bt_private_value *real_obj = NULL;
- real_obj = bt_value_real_create_init(val);
- ret = bt_value_array_append_element(array_obj, real_obj);
+ real_obj = bt_private_value_real_create_init(val);
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) real_obj);
bt_object_put_ref(real_obj);
return ret;
}
-enum bt_value_status bt_value_array_append_string_element(struct bt_value *array_obj,
- const char *val)
+enum bt_value_status bt_private_value_array_append_string_element(
+ struct bt_private_value *array_obj, const char *val)
{
enum bt_value_status ret;
- struct bt_value *string_obj = NULL;
+ struct bt_private_value *string_obj = NULL;
- string_obj = bt_value_string_create_init(val);
- ret = bt_value_array_append_element(array_obj, string_obj);
+ string_obj = bt_private_value_string_create_init(val);
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) string_obj);
bt_object_put_ref(string_obj);
return ret;
}
-enum bt_value_status bt_value_array_append_empty_array_element(
- struct bt_value *array_obj)
+enum bt_value_status bt_private_value_array_append_empty_array_element(
+ struct bt_private_value *array_obj)
{
enum bt_value_status ret;
- struct bt_value *empty_array_obj = NULL;
+ struct bt_private_value *empty_array_obj = NULL;
- empty_array_obj = bt_value_array_create();
- ret = bt_value_array_append_element(array_obj, empty_array_obj);
+ empty_array_obj = bt_private_value_array_create();
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) empty_array_obj);
bt_object_put_ref(empty_array_obj);
return ret;
}
-enum bt_value_status bt_value_array_append_empty_map_element(struct bt_value *array_obj)
+enum bt_value_status bt_private_value_array_append_empty_map_element(
+ struct bt_private_value *array_obj)
{
enum bt_value_status ret;
- struct bt_value *map_obj = NULL;
+ struct bt_private_value *map_obj = NULL;
- map_obj = bt_value_map_create();
- ret = bt_value_array_append_element(array_obj, map_obj);
+ map_obj = bt_private_value_map_create();
+ ret = bt_private_value_array_append_element(array_obj,
+ (void *) map_obj);
bt_object_put_ref(map_obj);
return ret;
}
-enum bt_value_status bt_value_array_set_element_by_index(struct bt_value *array_obj,
- uint64_t index, struct bt_value *element_obj)
+enum bt_value_status bt_private_value_array_set_element_by_index(
+ struct bt_private_value *array_obj, uint64_t index,
+ struct bt_value *element_obj)
{
struct bt_value_array *typed_array_obj =
BT_VALUE_TO_ARRAY(array_obj);
GUINT_TO_POINTER(g_quark_from_string(key)));
}
+struct bt_private_value *bt_private_value_map_borrow_entry_value(
+ const struct bt_private_value *map_obj, const char *key)
+{
+ return (void *) bt_value_map_borrow_entry_value((void *) map_obj, key);
+}
+
bt_bool bt_value_map_has_entry(const struct bt_value *map_obj, const char *key)
{
BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
GUINT_TO_POINTER(g_quark_from_string(key)));
}
-enum bt_value_status bt_value_map_insert_entry(struct bt_value *map_obj,
+enum bt_value_status bt_private_value_map_insert_entry(
+ struct bt_private_value *map_obj,
const char *key, struct bt_value *element_obj)
{
BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object");
return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_map_insert_bool_entry(struct bt_value *map_obj,
- const char *key, bt_bool val)
+enum bt_value_status bt_private_value_map_insert_bool_entry(
+ struct bt_private_value *map_obj, const char *key, bt_bool val)
{
enum bt_value_status ret;
- struct bt_value *bool_obj = NULL;
+ struct bt_private_value *bool_obj = NULL;
- bool_obj = bt_value_bool_create_init(val);
- ret = bt_value_map_insert_entry(map_obj, key, bool_obj);
+ bool_obj = bt_private_value_bool_create_init(val);
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) bool_obj);
bt_object_put_ref(bool_obj);
return ret;
}
-enum bt_value_status bt_value_map_insert_integer_entry(struct bt_value *map_obj,
- const char *key, int64_t val)
+enum bt_value_status bt_private_value_map_insert_integer_entry(
+ struct bt_private_value *map_obj, const char *key, int64_t val)
{
enum bt_value_status ret;
- struct bt_value *integer_obj = NULL;
+ struct bt_private_value *integer_obj = NULL;
- integer_obj = bt_value_integer_create_init(val);
- ret = bt_value_map_insert_entry(map_obj, key, integer_obj);
+ integer_obj = bt_private_value_integer_create_init(val);
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) integer_obj);
bt_object_put_ref(integer_obj);
return ret;
}
-enum bt_value_status bt_value_map_insert_real_entry(struct bt_value *map_obj,
- const char *key, double val)
+enum bt_value_status bt_private_value_map_insert_real_entry(
+ struct bt_private_value *map_obj, const char *key, double val)
{
enum bt_value_status ret;
- struct bt_value *real_obj = NULL;
+ struct bt_private_value *real_obj = NULL;
- real_obj = bt_value_real_create_init(val);
- ret = bt_value_map_insert_entry(map_obj, key, real_obj);
+ real_obj = bt_private_value_real_create_init(val);
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) real_obj);
bt_object_put_ref(real_obj);
return ret;
}
-enum bt_value_status bt_value_map_insert_string_entry(struct bt_value *map_obj,
- const char *key, const char *val)
+enum bt_value_status bt_private_value_map_insert_string_entry(
+ struct bt_private_value *map_obj, const char *key, const char *val)
{
enum bt_value_status ret;
- struct bt_value *string_obj = NULL;
+ struct bt_private_value *string_obj = NULL;
- string_obj = bt_value_string_create_init(val);
- ret = bt_value_map_insert_entry(map_obj, key, string_obj);
+ string_obj = bt_private_value_string_create_init(val);
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) string_obj);
bt_object_put_ref(string_obj);
return ret;
}
-enum bt_value_status bt_value_map_insert_empty_array_entry(struct bt_value *map_obj,
- const char *key)
+enum bt_value_status bt_private_value_map_insert_empty_array_entry(
+ struct bt_private_value *map_obj, const char *key)
{
enum bt_value_status ret;
- struct bt_value *array_obj = NULL;
+ struct bt_private_value *array_obj = NULL;
- array_obj = bt_value_array_create();
- ret = bt_value_map_insert_entry(map_obj, key, array_obj);
+ array_obj = bt_private_value_array_create();
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) array_obj);
bt_object_put_ref(array_obj);
return ret;
}
-enum bt_value_status bt_value_map_insert_empty_map_entry(struct bt_value *map_obj,
- const char *key)
+enum bt_value_status bt_private_value_map_insert_empty_map_entry(
+ struct bt_private_value *map_obj, const char *key)
{
enum bt_value_status ret;
- struct bt_value *empty_map_obj = NULL;
+ struct bt_private_value *empty_map_obj = NULL;
- empty_map_obj = bt_value_map_create();
- ret = bt_value_map_insert_entry(map_obj, key, empty_map_obj);
+ empty_map_obj = bt_private_value_map_create();
+ ret = bt_private_value_map_insert_entry(map_obj, key,
+ (void *) empty_map_obj);
bt_object_put_ref(empty_map_obj);
return ret;
}
return ret;
}
+enum bt_value_status bt_private_value_map_foreach_entry(
+ const struct bt_private_value *map_obj,
+ bt_private_value_map_foreach_entry_cb cb, void *data)
+{
+ return bt_value_map_foreach_entry((void *) map_obj,
+ (bt_value_map_foreach_entry_cb) cb, data);
+}
+
struct extend_map_element_data {
- struct bt_value *extended_obj;
+ struct bt_private_value *extended_obj;
bt_bool got_error;
};
struct extend_map_element_data *extend_data = data;
/* Copy object which is to replace the current one */
- struct bt_value *extension_obj_elem_copy =
+ struct bt_private_value *extension_obj_elem_copy =
bt_value_copy(extension_obj_elem);
/* Replace in extended object */
- if (bt_value_map_insert_entry(extend_data->extended_obj, key,
- extension_obj_elem_copy)) {
+ if (bt_private_value_map_insert_entry(extend_data->extended_obj, key,
+ (void *) extension_obj_elem_copy)) {
BT_LOGE("Cannot replace value in extended value: key=\"%s\", "
"extended-value-addr=%p, element-value-addr=%p",
key, extend_data->extended_obj,
return ret;
}
-struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj,
+struct bt_private_value *bt_value_map_extend(struct bt_value *base_map_obj,
struct bt_value *extension_obj)
{
- struct bt_value *extended_obj = NULL;
+ struct bt_private_value *extended_obj = NULL;
struct extend_map_element_data extend_data = { 0 };
BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
BT_OBJECT_PUT_REF_AND_RESET(extended_obj);
end:
- return extended_obj;
+ return (void *) extended_obj;
}
-struct bt_value *bt_value_copy(const struct bt_value *object)
+struct bt_private_value *bt_value_copy(const struct bt_value *object)
{
- struct bt_value *copy_obj = NULL;
+ struct bt_private_value *copy_obj = NULL;
BT_ASSERT_PRE_NON_NULL(object, "Value object");
BT_LOGD("Copying value object: addr=%p", object);
BT_LOGE_STR("Failed to copy value object.");
}
- return copy_obj;
+ return (void *) copy_obj;
}
bt_bool bt_value_compare(const struct bt_value *object_a,
"value-a-addr=%p, value-b-addr=%p, "
"value-a-type=%s, value-b-type=%s",
object_a, object_b,
- bt_value_type_string(object_a->type),
- bt_value_type_string(object_b->type));
+ bt_common_value_type_string(object_a->type),
+ bt_common_value_type_string(object_b->type));
goto end;
}
end:
return ret;
}
+
+struct bt_value *bt_value_borrow_from_private(
+ struct bt_private_value *priv_value)
+{
+ return (void *) priv_value;
+}
.status = BT_QUERY_STATUS_OK,
};
+ struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
char *metadata_text = NULL;
FILE *metadata_fp = NULL;
const char *path;
bool is_packetized;
- query_ret.result = bt_value_map_create();
- if (!query_ret.result) {
+ result = bt_private_value_map_create();
+ if (!result) {
query_ret.status = BT_QUERY_STATUS_NOMEM;
goto error;
}
+ query_ret.result = bt_value_borrow_from_private(result);
BT_ASSERT(params);
if (!bt_value_is_map(params)) {
g_string_append(g_metadata_text, metadata_text);
- ret = bt_value_map_insert_string_entry(query_ret.result, "text",
+ ret = bt_private_value_map_insert_string_entry(result, "text",
g_metadata_text->str);
if (ret) {
BT_LOGE_STR("Cannot insert metadata text into query result.");
goto error;
}
- ret = bt_value_map_insert_bool_entry(query_ret.result, "is-packetized",
+ ret = bt_private_value_map_insert_bool_entry(result, "is-packetized",
is_packetized);
if (ret) {
BT_LOGE_STR("Cannot insert \"is-packetized\" attribute into query result.");
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(query_ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(result);
+ query_ret.result = NULL;
if (query_ret.status >= 0) {
query_ret.status = BT_QUERY_STATUS_ERROR;
}
static
-int add_range(struct bt_value *info, struct range *range,
+int add_range(struct bt_private_value *info, struct range *range,
const char *range_name)
{
int ret = 0;
enum bt_value_status status;
- struct bt_value *range_map = NULL;
+ struct bt_private_value *range_map = NULL;
if (!range->set) {
/* Not an error. */
goto end;
}
- range_map = bt_value_map_create();
+ range_map = bt_private_value_map_create();
if (!range_map) {
ret = -1;
goto end;
}
- status = bt_value_map_insert_integer_entry(range_map, "begin",
+ status = bt_private_value_map_insert_integer_entry(range_map, "begin",
range->begin_ns);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_value_map_insert_integer_entry(range_map, "end",
+ status = bt_private_value_map_insert_integer_entry(range_map, "end",
range->end_ns);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_value_map_insert_entry(info, range_name, range_map);
+ status = bt_private_value_map_insert_entry(info, range_name,
+ bt_value_borrow_from_private(range_map));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
+
end:
bt_object_put_ref(range_map);
return ret;
}
static
-int add_stream_ids(struct bt_value *info, struct bt_stream *stream)
+int add_stream_ids(struct bt_private_value *info, struct bt_stream *stream)
{
int ret = 0;
int64_t stream_class_id, stream_instance_id;
stream_instance_id = bt_stream_get_id(stream);
if (stream_instance_id != -1) {
- status = bt_value_map_insert_integer_entry(info, "id",
+ status = bt_private_value_map_insert_integer_entry(info, "id",
stream_instance_id);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_value_map_insert_integer_entry(info, "class-id", stream_class_id);
+ status = bt_private_value_map_insert_integer_entry(info, "class-id", stream_class_id);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
static
int populate_stream_info(struct ctf_fs_ds_file_group *group,
- struct bt_value *group_info,
+ struct bt_private_value *group_info,
struct range *stream_range)
{
int ret = 0;
size_t file_idx;
enum bt_value_status status;
- struct bt_value *file_paths;
+ struct bt_private_value *file_paths;
stream_range->begin_ns = INT64_MAX;
stream_range->end_ns = 0;
- file_paths = bt_value_array_create();
+ file_paths = bt_private_value_array_create();
if (!file_paths) {
ret = -1;
goto end;
goto end;
}
- status = bt_value_array_append_string_element(file_paths,
+ status = bt_private_value_array_append_string_element(file_paths,
info->path->str);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
}
}
- status = bt_value_map_insert_entry(group_info, "paths", file_paths);
+ status = bt_private_value_map_insert_entry(group_info, "paths",
+ bt_value_borrow_from_private(file_paths));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
static
int populate_trace_info(const char *trace_path, const char *trace_name,
- struct bt_value *trace_info)
+ struct bt_private_value *trace_info)
{
int ret = 0;
size_t group_idx;
struct ctf_fs_trace *trace = NULL;
enum bt_value_status status;
- struct bt_value *file_groups;
+ struct bt_private_value *file_groups;
struct range trace_range = {
.begin_ns = INT64_MAX,
.end_ns = 0,
.set = false,
};
- file_groups = bt_value_array_create();
+ file_groups = bt_private_value_array_create();
if (!file_groups) {
goto end;
}
- status = bt_value_map_insert_string_entry(trace_info, "name",
- trace_name);
+ status = bt_private_value_map_insert_string_entry(trace_info, "name",
+ trace_name);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_value_map_insert_string_entry(trace_info, "path",
+ status = bt_private_value_map_insert_string_entry(trace_info, "path",
trace_path);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
/* Find range of all stream groups, and of the trace. */
for (group_idx = 0; group_idx < trace->ds_file_groups->len;
group_idx++) {
- struct bt_value *group_info;
+ struct bt_private_value *group_info;
struct range group_range = { .set = false };
struct ctf_fs_ds_file_group *group = g_ptr_array_index(
trace->ds_file_groups, group_idx);
- group_info = bt_value_map_create();
+ group_info = bt_private_value_map_create();
if (!group_info) {
ret = -1;
goto end;
trace_intersection.end_ns = min(trace_intersection.end_ns,
group_range.end_ns);
trace_intersection.set = true;
- status = bt_value_array_append_element(file_groups, group_info);
+ status = bt_private_value_array_append_element(
+ file_groups,
+ bt_value_borrow_from_private(group_info));
bt_object_put_ref(group_info);
if (status != BT_VALUE_STATUS_OK) {
goto end;
}
}
- status = bt_value_map_insert_entry(trace_info, "streams", file_groups);
+ status = bt_private_value_map_insert_entry(trace_info, "streams",
+ bt_value_borrow_from_private(file_groups));
BT_OBJECT_PUT_REF_AND_RESET(file_groups);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
.status = BT_QUERY_STATUS_OK,
};
+ struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
int ret = 0;
const char *path = NULL;
goto error;
}
- query_ret.result = bt_value_array_create();
- if (!query_ret.result) {
+ result = bt_private_value_array_create();
+ if (!result) {
query_ret.status = BT_QUERY_STATUS_NOMEM;
goto error;
}
+ query_ret.result = bt_value_borrow_from_private(result);
+
/* Iterates over both trace paths and names simultaneously. */
for (tp_node = trace_paths, tn_node = trace_names; tp_node;
tp_node = g_list_next(tp_node),
GString *trace_path = tp_node->data;
GString *trace_name = tn_node->data;
enum bt_value_status status;
- struct bt_value *trace_info;
+ struct bt_private_value *trace_info;
- trace_info = bt_value_map_create();
+ trace_info = bt_private_value_map_create();
if (!trace_info) {
BT_LOGE("Failed to create trace info map.");
goto error;
goto error;
}
- status = bt_value_array_append_element(query_ret.result, trace_info);
+ status = bt_private_value_array_append_element(result,
+ bt_value_borrow_from_private(trace_info));
bt_object_put_ref(trace_info);
if (status != BT_VALUE_STATUS_OK) {
goto error;
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(query_ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(result);
+ query_ret.result = NULL;
if (query_ret.status >= 0) {
query_ret.status = BT_QUERY_STATUS_ERROR;
}
/* sum */
val += streams;
- ret = bt_value_integer_set(btval, val);
+ ret = bt_private_integer_bool_set(btval, val);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
}
/* max */
val = max_t(int64_t, clients, val);
- ret = bt_value_integer_set(btval, val);
+ ret = bt_private_integer_bool_set(btval, val);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
goto end;
}
- map = bt_value_map_create();
+ map = bt_private_value_map_create();
if (!map) {
ret = BT_VALUE_STATUS_ERROR;
goto end;
g_string_append_c(url, '/');
g_string_append(url, session->session_name);
- ret = bt_value_map_insert_string_entry(map, "url", url->str);
+ ret = bt_private_value_map_insert_string_entry(map, "url", url->str);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
* key = "target-hostname",
* value = <string>,
*/
- ret = bt_value_map_insert_string_entry(map, "target-hostname",
+ ret = bt_private_value_map_insert_string_entry(map, "target-hostname",
session->hostname);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
* key = "session-name",
* value = <string>,
*/
- ret = bt_value_map_insert_string_entry(map, "session-name",
+ ret = bt_private_value_map_insert_string_entry(map, "session-name",
session->session_name);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
{
uint32_t live_timer = be32toh(session->live_timer);
- ret = bt_value_map_insert_integer_entry(map, "timer-us",
+ ret = bt_private_value_map_insert_integer_entry(map, "timer-us",
live_timer);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
{
uint32_t streams = be32toh(session->streams);
- ret = bt_value_map_insert_integer_entry(map, "stream-count",
+ ret = bt_private_value_map_insert_integer_entry(map, "stream-count",
streams);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
{
uint32_t clients = be32toh(session->clients);
- ret = bt_value_map_insert_integer_entry(map, "client-count",
+ ret = bt_private_value_map_insert_integer_entry(map, "client-count",
clients);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
}
- ret = bt_value_array_append_element(results, map);
+ ret = bt_private_value_array_append_element(results, map);
end:
if (url) {
g_string_free(url, TRUE);
goto error;
}
- results = bt_value_array_create();
+ results = bt_private_value_array_create();
if (!results) {
BT_LOGE("Error creating array");
goto error;
#include <ctype.h>
#include <stdio.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/common-internal.h>
#include <babeltrace/babeltrace.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/compat/utc-internal.h>
if (!bt_value_is_bool(no_timestamp)) {
BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
"type=%s",
- bt_value_type_string(
+ bt_common_value_type_string(
bt_value_get_type(no_timestamp)));
goto error;
}
if (!bt_value_is_string(path)) {
BT_LOGE("Expecting a string value for the `path` parameter: "
"type=%s",
- bt_value_type_string(
+ bt_common_value_type_string(
bt_value_get_type(path)));
goto error;
}
}
static
-enum bt_component_status add_params_to_map(struct bt_value *plugin_opt_map)
+enum bt_component_status add_params_to_map(
+ struct bt_private_value *plugin_opt_map)
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
unsigned int i;
const char *key = plugin_options[i];
enum bt_value_status status;
- status = bt_value_map_insert_entry(plugin_opt_map, key, bt_value_null);
+ status = bt_private_value_map_insert_entry(plugin_opt_map, key,
+ bt_value_null);
switch (status) {
case BT_VALUE_STATUS_OK:
break;
bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
{
struct pretty_component *pretty = data;
- struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
- if (!bt_value_map_has_entry(plugin_opt_map, key)) {
+ if (!bt_value_map_has_entry(
+ bt_value_borrow_from_private(pretty->plugin_opt_map),
+ key)) {
fprintf(pretty->err,
"[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
}
bool value, found;
char *str = NULL;
- pretty->plugin_opt_map = bt_value_map_create();
+ pretty->plugin_opt_map = bt_private_value_map_create();
if (!pretty->plugin_opt_map) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
bool start_line;
GString *string;
GString *tmp_string;
- struct bt_value *plugin_opt_map; /* Temporary parameter map. */
+ struct bt_private_value *plugin_opt_map; /* Temporary parameter map. */
bool use_colors;
uint64_t last_cycles_timestamp;
#include <stdbool.h>
#include <inttypes.h>
#include <babeltrace/assert-internal.h>
+#include <babeltrace/common-internal.h>
#include <stdlib.h>
#include <string.h>
}
static
-struct bt_value *get_default_params(void)
+struct bt_private_value *get_default_params(void)
{
- struct bt_value *params;
+ struct bt_private_value *params;
int ret;
- params = bt_value_map_create();
+ params = bt_private_value_map_create();
if (!params) {
BT_LOGE_STR("Cannot create a map value object.");
goto error;
}
- ret = bt_value_map_insert_bool_entry(params,
+ ret = bt_private_value_map_insert_bool_entry(params,
ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, false);
if (ret) {
BT_LOGE_STR("Cannot add boolean value to map value object.");
static
int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
{
- struct bt_value *default_params = NULL;
- struct bt_value *real_params = NULL;
+ struct bt_private_value *default_params = NULL;
+ struct bt_private_value *real_params = NULL;
struct bt_value *assume_absolute_clock_classes = NULL;
int ret = 0;
bt_bool bool_val;
goto error;
}
- real_params = bt_value_map_extend(default_params, params);
+ real_params = bt_value_map_extend(
+ bt_value_borrow_from_private(default_params), params);
if (!real_params) {
BT_LOGE("Cannot extend default parameters map value: "
"muxer-comp-addr=%p, def-params-addr=%p, "
goto error;
}
- assume_absolute_clock_classes = bt_value_map_borrow_entry_value(real_params,
+ assume_absolute_clock_classes = bt_value_map_borrow_entry_value(
+ bt_value_borrow_from_private(real_params),
ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
if (assume_absolute_clock_classes &&
!bt_value_is_bool(assume_absolute_clock_classes)) {
BT_LOGE("Expecting a boolean value for the `%s` parameter: "
"muxer-comp-addr=%p, value-type=%s",
ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, muxer_comp,
- bt_value_type_string(
+ bt_common_value_type_string(
bt_value_get_type(assume_absolute_clock_classes)));
goto error;
}
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-internal.h>
struct bt_query_executor *query_exec,
const char *object, struct bt_value *params)
{
+ struct bt_private_value *results = bt_private_value_array_create();
struct bt_component_class_query_method_return ret = {
.status = BT_QUERY_STATUS_OK,
- .result = bt_value_array_create(),
+ .result = bt_value_borrow_from_private(results),
};
int iret;
BT_ASSERT(ret.result);
- iret = bt_value_array_append_string_element(ret.result, object);
+ iret = bt_private_value_array_append_string_element(results, object);
BT_ASSERT(iret == 0);
- iret = bt_value_array_append_element(ret.result, params);
+ iret = bt_private_value_array_append_element(results, params);
BT_ASSERT(iret == 0);
return ret;
}
#include <babeltrace/object.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/assert-internal.h>
#include <string.h>
#include "tap/tap.h"
{
int ret;
bt_bool value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
- obj = bt_value_bool_create();
+ priv_obj = bt_private_value_bool_create();
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_bool(obj),
- "bt_value_bool_create() returns a boolean value object");
+ "bt_private_value_bool_create() returns a boolean value object");
value = BT_TRUE;
ret = bt_value_bool_get(obj, &value);
ok(!ret && !value, "default boolean value object value is BT_FALSE");
- BT_ASSERT(!bt_value_bool_set(obj, BT_FALSE));
- ret = bt_value_bool_set(obj, BT_TRUE);
- ok(!ret, "bt_value_bool_set() succeeds");
+ BT_ASSERT(!bt_private_value_bool_set(priv_obj, BT_FALSE));
+ ret = bt_private_value_bool_set(priv_obj, BT_TRUE);
+ ok(!ret, "bt_private_value_bool_set() succeeds");
ret = bt_value_bool_get(obj, &value);
- ok(!ret && value, "bt_value_bool_set() works");
+ ok(!ret && value, "bt_private_value_bool_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing boolean value object does not cause a crash")
value = BT_FALSE;
- obj = bt_value_bool_create_init(BT_TRUE);
+ priv_obj = bt_private_value_bool_create_init(BT_TRUE);
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_bool(obj),
- "bt_value_bool_create_init() returns a boolean value object");
+ "bt_private_value_bool_create_init() returns a boolean value object");
ret = bt_value_bool_get(obj, &value);
ok(!ret && value,
- "bt_value_bool_create_init() sets the appropriate initial value");
+ "bt_private_value_bool_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
}
static
{
int ret;
int64_t value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
- obj = bt_value_integer_create();
+ priv_obj = bt_private_value_integer_create();
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_integer(obj),
- "bt_value_integer_create() returns an integer value object");
+ "bt_private_value_integer_create() returns an integer value object");
value = 1961;
ret = bt_value_integer_get(obj, &value);
ok(!ret && value == 0, "default integer value object value is 0");
- ret = bt_value_integer_set(obj, -98765);
- ok(!ret, "bt_value_integer_set() succeeds");
+ ret = bt_private_integer_bool_set(priv_obj, -98765);
+ ok(!ret, "bt_private_integer_bool_set() succeeds");
ret = bt_value_integer_get(obj, &value);
- ok(!ret && value == -98765, "bt_value_integer_set() works");
+ ok(!ret && value == -98765, "bt_private_integer_bool_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing integer value object does not cause a crash")
- obj = bt_value_integer_create_init(321456987);
+ priv_obj = bt_private_value_integer_create_init(321456987);
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_integer(obj),
- "bt_value_integer_create_init() returns an integer value object");
+ "bt_private_value_integer_create_init() returns an integer value object");
ret = bt_value_integer_get(obj, &value);
ok(!ret && value == 321456987,
- "bt_value_integer_create_init() sets the appropriate initial value");
+ "bt_private_value_integer_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
}
static
{
int ret;
double value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
- obj = bt_value_real_create();
+ priv_obj = bt_private_value_real_create();
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_real(obj),
- "bt_value_real_create() returns a real number value object");
+ "bt_private_value_real_create() returns a real number value object");
value = 17.34;
ret = bt_value_real_get(obj, &value);
ok(!ret && value == 0.,
"default real number value object value is 0");
- ret = bt_value_real_set(obj, -3.1416);
- ok(!ret, "bt_value_real_set() succeeds");
+ ret = bt_private_value_real_set(priv_obj, -3.1416);
+ ok(!ret, "bt_private_value_real_set() succeeds");
ret = bt_value_real_get(obj, &value);
- ok(!ret && value == -3.1416, "bt_value_real_set() works");
+ ok(!ret && value == -3.1416, "bt_private_value_real_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing real number value object does not cause a crash")
- obj = bt_value_real_create_init(33.1649758);
+ priv_obj = bt_private_value_real_create_init(33.1649758);
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_real(obj),
- "bt_value_real_create_init() returns a real number value object");
+ "bt_private_value_real_create_init() returns a real number value object");
ret = bt_value_real_get(obj, &value);
ok(!ret && value == 33.1649758,
- "bt_value_real_create_init() sets the appropriate initial value");
+ "bt_private_value_real_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
}
static
{
int ret;
const char *value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
- obj = bt_value_string_create();
+ priv_obj = bt_private_value_string_create();
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_string(obj),
- "bt_value_string_create() returns a string value object");
+ "bt_private_value_string_create() returns a string value object");
ret = bt_value_string_get(obj, &value);
ok(!ret && value && !strcmp(value, ""),
"default string value object value is \"\"");
- ret = bt_value_string_set(obj, "hello worldz");
- ok(!ret, "bt_value_string_set() succeeds");
+ ret = bt_private_value_string_set(priv_obj, "hello worldz");
+ ok(!ret, "bt_private_value_string_set() succeeds");
ret = bt_value_string_get(obj, &value);
ok(!ret && value && !strcmp(value, "hello worldz"),
"bt_value_string_get() works");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing string value object does not cause a crash")
- obj = bt_value_string_create_init("initial value");
+ priv_obj = bt_private_value_string_create_init("initial value");
+ obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_string(obj),
- "bt_value_string_create_init() returns a string value object");
+ "bt_private_value_string_create_init() returns a string value object");
ret = bt_value_string_get(obj, &value);
ok(!ret && value && !strcmp(value, "initial value"),
- "bt_value_string_create_init() sets the appropriate initial value");
+ "bt_private_value_string_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
}
static
bt_bool bool_value;
int64_t int_value;
double real_value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
const char *string_value;
+ struct bt_private_value *priv_array_obj;
struct bt_value *array_obj;
- array_obj = bt_value_array_create();
+ priv_array_obj = bt_private_value_array_create();
+ array_obj = bt_value_borrow_from_private(priv_array_obj);
ok(array_obj && bt_value_is_array(array_obj),
- "bt_value_array_create() returns an array value object");
+ "bt_private_value_array_create() returns an array value object");
ok(bt_value_array_is_empty(array_obj),
"initial array value object size is 0");
- obj = bt_value_integer_create_init(345);
- ret = bt_value_array_append_element(array_obj, obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- obj = bt_value_real_create_init(-17.45);
- ret |= bt_value_array_append_element(array_obj, obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- obj = bt_value_bool_create_init(BT_TRUE);
- ret |= bt_value_array_append_element(array_obj, obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- ret |= bt_value_array_append_element(array_obj, bt_value_null);
- ok(!ret, "bt_value_array_append_element() succeeds");
+ priv_obj = bt_private_value_integer_create_init(345);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret = bt_private_value_array_append_element(priv_array_obj, obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ priv_obj = bt_private_value_real_create_init(-17.45);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret |= bt_private_value_array_append_element(priv_array_obj, obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ priv_obj = bt_private_value_bool_create_init(BT_TRUE);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret |= bt_private_value_array_append_element(priv_array_obj, obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ ret |= bt_private_value_array_append_element(priv_array_obj,
+ bt_value_null);
+ ok(!ret, "bt_private_value_array_append_element() succeeds");
ok(bt_value_array_get_size(array_obj) == 4,
"appending an element to an array value object increment its size");
ok(obj == bt_value_null,
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (null)");
- obj = bt_value_integer_create_init(1001);
+ priv_obj = bt_private_value_integer_create_init(1001);
+ obj = bt_value_borrow_from_private(priv_obj);
BT_ASSERT(obj);
- ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
+ ok(!bt_private_value_array_set_element_by_index(priv_array_obj, 2, obj),
"bt_value_array_set_element_by_index() succeeds");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
obj = bt_value_array_borrow_element_by_index(array_obj, 2);
ok(obj && bt_value_is_integer(obj),
"bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
ok(int_value == 1001,
"bt_value_array_set_element_by_index() inserts an value object with the appropriate value");
- ret = bt_value_array_append_bool_element(array_obj, BT_FALSE);
- ok(!ret, "bt_value_array_append_bool_element() succeeds");
- ret = bt_value_array_append_integer_element(array_obj, 98765);
- ok(!ret, "bt_value_array_append_integer_element() succeeds");
- ret = bt_value_array_append_real_element(array_obj, 2.49578);
- ok(!ret, "bt_value_array_append_real_element() succeeds");
- ret = bt_value_array_append_string_element(array_obj, "bt_value");
- ok(!ret, "bt_value_array_append_string_element() succeeds");
- ret = bt_value_array_append_empty_array_element(array_obj);
- ok(!ret, "bt_value_array_append_empty_array_element() succeeds");
- ret = bt_value_array_append_empty_map_element(array_obj);
- ok(!ret, "bt_value_array_append_empty_map_element() succeeds");
+ ret = bt_private_value_array_append_bool_element(priv_array_obj,
+ BT_FALSE);
+ ok(!ret, "bt_private_value_array_append_bool_element() succeeds");
+ ret = bt_private_value_array_append_integer_element(priv_array_obj,
+ 98765);
+ ok(!ret, "bt_private_value_array_append_integer_element() succeeds");
+ ret = bt_private_value_array_append_real_element(priv_array_obj,
+ 2.49578);
+ ok(!ret, "bt_private_value_array_append_real_element() succeeds");
+ ret = bt_private_value_array_append_string_element(priv_array_obj,
+ "bt_value");
+ ok(!ret, "bt_private_value_array_append_string_element() succeeds");
+ ret = bt_private_value_array_append_empty_array_element(priv_array_obj);
+ ok(!ret, "bt_private_value_array_append_empty_array_element() succeeds");
+ ret = bt_private_value_array_append_empty_map_element(priv_array_obj);
+ ok(!ret, "bt_private_value_array_append_empty_map_element() succeeds");
ok(bt_value_array_get_size(array_obj) == 10,
- "the bt_value_array_append_element_*() functions increment the array value object's size");
+ "the bt_private_value_array_append_element_*() functions increment the array value object's size");
ok(!bt_value_array_is_empty(array_obj),
"map value object is not empty");
obj = bt_value_array_borrow_element_by_index(array_obj, 4);
ok(obj && bt_value_is_bool(obj),
- "bt_value_array_append_bool_element() appends a boolean value object");
+ "bt_private_value_array_append_bool_element() appends a boolean value object");
ret = bt_value_bool_get(obj, &bool_value);
ok(!ret && !bool_value,
- "bt_value_array_append_bool_element() appends the appropriate value");
+ "bt_private_value_array_append_bool_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 5);
ok(obj && bt_value_is_integer(obj),
- "bt_value_array_append_integer_element() appends an integer value object");
+ "bt_private_value_array_append_integer_element() appends an integer value object");
ret = bt_value_integer_get(obj, &int_value);
ok(!ret && int_value == 98765,
- "bt_value_array_append_integer_element() appends the appropriate value");
+ "bt_private_value_array_append_integer_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 6);
ok(obj && bt_value_is_real(obj),
- "bt_value_array_append_real_element() appends a real number value object");
+ "bt_private_value_array_append_real_element() appends a real number value object");
ret = bt_value_real_get(obj, &real_value);
ok(!ret && real_value == 2.49578,
- "bt_value_array_append_real_element() appends the appropriate value");
+ "bt_private_value_array_append_real_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 7);
ok(obj && bt_value_is_string(obj),
- "bt_value_array_append_string_element() appends a string value object");
+ "bt_private_value_array_append_string_element() appends a string value object");
ret = bt_value_string_get(obj, &string_value);
ok(!ret && string_value && !strcmp(string_value, "bt_value"),
- "bt_value_array_append_string_element() appends the appropriate value");
+ "bt_private_value_array_append_string_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 8);
ok(obj && bt_value_is_array(obj),
- "bt_value_array_append_empty_array_element() appends an array value object");
+ "bt_private_value_array_append_empty_array_element() appends an array value object");
ok(bt_value_array_is_empty(obj),
- "bt_value_array_append_empty_array_element() an empty array value object");
+ "bt_private_value_array_append_empty_array_element() an empty array value object");
obj = bt_value_array_borrow_element_by_index(array_obj, 9);
ok(obj && bt_value_is_map(obj),
- "bt_value_array_append_empty_map_element() appends a map value object");
+ "bt_private_value_array_append_empty_map_element() appends a map value object");
ok(bt_value_map_is_empty(obj),
- "bt_value_array_append_empty_map_element() an empty map value object");
+ "bt_private_value_array_append_empty_map_element() an empty map value object");
- BT_OBJECT_PUT_REF_AND_RESET(array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_array_obj);
pass("putting an existing array value object does not cause a crash")
}
checklist->map2 = BT_TRUE;
}
} else {
- fail("test_map_foreach_cb_check(): unknown map key \"%s\"", key);
+ fail("test_map_foreach_cb_check(): unknown map key \"%s\"",
+ key);
}
return BT_TRUE;
bt_bool bool_value;
int64_t int_value;
double real_value;
+ struct bt_private_value *priv_obj;
struct bt_value *obj;
+ struct bt_private_value *priv_map_obj;
struct bt_value *map_obj;
struct map_foreach_checklist checklist;
- map_obj = bt_value_map_create();
+ priv_map_obj = bt_private_value_map_create();
+ map_obj = bt_value_borrow_from_private(priv_map_obj);
ok(map_obj && bt_value_is_map(map_obj),
- "bt_value_map_create() returns a map value object");
+ "bt_private_value_map_create() returns a map value object");
ok(bt_value_map_get_size(map_obj) == 0,
"initial map value object size is 0");
- obj = bt_value_integer_create_init(19457);
- ret = bt_value_map_insert_entry(map_obj, "int", obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- obj = bt_value_real_create_init(5.444);
- ret |= bt_value_map_insert_entry(map_obj, "real", obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- obj = bt_value_bool_create();
- ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- ret |= bt_value_map_insert_entry(map_obj, "null", bt_value_null);
- ok(!ret, "bt_value_map_insert_entry() succeeds");
+ priv_obj = bt_private_value_integer_create_init(19457);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret = bt_private_value_map_insert_entry(priv_map_obj, "int", obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ priv_obj = bt_private_value_real_create_init(5.444);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret |= bt_private_value_map_insert_entry(priv_map_obj, "real", obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ priv_obj = bt_private_value_bool_create();
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret |= bt_private_value_map_insert_entry(priv_map_obj, "bt_bool", obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ ret |= bt_private_value_map_insert_entry(priv_map_obj, "null",
+ bt_value_null);
+ ok(!ret, "bt_private_value_map_insert_entry() succeeds");
ok(bt_value_map_get_size(map_obj) == 4,
"inserting an element into a map value object increment its size");
- obj = bt_value_bool_create_init(BT_TRUE);
- ret = bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_OBJECT_PUT_REF_AND_RESET(obj);
- ok(!ret, "bt_value_map_insert_entry() accepts an existing key");
+ priv_obj = bt_private_value_bool_create_init(BT_TRUE);
+ obj = bt_value_borrow_from_private(priv_obj);
+ ret = bt_private_value_map_insert_entry(priv_map_obj, "bt_bool", obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ ok(!ret, "bt_private_value_map_insert_entry() accepts an existing key");
obj = bt_value_map_borrow_entry_value(map_obj, "life");
ok(!obj, "bt_value_map_borrow_entry_value() returns NULL with an non existing key");
ok(!ret && bool_value,
"bt_value_map_borrow_entry_value() returns an value object with the appropriate value (boolean)");
- ret = bt_value_map_insert_bool_entry(map_obj, "bool2", BT_TRUE);
- ok(!ret, "bt_value_map_insert_bool_entry() succeeds");
- ret = bt_value_map_insert_integer_entry(map_obj, "int2", 98765);
- ok(!ret, "bt_value_map_insert_integer_entry() succeeds");
- ret = bt_value_map_insert_real_entry(map_obj, "real2", -49.0001);
- ok(!ret, "bt_value_map_insert_real_entry() succeeds");
- ret = bt_value_map_insert_string_entry(map_obj, "string2", "bt_value");
- ok(!ret, "bt_value_map_insert_string_entry() succeeds");
- ret = bt_value_map_insert_empty_array_entry(map_obj, "array2");
- ok(!ret, "bt_value_map_insert_empty_array_entry() succeeds");
- ret = bt_value_map_insert_empty_map_entry(map_obj, "map2");
- ok(!ret, "bt_value_map_insert_empty_map_entry() succeeds");
+ ret = bt_private_value_map_insert_bool_entry(priv_map_obj, "bool2",
+ BT_TRUE);
+ ok(!ret, "bt_private_value_map_insert_bool_entry() succeeds");
+ ret = bt_private_value_map_insert_integer_entry(priv_map_obj, "int2",
+ 98765);
+ ok(!ret, "bt_private_value_map_insert_integer_entry() succeeds");
+ ret = bt_private_value_map_insert_real_entry(priv_map_obj, "real2",
+ -49.0001);
+ ok(!ret, "bt_private_value_map_insert_real_entry() succeeds");
+ ret = bt_private_value_map_insert_string_entry(priv_map_obj, "string2",
+ "bt_value");
+ ok(!ret, "bt_private_value_map_insert_string_entry() succeeds");
+ ret = bt_private_value_map_insert_empty_array_entry(priv_map_obj,
+ "array2");
+ ok(!ret, "bt_private_value_map_insert_empty_array_entry() succeeds");
+ ret = bt_private_value_map_insert_empty_map_entry(priv_map_obj, "map2");
+ ok(!ret, "bt_private_value_map_insert_empty_map_entry() succeeds");
ok(bt_value_map_get_size(map_obj) == 10,
"the bt_value_map_insert*() functions increment the map value object's size");
ok(bt_value_map_has_entry(map_obj, "map2"),
"map value object has key \"map2\"");
- ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count, &count);
+ ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count,
+ &count);
ok(ret == BT_VALUE_STATUS_CANCELED && count == 3,
"bt_value_map_foreach_entry() breaks the loop when the user function returns BT_FALSE");
checklist.array2 && checklist.map2,
"bt_value_map_foreach_entry() iterates over all the map value object's elements");
- BT_OBJECT_PUT_REF_AND_RESET(map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(priv_map_obj);
pass("putting an existing map value object does not cause a crash")
}
static
void test_compare_bool(void)
{
- struct bt_value *bool1 = bt_value_bool_create_init(BT_FALSE);
- struct bt_value *bool2 = bt_value_bool_create_init(BT_TRUE);
- struct bt_value *bool3 = bt_value_bool_create_init(BT_FALSE);
+ struct bt_private_value *bool1 =
+ bt_private_value_bool_create_init(BT_FALSE);
+ struct bt_private_value *bool2 =
+ bt_private_value_bool_create_init(BT_TRUE);
+ struct bt_private_value *bool3 =
+ bt_private_value_bool_create_init(BT_FALSE);
BT_ASSERT(bool1 && bool2 && bool3);
- ok(!bt_value_compare(bt_value_null, bool1),
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(bool1)),
"cannot compare null value object and bt_bool value object");
- ok(!bt_value_compare(bool1, bool2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(bool1),
+ bt_value_borrow_from_private(bool2)),
"boolean value objects are not equivalent (BT_FALSE and BT_TRUE)");
- ok(bt_value_compare(bool1, bool3),
+ ok(bt_value_compare(bt_value_borrow_from_private(bool1),
+ bt_value_borrow_from_private(bool3)),
"boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
BT_OBJECT_PUT_REF_AND_RESET(bool1);
static
void test_compare_integer(void)
{
- struct bt_value *int1 = bt_value_integer_create_init(10);
- struct bt_value *int2 = bt_value_integer_create_init(-23);
- struct bt_value *int3 = bt_value_integer_create_init(10);
+ struct bt_private_value *int1 =
+ bt_private_value_integer_create_init(10);
+ struct bt_private_value *int2 =
+ bt_private_value_integer_create_init(-23);
+ struct bt_private_value *int3 =
+ bt_private_value_integer_create_init(10);
BT_ASSERT(int1 && int2 && int3);
- ok(!bt_value_compare(bt_value_null, int1),
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(int1)),
"cannot compare null value object and integer value object");
- ok(!bt_value_compare(int1, int2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(int1),
+ bt_value_borrow_from_private(int2)),
"integer value objects are not equivalent (10 and -23)");
- ok(bt_value_compare(int1, int3),
+ ok(bt_value_compare(bt_value_borrow_from_private(int1),
+ bt_value_borrow_from_private(int3)),
"integer value objects are equivalent (10 and 10)");
BT_OBJECT_PUT_REF_AND_RESET(int1);
static
void test_compare_real(void)
{
- struct bt_value *real1 = bt_value_real_create_init(17.38);
- struct bt_value *real2 = bt_value_real_create_init(-14.23);
- struct bt_value *real3 = bt_value_real_create_init(17.38);
+ struct bt_private_value *real1 =
+ bt_private_value_real_create_init(17.38);
+ struct bt_private_value *real2 =
+ bt_private_value_real_create_init(-14.23);
+ struct bt_private_value *real3 =
+ bt_private_value_real_create_init(17.38);
BT_ASSERT(real1 && real2 && real3);
- ok(!bt_value_compare(bt_value_null, real1),
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(real1)),
"cannot compare null value object and real number value object");
- ok(!bt_value_compare(real1, real2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(real1),
+ bt_value_borrow_from_private(real2)),
"real number value objects are not equivalent (17.38 and -14.23)");
- ok(bt_value_compare(real1, real3),
+ ok(bt_value_compare(bt_value_borrow_from_private(real1),
+ bt_value_borrow_from_private(real3)),
"real number value objects are equivalent (17.38 and 17.38)");
BT_OBJECT_PUT_REF_AND_RESET(real1);
static
void test_compare_string(void)
{
- struct bt_value *string1 = bt_value_string_create_init("hello");
- struct bt_value *string2 = bt_value_string_create_init("bt_value");
- struct bt_value *string3 = bt_value_string_create_init("hello");
+ struct bt_private_value *string1 =
+ bt_private_value_string_create_init("hello");
+ struct bt_private_value *string2 =
+ bt_private_value_string_create_init("bt_value");
+ struct bt_private_value *string3 =
+ bt_private_value_string_create_init("hello");
BT_ASSERT(string1 && string2 && string3);
- ok(!bt_value_compare(bt_value_null, string1),
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(string1)),
"cannot compare null value object and string value object");
- ok(!bt_value_compare(string1, string2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(string1),
+ bt_value_borrow_from_private(string2)),
"string value objects are not equivalent (\"hello\" and \"bt_value\")");
- ok(bt_value_compare(string1, string3),
+ ok(bt_value_compare(bt_value_borrow_from_private(string1),
+ bt_value_borrow_from_private(string3)),
"string value objects are equivalent (\"hello\" and \"hello\")");
BT_OBJECT_PUT_REF_AND_RESET(string1);
static
void test_compare_array(void)
{
- struct bt_value *array1 = bt_value_array_create();
- struct bt_value *array2 = bt_value_array_create();
- struct bt_value *array3 = bt_value_array_create();
+ struct bt_private_value *array1 = bt_private_value_array_create();
+ struct bt_private_value *array2 = bt_private_value_array_create();
+ struct bt_private_value *array3 = bt_private_value_array_create();
+ enum bt_value_status status;
BT_ASSERT(array1 && array2 && array3);
- ok(bt_value_compare(array1, array2),
+ ok(bt_value_compare(bt_value_borrow_from_private(array1),
+ bt_value_borrow_from_private(array2)),
"empty array value objects are equivalent");
- BT_ASSERT(!bt_value_array_append_integer_element(array1, 23));
- BT_ASSERT(!bt_value_array_append_real_element(array1, 14.2));
- BT_ASSERT(!bt_value_array_append_bool_element(array1, BT_FALSE));
- BT_ASSERT(!bt_value_array_append_real_element(array2, 14.2));
- BT_ASSERT(!bt_value_array_append_integer_element(array2, 23));
- BT_ASSERT(!bt_value_array_append_bool_element(array2, BT_FALSE));
- BT_ASSERT(!bt_value_array_append_integer_element(array3, 23));
- BT_ASSERT(!bt_value_array_append_real_element(array3, 14.2));
- BT_ASSERT(!bt_value_array_append_bool_element(array3, BT_FALSE));
- BT_ASSERT(bt_value_array_get_size(array1) == 3);
- BT_ASSERT(bt_value_array_get_size(array2) == 3);
- BT_ASSERT(bt_value_array_get_size(array3) == 3);
-
- ok(!bt_value_compare(bt_value_null, array1),
+ status = bt_private_value_array_append_integer_element(array1, 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_real_element(array1, 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_bool_element(array1, BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_real_element(array2, 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_integer_element(array2, 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_bool_element(array2, BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_integer_element(array3, 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_real_element(array3, 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_bool_element(array3, BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ BT_ASSERT(bt_value_array_get_size(
+ bt_value_borrow_from_private(array1)) == 3);
+ BT_ASSERT(bt_value_array_get_size(
+ bt_value_borrow_from_private(array2)) == 3);
+ BT_ASSERT(bt_value_array_get_size(
+ bt_value_borrow_from_private(array3)) == 3);
+
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(array1)),
"cannot compare null value object and array value object");
- ok(!bt_value_compare(array1, array2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(array1),
+ bt_value_borrow_from_private(array2)),
"array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])");
- ok(bt_value_compare(array1, array3),
+ ok(bt_value_compare(bt_value_borrow_from_private(array1),
+ bt_value_borrow_from_private(array3)),
"array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
BT_OBJECT_PUT_REF_AND_RESET(array1);
static
void test_compare_map(void)
{
- struct bt_value *map1 = bt_value_map_create();
- struct bt_value *map2 = bt_value_map_create();
- struct bt_value *map3 = bt_value_map_create();
+ struct bt_private_value *map1 = bt_private_value_map_create();
+ struct bt_private_value *map2 = bt_private_value_map_create();
+ struct bt_private_value *map3 = bt_private_value_map_create();
+ enum bt_value_status status;
BT_ASSERT(map1 && map2 && map3);
- ok(bt_value_compare(map1, map2),
+ ok(bt_value_compare(bt_value_borrow_from_private(map1),
+ bt_value_borrow_from_private(map2)),
"empty map value objects are equivalent");
- BT_ASSERT(!bt_value_map_insert_integer_entry(map1, "one", 23));
- BT_ASSERT(!bt_value_map_insert_real_entry(map1, "two", 14.2));
- BT_ASSERT(!bt_value_map_insert_bool_entry(map1, "three", BT_FALSE));
- BT_ASSERT(!bt_value_map_insert_real_entry(map2, "one", 14.2));
- BT_ASSERT(!bt_value_map_insert_integer_entry(map2, "two", 23));
- BT_ASSERT(!bt_value_map_insert_bool_entry(map2, "three", BT_FALSE));
- BT_ASSERT(!bt_value_map_insert_bool_entry(map3, "three", BT_FALSE));
- BT_ASSERT(!bt_value_map_insert_integer_entry(map3, "one", 23));
- BT_ASSERT(!bt_value_map_insert_real_entry(map3, "two", 14.2));
- BT_ASSERT(bt_value_map_get_size(map1) == 3);
- BT_ASSERT(bt_value_map_get_size(map2) == 3);
- BT_ASSERT(bt_value_map_get_size(map3) == 3);
-
- ok(!bt_value_compare(bt_value_null, map1),
+
+ status = bt_private_value_map_insert_integer_entry(map1, "one", 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_real_entry(map1, "two", 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_bool_entry(map1, "three",
+ BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_real_entry(map2, "one", 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_integer_entry(map2, "two", 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_bool_entry(map2, "three",
+ BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_bool_entry(map3, "three",
+ BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_integer_entry(map3, "one", 23);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_real_entry(map3, "two", 14.2);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ BT_ASSERT(bt_value_map_get_size(
+ bt_value_borrow_from_private(map1)) == 3);
+ BT_ASSERT(bt_value_map_get_size(
+ bt_value_borrow_from_private(map2)) == 3);
+ BT_ASSERT(bt_value_map_get_size(
+ bt_value_borrow_from_private(map3)) == 3);
+
+ ok(!bt_value_compare(bt_value_null,
+ bt_value_borrow_from_private(map1)),
"cannot compare null value object and map value object");
- ok(!bt_value_compare(map1, map2),
+ ok(!bt_value_compare(bt_value_borrow_from_private(map1),
+ bt_value_borrow_from_private(map2)),
"map value objects are not equivalent");
- ok(bt_value_compare(map1, map3),
+ ok(bt_value_compare(bt_value_borrow_from_private(map1),
+ bt_value_borrow_from_private(map3)),
"map value objects are equivalent");
BT_OBJECT_PUT_REF_AND_RESET(map1);
* bt_value_compare() elsewhere, then the deep copy is a
* success.
*/
- struct bt_value *null_copy_obj;
- struct bt_value *bool_obj, *bool_copy_obj;
- struct bt_value *integer_obj, *integer_copy_obj;
- struct bt_value *real_obj, *real_copy_obj;
- struct bt_value *string_obj, *string_copy_obj;
- struct bt_value *array_obj, *array_copy_obj;
- struct bt_value *map_obj, *map_copy_obj;
-
- bool_obj = bt_value_bool_create_init(BT_TRUE);
- integer_obj = bt_value_integer_create_init(23);
- real_obj = bt_value_real_create_init(-3.1416);
- string_obj = bt_value_string_create_init("test");
- array_obj = bt_value_array_create();
- map_obj = bt_value_map_create();
+ struct bt_private_value *null_copy_obj;
+ struct bt_private_value *bool_obj, *bool_copy_obj;
+ struct bt_private_value *integer_obj, *integer_copy_obj;
+ struct bt_private_value *real_obj, *real_copy_obj;
+ struct bt_private_value *string_obj, *string_copy_obj;
+ struct bt_private_value *array_obj, *array_copy_obj;
+ struct bt_private_value *map_obj, *map_copy_obj;
+ enum bt_value_status status;
+
+ bool_obj = bt_private_value_bool_create_init(BT_TRUE);
+ integer_obj = bt_private_value_integer_create_init(23);
+ real_obj = bt_private_value_real_create_init(-3.1416);
+ string_obj = bt_private_value_string_create_init("test");
+ array_obj = bt_private_value_array_create();
+ map_obj = bt_private_value_map_create();
BT_ASSERT(bool_obj && integer_obj && real_obj && string_obj &&
array_obj && map_obj);
- BT_ASSERT(!bt_value_array_append_element(array_obj, bool_obj));
- BT_ASSERT(!bt_value_array_append_element(array_obj, integer_obj));
- BT_ASSERT(!bt_value_array_append_element(array_obj, real_obj));
- BT_ASSERT(!bt_value_array_append_element(array_obj, bt_value_null));
- BT_ASSERT(!bt_value_map_insert_entry(map_obj, "array", array_obj));
- BT_ASSERT(!bt_value_map_insert_entry(map_obj, "string", string_obj));
+ status = bt_private_value_array_append_element(array_obj,
+ bt_value_borrow_from_private(bool_obj));
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_element(array_obj,
+ bt_value_borrow_from_private(integer_obj));
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_element(array_obj,
+ bt_value_borrow_from_private(real_obj));
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_array_append_element(array_obj,
+ bt_value_null);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_entry(map_obj, "array",
+ bt_value_borrow_from_private(array_obj));
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_private_value_map_insert_entry(map_obj, "string",
+ bt_value_borrow_from_private(string_obj));
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
- map_copy_obj = bt_value_copy(map_obj);
+ map_copy_obj = bt_value_copy(bt_value_borrow_from_private(map_obj));
ok(map_copy_obj,
"bt_value_copy() succeeds");
ok(map_obj != map_copy_obj,
"bt_value_copy() returns a different pointer (map)");
- string_copy_obj = bt_value_map_borrow_entry_value(map_copy_obj, "string");
+ string_copy_obj = bt_private_value_map_borrow_entry_value(map_copy_obj,
+ "string");
ok(string_copy_obj != string_obj,
"bt_value_copy() returns a different pointer (string)");
- array_copy_obj = bt_value_map_borrow_entry_value(map_copy_obj, "array");
+ array_copy_obj = bt_private_value_map_borrow_entry_value(map_copy_obj,
+ "array");
ok(array_copy_obj != array_obj,
"bt_value_copy() returns a different pointer (array)");
- bool_copy_obj = bt_value_array_borrow_element_by_index(array_copy_obj, 0);
+ bool_copy_obj = bt_private_value_array_borrow_element_by_index(
+ array_copy_obj, 0);
ok(bool_copy_obj != bool_obj,
"bt_value_copy() returns a different pointer (bt_bool)");
- integer_copy_obj = bt_value_array_borrow_element_by_index(array_copy_obj, 1);
+ integer_copy_obj = bt_private_value_array_borrow_element_by_index(
+ array_copy_obj, 1);
ok(integer_copy_obj != integer_obj,
"bt_value_copy() returns a different pointer (integer)");
- real_copy_obj = bt_value_array_borrow_element_by_index(array_copy_obj, 2);
+ real_copy_obj = bt_private_value_array_borrow_element_by_index(
+ array_copy_obj, 2);
ok(real_copy_obj != real_obj,
"bt_value_copy() returns a different pointer (real)");
- null_copy_obj = bt_value_array_borrow_element_by_index(array_copy_obj, 3);
- ok(null_copy_obj == bt_value_null,
+ null_copy_obj = bt_private_value_array_borrow_element_by_index(
+ array_copy_obj, 3);
+ ok(bt_value_borrow_from_private(null_copy_obj) == bt_value_null,
"bt_value_copy() returns the same pointer (null)");
- ok(bt_value_compare(map_obj, map_copy_obj),
+ ok(bt_value_compare(bt_value_borrow_from_private(map_obj),
+ bt_value_borrow_from_private(map_copy_obj)),
"source and destination value objects have the same content");
BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj);
static
void test_extend(void)
{
- struct bt_value *base_map = bt_value_map_create();
- struct bt_value *extension_map = bt_value_map_create();
- struct bt_value *extended_map = NULL;
- struct bt_value *array = bt_value_array_create();
+ struct bt_private_value *base_map = bt_private_value_map_create();
+ struct bt_private_value *extension_map = bt_private_value_map_create();
+ struct bt_private_value *extended_map = NULL;
+ struct bt_private_value *array = bt_private_value_array_create();
enum bt_value_status status;
BT_ASSERT(base_map);
BT_ASSERT(extension_map);
BT_ASSERT(array);
- status = bt_value_map_insert_bool_entry(base_map, "file", BT_TRUE);
+ status = bt_private_value_map_insert_bool_entry(base_map, "file",
+ BT_TRUE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_bool_entry(base_map, "edit", BT_FALSE);
+ status = bt_private_value_map_insert_bool_entry(base_map, "edit",
+ BT_FALSE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_integer_entry(base_map, "selection", 17);
+ status = bt_private_value_map_insert_integer_entry(base_map,
+ "selection", 17);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_integer_entry(base_map, "find", -34);
+ status = bt_private_value_map_insert_integer_entry(base_map, "find",
+ -34);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_bool_entry(extension_map, "edit", BT_TRUE);
+ status = bt_private_value_map_insert_bool_entry(extension_map, "edit",
+ BT_TRUE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_integer_entry(extension_map, "find", 101);
+ status = bt_private_value_map_insert_integer_entry(extension_map,
+ "find", 101);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_value_map_insert_real_entry(extension_map, "project", -404);
+ status = bt_private_value_map_insert_real_entry(extension_map,
+ "project", -404);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- extended_map = bt_value_map_extend(base_map, extension_map);
+ extended_map = bt_value_map_extend(
+ bt_value_borrow_from_private(base_map),
+ bt_value_borrow_from_private(extension_map));
ok(extended_map, "bt_value_map_extend() succeeds");
- ok(bt_value_map_get_size(extended_map) == 5,
+ ok(bt_value_map_get_size(
+ bt_value_borrow_from_private(extended_map)) == 5,
"bt_value_map_extend() returns a map object with the correct size");
- ok(compare_map_elements(base_map, extended_map, "file"),
+ ok(compare_map_elements(bt_value_borrow_from_private(base_map),
+ bt_value_borrow_from_private(extended_map), "file"),
"bt_value_map_extend() picks the appropriate element (file)");
- ok(compare_map_elements(extension_map, extended_map, "edit"),
+ ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
+ bt_value_borrow_from_private(extended_map), "edit"),
"bt_value_map_extend() picks the appropriate element (edit)");
- ok(compare_map_elements(base_map, extended_map, "selection"),
+ ok(compare_map_elements(bt_value_borrow_from_private(base_map),
+ bt_value_borrow_from_private(extended_map), "selection"),
"bt_value_map_extend() picks the appropriate element (selection)");
- ok(compare_map_elements(extension_map, extended_map, "find"),
+ ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
+ bt_value_borrow_from_private(extended_map), "find"),
"bt_value_map_extend() picks the appropriate element (find)");
- ok(compare_map_elements(extension_map, extended_map, "project"),
+ ok(compare_map_elements(bt_value_borrow_from_private(extension_map),
+ bt_value_borrow_from_private(extended_map), "project"),
"bt_value_map_extend() picks the appropriate element (project)");
BT_OBJECT_PUT_REF_AND_RESET(array);
#define DEFAULT_CLOCK_TIME 0
#define DEFAULT_CLOCK_VALUE 0
-#define NR_TESTS 342
+#define NR_TESTS 335
struct bt_utsname {
char sysname[BABELTRACE_HOST_NAME_MAX];
NULL),
"bt_ctf_writer_add_environment_field error with NULL field value");
- /* Test bt_ctf_trace_set_environment_field with an integer object */
- obj = bt_value_integer_create_init(23);
- BT_ASSERT(obj);
- ok(bt_ctf_trace_set_environment_field(NULL, "test_env_int_obj", obj),
- "bt_ctf_trace_set_environment_field handles a NULL trace correctly");
- ok(bt_ctf_trace_set_environment_field(trace, NULL, obj),
- "bt_ctf_trace_set_environment_field handles a NULL name correctly");
- ok(bt_ctf_trace_set_environment_field(trace, "test_env_int_obj", NULL),
- "bt_ctf_trace_set_environment_field handles a NULL value correctly");
- ok(!bt_ctf_trace_set_environment_field(trace, "test_env_int_obj", obj),
- "bt_ctf_trace_set_environment_field succeeds in adding an integer object");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
-
- /* Test bt_ctf_trace_set_environment_field with a string object */
- obj = bt_value_string_create_init("the value");
- BT_ASSERT(obj);
- ok(!bt_ctf_trace_set_environment_field(trace, "test_env_str_obj", obj),
- "bt_ctf_trace_set_environment_field succeeds in adding a string object");
- BT_OBJECT_PUT_REF_AND_RESET(obj);
-
/* Test bt_ctf_trace_set_environment_field_integer */
ok(bt_ctf_trace_set_environment_field_integer(NULL, "test_env_int",
-194875),
"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) == 5,
+ 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 */
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_obj"),
- "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_obj"),
- "bt_ctf_trace_get_environment_field_name returns a correct field name");
- ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 3);
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, 4);
+ 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 = bt_value_integer_get(obj, &ret_int64_t);
- ok(!ret && ret_int64_t == 23,
+ ok(!ret && 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 = bt_value_string_get(obj, &ret_string);
- ok(!ret && ret_string && !strcmp(ret_string, "the value"),
+ ok(!ret && 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);
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) == 5,
+ 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, 3);
+ obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 1);
ret = bt_value_integer_get(obj, &ret_int64_t);
ok(!ret && ret_int64_t == 654321,
"bt_ctf_trace_get_environment_field_value successfully replaces an existing field");
#include <babeltrace/plugin/plugin.h>
#include <babeltrace/object.h>
#include <babeltrace/values.h>
+#include <babeltrace/private-values.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/query-executor.h>
char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
unsigned int major, minor, patch;
const char *extra;
- struct bt_value *params;
+ struct bt_private_value *params;
struct bt_value *results;
struct bt_value *object;
struct bt_value *res_params;
ok(!bt_plugin_get_component_class_by_name_and_type(plugin, "filter",
BT_COMPONENT_CLASS_TYPE_SOURCE),
"bt_plugin_get_component_class_by_name_and_type() does not find a component class given the wrong type");
- params = bt_value_integer_create_init(23);
+ params = bt_private_value_integer_create_init(23);
BT_ASSERT(params);
ret = bt_query_executor_query(NULL, filter_comp_class, "object",
- params, &results);
+ bt_value_borrow_from_private(params), &results);
ok (ret, "bt_query_executor_query() handles NULL (query executor)");
ret = bt_query_executor_query(query_exec, NULL, "object",
- params, &results);
+ bt_value_borrow_from_private(params), &results);
ok (ret, "bt_query_executor_query() handles NULL (component class)");
ret = bt_query_executor_query(query_exec, filter_comp_class, NULL,
- params, &results);
+ bt_value_borrow_from_private(params), &results);
ok (ret, "bt_query_executor_query() handles NULL (object)");
ret = bt_query_executor_query(query_exec, filter_comp_class,
- "get-something", params, &results);
+ "get-something", bt_value_borrow_from_private(params),
+ &results);
ok(ret == 0 && results, "bt_query_executor_query() succeeds");
BT_ASSERT(bt_value_is_array(results) && bt_value_array_get_size(results) == 2);
object = bt_value_array_borrow_element_by_index(results, 0);
ok(strcmp(object_str, "get-something") == 0,
"bt_component_class_query() receives the expected object name");
res_params = bt_value_array_borrow_element_by_index(results, 1);
- ok(res_params == params,
+ ok(res_params == bt_value_borrow_from_private(params),
"bt_component_class_query() receives the expected parameters");
diag("> putting the plugin object here");