This patch sets out the ground for subsequent const-correctness patches.
The rules are:
* Convert private API to non-const API, without any `private` prefix,
including in the file name. A non-const API function accept a
non-const object.
Put common enumerations in this header.
* Convert public API to const API:
* Use `-const.h` suffix in file name.
* Use `_const` suffix to borrowing functions and callback type
definitions.
In this particular patch, the `bt_value_null` singleton object is
non-const because you can use it with bt_value_array_append_element()
and bt_value_map_insert_entry().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
*/
#include <stdlib.h>
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/babeltrace.h>
#include <babeltrace/common-internal.h>
#include "babeltrace-cfg.h"
#include "babeltrace-cfg-cli-args-connect.h"
}
static int validate_all_components_connected_in_array(GPtrArray *comps,
- struct bt_value *connected_components,
+ const struct bt_value *connected_components,
char *error_buf, size_t error_buf_size)
{
int ret = 0;
{
size_t i;
int ret = 0;
- struct bt_private_value *connected_components =
- bt_private_value_map_create();
+ struct bt_value *connected_components = bt_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_private_value_map_insert_entry(connected_components,
+ ret = bt_value_map_insert_entry(connected_components,
connection->upstream_comp_name->str, bt_value_null);
if (ret) {
goto end;
}
- ret = bt_private_value_map_insert_entry(connected_components,
+ ret = bt_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,
- bt_private_value_as_value(connected_components),
+ connected_components,
error_buf, error_buf_size);
if (ret) {
goto end;
ret = validate_all_components_connected_in_array(
cfg->cmd_data.run.filters,
- bt_private_value_as_value(connected_components),
+ connected_components,
error_buf, error_buf_size);
if (ret) {
goto end;
ret = validate_all_components_connected_in_array(
cfg->cmd_data.run.sinks,
- bt_private_value_as_value(connected_components),
+ connected_components,
error_buf, error_buf_size);
if (ret) {
goto end;
{
size_t i;
int ret = 0;
- struct bt_private_value *flat_connection_names =
- bt_private_value_map_create();
+ struct bt_value *flat_connection_names =
+ bt_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(bt_private_value_as_value(
- flat_connection_names),
- flat_connection_name->str)) {
+ if (bt_value_map_has_entry(flat_connection_names,
+ flat_connection_name->str)) {
snprintf(error_buf, error_buf_size,
"Duplicate connection:\n %s\n",
connection->arg->str);
goto end;
}
- ret = bt_private_value_map_insert_entry(flat_connection_names,
+ ret = bt_value_map_insert_entry(flat_connection_names,
flat_connection_name->str, bt_value_null);
if (ret) {
goto end;
}
int bt_config_cli_args_create_connections(struct bt_config *cfg,
- struct bt_value *connection_args,
+ const struct bt_value *connection_args,
char *error_buf, size_t error_buf_size)
{
int ret;
}
for (i = 0; i < bt_value_array_get_size(connection_args); i++) {
- struct bt_value *arg_value =
- bt_value_array_borrow_element_by_index(
+ const struct bt_value *arg_value =
+ bt_value_array_borrow_element_by_index_const(
connection_args, i);
const char *arg;
struct bt_config_connection *cfg_connection;
#include "babeltrace-cfg.h"
int bt_config_cli_args_create_connections(struct bt_config *cfg,
- struct bt_value *connection_args,
+ const struct bt_value *connection_args,
char *error_buf, size_t error_buf_size);
#endif /* CLI_BABELTRACE_CFG_CLI_ARGS_CONNECT_H */
* SOFTWARE.
*/
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/babeltrace.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_private_value *initial_plugin_paths;
+ struct bt_value *initial_plugin_paths;
struct bt_config *cfg = NULL;
int ret;
- initial_plugin_paths = bt_private_value_array_create();
+ initial_plugin_paths = bt_value_array_create();
if (!initial_plugin_paths) {
goto error;
}
#include <inttypes.h>
#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_private_value *params;
+ struct bt_value *params;
/* Next expected FSM state */
enum ini_parsing_fsm_state expecting;
GString *output;
GString *dbg_info_dir;
GString *dbg_info_target_prefix;
- struct bt_value *names;
- struct bt_value *fields;
+ const struct bt_value *names;
+ const struct bt_value *fields;
/* Flags */
bool no_delta;
goto error;
}
- if (bt_value_map_has_entry(
- bt_private_value_as_value(state->params),
- state->last_map_key)) {
+ if (bt_value_map_has_entry(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_private_value_as_value(
- bt_private_value_integer_create_init(
- (int64_t) int_val));
+ value = bt_value_integer_create_init((int64_t)int_val);
break;
}
case G_TOKEN_FLOAT:
/* Positive floating point number */
- value = bt_private_value_as_value(
- bt_private_value_real_create_init(
- state->scanner->value.v_float));
+ value = bt_value_real_create_init(state->scanner->value.v_float);
break;
case G_TOKEN_STRING:
/* Quoted string */
- value = bt_private_value_as_value(
- bt_private_value_string_create_init(
- state->scanner->value.v_string));
+ value = bt_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_private_value_as_value(
- bt_private_value_bool_create_init(true));
+ value = bt_value_bool_create_init(true);
} else if (!strcmp(id, "false") ||
!strcmp(id, "FALSE") ||
!strcmp(id, "no") ||
!strcmp(id, "NO")) {
- value = bt_private_value_as_value(
- bt_private_value_bool_create_init(false));
+ value = bt_value_bool_create_init(false);
} else {
- value = bt_private_value_as_value(
- bt_private_value_string_create_init(id));
+ value = bt_value_string_create_init(id);
}
break;
}
goto error;
}
- value = bt_private_value_as_value(
- bt_private_value_integer_create_init(
- -((int64_t) int_val)));
+ value = bt_value_integer_create_init(-((int64_t)int_val));
break;
}
case G_TOKEN_FLOAT:
/* Negative floating point number */
- value = bt_private_value_as_value(
- bt_private_value_real_create_init(
- -state->scanner->value.v_float));
+ value = bt_value_real_create_init(-state->scanner->value.v_float);
break;
default:
/* Unset value variable will trigger the error */
success:
if (value) {
- if (bt_private_value_map_insert_entry(state->params,
+ if (bt_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_private_value *bt_private_value_from_ini(const char *arg,
+struct bt_value *bt_value_from_ini(const char *arg,
GString *ini_error)
{
/* Lexical scanner configuration */
.ini_error = ini_error,
};
- state.params = bt_private_value_map_create();
+ state.params = bt_value_map_create();
if (!state.params) {
goto error;
}
* Return value is owned by the caller.
*/
static
-struct bt_private_value *bt_private_value_from_arg(const char *arg)
+struct bt_value *bt_value_from_arg(const char *arg)
{
- struct bt_private_value *params = NULL;
+ struct bt_value *params = NULL;
GString *ini_error = NULL;
ini_error = g_string_new(NULL);
}
/* Try INI-style parsing */
- params = bt_private_value_from_ini(arg, ini_error);
+ params = bt_value_from_ini(arg, ini_error);
if (!params) {
printf_err("%s", ini_error->str);
goto end;
}
/* Start with empty parameters */
- cfg_component->params = bt_private_value_map_create();
+ cfg_component->params = bt_value_map_create();
if (!cfg_component->params) {
print_err_oom();
goto error;
* Return value is owned by the caller.
*/
static
-struct bt_private_value *names_from_arg(const char *arg)
+struct bt_value *names_from_arg(const char *arg)
{
GScanner *scanner = NULL;
- struct bt_private_value *names = NULL;
+ struct bt_value *names = NULL;
bool found_all = false, found_none = false, found_item = false;
- names = bt_private_value_array_create();
+ names = bt_value_array_create();
if (!names) {
print_err_oom();
goto error;
!strcmp(identifier, "args") ||
!strcmp(identifier, "arg")) {
found_item = true;
- if (bt_private_value_array_append_string_element(names,
+ if (bt_value_array_append_string_element(names,
"payload")) {
goto error;
}
} else if (!strcmp(identifier, "context") ||
!strcmp(identifier, "ctx")) {
found_item = true;
- if (bt_private_value_array_append_string_element(names,
+ if (bt_value_array_append_string_element(names,
"context")) {
goto error;
}
} else if (!strcmp(identifier, "scope") ||
!strcmp(identifier, "header")) {
found_item = true;
- if (bt_private_value_array_append_string_element(names,
+ if (bt_value_array_append_string_element(names,
identifier)) {
goto error;
}
} else if (!strcmp(identifier, "all")) {
found_all = true;
- if (bt_private_value_array_append_string_element(names,
+ if (bt_value_array_append_string_element(names,
identifier)) {
goto error;
}
} else if (!strcmp(identifier, "none")) {
found_none = true;
- if (bt_private_value_array_append_string_element(names,
+ if (bt_value_array_append_string_element(names,
identifier)) {
goto error;
}
* least one item is specified.
*/
if (found_item && !found_none && !found_all) {
- if (bt_private_value_array_append_string_element(names, "none")) {
+ if (bt_value_array_append_string_element(names, "none")) {
goto error;
}
}
* Return value is owned by the caller.
*/
static
-struct bt_private_value *fields_from_arg(const char *arg)
+struct bt_value *fields_from_arg(const char *arg)
{
GScanner *scanner = NULL;
- struct bt_private_value *fields;
+ struct bt_value *fields;
- fields = bt_private_value_array_create();
+ fields = bt_value_array_create();
if (!fields) {
print_err_oom();
goto error;
!strcmp(identifier, "emf") ||
!strcmp(identifier, "callsite") ||
!strcmp(identifier, "all")) {
- if (bt_private_value_array_append_string_element(fields,
+ if (bt_value_array_append_string_element(fields,
identifier)) {
goto error;
}
*/
static
int insert_flat_params_from_array(GString *params_arg,
- struct bt_value *names_array, const char *prefix)
+ const struct bt_value *names_array, const char *prefix)
{
int ret = 0;
int i;
}
for (i = 0; i < bt_value_array_get_size(names_array); i++) {
- struct bt_value *str_obj =
- bt_value_array_borrow_element_by_index(names_array, i);
+ const struct bt_value *str_obj =
+ bt_value_array_borrow_element_by_index_const(names_array,
+ i);
const char *suffix;
bool is_default = false;
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_private_value *instance_names)
+ struct bt_value *instance_names)
{
int ret = 0;
goto end;
}
- if (bt_value_map_has_entry(bt_private_value_as_value(instance_names),
- cfg_comp->instance_name->str)) {
+ if (bt_value_map_has_entry(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_private_value_map_insert_entry(instance_names,
+ if (bt_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_private_value *plugin_paths)
+int append_env_var_plugin_paths(struct bt_value *plugin_paths)
{
int ret = 0;
const char *envvar;
}
static
-int append_home_and_system_plugin_paths(struct bt_private_value *plugin_paths,
+int append_home_and_system_plugin_paths(struct bt_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_private_value *initial_plugin_paths,
+ const struct bt_value *initial_plugin_paths,
bool needs_plugins)
{
struct bt_config *cfg;
cfg->command_needs_plugins = needs_plugins;
if (initial_plugin_paths) {
- cfg->plugin_paths = initial_plugin_paths;
- bt_object_get_ref(cfg->plugin_paths);
+ struct bt_value *initial_plugin_paths_copy;
+
+ (void) bt_value_copy(&initial_plugin_paths_copy,
+ initial_plugin_paths);
+ cfg->plugin_paths = initial_plugin_paths_copy;
} else {
- cfg->plugin_paths = bt_private_value_array_create();
+ cfg->plugin_paths = bt_value_array_create();
if (!cfg->plugin_paths) {
print_err_oom();
goto error;
static
struct bt_config *bt_config_run_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_list_plugins_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_help_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_query_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_print_ctf_metadata_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
struct bt_config *bt_config_print_lttng_live_sessions_create(
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
static
int bt_config_append_plugin_paths_check_setuid_setgid(
- struct bt_private_value *plugin_paths, const char *arg)
+ struct bt_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_private_value *initial_plugin_paths)
+ const struct bt_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_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
poptContext pc = NULL;
char *arg = NULL;
int ret;
struct bt_config *cfg = NULL;
const char *leftover;
- struct bt_private_value *params = bt_private_value_null;
+ struct bt_value *params = bt_value_null;
*retcode = 0;
cfg = bt_config_query_create(initial_plugin_paths);
case OPT_PARAMS:
{
bt_object_put_ref(params);
- params = bt_private_value_from_arg(arg);
+ params = bt_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
arg);
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_private_value *initial_plugin_paths)
+ const struct bt_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_private_value *initial_plugin_paths)
+ const struct bt_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_private_value *cur_base_params = NULL;
+ struct bt_value *cur_base_params = NULL;
int opt, ret = 0;
struct bt_config *cfg = NULL;
- struct bt_private_value *instance_names = NULL;
- struct bt_private_value *connection_args = NULL;
+ struct bt_value *instance_names = NULL;
+ struct bt_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_private_value_map_create();
+ cur_base_params = bt_value_map_create();
if (!cur_base_params) {
print_err_oom();
goto error;
}
- instance_names = bt_private_value_map_create();
+ instance_names = bt_value_map_create();
if (!instance_names) {
print_err_oom();
goto error;
}
- connection_args = bt_private_value_array_create();
+ connection_args = bt_value_array_create();
if (!connection_args) {
print_err_oom();
goto error;
bt_object_put_ref(cur_cfg_comp->params);
status = bt_value_copy(
&cur_cfg_comp->params,
- bt_private_value_as_value(cur_base_params));
+ cur_base_params);
if (status != BT_VALUE_STATUS_OK) {
print_err_oom();
goto error;
}
case OPT_PARAMS:
{
- struct bt_private_value *params;
- struct bt_private_value *params_to_set;
+ struct bt_value *params;
+ struct bt_value *params_to_set;
if (!cur_cfg_comp) {
printf_err("Cannot add parameters to unavailable component:\n %s\n",
goto error;
}
- params = bt_private_value_from_arg(arg);
+ params = bt_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
arg);
}
status = bt_value_map_extend(¶ms_to_set,
- bt_private_value_as_value(cur_cfg_comp->params),
- bt_private_value_as_value(params));
+ cur_cfg_comp->params,
+ params);
BT_OBJECT_PUT_REF_AND_RESET(params);
if (status != BT_VALUE_STATUS_OK) {
printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n",
goto error;
}
- if (bt_private_value_map_insert_string_entry(cur_cfg_comp->params,
+ if (bt_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_private_value *params =
- bt_private_value_from_arg(arg);
+ struct bt_value *params =
+ bt_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_private_value_map_create();
+ cur_base_params = bt_value_map_create();
if (!cur_base_params) {
print_err_oom();
goto error;
}
break;
case OPT_CONNECT:
- if (bt_private_value_array_append_string_element(
+ if (bt_value_array_append_string_element(
connection_args, arg)) {
print_err_oom();
goto error;
}
ret = bt_config_cli_args_create_connections(cfg,
- bt_private_value_as_value(connection_args),
+ connection_args,
error_buf, 256);
if (ret) {
printf_err("Cannot creation connections:\n%s", error_buf);
}
static
-struct bt_config *bt_config_run_from_args_array(struct bt_value *run_args,
+struct bt_config *bt_config_run_from_args_array(const struct bt_value *run_args,
int *retcode, bool force_omit_system_plugin_path,
bool force_omit_home_plugin_path,
- struct bt_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg = NULL;
const char **argv;
goto end;
}
for (i = 0; i < len; i++) {
- struct bt_value *arg_value =
- bt_value_array_borrow_element_by_index(run_args, i);
+ const struct bt_value *arg_value =
+ bt_value_array_borrow_element_by_index_const(run_args,
+ i);
const char *arg;
BT_ASSERT(arg_value);
static
GString *get_component_auto_name(const char *prefix,
- struct bt_value *existing_names)
+ const struct bt_value *existing_names)
{
unsigned int i = 0;
GString *auto_name = g_string_new(NULL);
GString *comp_arg;
GString *name_arg;
GString *params_arg;
- struct bt_private_value *extra_params;
+ struct bt_value *extra_params;
};
static
int assign_name_to_implicit_component(struct implicit_component_args *args,
- const char *prefix, struct bt_private_value *existing_names,
+ const char *prefix, struct bt_value *existing_names,
GList **comp_names, bool append_to_comp_names)
{
int ret = 0;
}
name = get_component_auto_name(prefix,
- bt_private_value_as_value(existing_names));
+ existing_names);
if (!name) {
ret = -1;
g_string_assign(args->name_arg, name->str);
- if (bt_private_value_map_insert_entry(existing_names, name->str,
+ if (bt_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_private_value *run_args)
+ struct bt_value *run_args)
{
int ret = 0;
size_t i;
goto end;
}
- if (bt_private_value_array_append_string_element(run_args, "--component")) {
+ if (bt_value_array_append_string_element(run_args, "--component")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, impl_args->comp_arg->str)) {
+ if (bt_value_array_append_string_element(run_args, impl_args->comp_arg->str)) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--name")) {
+ if (bt_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, impl_args->name_arg->str)) {
+ if (bt_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_private_value_array_append_string_element(run_args, "--params")) {
+ if (bt_value_array_append_string_element(run_args, "--params")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args,
+ if (bt_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(
- bt_private_value_as_value(impl_args->extra_params));
+ for (i = 0; i < bt_value_array_get_size(impl_args->extra_params);
i++) {
- struct bt_value *elem;
+ const struct bt_value *elem;
const char *arg;
- elem = bt_value_array_borrow_element_by_index(
- bt_private_value_as_value(impl_args->extra_params),
- i);
+ elem = bt_value_array_borrow_element_by_index(impl_args->extra_params,
+ i);
if (!elem) {
goto error;
}
BT_ASSERT(bt_value_is_string(elem));
arg = bt_value_string_get(elem);
- ret = bt_private_value_array_append_string_element(run_args, arg);
+ ret = bt_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_private_value_array_create();
+ args->extra_params = bt_value_array_create();
if (!args->comp_arg || !args->name_arg ||
!args->params_arg || !args->extra_params) {
BT_ASSERT(key);
BT_ASSERT(value);
- if (bt_private_value_array_append_string_element(args->extra_params, "--key")) {
+ if (bt_value_array_append_string_element(args->extra_params, "--key")) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_private_value_array_append_string_element(args->extra_params, key)) {
+ if (bt_value_array_append_string_element(args->extra_params, key)) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_private_value_array_append_string_element(args->extra_params, "--value")) {
+ if (bt_value_array_append_string_element(args->extra_params, "--value")) {
print_err_oom();
ret = -1;
goto end;
}
- if (bt_private_value_array_append_string_element(args->extra_params, value)) {
+ if (bt_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_private_value *run_args,
- struct bt_private_value *all_names,
+ struct bt_value *run_args,
+ struct bt_value *all_names,
GList **source_names, GList **filter_names,
GList **sink_names)
{
* component.
*/
name = get_component_auto_name(cur_name_prefix->str,
- bt_private_value_as_value(all_names));
+ all_names);
append_name_opt = true;
} else {
/*
* An explicit name was provided for the user
* component.
*/
- if (bt_value_map_has_entry(
- bt_private_value_as_value(all_names),
- cur_name->str)) {
+ if (bt_value_map_has_entry(all_names,
+ cur_name->str)) {
printf_err("Duplicate component instance name:\n %s\n",
cur_name->str);
goto error;
* Remember this name globally, for the uniqueness of
* all component names.
*/
- if (bt_private_value_map_insert_entry(all_names, name->str, bt_value_null)) {
+ if (bt_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_private_value_array_append_string_element(run_args, "--name")) {
+ if (bt_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, name->str)) {
+ if (bt_value_array_append_string_element(run_args, name->str)) {
print_err_oom();
goto error;
}
* function.
*/
static
-int append_connect_arg(struct bt_private_value *run_args,
+int append_connect_arg(struct bt_value *run_args,
const char *upstream_name, const char *downstream_name)
{
int ret = 0;
goto end;
}
- ret = bt_private_value_array_append_string_element(run_args, "--connect");
+ ret = bt_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_private_value_array_append_string_element(run_args, arg->str);
+ ret = bt_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_private_value *run_args,
+int convert_auto_connect(struct bt_value *run_args,
GList *source_names, GList *filter_names,
GList *sink_names)
{
*/
BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
status = bt_value_copy(&impl_args->extra_params,
- bt_private_value_as_value(
- base_implicit_ctf_input_args->extra_params));
+ base_implicit_ctf_input_args->extra_params);
if (status != BT_VALUE_STATUS_OK) {
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_private_value *initial_plugin_paths, char *log_level)
+ const struct bt_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_private_value *run_args = NULL;
- struct bt_private_value *all_names = NULL;
+ struct bt_value *run_args = NULL;
+ struct bt_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_private_value *plugin_paths;
+ struct bt_value *plugin_paths;
char error_buf[256] = { 0 };
size_t i;
struct bt_common_lttng_live_url_parts lttng_live_url_parts = { 0 };
char *output = NULL;
- plugin_paths = initial_plugin_paths;
- bt_object_get_ref(plugin_paths);
+ (void) bt_value_copy(&plugin_paths, initial_plugin_paths);
*retcode = 0;
goto error;
}
- all_names = bt_private_value_map_create();
+ all_names = bt_value_map_create();
if (!all_names) {
print_err_oom();
goto error;
}
- run_args = bt_private_value_array_create();
+ run_args = bt_value_array_create();
if (!run_args) {
print_err_oom();
goto error;
abort();
}
- if (bt_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--component")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--params")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--key")) {
+ if (bt_value_array_append_string_element(run_args, "--key")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "path")) {
+ if (bt_value_array_append_string_element(run_args, "path")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--value")) {
+ if (bt_value_array_append_string_element(run_args, "--value")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--key")) {
+ if (bt_value_array_append_string_element(run_args, "--key")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "url")) {
+ if (bt_value_array_append_string_element(run_args, "url")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--value")) {
+ if (bt_value_array_append_string_element(run_args, "--value")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, "--name")) {
+ if (bt_value_array_append_string_element(run_args, "--name")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_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_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--omit-home-plugin-path")) {
print_err_oom();
goto error;
}
break;
case OPT_RETRY_DURATION:
- if (bt_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--retry-duration")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_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_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--omit-system-plugin-path")) {
print_err_oom();
goto error;
goto error;
}
- if (bt_private_value_array_append_string_element(run_args,
+ if (bt_value_array_append_string_element(run_args,
"--plugin-path")) {
print_err_oom();
goto error;
}
- if (bt_private_value_array_append_string_element(run_args, arg)) {
+ if (bt_value_array_append_string_element(run_args, arg)) {
print_err_oom();
goto error;
}
break;
case OPT_FIELDS:
{
- struct bt_private_value *fields = fields_from_arg(arg);
+ struct bt_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,
- bt_private_value_as_value(fields), "field");
+ fields, "field");
bt_object_put_ref(fields);
if (ret) {
goto error;
}
case OPT_NAMES:
{
- struct bt_private_value *names = names_from_arg(arg);
+ struct bt_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,
- bt_private_value_as_value(names), "name");
+ names, "name");
bt_object_put_ref(names);
if (ret) {
goto error;
goto error;
}
- for (i = 0; i < bt_value_array_get_size(
- bt_private_value_as_value(run_args)); i++) {
- struct bt_value *arg_value =
- bt_value_array_borrow_element_by_index(
- bt_private_value_as_value(run_args),
- i);
+ for (i = 0; i < bt_value_array_get_size(run_args); i++) {
+ const struct bt_value *arg_value =
+ bt_value_array_borrow_element_by_index(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(
- bt_private_value_as_value(run_args)) - 1) {
+ if (i < bt_value_array_get_size(run_args) - 1) {
if (print_run_args) {
putchar(' ');
} else {
goto end;
}
- cfg = bt_config_run_from_args_array(
- bt_private_value_as_value(run_args), retcode,
- force_omit_system_plugin_path, force_omit_home_plugin_path,
- initial_plugin_paths);
+ cfg = bt_config_run_from_args_array(run_args, retcode,
+ force_omit_system_plugin_path,
+ force_omit_home_plugin_path,
+ initial_plugin_paths);
if (!cfg) {
goto error;
}
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_private_value *initial_plugin_paths)
+ const struct bt_value *initial_plugin_paths)
{
struct bt_config *config = NULL;
int i;
*retcode = -1;
if (!initial_plugin_paths) {
- initial_plugin_paths = bt_private_value_array_create();
+ initial_plugin_paths = bt_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_private_value *initial_plugin_paths);
+ const struct bt_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 <babeltrace/babeltrace.h>
#include <glib.h>
#include "babeltrace-cfg.h"
* and appends them to the array value object plugin_paths.
*/
int bt_config_append_plugin_paths(
- struct bt_private_value *plugin_paths, const char *arg)
+ struct bt_value *plugin_paths, const char *arg)
{
int ret = 0;
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);
- ret = bt_private_value_array_append_string_element(
+ ret = bt_value_array_append_string_element(
plugin_paths, dir->str);
if (ret != BT_VALUE_STATUS_OK) {
ret = -1;
enum bt_component_class_type type;
GString *plugin_name;
GString *comp_cls_name;
- struct bt_private_value *params;
+ struct bt_value *params;
GString *instance_name;
};
struct bt_object base;
bool debug;
bool verbose;
- struct bt_private_value *plugin_paths;
+ struct bt_value *plugin_paths;
bool omit_system_plugin_path;
bool omit_home_plugin_path;
bool command_needs_plugins;
return comp;
}
-int bt_config_append_plugin_paths(struct bt_private_value *plugin_paths,
+int bt_config_append_plugin_paths(struct bt_value *plugin_paths,
const char *arg);
void bt_config_connection_destroy(struct bt_config_connection *connection);
static
int query(struct bt_component_class *comp_cls, const char *obj,
- struct bt_value *params, struct bt_value **user_result,
+ const struct bt_value *params, const struct bt_value **user_result,
const char **fail_reason)
{
- struct bt_value *result = NULL;
+ const struct bt_value *result = NULL;
enum bt_query_executor_status status;
*fail_reason = "unknown error";
int ret = 0;
}
static
-void print_value(FILE *, struct bt_value *, size_t);
+void print_value(FILE *, const struct bt_value *, size_t);
static
-void print_value_rec(FILE *, struct bt_value *, size_t);
+void print_value_rec(FILE *, const struct bt_value *, size_t);
struct print_map_value_data {
size_t indent;
};
static
-bt_bool print_map_value(const char *key, struct bt_value *object, void *data)
+bt_bool print_map_value(const char *key, const struct bt_value *object,
+ void *data)
{
struct print_map_value_data *print_map_value_data = data;
}
static
-void print_value_rec(FILE *fp, struct bt_value *value, size_t indent)
+void print_value_rec(FILE *fp, const struct bt_value *value, size_t indent)
{
bt_bool bool_val;
int64_t int_val;
}
for (i = 0; i < size; i++) {
- struct bt_value *element =
- bt_value_array_borrow_element_by_index(
+ const struct bt_value *element =
+ bt_value_array_borrow_element_by_index_const(
value, i);
if (!element) {
break;
}
- bt_value_map_foreach_entry(value, print_map_value, &data);
+ bt_value_map_foreach_entry_const(value, print_map_value, &data);
break;
}
default:
}
static
-void print_value(FILE *fp, struct bt_value *value, size_t indent)
+void print_value(FILE *fp, const struct bt_value *value, size_t indent)
{
if (!bt_value_is_array(value) && !bt_value_is_map(value)) {
print_indent(fp, indent);
}
fprintf(stderr, " Parameters:\n");
- print_value(stderr,
- bt_private_value_as_value(bt_config_component->params), 8);
+ print_value(stderr, bt_config_component->params, 8);
}
static
}
static
-void print_plugin_paths(struct bt_value *plugin_paths)
+void print_plugin_paths(const struct bt_value *plugin_paths)
{
fprintf(stderr, " Plugin paths:\n");
print_value(stderr, plugin_paths, 4);
{
size_t i;
- print_plugin_paths(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(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(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(cfg->plugin_paths);
}
static
void print_cfg_help(struct bt_config *cfg)
{
- print_plugin_paths(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(cfg->plugin_paths);
}
static
void print_cfg_print_ctf_metadata(struct bt_config *cfg)
{
- print_plugin_paths(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(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(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(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(bt_private_value_as_value(cfg->plugin_paths));
+ print_plugin_paths(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);
}
static
-int load_dynamic_plugins(struct bt_value *plugin_paths)
+int load_dynamic_plugins(const struct bt_value *plugin_paths)
{
int nr_paths, i, ret = 0;
BT_LOGI("Loading dynamic plugins.");
for (i = 0; i < nr_paths; i++) {
- struct bt_value *plugin_path_value = NULL;
+ const struct bt_value *plugin_path_value = NULL;
const char *plugin_path;
struct bt_plugin_set *plugin_set;
- plugin_path_value = bt_value_array_borrow_element_by_index(
- plugin_paths, i);
+ plugin_path_value =
+ bt_value_array_borrow_element_by_index_const(
+ plugin_paths, i);
plugin_path = bt_value_string_get(plugin_path_value);
/*
}
static
-int load_all_plugins(struct bt_value *plugin_paths)
+int load_all_plugins(const struct bt_value *plugin_paths)
{
int ret = 0;
{
int ret = 0;
struct bt_component_class *comp_cls = NULL;
- struct bt_value *results = NULL;
+ const struct bt_value *results = NULL;
const char *fail_reason = NULL;
comp_cls = find_component_class(
}
ret = query(comp_cls, cfg->cmd_data.query.object->str,
- bt_private_value_as_value(
- cfg->cmd_data.query.cfg_component->params),
+ 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, bt_private_value_as_value(cfg->plugin_paths), 2);
+ print_value(stdout, 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_private_value *params = NULL;
- struct bt_value *map = NULL;
- struct bt_value *v = NULL;
+ const struct bt_value *results = NULL;
+ struct bt_value *params = NULL;
+ const struct bt_value *map = NULL;
+ const struct bt_value *v = NULL;
static const char * const plugin_name = "ctf";
static const char * const comp_cls_name = "lttng-live";
static const enum bt_component_class_type comp_cls_type =
goto error;
}
- params = bt_private_value_map_create();
+ params = bt_value_map_create();
if (!params) {
goto error;
}
- ret = bt_private_value_map_insert_string_entry(params, "url",
+ ret = bt_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", bt_private_value_as_value(params),
- &results, &fail_reason);
+ ret = query(comp_cls, "sessions", params,
+ &results, &fail_reason);
if (ret) {
goto failed;
}
const char *url_text;
int64_t timer_us, streams, clients;
- map = bt_value_array_borrow_element_by_index(results, i);
+ map = bt_value_array_borrow_element_by_index_const(results, i);
if (!map) {
BT_LOGE_STR("Unexpected empty array entry.");
goto error;
goto error;
}
- v = bt_value_map_borrow_entry_value(map, "url");
+ v = bt_value_map_borrow_entry_value_const(map, "url");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"url\" entry.");
goto error;
}
url_text = bt_value_string_get(v);
fprintf(out_stream, "%s", url_text);
- v = bt_value_map_borrow_entry_value(map, "timer-us");
+ v = bt_value_map_borrow_entry_value_const(map, "timer-us");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"timer-us\" entry.");
goto error;
}
timer_us = bt_value_integer_get(v);
fprintf(out_stream, " (timer = %" PRIu64 ", ", timer_us);
- v = bt_value_map_borrow_entry_value(map, "stream-count");
+ v = bt_value_map_borrow_entry_value_const(map, "stream-count");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"stream-count\" entry.");
goto error;
}
streams = bt_value_integer_get(v);
fprintf(out_stream, "%" PRIu64 " stream(s), ", streams);
- v = bt_value_map_borrow_entry_value(map, "client-count");
+ v = bt_value_map_borrow_entry_value_const(map, "client-count");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"client-count\" entry.");
goto error;
{
int ret = 0;
struct bt_component_class *comp_cls = NULL;
- struct bt_value *results = NULL;
- struct bt_private_value *params = NULL;
- struct bt_value *metadata_text_value = NULL;
+ const struct bt_value *results = NULL;
+ struct bt_value *params = NULL;
+ const struct bt_value *metadata_text_value = NULL;
const char *metadata_text = NULL;
static const char * const plugin_name = "ctf";
static const char * const comp_cls_name = "fs";
goto end;
}
- params = bt_private_value_map_create();
+ params = bt_value_map_create();
if (!params) {
ret = -1;
goto end;
}
- ret = bt_private_value_map_insert_string_entry(params, "path",
+ ret = bt_value_map_insert_string_entry(params, "path",
cfg->cmd_data.print_ctf_metadata.path->str);
if (ret) {
ret = -1;
}
ret = query(comp_cls, "metadata-info",
- bt_private_value_as_value(params), &results, &fail_reason);
+ params, &results, &fail_reason);
if (ret) {
goto failed;
}
- metadata_text_value = bt_value_map_borrow_entry_value(results, "text");
+ metadata_text_value = bt_value_map_borrow_entry_value_const(results,
+ "text");
if (!metadata_text_value) {
BT_LOGE_STR("Cannot find `text` string value in the resulting metadata info object.");
ret = -1;
borrow_input_port_by_index_func_t port_by_index_fn;
enum bt_graph_status status = BT_GRAPH_STATUS_ERROR;
bool insert_trimmer = false;
- struct bt_private_value *trimmer_params = NULL;
+ struct bt_value *trimmer_params = NULL;
char *intersection_begin = NULL;
char *intersection_end = NULL;
struct bt_component_filter *trimmer = NULL;
}
insert_trimmer = true;
- trimmer_params = bt_private_value_map_create();
+ trimmer_params = bt_value_map_create();
if (!trimmer_params) {
goto error;
}
- status = bt_private_value_map_insert_string_entry(
+ status = bt_value_map_insert_string_entry(
trimmer_params, "begin", intersection_begin);
if (status != BT_VALUE_STATUS_OK) {
goto error;
}
- status = bt_private_value_map_insert_string_entry(
+ status = bt_value_map_insert_string_entry(
trimmer_params,
"end", intersection_end);
if (status != BT_VALUE_STATUS_OK) {
ctx->connect_ports = false;
graph_status = bt_private_graph_add_filter_component(
ctx->graph, trimmer_class, trimmer_name,
- bt_private_value_as_value(trimmer_params),
+ trimmer_params,
&trimmer);
free(trimmer_name);
if (graph_status != BT_GRAPH_STATUS_OK) {
int64_t trace_count;
enum bt_value_status value_status;
const char *path = NULL;
- struct bt_value *component_path_value = 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 bt_value *intersection_begin = NULL;
- struct bt_value *intersection_end = NULL;
- struct bt_value *stream_path_value = NULL;
- struct bt_value *stream_paths = NULL;
- struct bt_value *stream_infos = NULL;
- struct bt_value *stream_info = NULL;
+ const struct bt_value *component_path_value = NULL;
+ struct bt_value *query_params = NULL;
+ const struct bt_value *query_result = NULL;
+ const struct bt_value *trace_info = NULL;
+ const struct bt_value *intersection_range = NULL;
+ const struct bt_value *intersection_begin = NULL;
+ const struct bt_value *intersection_end = NULL;
+ const struct bt_value *stream_path_value = NULL;
+ const struct bt_value *stream_paths = NULL;
+ const struct bt_value *stream_infos = NULL;
+ const struct bt_value *stream_info = NULL;
struct port_id *port_id = NULL;
struct trace_range *trace_range = NULL;
const char *fail_reason = NULL;
struct bt_component_class *comp_cls =
bt_component_class_source_as_component_class(src_comp_cls);
- component_path_value = bt_value_map_borrow_entry_value(
- bt_private_value_as_value(cfg_comp->params),
- "path");
+ component_path_value = bt_value_map_borrow_entry_value(cfg_comp->params,
+ "path");
if (component_path_value && !bt_value_is_string(component_path_value)) {
BT_LOGD("Cannot get path parameter: component-name=%s",
cfg_comp->instance_name->str);
}
path = bt_value_string_get(component_path_value);
- query_params = bt_private_value_map_create();
+ query_params = bt_value_map_create();
if (!query_params) {
BT_LOGE_STR("Cannot create query parameters.");
ret = -1;
goto error;
}
- value_status = bt_private_value_map_insert_entry(query_params, "path",
- component_path_value);
+ value_status = bt_value_map_insert_string_entry(query_params, "path",
+ path);
if (value_status != BT_VALUE_STATUS_OK) {
BT_LOGE_STR("Cannot insert path parameter in query parameter map.");
ret = -1;
}
ret = query(comp_cls, "trace-info",
- bt_private_value_as_value(query_params), &query_result,
+ query_params, &query_result,
&fail_reason);
if (ret) {
BT_LOGD("Component class does not support the `trace-info` query: %s: "
uint64_t stream_idx;
int64_t stream_count;
- trace_info = bt_value_array_borrow_element_by_index(
+ trace_info = bt_value_array_borrow_element_by_index_const(
query_result, trace_idx);
if (!trace_info || !bt_value_is_map(trace_info)) {
ret = -1;
goto error;
}
- intersection_range = bt_value_map_borrow_entry_value(trace_info,
- "intersection-range-ns");
+ intersection_range = bt_value_map_borrow_entry_value_const(
+ trace_info, "intersection-range-ns");
if (!intersection_range) {
ret = -1;
BT_LOGD_STR("Cannot retrieve \'intersetion-range-ns\' field from query result.");
goto error;
}
- intersection_begin = bt_value_map_borrow_entry_value(
- intersection_range, "begin");
+ intersection_begin = bt_value_map_borrow_entry_value_const(intersection_range,
+ "begin");
if (!intersection_begin) {
ret = -1;
BT_LOGD_STR("Cannot retrieve intersection-range-ns \'begin\' field from query result.");
goto error;
}
- intersection_end = bt_value_map_borrow_entry_value(
- intersection_range, "end");
+ intersection_end = bt_value_map_borrow_entry_value_const(intersection_range,
+ "end");
if (!intersection_end) {
ret = -1;
BT_LOGD_STR("Cannot retrieve intersection-range-ns \'end\' field from query result.");
goto error;
}
- stream_infos = bt_value_map_borrow_entry_value(trace_info,
- "streams");
+ stream_infos = bt_value_map_borrow_entry_value_const(trace_info,
+ "streams");
if (!stream_infos || !bt_value_is_array(stream_infos)) {
ret = -1;
BT_LOGD_STR("Cannot retrieve stream information from trace in query result.");
trace_range->intersection_range_begin_ns = begin;
trace_range->intersection_range_end_ns = end;
- stream_info = bt_value_array_borrow_element_by_index(
+ stream_info = bt_value_array_borrow_element_by_index_const(
stream_infos, stream_idx);
if (!stream_info || !bt_value_is_map(stream_info)) {
ret = -1;
goto error;
}
- stream_paths = bt_value_map_borrow_entry_value(
- stream_info, "paths");
+ stream_paths = bt_value_map_borrow_entry_value_const(stream_info,
+ "paths");
if (!stream_paths || !bt_value_is_array(stream_paths)) {
ret = -1;
BT_LOGD_STR("Cannot retrieve stream paths from trace in query result.");
}
stream_path_value =
- bt_value_array_borrow_element_by_index(
+ bt_value_array_borrow_element_by_index_const(
stream_paths, 0);
if (!stream_path_value ||
!bt_value_is_string(stream_path_value)) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
ret = bt_private_graph_add_source_component(ctx->graph,
comp_cls, cfg_comp->instance_name->str,
- bt_private_value_as_value(cfg_comp->params),
+ cfg_comp->params,
(void *) &comp);
break;
case BT_COMPONENT_CLASS_TYPE_FILTER:
ret = bt_private_graph_add_filter_component(ctx->graph,
comp_cls, cfg_comp->instance_name->str,
- bt_private_value_as_value(cfg_comp->params),
+ cfg_comp->params,
(void *) &comp);
break;
case BT_COMPONENT_CLASS_TYPE_SINK:
ret = bt_private_graph_add_sink_component(ctx->graph,
comp_cls, cfg_comp->instance_name->str,
- bt_private_value_as_value(cfg_comp->params),
+ cfg_comp->params,
(void *) &comp);
break;
default:
print_cfg(cfg);
if (cfg->command_needs_plugins) {
- ret = load_all_plugins(
- bt_private_value_as_value(cfg->plugin_paths));
+ ret = load_all_plugins(cfg->plugin_paths);
if (ret) {
BT_LOGE("Failed to load plugins: ret=%d", ret);
retcode = 1;
babeltrace/babeltrace.h \
babeltrace/logging.h \
babeltrace/object.h \
- babeltrace/private-values.h \
babeltrace/property.h \
babeltrace/types.h \
+ babeltrace/values-const.h \
babeltrace/values.h \
babeltrace/version.h
/* Core API */
#include <babeltrace/logging.h>
#include <babeltrace/object.h>
-#include <babeltrace/private-values.h>
#include <babeltrace/property.h>
#include <babeltrace/types.h>
+#include <babeltrace/values-const.h>
#include <babeltrace/values.h>
#include <babeltrace/version.h>
typedef enum bt_self_component_status
(*bt_private_component_class_filter_init_method)(
struct bt_self_component_filter *self_component,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
typedef void (*bt_private_component_class_filter_finalize_method)(
struct bt_self_component_filter *self_component);
(*bt_private_component_class_filter_query_method)(
struct bt_self_component_class_filter *comp_class,
struct bt_query_executor *query_executor,
- const char *object, struct bt_value *params,
- struct bt_value **result);
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result);
typedef enum bt_self_component_status
(*bt_private_component_class_filter_accept_input_port_connection_method)(
typedef enum bt_self_component_status
(*bt_private_component_class_sink_init_method)(
struct bt_self_component_sink *self_component,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
typedef void (*bt_private_component_class_sink_finalize_method)(
struct bt_self_component_sink *self_component);
(*bt_private_component_class_sink_query_method)(
struct bt_self_component_class_sink *comp_class,
struct bt_query_executor *query_executor,
- const char *object, struct bt_value *params,
- struct bt_value **result);
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result);
typedef enum bt_self_component_status
(*bt_private_component_class_sink_accept_input_port_connection_method)(
typedef enum bt_self_component_status
(*bt_private_component_class_source_init_method)(
struct bt_self_component_source *self_component,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
typedef void (*bt_private_component_class_source_finalize_method)(
struct bt_self_component_source *self_component);
(*bt_private_component_class_source_query_method)(
struct bt_self_component_class_source *comp_class,
struct bt_query_executor *query_executor,
- const char *object, struct bt_value *params,
- struct bt_value **result);
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result);
typedef enum bt_self_component_status
(*bt_private_component_class_source_accept_output_port_connection_method)(
extern enum bt_graph_status bt_private_graph_add_source_component(
struct bt_private_graph *graph,
struct bt_component_class_source *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_source **component);
extern enum bt_graph_status
bt_private_graph_add_source_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_source *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_source **component);
extern enum bt_graph_status bt_private_graph_add_filter_component(
struct bt_private_graph *graph,
struct bt_component_class_filter *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_filter **component);
extern enum bt_graph_status
bt_private_graph_add_filter_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_filter *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_filter **component);
extern enum bt_graph_status bt_private_graph_add_sink_component(
struct bt_private_graph *graph,
struct bt_component_class_sink *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_sink **component);
extern enum bt_graph_status
bt_private_graph_add_sink_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_sink *component_class,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_sink **component);
extern enum bt_graph_status bt_private_graph_connect_ports(
enum bt_query_executor_status bt_private_query_executor_query(
struct bt_private_query_executor *query_executor,
struct bt_component_class *component_class,
- const char *object, struct bt_value *params,
- struct bt_value **result);
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result);
extern
enum bt_query_executor_status bt_private_query_executor_cancel(
+++ /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;
-
-static inline
-struct bt_value *bt_private_value_as_value(
- struct bt_private_value *priv_value)
-{
- return (void *) 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 void 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 void bt_private_value_integer_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 void 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 */
#define BABELTRACE_TRACE_IR_ATTRIBUTES_H
/*
- * Babeltrace - Trace IR: Attributes internal
- *
* Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
* Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
*
#include <babeltrace/values.h>
BT_HIDDEN
-struct bt_private_value *bt_attributes_create(void);
+struct bt_value *bt_attributes_create(void);
BT_HIDDEN
-void bt_attributes_destroy(struct bt_private_value *attr_obj);
+void bt_attributes_destroy(struct bt_value *attr_obj);
BT_HIDDEN
-int64_t bt_attributes_get_count(struct bt_private_value *attr_obj);
+int64_t bt_attributes_get_count(const struct bt_value *attr_obj);
BT_HIDDEN
-const char *bt_attributes_get_field_name(struct bt_private_value *attr_obj,
+const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
uint64_t index);
BT_HIDDEN
-struct bt_private_value *bt_attributes_borrow_field_value(
- struct bt_private_value *attr_obj,
+struct bt_value *bt_attributes_borrow_field_value(
+ struct bt_value *attr_obj,
uint64_t index);
BT_HIDDEN
-int bt_attributes_set_field_value(struct bt_private_value *attr_obj,
- const char *name, struct bt_private_value *value_obj);
+int bt_attributes_set_field_value(struct bt_value *attr_obj,
+ const char *name, struct bt_value *value_obj);
BT_HIDDEN
-struct bt_private_value *bt_attributes_borrow_field_value_by_name(
- struct bt_private_value *attr_obj, const char *name);
+struct bt_value *bt_attributes_borrow_field_value_by_name(
+ struct bt_value *attr_obj, const char *name);
BT_HIDDEN
-int bt_attributes_freeze(struct bt_private_value *attr_obj);
+int bt_attributes_freeze(const struct bt_value *attr_obj);
#ifdef __cplusplus
}
struct bt_private_stream;
struct bt_private_stream_class;
struct bt_private_field_class;
-struct bt_private_value;
+struct bt_value;
struct bt_private_packet_header_field;
typedef void (* bt_private_trace_is_static_listener)(
extern void bt_private_trace_borrow_environment_entry_by_index(
struct bt_private_trace *trace, uint64_t index,
- const char **name, struct bt_private_value **value);
+ const char **name, const struct bt_value **value);
-extern struct bt_private_value *
+extern const struct bt_value *
bt_private_trace_borrow_environment_entry_value_by_name(
struct bt_private_trace *trace, const char *name);
bt_uuid value;
} uuid;
- struct bt_private_value *environment;
+ struct bt_value *environment;
/* Array of `struct bt_stream_class *` */
GPtrArray *stream_classes;
extern void bt_trace_borrow_environment_entry_by_index(
struct bt_trace *trace, uint64_t index,
- const char **name, struct bt_value **value);
+ const char **name, const struct bt_value **value);
-extern struct bt_value *bt_trace_borrow_environment_entry_value_by_name(
+extern const struct bt_value *bt_trace_borrow_environment_entry_value_by_name(
struct bt_trace *trace, const char *name);
extern struct bt_field_class *bt_trace_borrow_packet_header_field_class(
--- /dev/null
+#ifndef BABELTRACE_VALUES_CONST_H
+#define BABELTRACE_VALUES_CONST_H
+
+/*
+ * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-2016 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 bt_bool */
+#include <babeltrace/types.h>
+
+/* For enum bt_value_status, enum bt_value_type */
+#include <babeltrace/values.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_value;
+
+extern enum bt_value_type bt_value_get_type(const struct bt_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;
+}
+
+static inline
+bt_bool bt_value_is_bool(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
+}
+
+static inline
+bt_bool bt_value_is_integer(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_INTEGER;
+}
+
+static inline
+bt_bool bt_value_is_real(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
+}
+
+static inline
+bt_bool bt_value_is_string(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
+}
+
+static inline
+bt_bool bt_value_is_array(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
+}
+
+static inline
+bt_bool bt_value_is_map(const struct bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
+}
+
+extern enum bt_value_status bt_value_copy(struct bt_value **copy,
+ const struct bt_value *object);
+
+extern bt_bool bt_value_compare(const struct bt_value *object_a,
+ const struct bt_value *object_b);
+
+extern bt_bool bt_value_bool_get(const struct bt_value *bool_obj);
+
+extern int64_t bt_value_integer_get(const struct bt_value *integer_obj);
+
+extern double bt_value_real_get(const struct bt_value *real_obj);
+
+extern const char *bt_value_string_get(const struct bt_value *string_obj);
+
+extern uint64_t bt_value_array_get_size(const struct bt_value *array_obj);
+
+static inline
+bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
+{
+ return bt_value_array_get_size(array_obj) == 0;
+}
+
+extern const struct bt_value *bt_value_array_borrow_element_by_index_const(
+ const struct bt_value *array_obj, uint64_t index);
+
+extern uint64_t bt_value_map_get_size(const struct bt_value *map_obj);
+
+static inline
+bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
+{
+ return bt_value_map_get_size(map_obj) == 0;
+}
+
+extern const struct bt_value *bt_value_map_borrow_entry_value_const(
+ const struct bt_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_value_map_foreach_entry_const_cb)(const char *key,
+ const struct bt_value *object, void *data);
+
+extern enum bt_value_status bt_value_map_foreach_entry_const(
+ const struct bt_value *map_obj,
+ bt_value_map_foreach_entry_const_cb cb, void *data);
+
+extern bt_bool bt_value_map_has_entry(const struct bt_value *map_obj,
+ const char *key);
+
+extern enum bt_value_status bt_value_map_extend(
+ struct bt_value **extended_map_obj,
+ const struct bt_value *base_map_obj,
+ const struct bt_value *extension_map_obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_VALUES_CONST_H */
*/
#include <babeltrace/values.h>
+#include <babeltrace/values-const.h>
BT_HIDDEN
-enum bt_value_status _bt_value_freeze(struct bt_value *object);
+enum bt_value_status _bt_value_freeze(const struct bt_value *object);
#ifdef BT_DEV_MODE
# define bt_value_freeze _bt_value_freeze
/*
* Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
+ * 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
extern "C" {
#endif
-/**
-@brief Status codes.
-*/
enum bt_value_status {
/// Operation canceled.
BT_VALUE_STATUS_CANCELED = 125,
BT_VALUE_STATUS_OK = 0,
};
-struct bt_value;
-struct bt_private_value;
-
-extern struct bt_value *bt_value_null;
-
enum bt_value_type {
/// Null value object.
BT_VALUE_TYPE_NULL = 0,
BT_VALUE_TYPE_MAP = 6,
};
-extern enum bt_value_type bt_value_get_type(const struct bt_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;
-}
+struct bt_value;
-static inline
-bt_bool bt_value_is_bool(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
-}
+extern struct bt_value *bt_value_null;
-static inline
-bt_bool bt_value_is_integer(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_INTEGER;
-}
+extern struct bt_value *bt_value_bool_create(void);
-static inline
-bt_bool bt_value_is_real(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
-}
+extern struct bt_value *bt_value_bool_create_init(bt_bool val);
-static inline
-bt_bool bt_value_is_string(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
-}
+extern void bt_value_bool_set(struct bt_value *bool_obj, bt_bool val);
-static inline
-bt_bool bt_value_is_array(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
-}
+extern struct bt_value *bt_value_integer_create(void);
-static inline
-bt_bool bt_value_is_map(const struct bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
-}
+extern struct bt_value *bt_value_integer_create_init(
+ int64_t val);
-extern enum bt_value_status bt_value_copy(struct bt_private_value **copy,
- const struct bt_value *object);
+extern void bt_value_integer_set(struct bt_value *integer_obj, int64_t val);
-extern bt_bool bt_value_compare(const struct bt_value *object_a,
- const struct bt_value *object_b);
+extern struct bt_value *bt_value_real_create(void);
-extern bt_bool bt_value_bool_get(const struct bt_value *bool_obj);
+extern struct bt_value *bt_value_real_create_init(double val);
-extern int64_t bt_value_integer_get(const struct bt_value *integer_obj);
+extern void bt_value_real_set(struct bt_value *real_obj, double val);
-extern double bt_value_real_get(const struct bt_value *real_obj);
+extern struct bt_value *bt_value_string_create(void);
-extern const char *bt_value_string_get(const struct bt_value *string_obj);
+extern struct bt_value *bt_value_string_create_init(const char *val);
-extern uint64_t bt_value_array_get_size(const struct bt_value *array_obj);
+extern enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
+ const char *val);
-static inline
-bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
-{
- return bt_value_array_get_size(array_obj) == 0;
-}
+extern struct bt_value *bt_value_array_create(void);
extern struct bt_value *bt_value_array_borrow_element_by_index(
- const struct bt_value *array_obj, uint64_t index);
+ struct bt_value *array_obj, uint64_t index);
-extern uint64_t bt_value_map_get_size(const struct bt_value *map_obj);
+extern enum bt_value_status bt_value_array_append_element(
+ struct bt_value *array_obj,
+ struct bt_value *element_obj);
-static inline
-bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
-{
- return bt_value_map_get_size(map_obj) == 0;
-}
+extern enum bt_value_status bt_value_array_append_bool_element(
+ struct bt_value *array_obj, bt_bool val);
+
+extern enum bt_value_status bt_value_array_append_integer_element(
+ struct bt_value *array_obj, int64_t val);
+
+extern enum bt_value_status bt_value_array_append_real_element(
+ struct bt_value *array_obj, double val);
+
+extern enum bt_value_status bt_value_array_append_string_element(
+ struct bt_value *array_obj, const char *val);
+
+extern enum bt_value_status bt_value_array_append_empty_array_element(
+ struct bt_value *array_obj);
+
+extern enum bt_value_status bt_value_array_append_empty_map_element(
+ struct bt_value *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);
+
+extern struct bt_value *bt_value_map_create(void);
extern struct bt_value *bt_value_map_borrow_entry_value(
- const struct bt_value *map_obj, const char *key);
+ struct bt_value *map_obj, const char *key);
typedef bt_bool (* bt_value_map_foreach_entry_cb)(const char *key,
- struct bt_value *object, void *data);
+ struct bt_value *object, void *data);
extern enum bt_value_status bt_value_map_foreach_entry(
- const struct bt_value *map_obj,
+ struct bt_value *map_obj,
bt_value_map_foreach_entry_cb cb, void *data);
-extern bt_bool bt_value_map_has_entry(const struct bt_value *map_obj,
- const char *key);
+extern enum bt_value_status bt_value_map_insert_entry(
+ struct bt_value *map_obj, const char *key,
+ struct bt_value *element_obj);
+
+extern enum bt_value_status bt_value_map_insert_bool_entry(
+ struct bt_value *map_obj, const char *key, bt_bool val);
+
+extern enum bt_value_status bt_value_map_insert_integer_entry(
+ struct bt_value *map_obj, const char *key, int64_t val);
+
+extern enum bt_value_status bt_value_map_insert_real_entry(
+ struct bt_value *map_obj, const char *key, double val);
+
+extern enum bt_value_status bt_value_map_insert_string_entry(
+ struct bt_value *map_obj, const char *key,
+ const char *val);
+
+extern enum bt_value_status bt_value_map_insert_empty_array_entry(
+ struct bt_value *map_obj, const char *key);
-extern enum bt_value_status bt_value_map_extend(
- struct bt_private_value **extended_map_obj,
- const struct bt_value *base_map_obj,
- const struct bt_value *extension_map_obj);
+extern enum bt_value_status bt_value_map_insert_empty_map_entry(
+ struct bt_value *map_obj, const char *key);
#ifdef __cplusplus
}
static
enum bt_self_component_status colander_init(
struct bt_self_component_sink *self_comp,
- struct bt_value *params, void *init_method_data)
+ const struct bt_value *params, void *init_method_data)
{
enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
struct colander_data *colander_data = NULL;
#include <babeltrace/common-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/values-const.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
typedef void (*port_removed_func_t)(void *, void *, void *);
typedef void (*ports_connected_func_t)(void *, void *, void *, void *, void *);
typedef void (*ports_disconnected_func_t)(void *, void *, void *, void *, void *);
-typedef enum bt_self_component_status (*comp_init_method_t)(void *, void *, void *);
+typedef enum bt_self_component_status (*comp_init_method_t)(void *, const void *, void *);
struct bt_graph_listener {
bt_private_graph_listener_removed removed;
struct bt_private_graph *priv_graph,
struct bt_component_class *comp_cls,
comp_init_method_t init_method,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component **user_component)
{
struct bt_graph *graph = (void *) priv_graph;
struct bt_component *component = NULL;
int ret;
bool init_can_consume;
+ struct bt_value *new_params = NULL;
BT_ASSERT(comp_cls);
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
"Duplicate component name: %!+g, name=\"%s\"", graph, name);
BT_ASSERT_PRE(!params || bt_value_is_map(params),
"Parameter value is not a map value: %!+v", params);
- bt_object_get_ref(params);
init_can_consume = graph->can_consume;
bt_graph_set_can_consume(graph, false);
BT_LIB_LOGD("Adding component to graph: "
graph, comp_cls, name, params, init_method_data);
if (!params) {
- params = bt_private_value_as_value(
- bt_private_value_map_create());
- if (!params) {
+ new_params = bt_value_map_create();
+ if (!new_params) {
BT_LOGE_STR("Cannot create map value object.");
graph_status = BT_GRAPH_STATUS_NOMEM;
goto end;
}
+
+ params = new_params;
}
ret = bt_component_create(comp_cls, name, &component);
end:
bt_object_put_ref(component);
- bt_object_put_ref(params);
+ bt_object_put_ref(new_params);
(void) init_can_consume;
bt_graph_set_can_consume(graph, init_can_consume);
return graph_status;
bt_private_graph_add_source_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_source *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_source **component)
{
BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
enum bt_graph_status bt_private_graph_add_source_component(
struct bt_private_graph *graph,
struct bt_component_class_source *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_source **component)
{
return bt_private_graph_add_source_component_with_init_method_data(
bt_private_graph_add_filter_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_filter *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_filter **component)
{
BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
enum bt_graph_status bt_private_graph_add_filter_component(
struct bt_private_graph *graph,
struct bt_component_class_filter *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_filter **component)
{
return bt_private_graph_add_filter_component_with_init_method_data(
bt_private_graph_add_sink_component_with_init_method_data(
struct bt_private_graph *graph,
struct bt_component_class_sink *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
void *init_method_data, struct bt_component_sink **component)
{
BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
enum bt_graph_status bt_private_graph_add_sink_component(
struct bt_private_graph *graph,
struct bt_component_class_sink *comp_cls,
- const char *name, struct bt_value *params,
+ const char *name, const struct bt_value *params,
struct bt_component_sink **component)
{
return bt_private_graph_add_sink_component_with_init_method_data(
#include <babeltrace/graph/query-executor-internal.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/values.h>
+#include <babeltrace/values-const.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
enum bt_query_executor_status bt_private_query_executor_query(
struct bt_private_query_executor *priv_query_exec,
struct bt_component_class *comp_cls,
- const char *object, struct bt_value *params,
- struct bt_value **user_result)
+ const char *object, const struct bt_value *params,
+ const struct bt_value **user_result)
{
typedef enum bt_query_status (*method_t)(void *, void *,
- const void *, void *, void *);
+ const void *, const void *, void *);
struct bt_query_executor *query_exec = (void *) priv_query_exec;
enum bt_query_status status;
#include <babeltrace/common-internal.h>
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/values-internal.h>
+#include <babeltrace/values-internal.h>
#include <babeltrace/object-pool-internal.h>
#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/values-const.h>
#include <babeltrace/values-internal.h>
+#include <babeltrace/trace-ir/attributes-internal.h>
#include <inttypes.h>
#include <babeltrace/compat/string-internal.h>
#include <babeltrace/assert-internal.h>
#define BT_ATTR_VALUE_INDEX 1
BT_HIDDEN
-struct bt_private_value *bt_attributes_create(void)
+struct bt_value *bt_attributes_create(void)
{
- struct bt_private_value *attr_obj;
+ struct bt_value *attr_obj;
/*
* Attributes: array value object of array value objects, each one
* ]
*/
BT_LOGD_STR("Creating attributes object.");
- attr_obj = bt_private_value_array_create();
+ attr_obj = bt_value_array_create();
if (!attr_obj) {
BT_LOGE_STR("Failed to create array value.");
} else {
}
BT_HIDDEN
-void bt_attributes_destroy(struct bt_private_value *attr_obj)
+void bt_attributes_destroy(struct bt_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
BT_OBJECT_PUT_REF_AND_RESET(attr_obj);
}
BT_HIDDEN
-int64_t bt_attributes_get_count(struct bt_private_value *attr_obj)
+int64_t bt_attributes_get_count(const struct bt_value *attr_obj)
{
- return bt_value_array_get_size(bt_private_value_as_value(attr_obj));
+ return bt_value_array_get_size(attr_obj);
}
BT_HIDDEN
-const char *bt_attributes_get_field_name(struct bt_private_value *attr_obj,
+const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
uint64_t index)
{
const char *ret = NULL;
- struct bt_private_value *attr_field_obj = NULL;
- struct bt_private_value *attr_field_name_obj = NULL;
+ const struct bt_value *attr_field_obj = NULL;
+ const struct bt_value *attr_field_name_obj = NULL;
if (!attr_obj) {
BT_LOGW_STR("Invalid parameter: attributes object is NULL.");
goto end;
}
- if (index >= bt_value_array_get_size(
- bt_private_value_as_value(attr_obj))) {
+ if (index >= bt_value_array_get_size(attr_obj)) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(
- bt_private_value_as_value(attr_obj)));
+ index, bt_value_array_get_size(attr_obj));
goto end;
}
- attr_field_obj = bt_private_value_array_borrow_element_by_index(
+ attr_field_obj = bt_value_array_borrow_element_by_index_const(
attr_obj, index);
if (!attr_field_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
}
attr_field_name_obj =
- bt_private_value_array_borrow_element_by_index(attr_field_obj,
+ bt_value_array_borrow_element_by_index_const(attr_field_obj,
BT_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
goto end;
}
- ret = bt_value_string_get(
- bt_private_value_as_value(attr_field_name_obj));
+ ret = bt_value_string_get(attr_field_name_obj);
end:
return ret;
}
BT_HIDDEN
-struct bt_private_value *bt_attributes_borrow_field_value(
- struct bt_private_value *attr_obj, uint64_t index)
+struct bt_value *bt_attributes_borrow_field_value(
+ struct bt_value *attr_obj, uint64_t index)
{
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_value *value_obj = NULL;
+ struct bt_value *attr_field_obj = NULL;
if (!attr_obj) {
BT_LOGW_STR("Invalid parameter: attributes object is NULL.");
goto end;
}
- if (index >= bt_value_array_get_size(bt_private_value_as_value(attr_obj))) {
+ if (index >= bt_value_array_get_size(attr_obj)) {
BT_LOGW("Invalid parameter: index is out of bounds: "
"index=%" PRIu64 ", count=%" PRId64,
- index, bt_value_array_get_size(
- bt_private_value_as_value(attr_obj)));
+ index, bt_value_array_get_size(attr_obj));
goto end;
}
attr_field_obj =
- bt_private_value_array_borrow_element_by_index(attr_obj, index);
+ bt_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_private_value_array_borrow_element_by_index(
+ value_obj = bt_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: "
}
static
-struct bt_private_value *bt_attributes_borrow_field_by_name(
- struct bt_private_value *attr_obj, const char *name)
+struct bt_value *bt_attributes_borrow_field_by_name(
+ struct bt_value *attr_obj, const char *name)
{
uint64_t i;
int64_t attr_size;
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_name_obj = NULL;
+ struct bt_value *value_obj = NULL;
+ struct bt_value *attr_field_name_obj = NULL;
- attr_size = bt_value_array_get_size(
- bt_private_value_as_value(attr_obj));
+ attr_size = bt_value_array_get_size(attr_obj);
if (attr_size < 0) {
BT_LOGE("Cannot get array value's size: value-addr=%p",
attr_obj);
for (i = 0; i < attr_size; ++i) {
const char *field_name;
- value_obj = bt_private_value_array_borrow_element_by_index(
+ value_obj = bt_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: "
}
attr_field_name_obj =
- bt_private_value_array_borrow_element_by_index(
+ bt_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: "
goto error;
}
- field_name = bt_value_string_get(
- bt_private_value_as_value(attr_field_name_obj));
+ field_name = bt_value_string_get(attr_field_name_obj);
if (!strcmp(field_name, name)) {
break;
}
BT_HIDDEN
-int bt_attributes_set_field_value(struct bt_private_value *attr_obj,
- const char *name, struct bt_private_value *value_obj)
+int bt_attributes_set_field_value(struct bt_value *attr_obj,
+ const char *name, struct bt_value *value_obj)
{
int ret = 0;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_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_private_value_array_set_element_by_index(
+ ret = bt_value_array_set_element_by_index(
attr_field_obj, BT_ATTR_VALUE_INDEX,
- bt_private_value_as_value(value_obj));
+ value_obj);
attr_field_obj = NULL;
goto end;
}
- attr_field_obj = bt_private_value_array_create();
+ attr_field_obj = bt_value_array_create();
if (!attr_field_obj) {
BT_LOGE_STR("Failed to create empty array value.");
ret = -1;
goto end;
}
- ret = bt_private_value_array_append_string_element(attr_field_obj,
+ ret = bt_value_array_append_string_element(attr_field_obj,
name);
- ret |= bt_private_value_array_append_element(attr_field_obj,
- bt_private_value_as_value(value_obj));
+ ret |= bt_value_array_append_element(attr_field_obj,
+ value_obj);
if (ret) {
BT_LOGE("Cannot append elements to array value: addr=%p",
attr_field_obj);
goto end;
}
- ret = bt_private_value_array_append_element(attr_obj,
- bt_private_value_as_value(attr_field_obj));
+ ret = bt_value_array_append_element(attr_obj,
+ 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_private_value *bt_attributes_borrow_field_value_by_name(
- struct bt_private_value *attr_obj, const char *name)
+struct bt_value *bt_attributes_borrow_field_value_by_name(
+ struct bt_value *attr_obj, const char *name)
{
- struct bt_private_value *value_obj = NULL;
- struct bt_private_value *attr_field_obj = NULL;
+ struct bt_value *value_obj = NULL;
+ struct bt_value *attr_field_obj = NULL;
if (!attr_obj || !name) {
BT_LOGW("Invalid parameter: attributes object or name is NULL: "
goto end;
}
- value_obj = bt_private_value_array_borrow_element_by_index(
+ value_obj = bt_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: "
}
BT_HIDDEN
-int bt_attributes_freeze(struct bt_private_value *attr_obj)
+int bt_attributes_freeze(const struct bt_value *attr_obj)
{
uint64_t i;
int64_t count;
}
BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj);
- count = bt_value_array_get_size(bt_private_value_as_value(attr_obj));
+ count = bt_value_array_get_size(attr_obj);
BT_ASSERT(count >= 0);
/*
* attribute is frozen one by one.
*/
for (i = 0; i < count; ++i) {
- struct bt_private_value *obj = NULL;
+ struct bt_value *obj = NULL;
- obj = bt_attributes_borrow_field_value(attr_obj, i);
+ obj = bt_attributes_borrow_field_value(
+ (void *) attr_obj, i);
if (!obj) {
BT_LOGE("Cannot get attributes object's field value by index: "
"value-addr=%p, index=%" PRIu64,
goto end;
}
- bt_value_freeze(bt_private_value_as_value(obj));
+ bt_value_freeze(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-const.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/object.h>
#include <babeltrace/types.h>
static
int set_environment_entry(struct bt_trace *trace, const char *name,
- struct bt_private_value *value)
+ struct bt_value *value)
{
int ret;
"%![trace-]+t, entry-name=\"%s\"", trace, name);
ret = bt_attributes_set_field_value(trace->environment, name,
value);
- bt_value_freeze(bt_private_value_as_value(value));
+ bt_value_freeze(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_private_value *value_obj;
+ struct bt_value *value_obj;
struct bt_trace *trace = (void *) priv_trace;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
BT_ASSERT_PRE_NON_NULL(value, "Value");
- value_obj = bt_private_value_string_create_init(value);
+ value_obj = bt_value_string_create_init(value);
if (!value_obj) {
BT_LOGE_STR("Cannot create a string value object.");
ret = -1;
const char *name, int64_t value)
{
int ret;
- struct bt_private_value *value_obj;
+ struct bt_value *value_obj;
struct bt_trace *trace = (void *) priv_trace;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- value_obj = bt_private_value_integer_create_init(value);
+ value_obj = bt_value_integer_create_init(value);
if (!value_obj) {
BT_LOGE_STR("Cannot create an integer value object.");
ret = -1;
void bt_trace_borrow_environment_entry_by_index(
struct bt_trace *trace, uint64_t index,
- const char **name, struct bt_value **value)
+ const char **name, const struct bt_value **value)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
BT_ASSERT_PRE_NON_NULL(value, "Value");
BT_ASSERT_PRE_VALID_INDEX(index,
bt_attributes_get_count(trace->environment));
- *value = bt_private_value_as_value(
- bt_attributes_borrow_field_value(trace->environment, index));
+ *value = bt_attributes_borrow_field_value(trace->environment, index);
BT_ASSERT(*value);
*name = bt_attributes_get_field_name(trace->environment, index);
BT_ASSERT(*name);
void bt_private_trace_borrow_environment_entry_by_index(
struct bt_private_trace *trace, uint64_t index,
- const char **name, struct bt_private_value **value)
+ const char **name, const struct bt_value **value)
{
bt_trace_borrow_environment_entry_by_index((void *) trace,
index, name, (void *) value);
}
-struct bt_value *bt_trace_borrow_environment_entry_value_by_name(
+const struct bt_value *bt_trace_borrow_environment_entry_value_by_name(
struct bt_trace *trace, const char *name)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_private_value_as_value(
- bt_attributes_borrow_field_value_by_name(trace->environment,
- name));
+ return bt_attributes_borrow_field_value_by_name(trace->environment,
+ name);
}
-struct bt_private_value *
+const struct bt_value *
bt_private_trace_borrow_environment_entry_value_by_name(
struct bt_private_trace *trace, const char *name)
{
#include <babeltrace/compiler-internal.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/object.h>
+#include <babeltrace/values-const.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>
};
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_private_value *bt_value_null_copy(const struct bt_value *null_obj)
+struct bt_value *bt_value_null_copy(const struct bt_value *null_obj)
{
return (void *) bt_value_null;
}
static
-struct bt_private_value *bt_value_bool_copy(const struct bt_value *bool_obj)
+struct bt_value *bt_value_bool_copy(const struct bt_value *bool_obj)
{
- return bt_private_value_bool_create_init(
+ return bt_value_bool_create_init(
BT_VALUE_TO_BOOL(bool_obj)->value);
}
static
-struct bt_private_value *bt_value_integer_copy(
+struct bt_value *bt_value_integer_copy(
const struct bt_value *integer_obj)
{
- return bt_private_value_integer_create_init(
+ return bt_value_integer_create_init(
BT_VALUE_TO_INTEGER(integer_obj)->value);
}
static
-struct bt_private_value *bt_value_real_copy(const struct bt_value *real_obj)
+struct bt_value *bt_value_real_copy(const struct bt_value *real_obj)
{
- return bt_private_value_real_create_init(
+ return bt_value_real_create_init(
BT_VALUE_TO_REAL(real_obj)->value);
}
static
-struct bt_private_value *bt_value_string_copy(const struct bt_value *string_obj)
+struct bt_value *bt_value_string_copy(const struct bt_value *string_obj)
{
- return bt_private_value_string_create_init(
+ return bt_value_string_create_init(
BT_VALUE_TO_STRING(string_obj)->gstr->str);
}
static
-struct bt_private_value *bt_value_array_copy(const struct bt_value *array_obj)
+struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
{
int i;
int ret;
- struct bt_private_value *copy_obj;
+ struct bt_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_private_value_array_create();
+ copy_obj = bt_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_private_value *element_obj_copy = NULL;
- struct bt_value *element_obj =
- bt_value_array_borrow_element_by_index(
+ struct bt_value *element_obj_copy = NULL;
+ const struct bt_value *element_obj =
+ bt_value_array_borrow_element_by_index_const(
array_obj, i);
BT_ASSERT(element_obj);
}
BT_ASSERT(element_obj_copy);
- ret = bt_private_value_array_append_element(copy_obj,
+ ret = bt_value_array_append_element(copy_obj,
(void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
}
static
-struct bt_private_value *bt_value_map_copy(const struct bt_value *map_obj)
+struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
{
int ret;
GHashTableIter iter;
gpointer key, element_obj;
- struct bt_private_value *copy_obj;
- struct bt_private_value *element_obj_copy = NULL;
+ struct bt_value *copy_obj;
+ struct bt_value *element_obj_copy = NULL;
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_private_value_map_create();
+ copy_obj = bt_value_map_create();
if (!copy_obj) {
goto end;
}
}
BT_ASSERT(element_obj_copy);
- ret = bt_private_value_map_insert_entry(copy_obj, key_str,
+ ret = bt_value_map_insert_entry(copy_obj, key_str,
(void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
}
static
-struct bt_private_value *(* const copy_funcs[])(const struct bt_value *) = {
+struct bt_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,
}
for (i = 0; i < array_obj_a->garray->len; ++i) {
- struct bt_value *element_obj_a;
- struct bt_value *element_obj_b;
+ const struct bt_value *element_obj_a;
+ const struct bt_value *element_obj_b;
- element_obj_a = bt_value_array_borrow_element_by_index(
+ element_obj_a = bt_value_array_borrow_element_by_index_const(
object_a, i);
- element_obj_b = bt_value_array_borrow_element_by_index(
+ element_obj_b = bt_value_array_borrow_element_by_index_const(
object_b, i);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
g_hash_table_iter_init(&iter, map_obj_a->ght);
while (g_hash_table_iter_next(&iter, &key, &element_obj_a)) {
- struct bt_value *element_obj_b;
+ const 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,
+ element_obj_b = bt_value_map_borrow_entry_value_const(object_b,
key_str);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
}
BT_HIDDEN
-enum bt_value_status _bt_value_freeze(struct bt_value *object)
+enum bt_value_status _bt_value_freeze(const struct bt_value *c_object)
{
+ const struct bt_value *object = (void *) c_object;
enum bt_value_status ret = BT_VALUE_STATUS_OK;
BT_ASSERT(object);
}
BT_LOGD("Freezing value: addr=%p", object);
- freeze_funcs[object->type](object);
+ freeze_funcs[object->type]((void *) object);
end:
return ret;
return value;
}
-struct bt_private_value *bt_private_value_bool_create_init(bt_bool val)
+struct bt_value *bt_value_bool_create_init(bt_bool val)
{
struct bt_value_bool *bool_obj;
return (void *) BT_VALUE_FROM_CONCRETE(bool_obj);
}
-struct bt_private_value *bt_private_value_bool_create(void)
+struct bt_value *bt_value_bool_create(void)
{
- return bt_private_value_bool_create_init(BT_FALSE);
+ return bt_value_bool_create_init(BT_FALSE);
}
-struct bt_private_value *bt_private_value_integer_create_init(int64_t val)
+struct bt_value *bt_value_integer_create_init(int64_t val)
{
struct bt_value_integer *integer_obj;
return (void *) BT_VALUE_FROM_CONCRETE(integer_obj);
}
-struct bt_private_value *bt_private_value_integer_create(void)
+struct bt_value *bt_value_integer_create(void)
{
- return bt_private_value_integer_create_init(0);
+ return bt_value_integer_create_init(0);
}
-struct bt_private_value *bt_private_value_real_create_init(double val)
+struct bt_value *bt_value_real_create_init(double val)
{
struct bt_value_real *real_obj;
return (void *) BT_VALUE_FROM_CONCRETE(real_obj);
}
-struct bt_private_value *bt_private_value_real_create(void)
+struct bt_value *bt_value_real_create(void)
{
- return bt_private_value_real_create_init(0.);
+ return bt_value_real_create_init(0.);
}
-struct bt_private_value *bt_private_value_string_create_init(const char *val)
+struct bt_value *bt_value_string_create_init(const char *val)
{
struct bt_value_string *string_obj = NULL;
return (void *) BT_VALUE_FROM_CONCRETE(string_obj);
}
-struct bt_private_value *bt_private_value_string_create(void)
+struct bt_value *bt_value_string_create(void)
{
- return bt_private_value_string_create_init("");
+ return bt_value_string_create_init("");
}
-struct bt_private_value *bt_private_value_array_create(void)
+struct bt_value *bt_value_array_create(void)
{
struct bt_value_array *array_obj;
return (void *) BT_VALUE_FROM_CONCRETE(array_obj);
}
-struct bt_private_value *bt_private_value_map_create(void)
+struct bt_value *bt_value_map_create(void)
{
struct bt_value_map *map_obj;
return BT_VALUE_TO_BOOL(bool_obj)->value;
}
-void bt_private_value_bool_set(struct bt_private_value *bool_obj, bt_bool val)
+void bt_value_bool_set(struct bt_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_TO_INTEGER(integer_obj)->value;
}
-void bt_private_value_integer_set(struct bt_private_value *integer_obj,
+void bt_value_integer_set(struct bt_value *integer_obj,
int64_t val)
{
BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
return BT_VALUE_TO_REAL(real_obj)->value;
}
-void bt_private_value_real_set(struct bt_private_value *real_obj, double val)
+void bt_value_real_set(struct bt_value *real_obj, double val)
{
BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
return BT_VALUE_TO_STRING(string_obj)->gstr->str;
}
-enum bt_value_status bt_private_value_string_set(
- struct bt_private_value *string_obj, const char *val)
+enum bt_value_status bt_value_string_set(
+ struct bt_value *string_obj, const char *val)
{
BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
}
struct bt_value *bt_value_array_borrow_element_by_index(
- const struct bt_value *array_obj,
- uint64_t index)
+ struct bt_value *array_obj, uint64_t index)
{
struct bt_value_array *typed_array_obj =
BT_VALUE_TO_ARRAY(array_obj);
return g_ptr_array_index(typed_array_obj->garray, index);
}
-struct bt_private_value *bt_private_value_array_borrow_element_by_index(
- const struct bt_private_value *array_obj,
+const struct bt_value *bt_value_array_borrow_element_by_index_const(
+ const struct bt_value *array_obj,
uint64_t index)
{
- return (void *) bt_value_array_borrow_element_by_index(
+ return 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,
+enum bt_value_status bt_value_array_append_element(
+ struct bt_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_private_value_array_append_bool_element(
- struct bt_private_value *array_obj, bt_bool val)
+enum bt_value_status bt_value_array_append_bool_element(
+ struct bt_value *array_obj, bt_bool val)
{
enum bt_value_status ret;
- struct bt_private_value *bool_obj = NULL;
+ struct bt_value *bool_obj = NULL;
- bool_obj = bt_private_value_bool_create_init(val);
- ret = bt_private_value_array_append_element(array_obj,
+ bool_obj = bt_value_bool_create_init(val);
+ ret = bt_value_array_append_element(array_obj,
(void *) bool_obj);
bt_object_put_ref(bool_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_append_integer_element(
- struct bt_private_value *array_obj, int64_t val)
+enum bt_value_status bt_value_array_append_integer_element(
+ struct bt_value *array_obj, int64_t val)
{
enum bt_value_status ret;
- struct bt_private_value *integer_obj = NULL;
+ struct bt_value *integer_obj = NULL;
- integer_obj = bt_private_value_integer_create_init(val);
- ret = bt_private_value_array_append_element(array_obj,
+ integer_obj = bt_value_integer_create_init(val);
+ ret = bt_value_array_append_element(array_obj,
(void *) integer_obj);
bt_object_put_ref(integer_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_append_real_element(
- struct bt_private_value *array_obj, double val)
+enum bt_value_status bt_value_array_append_real_element(
+ struct bt_value *array_obj, double val)
{
enum bt_value_status ret;
- struct bt_private_value *real_obj = NULL;
+ struct bt_value *real_obj = NULL;
- real_obj = bt_private_value_real_create_init(val);
- ret = bt_private_value_array_append_element(array_obj,
+ real_obj = bt_value_real_create_init(val);
+ ret = bt_value_array_append_element(array_obj,
(void *) real_obj);
bt_object_put_ref(real_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_append_string_element(
- struct bt_private_value *array_obj, const char *val)
+enum bt_value_status bt_value_array_append_string_element(
+ struct bt_value *array_obj, const char *val)
{
enum bt_value_status ret;
- struct bt_private_value *string_obj = NULL;
+ struct bt_value *string_obj = NULL;
- string_obj = bt_private_value_string_create_init(val);
- ret = bt_private_value_array_append_element(array_obj,
+ string_obj = bt_value_string_create_init(val);
+ ret = bt_value_array_append_element(array_obj,
(void *) string_obj);
bt_object_put_ref(string_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_append_empty_array_element(
- struct bt_private_value *array_obj)
+enum bt_value_status bt_value_array_append_empty_array_element(
+ struct bt_value *array_obj)
{
enum bt_value_status ret;
- struct bt_private_value *empty_array_obj = NULL;
+ struct bt_value *empty_array_obj = NULL;
- empty_array_obj = bt_private_value_array_create();
- ret = bt_private_value_array_append_element(array_obj,
+ empty_array_obj = bt_value_array_create();
+ ret = bt_value_array_append_element(array_obj,
(void *) empty_array_obj);
bt_object_put_ref(empty_array_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_append_empty_map_element(
- struct bt_private_value *array_obj)
+enum bt_value_status bt_value_array_append_empty_map_element(
+ struct bt_value *array_obj)
{
enum bt_value_status ret;
- struct bt_private_value *map_obj = NULL;
+ struct bt_value *map_obj = NULL;
- map_obj = bt_private_value_map_create();
- ret = bt_private_value_array_append_element(array_obj,
+ map_obj = bt_value_map_create();
+ ret = bt_value_array_append_element(array_obj,
(void *) map_obj);
bt_object_put_ref(map_obj);
return ret;
}
-enum bt_value_status bt_private_value_array_set_element_by_index(
- struct bt_private_value *array_obj, uint64_t index,
+enum bt_value_status bt_value_array_set_element_by_index(
+ struct bt_value *array_obj, uint64_t index,
struct bt_value *element_obj)
{
struct bt_value_array *typed_array_obj =
return (uint64_t) g_hash_table_size(BT_VALUE_TO_MAP(map_obj)->ght);
}
-struct bt_value *bt_value_map_borrow_entry_value(const struct bt_value *map_obj,
+struct bt_value *bt_value_map_borrow_entry_value(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)));
}
-struct bt_private_value *bt_private_value_map_borrow_entry_value(
- const struct bt_private_value *map_obj, const char *key)
+const struct bt_value *bt_value_map_borrow_entry_value_const(
+ const struct bt_value *map_obj, const char *key)
{
- return (void *) bt_value_map_borrow_entry_value((void *) map_obj, key);
+ return 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)
GUINT_TO_POINTER(g_quark_from_string(key)));
}
-enum bt_value_status bt_private_value_map_insert_entry(
- struct bt_private_value *map_obj,
+enum bt_value_status bt_value_map_insert_entry(
+ struct bt_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_private_value_map_insert_bool_entry(
- struct bt_private_value *map_obj, const char *key, bt_bool val)
+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 ret;
- struct bt_private_value *bool_obj = NULL;
+ struct bt_value *bool_obj = NULL;
- bool_obj = bt_private_value_bool_create_init(val);
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ bool_obj = bt_value_bool_create_init(val);
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) bool_obj);
bt_object_put_ref(bool_obj);
return ret;
}
-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 bt_value_map_insert_integer_entry(
+ struct bt_value *map_obj, const char *key, int64_t val)
{
enum bt_value_status ret;
- struct bt_private_value *integer_obj = NULL;
+ struct bt_value *integer_obj = NULL;
- integer_obj = bt_private_value_integer_create_init(val);
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ integer_obj = bt_value_integer_create_init(val);
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) integer_obj);
bt_object_put_ref(integer_obj);
return ret;
}
-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 bt_value_map_insert_real_entry(
+ struct bt_value *map_obj, const char *key, double val)
{
enum bt_value_status ret;
- struct bt_private_value *real_obj = NULL;
+ struct bt_value *real_obj = NULL;
- real_obj = bt_private_value_real_create_init(val);
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ real_obj = bt_value_real_create_init(val);
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) real_obj);
bt_object_put_ref(real_obj);
return ret;
}
-enum bt_value_status bt_private_value_map_insert_string_entry(
- struct bt_private_value *map_obj, const char *key,
+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 ret;
- struct bt_private_value *string_obj = NULL;
+ struct bt_value *string_obj = NULL;
- string_obj = bt_private_value_string_create_init(val);
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ string_obj = bt_value_string_create_init(val);
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) string_obj);
bt_object_put_ref(string_obj);
return ret;
}
-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 bt_value_map_insert_empty_array_entry(
+ struct bt_value *map_obj, const char *key)
{
enum bt_value_status ret;
- struct bt_private_value *array_obj = NULL;
+ struct bt_value *array_obj = NULL;
- array_obj = bt_private_value_array_create();
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ array_obj = bt_value_array_create();
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) array_obj);
bt_object_put_ref(array_obj);
return ret;
}
-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 bt_value_map_insert_empty_map_entry(
+ struct bt_value *map_obj, const char *key)
{
enum bt_value_status ret;
- struct bt_private_value *empty_map_obj = NULL;
+ struct bt_value *empty_map_obj = NULL;
- empty_map_obj = bt_private_value_map_create();
- ret = bt_private_value_map_insert_entry(map_obj, key,
+ empty_map_obj = bt_value_map_create();
+ ret = bt_value_map_insert_entry(map_obj, key,
(void *) empty_map_obj);
bt_object_put_ref(empty_map_obj);
return ret;
}
-enum bt_value_status bt_value_map_foreach_entry(const struct bt_value *map_obj,
+enum bt_value_status bt_value_map_foreach_entry(struct bt_value *map_obj,
bt_value_map_foreach_entry_cb cb, void *data)
{
enum bt_value_status ret = BT_VALUE_STATUS_OK;
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)
+enum bt_value_status bt_value_map_foreach_entry_const(
+ const struct bt_value *map_obj,
+ bt_value_map_foreach_entry_const_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_private_value *extended_obj;
+ struct bt_value *extended_obj;
enum bt_value_status status;
};
static
bt_bool extend_map_element(const char *key,
- struct bt_value *extension_obj_elem, void *data)
+ const struct bt_value *extension_obj_elem, void *data)
{
bt_bool ret = BT_TRUE;
struct extend_map_element_data *extend_data = data;
- struct bt_private_value *extension_obj_elem_copy = NULL;
+ struct bt_value *extension_obj_elem_copy = NULL;
/* Copy object which is to replace the current one */
extend_data->status = bt_value_copy(&extension_obj_elem_copy,
BT_ASSERT(extension_obj_elem_copy);
/* Replace in extended object */
- extend_data->status = bt_private_value_map_insert_entry(
+ extend_data->status = bt_value_map_insert_entry(
extend_data->extended_obj, key,
(void *) extension_obj_elem_copy);
if (extend_data->status) {
}
enum bt_value_status bt_value_map_extend(
- struct bt_private_value **extended_map_obj,
+ struct bt_value **extended_map_obj,
const struct bt_value *base_map_obj,
const struct bt_value *extension_obj)
{
*/
extend_data.extended_obj = *extended_map_obj;
- if (bt_value_map_foreach_entry(extension_obj, extend_map_element,
+ if (bt_value_map_foreach_entry_const(extension_obj, extend_map_element,
&extend_data)) {
BT_LOGE("Cannot iterate on the extension object's elements: "
"extension-value-addr=%p", extension_obj);
return extend_data.status;
}
-enum bt_value_status bt_value_copy(struct bt_private_value **copy_obj,
+enum bt_value_status bt_value_copy(struct bt_value **copy_obj,
const struct bt_value *object)
{
enum bt_value_status status = BT_VALUE_STATUS_OK;
static
struct ctf_fs_component *ctf_fs_create(
struct bt_self_component_source *self_comp,
- struct bt_value *params)
+ const struct bt_value *params)
{
struct ctf_fs_component *ctf_fs;
- struct bt_value *value = NULL;
+ const struct bt_value *value = NULL;
const char *path_param;
ctf_fs = g_new0(struct ctf_fs_component, 1);
* private component should also exist.
*/
ctf_fs->self_comp = self_comp;
- value = bt_value_map_borrow_entry_value(params, "path");
+ value = bt_value_map_borrow_entry_value_const(params, "path");
if (value && !bt_value_is_string(value)) {
goto error;
}
path_param = bt_value_string_get(value);
- value = bt_value_map_borrow_entry_value(params, "clock-class-offset-s");
+ value = bt_value_map_borrow_entry_value_const(params,
+ "clock-class-offset-s");
if (value) {
if (!bt_value_is_integer(value)) {
BT_LOGE("clock-class-offset-s should be an integer");
ctf_fs->metadata_config.clock_class_offset_s = bt_value_integer_get(value);
}
- value = bt_value_map_borrow_entry_value(params, "clock-class-offset-ns");
+ value = bt_value_map_borrow_entry_value_const(params,
+ "clock-class-offset-ns");
if (value) {
if (!bt_value_is_integer(value)) {
BT_LOGE("clock-class-offset-ns should be an integer");
BT_HIDDEN
enum bt_self_component_status ctf_fs_init(
struct bt_self_component_source *self_comp,
- struct bt_value *params, UNUSED_VAR void *init_method_data)
+ const struct bt_value *params, UNUSED_VAR void *init_method_data)
{
struct ctf_fs_component *ctf_fs;
enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
enum bt_query_status ctf_fs_query(
struct bt_self_component_class_source *comp_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params,
- struct bt_value **result)
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result)
{
enum bt_query_status status = BT_QUERY_STATUS_OK;
BT_HIDDEN
enum bt_self_component_status ctf_fs_init(
struct bt_self_component_source *source,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
BT_HIDDEN
void ctf_fs_finalize(struct bt_self_component_source *component);
enum bt_query_status ctf_fs_query(
struct bt_self_component_class_source *comp_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params,
- struct bt_value **result);
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result);
BT_HIDDEN
struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name,
BT_HIDDEN
enum bt_query_status metadata_info_query(
struct bt_self_component_class_source *comp_class,
- struct bt_value *params, struct bt_value **user_result)
+ const struct bt_value *params,
+ const struct bt_value **user_result)
{
enum bt_query_status status = BT_QUERY_STATUS_OK;
- struct bt_private_value *result = NULL;
- struct bt_value *path_value = NULL;
+ struct bt_value *result = NULL;
+ const struct bt_value *path_value = NULL;
char *metadata_text = NULL;
FILE *metadata_fp = NULL;
GString *g_metadata_text = NULL;
const char *path;
bool is_packetized;
- result = bt_private_value_map_create();
+ result = bt_value_map_create();
if (!result) {
status = BT_QUERY_STATUS_NOMEM;
goto error;
goto error;
}
- path_value = bt_value_map_borrow_entry_value(params, "path");
+ path_value = bt_value_map_borrow_entry_value_const(params, "path");
path = bt_value_string_get(path_value);
BT_ASSERT(path);
g_string_append(g_metadata_text, metadata_text);
- ret = bt_private_value_map_insert_string_entry(result, "text",
+ ret = bt_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_private_value_map_insert_bool_entry(result, "is-packetized",
+ ret = bt_value_map_insert_bool_entry(result, "is-packetized",
is_packetized);
if (ret) {
BT_LOGE_STR("Cannot insert \"is-packetized\" attribute into query result.");
fclose(metadata_fp);
}
- *user_result = bt_private_value_as_value(result);
+ *user_result = result;
return status;
}
static
-int add_range(struct bt_private_value *info, struct range *range,
+int add_range(struct bt_value *info, struct range *range,
const char *range_name)
{
int ret = 0;
enum bt_value_status status;
- struct bt_private_value *range_map = NULL;
+ struct bt_value *range_map = NULL;
if (!range->set) {
/* Not an error. */
goto end;
}
- range_map = bt_private_value_map_create();
+ range_map = bt_value_map_create();
if (!range_map) {
ret = -1;
goto end;
}
- status = bt_private_value_map_insert_integer_entry(range_map, "begin",
+ status = bt_value_map_insert_integer_entry(range_map, "begin",
range->begin_ns);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_private_value_map_insert_integer_entry(range_map, "end",
+ status = bt_value_map_insert_integer_entry(range_map, "end",
range->end_ns);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_private_value_map_insert_entry(info, range_name,
- bt_private_value_as_value(range_map));
+ status = bt_value_map_insert_entry(info, range_name,
+ range_map);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
static
-int add_stream_ids(struct bt_private_value *info,
- struct bt_stream *stream)
+int add_stream_ids(struct bt_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_private_value_map_insert_integer_entry(info, "id",
+ status = bt_value_map_insert_integer_entry(info, "id",
stream_instance_id);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_private_value_map_insert_integer_entry(info, "class-id", stream_class_id);
+ status = bt_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_private_value *group_info,
- struct range *stream_range)
+ struct bt_value *group_info, struct range *stream_range)
{
int ret = 0;
size_t file_idx;
enum bt_value_status status;
- struct bt_private_value *file_paths;
+ struct bt_value *file_paths;
stream_range->begin_ns = INT64_MAX;
stream_range->end_ns = 0;
- file_paths = bt_private_value_array_create();
+ file_paths = bt_value_array_create();
if (!file_paths) {
ret = -1;
goto end;
goto end;
}
- status = bt_private_value_array_append_string_element(file_paths,
+ status = bt_value_array_append_string_element(file_paths,
info->path->str);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
}
}
- status = bt_private_value_map_insert_entry(group_info, "paths",
- bt_private_value_as_value(file_paths));
+ status = bt_value_map_insert_entry(group_info, "paths",
+ 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_private_value *trace_info)
+ struct bt_value *trace_info)
{
int ret = 0;
size_t group_idx;
struct ctf_fs_trace *trace = NULL;
enum bt_value_status status;
- struct bt_private_value *file_groups;
+ struct bt_value *file_groups;
struct range trace_range = {
.begin_ns = INT64_MAX,
.end_ns = 0,
.set = false,
};
- file_groups = bt_private_value_array_create();
+ file_groups = bt_value_array_create();
if (!file_groups) {
goto end;
}
- status = bt_private_value_map_insert_string_entry(trace_info, "name",
+ status = bt_value_map_insert_string_entry(trace_info, "name",
trace_name);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
- status = bt_private_value_map_insert_string_entry(trace_info, "path",
+ status = bt_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_private_value *group_info;
+ struct bt_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_private_value_map_create();
+ group_info = bt_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_private_value_array_append_element(
+ status = bt_value_array_append_element(
file_groups,
- bt_private_value_as_value(group_info));
+ group_info);
bt_object_put_ref(group_info);
if (status != BT_VALUE_STATUS_OK) {
goto end;
}
}
- status = bt_private_value_map_insert_entry(trace_info, "streams",
- bt_private_value_as_value(file_groups));
+ status = bt_value_map_insert_entry(trace_info, "streams",
+ file_groups);
BT_OBJECT_PUT_REF_AND_RESET(file_groups);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
BT_HIDDEN
enum bt_query_status trace_info_query(
struct bt_self_component_class_source *comp_class,
- struct bt_value *params, struct bt_value **user_result)
+ const struct bt_value *params,
+ const struct bt_value **user_result)
{
enum bt_query_status status = BT_QUERY_STATUS_OK;
- struct bt_private_value *result = NULL;
- struct bt_value *path_value = NULL;
+ struct bt_value *result = NULL;
+ const struct bt_value *path_value = NULL;
int ret = 0;
const char *path = NULL;
GList *trace_paths = NULL;
goto error;
}
- path_value = bt_value_map_borrow_entry_value(params, "path");
+ path_value = bt_value_map_borrow_entry_value_const(params, "path");
path = bt_value_string_get(path_value);
normalized_path = bt_common_normalize_path(path, NULL);
goto error;
}
- result = bt_private_value_array_create();
+ result = bt_value_array_create();
if (!result) {
status = BT_QUERY_STATUS_NOMEM;
goto error;
GString *trace_path = tp_node->data;
GString *trace_name = tn_node->data;
enum bt_value_status status;
- struct bt_private_value *trace_info;
+ struct bt_value *trace_info;
- trace_info = bt_private_value_map_create();
+ trace_info = bt_value_map_create();
if (!trace_info) {
BT_LOGE("Failed to create trace info map.");
goto error;
goto error;
}
- status = bt_private_value_array_append_element(result,
- bt_private_value_as_value(trace_info));
+ status = bt_value_array_append_element(result, trace_info);
bt_object_put_ref(trace_info);
if (status != BT_VALUE_STATUS_OK) {
goto error;
g_list_free(trace_names);
}
- *user_result = bt_private_value_as_value(result);
+ *user_result = result;
return status;
}
BT_HIDDEN
enum bt_query_status metadata_info_query(
struct bt_self_component_class_source *comp_class,
- struct bt_value *params, struct bt_value **result);
+ const struct bt_value *params, const struct bt_value **result);
BT_HIDDEN
enum bt_query_status trace_info_query(
struct bt_self_component_class_source *comp_class,
- struct bt_value *params, struct bt_value **result);
+ const struct bt_value *params, const struct bt_value **result);
#endif /* BABELTRACE_PLUGIN_CTF_FS_QUERY_H */
}
static
-int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params)
+int handle_params(struct dmesg_component *dmesg_comp,
+ const struct bt_value *params)
{
- struct bt_value *no_timestamp = NULL;
- struct bt_value *path = NULL;
+ const struct bt_value *no_timestamp = NULL;
+ const struct bt_value *path = NULL;
const char *path_str;
int ret = 0;
- no_timestamp = bt_value_map_borrow_entry_value(params,
+ no_timestamp = bt_value_map_borrow_entry_value_const(params,
"no-extract-timestamp");
if (no_timestamp) {
if (!bt_value_is_bool(no_timestamp)) {
bt_value_bool_get(no_timestamp);
}
- path = bt_value_map_borrow_entry_value(params, "path");
+ path = bt_value_map_borrow_entry_value_const(params, "path");
if (path) {
if (dmesg_comp->params.read_from_stdin) {
BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
BT_HIDDEN
enum bt_self_component_status dmesg_init(
struct bt_self_component_source *self_comp,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
BT_HIDDEN
void dmesg_finalize(struct bt_self_component_source *self_comp);
*/
#include <babeltrace/babeltrace.h>
-#include <babeltrace/values.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/common-internal.h>
#include <plugins-common.h>
}
static
-int add_params_to_map(struct bt_private_value *plugin_opt_map)
+int add_params_to_map(struct bt_value *plugin_opt_map)
{
int ret = 0;
unsigned int i;
const char *key = plugin_options[i];
enum bt_value_status status;
- status = bt_private_value_map_insert_entry(plugin_opt_map, key,
+ status = bt_value_map_insert_entry(plugin_opt_map, key,
bt_value_null);
switch (status) {
case BT_VALUE_STATUS_OK:
}
static
-bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
+bt_bool check_param_exists(const char *key, const struct bt_value *object,
+ void *data)
{
struct pretty_component *pretty = data;
- if (!bt_value_map_has_entry(
- bt_private_value_as_value(pretty->plugin_opt_map),
- key)) {
+ if (!bt_value_map_has_entry(pretty->plugin_opt_map,
+ key)) {
fprintf(pretty->err,
"[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
}
}
static
-void apply_one_string(const char *key, struct bt_value *params, char **option)
+void apply_one_string(const char *key, const struct bt_value *params, char **option)
{
- struct bt_value *value = NULL;
+ const struct bt_value *value = NULL;
const char *str;
- value = bt_value_map_borrow_entry_value(params, key);
+ value = bt_value_map_borrow_entry_value_const(params, key);
if (!value) {
goto end;
}
}
static
-void apply_one_bool(const char *key, struct bt_value *params, bool *option,
+void apply_one_bool(const char *key, const struct bt_value *params, bool *option,
bool *found)
{
- struct bt_value *value = NULL;
+ const struct bt_value *value = NULL;
bt_bool bool_val;
- value = bt_value_map_borrow_entry_value(params, key);
+ value = bt_value_map_borrow_entry_value_const(params, key);
if (!value) {
goto end;
}
}
static
-int apply_params(struct pretty_component *pretty, struct bt_value *params)
+int apply_params(struct pretty_component *pretty, const struct bt_value *params)
{
int ret = 0;
enum bt_value_status status;
bool value, found;
char *str = NULL;
- pretty->plugin_opt_map = bt_private_value_map_create();
+ pretty->plugin_opt_map = bt_value_map_create();
if (!pretty->plugin_opt_map) {
ret = -1;
goto end;
goto end;
}
/* Report unknown parameters. */
- status = bt_value_map_foreach_entry(params, check_param_exists, pretty);
+ status = bt_value_map_foreach_entry_const(params,
+ check_param_exists, pretty);
switch (status) {
case BT_VALUE_STATUS_OK:
break;
/* Known parameters. */
pretty->options.color = PRETTY_COLOR_OPT_AUTO;
if (bt_value_map_has_entry(params, "color")) {
- struct bt_value *color_value;
+ const struct bt_value *color_value;
const char *color;
- color_value = bt_value_map_borrow_entry_value(params, "color");
+ color_value = bt_value_map_borrow_entry_value_const(params,
+ "color");
if (!color_value) {
goto end;
}
BT_HIDDEN
enum bt_self_component_status pretty_init(
struct bt_self_component_sink *comp,
- struct bt_value *params,
+ const struct bt_value *params,
UNUSED_VAR void *init_method_data)
{
enum bt_self_component_status ret;
bool start_line;
GString *string;
GString *tmp_string;
- struct bt_private_value *plugin_opt_map; /* Temporary parameter map. */
+ struct bt_value *plugin_opt_map; /* Temporary parameter map. */
bool use_colors;
uint64_t last_cycles_timestamp;
BT_HIDDEN
enum bt_self_component_status pretty_init(
struct bt_self_component_sink *component,
- struct bt_value *params,
+ const struct bt_value *params,
void *init_method_data);
BT_HIDDEN
}
}
if (pretty->options.print_trace_hostname_field) {
- struct bt_value *hostname_str;
+ const struct bt_value *hostname_str;
hostname_str = bt_trace_borrow_environment_entry_value_by_name(
trace_class, "hostname");
}
}
if (pretty->options.print_trace_domain_field) {
- struct bt_value *domain_str;
+ const struct bt_value *domain_str;
domain_str = bt_trace_borrow_environment_entry_value_by_name(
trace_class, "domain");
}
}
if (pretty->options.print_trace_procname_field) {
- struct bt_value *procname_str;
+ const struct bt_value *procname_str;
procname_str = bt_trace_borrow_environment_entry_value_by_name(
trace_class, "procname");
}
}
if (pretty->options.print_trace_vpid_field) {
- struct bt_value *vpid_value;
+ const struct bt_value *vpid_value;
vpid_value = bt_trace_borrow_environment_entry_value_by_name(
trace_class, "vpid");
BT_HIDDEN
enum bt_self_component_status counter_init(
struct bt_self_component_sink *component,
- struct bt_value *params, UNUSED_VAR void *init_method_data)
+ const struct bt_value *params,
+ UNUSED_VAR void *init_method_data)
{
enum bt_self_component_status ret;
struct counter *counter = g_new0(struct counter, 1);
- struct bt_value *step = NULL;
- struct bt_value *hide_zero = NULL;
+ const struct bt_value *step = NULL;
+ const struct bt_value *hide_zero = NULL;
if (!counter) {
ret = BT_SELF_COMPONENT_STATUS_NOMEM;
counter->last_printed_total = -1ULL;
counter->step = 1000;
- step = bt_value_map_borrow_entry_value(params, "step");
+ step = bt_value_map_borrow_entry_value_const(params, "step");
if (step && bt_value_is_integer(step)) {
int64_t val;
}
}
- hide_zero = bt_value_map_borrow_entry_value(params, "hide-zero");
+ hide_zero = bt_value_map_borrow_entry_value_const(params, "hide-zero");
if (hide_zero && bt_value_is_bool(hide_zero)) {
bt_bool val;
BT_HIDDEN
enum bt_self_component_status counter_init(
struct bt_self_component_sink *component,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
BT_HIDDEN
void counter_finalize(struct bt_self_component_sink *component);
BT_HIDDEN
enum bt_self_component_status dummy_init(
struct bt_self_component_sink *component,
- struct bt_value *params, UNUSED_VAR void *init_method_data)
+ const struct bt_value *params,
+ UNUSED_VAR void *init_method_data)
{
enum bt_self_component_status ret;
struct dummy *dummy = g_new0(struct dummy, 1);
BT_HIDDEN
enum bt_self_component_status dummy_init(
struct bt_self_component_sink *component,
- struct bt_value *params, void *init_method_data);
+ const struct bt_value *params, void *init_method_data);
BT_HIDDEN
void dummy_finalize(struct bt_self_component_sink *component);
}
static
-struct bt_private_value *get_default_params(void)
+struct bt_value *get_default_params(void)
{
- struct bt_private_value *params;
+ struct bt_value *params;
int ret;
- params = bt_private_value_map_create();
+ params = bt_value_map_create();
if (!params) {
BT_LOGE_STR("Cannot create a map value object.");
goto error;
}
- ret = bt_private_value_map_insert_bool_entry(params,
+ ret = bt_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)
+int configure_muxer_comp(struct muxer_comp *muxer_comp,
+ const struct bt_value *params)
{
- struct bt_private_value *default_params = NULL;
- struct bt_private_value *real_params = NULL;
- struct bt_value *assume_absolute_clock_classes = NULL;
+ struct bt_value *default_params = NULL;
+ struct bt_value *real_params = NULL;
+ const struct bt_value *assume_absolute_clock_classes = NULL;
int ret = 0;
bt_bool bool_val;
}
ret = bt_value_map_extend(&real_params,
- bt_private_value_as_value(default_params), params);
+ default_params, params);
if (ret) {
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(
- bt_private_value_as_value(real_params),
- ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
+ assume_absolute_clock_classes = bt_value_map_borrow_entry_value(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: "
BT_HIDDEN
enum bt_self_component_status muxer_init(
struct bt_self_component_filter *self_comp,
- struct bt_value *params, void *init_data);
+ const struct bt_value *params, void *init_data);
BT_HIDDEN
void muxer_finalize(struct bt_self_component_filter *self_comp);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/plugin/plugin-dev.h>
+#include <babeltrace/babeltrace.h>
#include <stdlib.h>
#include <glib.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#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/babeltrace.h>
#include <babeltrace/assert-internal.h>
static enum bt_self_component_status sink_consume(
static enum bt_query_status flt_query_method(
struct bt_self_component_class_filter *component_class,
struct bt_query_executor *query_exec,
- const char *object, struct bt_value *params,
- struct bt_value **result)
+ const char *object, const struct bt_value *params,
+ const struct bt_value **result)
{
- struct bt_private_value *res = bt_private_value_array_create();
- *result = bt_private_value_as_value(res);
+ struct bt_value *res = bt_value_array_create();
+ struct bt_value *val;
+ *result = res;
int iret;
BT_ASSERT(*result);
- iret = bt_private_value_array_append_string_element(res, object);
+ iret = bt_value_array_append_string_element(res, object);
+ BT_ASSERT(iret == 0);
+ iret = bt_value_copy(&val, params);
BT_ASSERT(iret == 0);
- iret = bt_private_value_array_append_element(res, params);
+ iret = bt_value_array_append_element(res, val);
BT_ASSERT(iret == 0);
+ bt_object_put_ref(val);
return BT_QUERY_STATUS_OK;
}
static
enum bt_self_component_status src_init(
struct bt_self_component_source *self_comp,
- struct bt_value *params, void *init_method_data)
+ const struct bt_value *params, void *init_method_data)
{
int ret;
static
enum bt_self_component_status sink_init(
struct bt_self_component_sink *self_comp,
- struct bt_value *params, void *init_method_data)
+ const struct bt_value *params, void *init_method_data)
{
struct sink_user_data *user_data = g_new0(struct sink_user_data, 1);
int ret;
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/object.h>
-#include <babeltrace/values.h>
-#include <babeltrace/private-values.h>
+#include <babeltrace/babeltrace.h>
#include <babeltrace/assert-internal.h>
#include <string.h>
#include "tap/tap.h"
void test_bool(void)
{
bt_bool value;
- struct bt_private_value *priv_obj;
struct bt_value *obj;
- priv_obj = bt_private_value_bool_create();
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_bool_create();
ok(obj && bt_value_is_bool(obj),
- "bt_private_value_bool_create() returns a boolean value object");
+ "bt_value_bool_create() returns a boolean value object");
value = BT_TRUE;
value = bt_value_bool_get(obj);
ok(!value, "default boolean value object value is BT_FALSE");
- bt_private_value_bool_set(priv_obj, BT_FALSE);
- bt_private_value_bool_set(priv_obj, BT_TRUE);
+ bt_value_bool_set(obj, BT_FALSE);
+ bt_value_bool_set(obj, BT_TRUE);
value = bt_value_bool_get(obj);
- ok(value, "bt_private_value_bool_set() works");
+ ok(value, "bt_value_bool_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing boolean value object does not cause a crash")
value = BT_FALSE;
- priv_obj = bt_private_value_bool_create_init(BT_TRUE);
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_bool_create_init(BT_TRUE);
ok(obj && bt_value_is_bool(obj),
- "bt_private_value_bool_create_init() returns a boolean value object");
+ "bt_value_bool_create_init() returns a boolean value object");
value = bt_value_bool_get(obj);
ok(value,
- "bt_private_value_bool_create_init() sets the appropriate initial value");
+ "bt_value_bool_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
void test_integer(void)
{
int64_t value;
- struct bt_private_value *priv_obj;
struct bt_value *obj;
- priv_obj = bt_private_value_integer_create();
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_integer_create();
ok(obj && bt_value_is_integer(obj),
- "bt_private_value_integer_create() returns an integer value object");
+ "bt_value_integer_create() returns an integer value object");
value = 1961;
value = bt_value_integer_get(obj);
ok(value == 0, "default integer value object value is 0");
- bt_private_value_integer_set(priv_obj, -98765);
+ bt_value_integer_set(obj, -98765);
value = bt_value_integer_get(obj);
ok(value == -98765, "bt_private_integer_bool_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing integer value object does not cause a crash")
- priv_obj = bt_private_value_integer_create_init(321456987);
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_integer_create_init(321456987);
ok(obj && bt_value_is_integer(obj),
- "bt_private_value_integer_create_init() returns an integer value object");
+ "bt_value_integer_create_init() returns an integer value object");
value = bt_value_integer_get(obj);
ok(value == 321456987,
- "bt_private_value_integer_create_init() sets the appropriate initial value");
+ "bt_value_integer_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
void test_real(void)
{
double value;
- struct bt_private_value *priv_obj;
struct bt_value *obj;
- priv_obj = bt_private_value_real_create();
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_real_create();
ok(obj && bt_value_is_real(obj),
- "bt_private_value_real_create() returns a real number value object");
+ "bt_value_real_create() returns a real number value object");
value = 17.34;
value = bt_value_real_get(obj);
ok(value == 0.,
"default real number value object value is 0");
- bt_private_value_real_set(priv_obj, -3.1416);
+ bt_value_real_set(obj, -3.1416);
value = bt_value_real_get(obj);
- ok(value == -3.1416, "bt_private_value_real_set() works");
+ ok(value == -3.1416, "bt_value_real_set() works");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing real number value object does not cause a crash")
- priv_obj = bt_private_value_real_create_init(33.1649758);
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_real_create_init(33.1649758);
ok(obj && bt_value_is_real(obj),
- "bt_private_value_real_create_init() returns a real number value object");
+ "bt_value_real_create_init() returns a real number value object");
value = bt_value_real_get(obj);
ok(value == 33.1649758,
- "bt_private_value_real_create_init() sets the appropriate initial value");
+ "bt_value_real_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
void test_string(void)
{
const char *value;
- struct bt_private_value *priv_obj;
struct bt_value *obj;
- priv_obj = bt_private_value_string_create();
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_string_create();
ok(obj && bt_value_is_string(obj),
- "bt_private_value_string_create() returns a string value object");
+ "bt_value_string_create() returns a string value object");
value = bt_value_string_get(obj);
ok(value && !strcmp(value, ""),
"default string value object value is \"\"");
- bt_private_value_string_set(priv_obj, "hello worldz");
+ bt_value_string_set(obj, "hello worldz");
value = bt_value_string_get(obj);
ok(value && !strcmp(value, "hello worldz"),
"bt_value_string_get() works");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing string value object does not cause a crash")
- priv_obj = bt_private_value_string_create_init("initial value");
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_string_create_init("initial value");
ok(obj && bt_value_is_string(obj),
- "bt_private_value_string_create_init() returns a string value object");
+ "bt_value_string_create_init() returns a string value object");
value = bt_value_string_get(obj);
ok(value && !strcmp(value, "initial value"),
- "bt_private_value_string_create_init() sets the appropriate initial value");
+ "bt_value_string_create_init() sets the appropriate initial value");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(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;
- priv_array_obj = bt_private_value_array_create();
- array_obj = bt_private_value_as_value(priv_array_obj);
+ array_obj = bt_value_array_create();
ok(array_obj && bt_value_is_array(array_obj),
- "bt_private_value_array_create() returns an array value object");
+ "bt_value_array_create() returns an array value object");
ok(bt_value_array_is_empty(array_obj),
"initial array value object size is 0");
- priv_obj = bt_private_value_integer_create_init(345);
- obj = bt_private_value_as_value(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_private_value_as_value(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_private_value_as_value(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,
+ 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_private_value_array_append_element() succeeds");
+ ok(!ret, "bt_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)");
- priv_obj = bt_private_value_integer_create_init(1001);
- obj = bt_private_value_as_value(priv_obj);
+ obj = bt_value_integer_create_init(1001);
BT_ASSERT(obj);
- ok(!bt_private_value_array_set_element_by_index(priv_array_obj, 2, obj),
+ ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
"bt_value_array_set_element_by_index() succeeds");
- BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(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_private_value_array_append_bool_element(priv_array_obj,
+ ret = bt_value_array_append_bool_element(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,
+ ok(!ret, "bt_value_array_append_bool_element() succeeds");
+ ret = bt_value_array_append_integer_element(array_obj,
98765);
- ok(!ret, "bt_private_value_array_append_integer_element() succeeds");
- ret = bt_private_value_array_append_real_element(priv_array_obj,
+ ok(!ret, "bt_value_array_append_integer_element() succeeds");
+ ret = bt_value_array_append_real_element(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,
+ ok(!ret, "bt_value_array_append_real_element() succeeds");
+ ret = bt_value_array_append_string_element(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(!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");
ok(bt_value_array_get_size(array_obj) == 10,
- "the bt_private_value_array_append_element_*() functions increment the array value object's size");
+ "the bt_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_private_value_array_append_bool_element() appends a boolean value object");
+ "bt_value_array_append_bool_element() appends a boolean value object");
bool_value = bt_value_bool_get(obj);
ok(!bool_value,
- "bt_private_value_array_append_bool_element() appends the appropriate value");
+ "bt_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_private_value_array_append_integer_element() appends an integer value object");
+ "bt_value_array_append_integer_element() appends an integer value object");
int_value = bt_value_integer_get(obj);
ok(int_value == 98765,
- "bt_private_value_array_append_integer_element() appends the appropriate value");
+ "bt_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_private_value_array_append_real_element() appends a real number value object");
+ "bt_value_array_append_real_element() appends a real number value object");
real_value = bt_value_real_get(obj);
ok(real_value == 2.49578,
- "bt_private_value_array_append_real_element() appends the appropriate value");
+ "bt_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_private_value_array_append_string_element() appends a string value object");
+ "bt_value_array_append_string_element() appends a string value object");
string_value = bt_value_string_get(obj);
ok(!ret && string_value && !strcmp(string_value, "bt_value"),
- "bt_private_value_array_append_string_element() appends the appropriate value");
+ "bt_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_private_value_array_append_empty_array_element() appends an array value object");
+ "bt_value_array_append_empty_array_element() appends an array value object");
ok(bt_value_array_is_empty(obj),
- "bt_private_value_array_append_empty_array_element() an empty array value object");
+ "bt_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_private_value_array_append_empty_map_element() appends a map value object");
+ "bt_value_array_append_empty_map_element() appends a map value object");
ok(bt_value_map_is_empty(obj),
- "bt_private_value_array_append_empty_map_element() an empty map value object");
+ "bt_value_array_append_empty_map_element() an empty map value object");
- BT_OBJECT_PUT_REF_AND_RESET(priv_array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(array_obj);
pass("putting an existing array value object does not cause a crash")
}
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;
- priv_map_obj = bt_private_value_map_create();
- map_obj = bt_private_value_as_value(priv_map_obj);
+ map_obj = bt_value_map_create();
ok(map_obj && bt_value_is_map(map_obj),
- "bt_private_value_map_create() returns a map value object");
+ "bt_value_map_create() returns a map value object");
ok(bt_value_map_get_size(map_obj) == 0,
"initial map value object size is 0");
- priv_obj = bt_private_value_integer_create_init(19457);
- obj = bt_private_value_as_value(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_private_value_as_value(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_private_value_as_value(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",
+ 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_private_value_map_insert_entry() succeeds");
+ ok(!ret, "bt_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");
- priv_obj = bt_private_value_bool_create_init(BT_TRUE);
- obj = bt_private_value_as_value(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_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");
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(bool_value,
"bt_value_map_borrow_entry_value() returns an value object with the appropriate value (boolean)");
- ret = bt_private_value_map_insert_bool_entry(priv_map_obj, "bool2",
+ ret = bt_value_map_insert_bool_entry(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",
+ ok(!ret, "bt_value_map_insert_bool_entry() succeeds");
+ ret = bt_value_map_insert_integer_entry(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",
+ ok(!ret, "bt_value_map_insert_integer_entry() succeeds");
+ ret = bt_value_map_insert_real_entry(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",
+ ok(!ret, "bt_value_map_insert_real_entry() succeeds");
+ ret = bt_value_map_insert_string_entry(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,
+ ok(!ret, "bt_value_map_insert_string_entry() succeeds");
+ ret = bt_value_map_insert_empty_array_entry(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(!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");
ok(bt_value_map_get_size(map_obj) == 10,
"the bt_value_map_insert*() functions increment the map value object's size");
checklist.array2 && checklist.map2,
"bt_value_map_foreach_entry() iterates over all the map value object's elements");
- BT_OBJECT_PUT_REF_AND_RESET(priv_map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_obj);
pass("putting an existing map value object does not cause a crash")
}
static
void test_compare_bool(void)
{
- 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);
+ 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);
BT_ASSERT(bool1 && bool2 && bool3);
ok(!bt_value_compare(bt_value_null,
- bt_private_value_as_value(bool1)),
+ bool1),
"cannot compare null value object and bt_bool value object");
- ok(!bt_value_compare(bt_private_value_as_value(bool1),
- bt_private_value_as_value(bool2)),
+ ok(!bt_value_compare(bool1,
+ bool2),
"boolean value objects are not equivalent (BT_FALSE and BT_TRUE)");
- ok(bt_value_compare(bt_private_value_as_value(bool1),
- bt_private_value_as_value(bool3)),
+ ok(bt_value_compare(bool1,
+ 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_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);
+ 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);
BT_ASSERT(int1 && int2 && int3);
ok(!bt_value_compare(bt_value_null,
- bt_private_value_as_value(int1)),
+ int1),
"cannot compare null value object and integer value object");
- ok(!bt_value_compare(bt_private_value_as_value(int1),
- bt_private_value_as_value(int2)),
+ ok(!bt_value_compare(int1,
+ int2),
"integer value objects are not equivalent (10 and -23)");
- ok(bt_value_compare(bt_private_value_as_value(int1),
- bt_private_value_as_value(int3)),
+ ok(bt_value_compare(int1,
+ int3),
"integer value objects are equivalent (10 and 10)");
BT_OBJECT_PUT_REF_AND_RESET(int1);
static
void test_compare_real(void)
{
- 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);
+ 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);
BT_ASSERT(real1 && real2 && real3);
ok(!bt_value_compare(bt_value_null,
- bt_private_value_as_value(real1)),
+ real1),
"cannot compare null value object and real number value object");
- ok(!bt_value_compare(bt_private_value_as_value(real1),
- bt_private_value_as_value(real2)),
+ ok(!bt_value_compare(real1,
+ real2),
"real number value objects are not equivalent (17.38 and -14.23)");
- ok(bt_value_compare(bt_private_value_as_value(real1),
- bt_private_value_as_value(real3)),
+ ok(bt_value_compare(real1,
+ 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_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");
+ 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");
BT_ASSERT(string1 && string2 && string3);
ok(!bt_value_compare(bt_value_null,
- bt_private_value_as_value(string1)),
+ string1),
"cannot compare null value object and string value object");
- ok(!bt_value_compare(bt_private_value_as_value(string1),
- bt_private_value_as_value(string2)),
+ ok(!bt_value_compare(string1,
+ string2),
"string value objects are not equivalent (\"hello\" and \"bt_value\")");
- ok(bt_value_compare(bt_private_value_as_value(string1),
- bt_private_value_as_value(string3)),
+ ok(bt_value_compare(string1,
+ string3),
"string value objects are equivalent (\"hello\" and \"hello\")");
BT_OBJECT_PUT_REF_AND_RESET(string1);
static
void test_compare_array(void)
{
- 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();
+ struct bt_value *array1 = bt_value_array_create();
+ struct bt_value *array2 = bt_value_array_create();
+ struct bt_value *array3 = bt_value_array_create();
enum bt_value_status status;
BT_ASSERT(array1 && array2 && array3);
- ok(bt_value_compare(bt_private_value_as_value(array1),
- bt_private_value_as_value(array2)),
+ ok(bt_value_compare(array1,
+ array2),
"empty array value objects are equivalent");
- status = bt_private_value_array_append_integer_element(array1, 23);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_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);
+ status = bt_value_array_append_bool_element(array3, BT_FALSE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- BT_ASSERT(bt_value_array_get_size(
- bt_private_value_as_value(array1)) == 3);
- BT_ASSERT(bt_value_array_get_size(
- bt_private_value_as_value(array2)) == 3);
- BT_ASSERT(bt_value_array_get_size(
- bt_private_value_as_value(array3)) == 3);
+ 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,
- bt_private_value_as_value(array1)),
+ array1),
"cannot compare null value object and array value object");
- ok(!bt_value_compare(bt_private_value_as_value(array1),
- bt_private_value_as_value(array2)),
+ ok(!bt_value_compare(array1,
+ array2),
"array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])");
- ok(bt_value_compare(bt_private_value_as_value(array1),
- bt_private_value_as_value(array3)),
+ ok(bt_value_compare(array1,
+ 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_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();
+ struct bt_value *map1 = bt_value_map_create();
+ struct bt_value *map2 = bt_value_map_create();
+ struct bt_value *map3 = bt_value_map_create();
enum bt_value_status status;
BT_ASSERT(map1 && map2 && map3);
- ok(bt_value_compare(bt_private_value_as_value(map1),
- bt_private_value_as_value(map2)),
+ ok(bt_value_compare(map1,
+ map2),
"empty map value objects are equivalent");
- status = bt_private_value_map_insert_integer_entry(map1, "one", 23);
+ status = bt_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);
+ status = bt_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",
+ status = bt_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);
+ status = bt_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);
+ status = bt_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",
+ status = bt_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",
+ status = bt_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);
+ status = bt_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);
+ status = bt_value_map_insert_real_entry(map3, "two", 14.2);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- BT_ASSERT(bt_value_map_get_size(
- bt_private_value_as_value(map1)) == 3);
- BT_ASSERT(bt_value_map_get_size(
- bt_private_value_as_value(map2)) == 3);
- BT_ASSERT(bt_value_map_get_size(
- bt_private_value_as_value(map3)) == 3);
+ 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,
- bt_private_value_as_value(map1)),
+ map1),
"cannot compare null value object and map value object");
- ok(!bt_value_compare(bt_private_value_as_value(map1),
- bt_private_value_as_value(map2)),
+ ok(!bt_value_compare(map1,
+ map2),
"map value objects are not equivalent");
- ok(bt_value_compare(bt_private_value_as_value(map1),
- bt_private_value_as_value(map3)),
+ ok(bt_value_compare(map1,
+ 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_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;
+ 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;
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();
+ 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();
BT_ASSERT(bool_obj && integer_obj && real_obj && string_obj &&
array_obj && map_obj);
- status = bt_private_value_array_append_element(array_obj,
- bt_private_value_as_value(bool_obj));
+ status = bt_value_array_append_element(array_obj,
+ bool_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_array_append_element(array_obj,
- bt_private_value_as_value(integer_obj));
+ status = bt_value_array_append_element(array_obj,
+ integer_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_array_append_element(array_obj,
- bt_private_value_as_value(real_obj));
+ status = bt_value_array_append_element(array_obj,
+ real_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_array_append_element(array_obj,
+ status = bt_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_private_value_as_value(array_obj));
+ status = bt_value_map_insert_entry(map_obj, "array",
+ array_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_entry(map_obj, "string",
- bt_private_value_as_value(string_obj));
+ status = bt_value_map_insert_entry(map_obj, "string",
+ string_obj);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_value_copy(&map_copy_obj,
- bt_private_value_as_value(map_obj));
+ map_obj);
ok(status == BT_VALUE_STATUS_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_private_value_map_borrow_entry_value(map_copy_obj,
+ string_copy_obj = bt_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_private_value_map_borrow_entry_value(map_copy_obj,
+ array_copy_obj = bt_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_private_value_array_borrow_element_by_index(
+ bool_copy_obj = bt_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_private_value_array_borrow_element_by_index(
+ integer_copy_obj = bt_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_private_value_array_borrow_element_by_index(
+ real_copy_obj = bt_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_private_value_array_borrow_element_by_index(
+ null_copy_obj = bt_value_array_borrow_element_by_index(
array_copy_obj, 3);
- ok(bt_private_value_as_value(null_copy_obj) == bt_value_null,
+ ok(null_copy_obj == bt_value_null,
"bt_value_copy() returns the same pointer (null)");
- ok(bt_value_compare(bt_private_value_as_value(map_obj),
- bt_private_value_as_value(map_copy_obj)),
+ ok(bt_value_compare(map_obj,
+ map_copy_obj),
"source and destination value objects have the same content");
BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj);
}
static
-bt_bool compare_map_elements(struct bt_value *map_a, struct bt_value *map_b,
+bt_bool compare_map_elements(const struct bt_value *map_a, const struct bt_value *map_b,
const char *key)
{
- struct bt_value *elem_a = NULL;
- struct bt_value *elem_b = NULL;
+ const struct bt_value *elem_a = NULL;
+ const struct bt_value *elem_b = NULL;
bt_bool equal;
- elem_a = bt_value_map_borrow_entry_value(map_a, key);
- elem_b = bt_value_map_borrow_entry_value(map_b, key);
+ elem_a = bt_value_map_borrow_entry_value_const(map_a, key);
+ elem_b = bt_value_map_borrow_entry_value_const(map_b, key);
equal = bt_value_compare(elem_a, elem_b);
return equal;
}
static
void test_extend(void)
{
- 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();
+ 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();
enum bt_value_status status;
BT_ASSERT(base_map);
BT_ASSERT(extension_map);
BT_ASSERT(array);
- status = bt_private_value_map_insert_bool_entry(base_map, "file",
+ status = bt_value_map_insert_bool_entry(base_map, "file",
BT_TRUE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_bool_entry(base_map, "edit",
+ status = bt_value_map_insert_bool_entry(base_map, "edit",
BT_FALSE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_integer_entry(base_map,
+ status = bt_value_map_insert_integer_entry(base_map,
"selection", 17);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_integer_entry(base_map, "find",
+ status = bt_value_map_insert_integer_entry(base_map, "find",
-34);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_bool_entry(extension_map, "edit",
+ status = bt_value_map_insert_bool_entry(extension_map, "edit",
BT_TRUE);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_integer_entry(extension_map,
+ status = bt_value_map_insert_integer_entry(extension_map,
"find", 101);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- status = bt_private_value_map_insert_real_entry(extension_map,
+ status = bt_value_map_insert_real_entry(extension_map,
"project", -404);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
status = bt_value_map_extend(
&extended_map,
- bt_private_value_as_value(base_map),
- bt_private_value_as_value(extension_map));
+ base_map,
+ extension_map);
ok(status == BT_VALUE_STATUS_OK &&
extended_map, "bt_value_map_extend() succeeds");
- ok(bt_value_map_get_size(
- bt_private_value_as_value(extended_map)) == 5,
+ ok(bt_value_map_get_size(extended_map) == 5,
"bt_value_map_extend() returns a map object with the correct size");
- ok(compare_map_elements(bt_private_value_as_value(base_map),
- bt_private_value_as_value(extended_map), "file"),
+ ok(compare_map_elements(base_map,
+ extended_map, "file"),
"bt_value_map_extend() picks the appropriate element (file)");
- ok(compare_map_elements(bt_private_value_as_value(extension_map),
- bt_private_value_as_value(extended_map), "edit"),
+ ok(compare_map_elements(extension_map,
+ extended_map, "edit"),
"bt_value_map_extend() picks the appropriate element (edit)");
- ok(compare_map_elements(bt_private_value_as_value(base_map),
- bt_private_value_as_value(extended_map), "selection"),
+ ok(compare_map_elements(base_map,
+ extended_map, "selection"),
"bt_value_map_extend() picks the appropriate element (selection)");
- ok(compare_map_elements(bt_private_value_as_value(extension_map),
- bt_private_value_as_value(extended_map), "find"),
+ ok(compare_map_elements(extension_map,
+ extended_map, "find"),
"bt_value_map_extend() picks the appropriate element (find)");
- ok(compare_map_elements(bt_private_value_as_value(extension_map),
- bt_private_value_as_value(extended_map), "project"),
+ ok(compare_map_elements(extension_map,
+ extended_map, "project"),
"bt_value_map_extend() picks the appropriate element (project)");
BT_OBJECT_PUT_REF_AND_RESET(array);
static
enum bt_self_component_status src_init(
struct bt_self_component_source *self_comp,
- struct bt_value *params, void *init_method_data)
+ const struct bt_value *params, void *init_method_data)
{
int ret;
static
enum bt_self_component_status sink_init(
struct bt_self_component_sink *self_comp,
- struct bt_value *params, void *init_method_data)
+ const struct bt_value *params, void *init_method_data)
{
int ret;
char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
unsigned int major, minor, patch;
const char *extra;
- struct bt_private_value *params;
- struct bt_value *results;
- struct bt_value *object;
- struct bt_value *res_params;
+ struct bt_value *params;
+ const struct bt_value *results;
+ const struct bt_value *object;
+ const struct bt_value *res_params;
struct bt_private_graph *graph;
const char *object_str;
enum bt_graph_status graph_ret;
plugin, "filter");
ok(filter_comp_class,
"bt_plugin_borrow_filter_component_class_by_name() finds a filter component class");
- params = bt_private_value_integer_create_init(23);
+ params = bt_value_integer_create_init(23);
BT_ASSERT(params);
ret = bt_private_query_executor_query(query_exec,
bt_component_class_filter_as_component_class(filter_comp_class),
- "get-something", bt_private_value_as_value(params),
- &results);
+ "get-something", params, &results);
ok(ret == 0 && results, "bt_private_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);
+ object = bt_value_array_borrow_element_by_index_const(results, 0);
BT_ASSERT(object && bt_value_is_string(object));
object_str = bt_value_string_get(object);
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 == bt_private_value_as_value(params),
+ res_params = bt_value_array_borrow_element_by_index_const(results, 1);
+ ok(bt_value_compare(res_params, params),
"bt_component_class_query() receives the expected parameters");
bt_object_get_ref(sink_comp_class);