Add structure align() attribute, fix empty string support in definition paths
[babeltrace.git] / types / types.c
index 08324acc481dd5e594525282d3329d4a15459f41..e63394692410ea3f6a885263c5969411caad321d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * declarations.c
+ * types.c
  *
  * BabelTrace - Converter
  *
@@ -469,6 +469,34 @@ static struct definition_scope *
        return scope;
 }
 
+GQuark new_definition_path(struct definition_scope *parent_scope, GQuark field_name)
+{
+       GQuark path;
+       GString *str;
+       gchar *c_str;
+       int i;
+
+       str = g_string_new("");
+       if (parent_scope) {
+               for (i = 0; i < parent_scope->scope_path->len; i++) {
+                       GQuark q = g_array_index(parent_scope->scope_path,
+                                                GQuark, i);
+                       if (!q)
+                               continue;
+                       g_string_append(str, g_quark_to_string(q));
+                       g_string_append(str, ".");
+               }
+       }
+       if (field_name)
+               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);
+       g_free(c_str);
+       return path;
+}
+
 struct definition_scope *
        new_definition_scope(struct definition_scope *parent_scope,
                             GQuark field_name)
This page took 0.023857 seconds and 4 git commands to generate.