961337800a1e45472a2abd175de21448726884d5
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_class
*lookup_type_class_scope(GQuark qname
,
27 struct declaration_scope
*scope
)
29 return g_hash_table_lookup(scope
->type_classes
,
30 (gconstpointer
) (unsigned long) qname
);
33 struct type_class
*lookup_type_class(GQuark qname
,
34 struct declaration_scope
*scope
)
36 struct type_class
*tc
;
39 tc
= lookup_type_class_scope(qname
, scope
);
42 scope
= scope
->parent_scope
;
47 static void free_type_class(struct type_class
*type_class
)
49 type_class
->class_free(type_class
);
52 static void free_type(struct type
*type
)
54 type
->p
.type_free(type
);
57 int register_type_class(struct type_class
*type_class
,
58 struct declaration_scope
*scope
)
60 /* Only lookup in local scope */
61 if (lookup_type_class_scope(type_class
->name
, scope
))
64 g_hash_table_insert(scope
->type_classes
,
65 (gpointer
) (unsigned long) type_class
->name
,
70 void type_class_ref(struct type_class
*type_class
)
75 void type_class_unref(struct type_class
*type_class
)
77 if (!--type_class
->ref
)
78 free_type_class(type_class
);
81 void type_ref(struct type
*type
)
86 void type_unref(struct type
*type
)
92 struct declaration_scope
*
93 new_declaration_scope(struct declaration_scope
*parent_scope
)
95 struct declaration_scope
*scope
= g_new(struct declaration_scope
, 1);
97 scope
->type_classes
= g_hash_table_new_full(g_direct_hash
,
99 (GDestroyNotify
) type_class_unref
);
100 scope
->parent_scope
= parent_scope
;
104 void free_declaration_scope(struct declaration_scope
*scope
)
106 g_hash_table_destroy(scope
->type_classes
);
This page took 0.032573 seconds and 4 git commands to generate.