+ scope->scope_path = g_array_sized_new(FALSE, TRUE, sizeof(GQuark),
+ scope_path_len);
+ g_array_set_size(scope->scope_path, scope_path_len);
+ return scope;
+}
+
+GQuark bt_new_definition_path(struct definition_scope *parent_scope,
+ GQuark field_name, const char *root_name)
+{
+ GQuark path;
+ GString *str;
+ gchar *c_str;
+ int need_dot = 0;
+
+ str = g_string_new("");
+ if (root_name) {
+ g_string_append(str, root_name);
+ need_dot = 1;
+ } else if (parent_scope) {
+ int i;
+
+ for (i = 0; i < parent_scope->scope_path->len; i++) {
+ GQuark q = g_array_index(parent_scope->scope_path,
+ GQuark, i);
+ if (!q)
+ continue;
+ if (need_dot)
+ g_string_append(str, ".");
+ g_string_append(str, g_quark_to_string(q));
+ need_dot = 1;
+ }
+ }
+ if (field_name) {
+ if (need_dot)
+ g_string_append(str, ".");
+ g_string_append(str, g_quark_to_string(field_name));
+ }
+ c_str = g_string_free(str, FALSE);
+ if (c_str[0] == '\0')
+ return 0;
+ path = g_quark_from_string(c_str);
+ printf_debug("new definition path: %s\n", c_str);
+ g_free(c_str);
+ return path;
+}
+
+struct definition_scope *
+ bt_new_definition_scope(struct definition_scope *parent_scope,
+ GQuark field_name, const char *root_name)
+{
+ struct definition_scope *scope;
+
+ if (root_name) {
+ scope = _bt_new_definition_scope(parent_scope, 0);
+ bt_append_scope_path(root_name, scope->scope_path);
+ } else {
+ int scope_path_len = 1;
+
+ assert(parent_scope);
+ scope_path_len += parent_scope->scope_path->len;
+ scope = _bt_new_definition_scope(parent_scope, scope_path_len);
+ memcpy(scope->scope_path->data, parent_scope->scope_path->data,
+ sizeof(GQuark) * (scope_path_len - 1));
+ g_array_index(scope->scope_path, GQuark, scope_path_len - 1) =
+ field_name;
+ }
+ if (babeltrace_debug) {
+ int i, need_dot = 0;
+
+ printf_debug("new definition scope: ");
+ for (i = 0; i < scope->scope_path->len; need_dot = 1, i++)
+ printf("%s%s", need_dot ? "." : "",
+ g_quark_to_string(g_array_index(scope->scope_path, GQuark, i)));
+ printf("\n");
+ }