4 * BabelTrace - Converter
8 * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
21 #include <babeltrace/format.h>
26 struct type
*lookup_type_scope(GQuark qname
, struct declaration_scope
*scope
)
28 return g_hash_table_lookup(scope
->types
,
29 (gconstpointer
) (unsigned long) qname
);
32 struct type
*lookup_type(GQuark qname
, struct declaration_scope
*scope
)
37 type
= lookup_type_scope(qname
, scope
);
40 scope
= scope
->parent_scope
;
45 static void free_type(struct type
*type
)
47 type
->type_free(type
);
50 static void free_declaration(struct declaration
*declaration
)
52 declaration
->p
.declaration_free(declaration
);
55 int register_type(struct type
*type
, struct declaration_scope
*scope
)
57 /* Only lookup in local scope */
58 if (lookup_type_scope(type
->name
, scope
))
61 g_hash_table_insert(scope
->types
,
62 (gpointer
) (unsigned long) type
->name
,
67 void type_ref(struct type
*type
)
72 void type_unref(struct type
*type
)
78 void declaration_ref(struct declaration
*declaration
)
83 void declaration_unref(struct declaration
*declaration
)
85 if (!--declaration
->ref
)
86 free_declaration(declaration
);
89 struct declaration_scope
*
90 new_declaration_scope(struct declaration_scope
*parent_scope
)
92 struct declaration_scope
*scope
= g_new(struct declaration_scope
, 1);
94 scope
->types
= g_hash_table_new_full(g_direct_hash
,
96 (GDestroyNotify
) type_unref
);
97 scope
->parent_scope
= parent_scope
;
101 void free_declaration_scope(struct declaration_scope
*scope
)
103 g_hash_table_destroy(scope
->types
);
This page took 0.032651 seconds and 4 git commands to generate.