struct ctf_type *ctf_type_specifier_visit(FILE *fd,
int depth, struct list_head *head,
struct type_scope *type_scope,
- struct declaration_scope *declaration_scope)
+ struct definition_scope *definition_scope)
{
struct ctf_type *type;
struct node *first;
struct ctf_declaration *ctf_declaration_specifier_visit(FILE *fd,
int depth, struct list_head *head,
struct type_scope *type_scope,
- struct declaration_scope *declaration_scope)
+ struct definition_scope *definition_scope)
{
struct ctf_declaration *declaration;
struct ctf_type *type;
type = ctf_type_specifier_visit(fd, depth, head, type_scope,
- declaration_scope);
- declaration = type->declaration_new(type, declaration_scope);
+ definition_scope);
+ declaration = type->declaration_new(type, definition_scope);
if (type->id == CTF_TYPE_VARIANT) {
struct declaration_variant *variant =
container_of(declaration, struct declaration_variant, p);
struct declaration *enum_tag =
- lookup_field_declaration(enum_tag_name, declaration_scope);
+ lookup_field_declaration(enum_tag_name, definition_scope);
if (!enum_tag) {
fprintf(fd, "[error]: expected enumeration tag field %s for variant\n",
enum_tag_name);
int ctf_typedef_declarator_visit(FILE *fd, int depth,
struct list_head *declaration_specifier,
struct node *type_declarator, struct type_scope *type_scope,
- struct declaration_scope *declaration_scope)
+ struct definition_scope *definition_scope)
{
/*
* Build the type using declaration specifier (creating
struct list_head *declaration_specifier,
struct list_head *type_declarators,
struct type_scope *type_scope,
- struct declaration_scope *declaration_scope)
+ struct definition_scope *definition_scope)
{
struct ctf_node *iter;
cds_list_for_each_entry(iter, type_declarators, siblings) {
ret = ctf_typedef_declarator_visit(fd, depth + 1,
&node->u._typedef.declaration_specifier, iter,
- type_scope, declaration_scope);
+ type_scope, definition_scope);
if (ret)
return ret;
}
static
int ctf_typealias_visit(FILE *fd, int depth, struct ctf_node *target,
struct ctf_node *alias, struct type_scope *type_scope,
- struct declaration_scope *declaration_scope)
+ struct definition_scope *definition_scope)
{
/* Build target type, check that it is reachable in current type scope. */
/* Only one type declarator is allowed */
ret = ctf_typedef_visit(fd, depth + 1,
&node->u._typedef.declaration_specifier,
&node->u._typedef.type_declarators,
- event->type_scope, event->declaration_scope);
+ event->type_scope, event->definition_scope);
if (ret)
return ret;
break;
case NODE_TYPEALIAS:
ret = ctf_typealias_visit(fd, depth + 1,
&node->u.typealias.target, &node->u.typealias.alias
- event->type_scope, event->declaration_scope);
+ event->type_scope, event->definition_scope);
if (ret)
return ret;
break;
fprintf(stderr, "[error] %s: stream id %" PRIu64 " cannot be found\n", __func__, event->stream_id);
return -EINVAL;
}
- event->declaration_scope = new_declaration_scope(stream->declaration_scope);
- if (!event->declaration_scope) {
+ event->definition_scope = new_definition_scope(stream->definition_scope);
+ if (!event->definition_scope) {
fprintf(stderr, "[error] %s: Error allocating declaration scope\n", __func__);
return -EPERM;
}
} else if (!strcmp(left, "context")) {
struct declaration *declaration;
- if (!event->declaration_scope)
+ if (!event->definition_scope)
return -EPERM;
declaration = ctf_declaration_specifier_visit(fd, depth,
&node->u.ctf_expression.right,
- event->type_scope, event->declaration_scope);
+ event->type_scope, event->definition_scope);
if (!declaration)
return -EPERM;
if (declaration->type->id != CTF_TYPE_STRUCT)
} else if (!strcmp(left, "fields")) {
struct declaration *declaration;
- if (!event->declaration_scope)
+ if (!event->definition_scope)
return -EPERM;
declaration = ctf_declaration_specifier_visit(fd, depth,
&node->u.ctf_expression.right,
- event->type_scope, event->declaration_scope);
+ event->type_scope, event->definition_scope);
if (!declaration)
return -EPERM;
if (declaration->type->id != CTF_TYPE_STRUCT)
error:
declaration_unref(event->fields);
declaration_unref(event->context);
- free_declaration_scope(event->declaration_scope);
+ free_definition_scope(event->definition_scope);
free_type_scope(event->type_scope);
g_free(event);
return ret;
ret = ctf_typedef_visit(fd, depth + 1,
&node->u._typedef.declaration_specifier,
&node->u._typedef.type_declarators,
- stream->type_scope, stream->declaration_scope);
+ stream->type_scope, stream->definition_scope);
if (ret)
return ret;
break;
case NODE_TYPEALIAS:
ret = ctf_typealias_visit(fd, depth + 1,
&node->u.typealias.target, &node->u.typealias.alias
- stream->type_scope, stream->declaration_scope);
+ stream->type_scope, stream->definition_scope);
if (ret)
return ret;
break;
declaration = ctf_declaration_specifier_visit(fd, depth,
&node->u.ctf_expression.right,
- stream->type_scope, stream->declaration_scope);
+ stream->type_scope, stream->definition_scope);
if (!declaration)
return -EPERM;
if (declaration->type->id != CTF_TYPE_STRUCT)
declaration = ctf_declaration_specifier_visit(fd, depth,
&node->u.ctf_expression.right,
- stream->type_scope, stream->declaration_scope);
+ stream->type_scope, stream->definition_scope);
if (!declaration)
return -EPERM;
if (declaration->type->id != CTF_TYPE_STRUCT)
declaration = ctf_declaration_specifier_visit(fd, depth,
&node->u.ctf_expression.right,
- stream->type_scope, stream->declaration_scope);
+ stream->type_scope, stream->definition_scope);
if (!declaration)
return -EPERM;
if (declaration->type->id != CTF_TYPE_STRUCT)
stream = g_new0(struct ctf_stream, 1);
stream->type_scope = new_type_scope(parent_type_scope);
- stream->declaration_scope = new_declaration_scope(trace->declaration_scope);
+ stream->definition_scope = new_definition_scope(trace->definition_scope);
stream->events_by_id = g_ptr_array_new();
stream->event_quark_to_id = g_hash_table_new(g_int_hash, g_int_equal);
cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
declaration_unref(stream->packet_context);
g_ptr_array_free(stream->events_by_id, TRUE);
g_hash_table_free(stream->event_quark_to_id);
- free_declaration_scope(stream->declaration_scope);
+ free_definition_scope(stream->definition_scope);
free_type_scope(stream->type_scope);
g_free(stream);
return ret;
ret = ctf_typedef_visit(fd, depth + 1,
&node->u._typedef.declaration_specifier,
&node->u._typedef.type_declarators,
- trace->type_scope, trace->declaration_scope);
+ trace->type_scope, trace->definition_scope);
if (ret)
return ret;
break;
case NODE_TYPEALIAS:
ret = ctf_typealias_visit(fd, depth + 1,
&node->u.typealias.target, &node->u.typealias.alias
- trace->type_scope, trace->declaration_scope);
+ trace->type_scope, trace->definition_scope);
if (ret)
return ret;
break;
if (trace->type_scope)
return -EEXIST;
trace->type_scope = new_type_scope(trace->root_type_scope);
- trace->declaration_scope = new_declaration_scope(trace->root_declaration_scope);
+ trace->definition_scope = new_definition_scope(trace->root_definition_scope);
trace->streams = g_ptr_array_new();
cds_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
ret = ctf_trace_declaration_visit(fd, depth + 1, iter, trace);
error:
g_ptr_array_free(trace->streams, TRUE);
- free_declaration_scope(stream->declaration_scope);
+ free_definition_scope(stream->definition_scope);
free_type_scope(stream->type_scope);
return ret;
}
ret = ctf_typedef_visit(fd, depth + 1,
&iter->u._typedef.declaration_specifier,
&iter->u._typedef.type_declarators,
- trace->type_scope, trace->declaration_scope);
+ trace->type_scope, trace->definition_scope);
if (ret)
return ret;
}
siblings) {
ret = ctf_typealias_visit(fd, depth + 1,
&iter->u.typealias.target, &iter->u.typealias.alias
- trace->type_scope, trace->declaration_scope);
+ trace->type_scope, trace->definition_scope);
if (ret)
return ret;
}
cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, siblings) {
ret = ctf_declaration_specifier_visit(fd, depth, iter,
trace->root_type_scope,
- trace->root_declaration_scope);
+ trace->root_definition_scope);
if (ret)
return ret;
}
/* root scope */
struct type_scope *root_type_scope;
/* root scope */
- struct declaration_scope *root_declaration_scope;
+ struct definition_scope *root_definition_scope;
struct type_scope *type_scope;
- struct declaration_scope *declaration_scope;
+ struct definition_scope *definition_scope;
GPtrArray *streams; /* Array of struct ctf_stream pointers*/
uint64_t major;
/* parent is lexical scope conaining the stream scope */
struct type_scope *type_scope;
/* parent is trace scope */
- struct declaration_scope *declaration_scope;
+ struct definition_scope *definition_scope;
GPtrArray *events_by_id; /* Array of struct ctf_event pointers indexed by id */
GHashTable *event_quark_to_id; /* GQuark to numeric id */
- struct declaration_struct *event_header;
- struct declaration_struct *event_context;
- struct declaration_struct *packet_context;
+ struct definition_struct *event_header;
+ struct definition_struct *event_context;
+ struct definition_struct *packet_context;
uint64_t stream_id;
/* parent is lexical scope conaining the event scope */
struct type_scope *type_scope;
/* parent is stream scope */
- struct declaration_scope *declaration_scope;
- struct declaration_struct *context;
- struct declaration_struct *fields;
+ struct definition_scope *definition_scope;
+ struct definition_struct *context;
+ struct definition_struct *fields;
GQuark name;
uint64_t id; /* Numeric identifier within the stream */
}
struct format;
-struct declaration;
+struct definition;
/* type scope */
struct type_scope {
/* Hash table mapping type name GQuark to "struct declaration" */
- GHashTable *type_declarations;
+ GHashTable *type_definitions;
/* Hash table mapping struct name GQuark to "struct type_struct" */
GHashTable *struct_types;
/* Hash table mapping variant name GQuark to "struct type_variant" */
struct type_scope *parent_scope;
};
-/* declaration scope */
-struct declaration_scope {
- /* Hash table mapping field name GQuark to "struct declaration" */
- GHashTable *declarations;
- struct declaration_scope *parent_scope;
+/* definition scope */
+struct definition_scope {
+ /* Hash table mapping field name GQuark to "struct definition" */
+ GHashTable *definitions;
+ struct definition_scope *parent_scope;
};
enum ctf_type_id {
* type_free called with type ref is decremented to 0.
*/
void (*type_free)(struct type *type);
- struct declaration *
- (*declaration_new)(struct type *type,
- struct declaration_scope *parent_scope);
+ struct definition *
+ (*definition_new)(struct type *type,
+ struct definition_scope *parent_scope);
/*
- * declaration_free called with declaration ref is decremented to 0.
+ * definition_free called with definition ref is decremented to 0.
*/
- void (*declaration_free)(struct declaration *declaration);
+ void (*definition_free)(struct definition *definition);
/*
- * Declaration copy function. Knows how to find the child declaration
- * from the parent declaration.
+ * Definition copy function. Knows how to find the child
+ * definition from the parent definition.
*/
void (*copy)(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration);
+ struct definition *definition);
};
-struct declaration {
+struct definition {
struct type *type;
- int ref; /* number of references to the declaration */
+ int ref; /* number of references to the definition */
};
/*
int signedness;
};
-struct declaration_integer {
- struct declaration p;
+struct definition_integer {
+ struct definition p;
struct type_integer *type;
/* Last values read */
union {
/* TODO: we might want to express more info about NaN, +inf and -inf */
};
-struct declaration_float {
- struct declaration p;
+struct definition_float {
+ struct definition p;
struct type_float *type;
/* Last values read */
long double value;
struct enum_table table;
};
-struct declaration_enum {
- struct declaration p;
- struct declaration_integer *integer;
+struct definition_enum {
+ struct definition p;
+ struct definition_integer *integer;
struct type_enum *type;
/* Last GQuark values read. Keeping a reference on the GQuark array. */
GArray *value;
struct type p;
};
-struct declaration_string {
- struct declaration p;
+struct definition_string {
+ struct definition p;
struct type_string *type;
- char *value; /* freed at declaration_string teardown */
+ char *value; /* freed at definition_string teardown */
};
struct type_field {
struct field {
GQuark name;
- struct declaration *declaration;
+ struct definition *definition;
};
struct type_struct {
GArray *fields; /* Array of type_field */
};
-struct declaration_struct {
- struct declaration p;
+struct definition_struct {
+ struct definition p;
struct type_struct *type;
- struct declaration_scope *scope;
+ struct definition_scope *scope;
GArray *fields; /* Array of struct field */
};
/* Tag name must be nonzero and must exist when defining the variant */
};
-struct declaration_variant {
- struct declaration p;
+struct definition_variant {
+ struct definition p;
struct type_variant *type;
- struct declaration_scope *scope;
- struct declaration *enum_tag;
+ struct definition_scope *scope;
+ struct definition *enum_tag;
GArray *fields; /* Array of struct field */
struct field *current_field; /* Last field read */
};
struct type_scope *scope;
};
-struct declaration_array {
- struct declaration p;
+struct definition_array {
+ struct definition p;
struct type_array *type;
- struct declaration_scope *scope;
+ struct definition_scope *scope;
struct field current_element; /* struct field */
};
struct type_scope *scope;
};
-struct declaration_sequence {
- struct declaration p;
+struct definition_sequence {
+ struct definition p;
struct type_sequence *type;
- struct declaration_scope *scope;
- struct declaration_integer *len;
+ struct definition_scope *scope;
+ struct definition_integer *len;
struct field current_element; /* struct field */
};
-/*
- * type_declaration is for typedef and typealias. They are registered
- * into type scopes.
- */
-int register_type_declaration(GQuark type_name, struct declaration *declaration,
- struct type_scope *scope);
-struct declaration *lookup_type_declaration(GQuark type_name,
- struct type_scope *scope);
+int register_type(GQuark type_name, struct definition *definition,
+ struct type_scope *scope);
+struct definition *lookup_type(GQuark type_name,
+ struct type_scope *scope);
/*
* Type scopes also contain a separate registry for struct, variant and
- * enum types. Those register types rather than type declarations, so
+ * enum types. Those register types rather than type definitions, so
* that a named variant can be declared without specifying its target
* "choice" tag field immediately.
*/
void free_type_scope(struct type_scope *scope);
/*
- * field_declaration is for field declarations. They are registered into
- * declaration scopes.
+ * field_definition is for field definitions. They are registered into
+ * definition scopes.
*/
-struct declaration *
- lookup_field_declaration(GQuark field_name,
- struct declaration_scope *scope);
-int register_field_declaration(GQuark field_name,
- struct declaration *declaration,
- struct declaration_scope *scope);
-struct declaration_scope *
- new_declaration_scope(struct declaration_scope *parent_scope);
-void free_declaration_scope(struct declaration_scope *scope);
+struct definition *
+ lookup_field_definition(GQuark field_name,
+ struct definition_scope *scope);
+int register_field_definition(GQuark field_name,
+ struct definition *definition,
+ struct definition_scope *scope);
+struct definition_scope *
+ new_definition_scope(struct definition_scope *parent_scope);
+void free_definition_scope(struct definition_scope *scope);
void type_ref(struct type *type);
void type_unref(struct type *type);
-void declaration_ref(struct declaration *declaration);
-void declaration_unref(struct declaration *declaration);
+void definition_ref(struct definition *definition);
+void definition_unref(struct definition *definition);
/* Nameless types can be created by passing a NULL name */
struct_type_get_field_from_index(struct type_struct *struct_type,
unsigned long index);
struct field *
-struct_get_field_from_index(struct declaration_struct *struct_declaration,
+struct_get_field_from_index(struct definition_struct *struct_definition,
unsigned long index);
/*
/*
* Returns 0 on success, -EPERM on error.
*/
-int variant_declaration_set_tag(struct declaration_variant *variant,
- struct declaration *enum_tag);
+int variant_definition_set_tag(struct definition_variant *variant,
+ struct definition *enum_tag);
/*
* Returns the field selected by the current tag value.
* field returned only valid as long as the variant structure is not appended
* to.
*/
struct field *
-variant_get_current_field(struct declaration_variant *variant);
+variant_get_current_field(struct definition_variant *variant);
/*
* elem_type passed as parameter now belongs to the array. No need to free it
#include <babeltrace/format.h>
static
-struct declaration *_array_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_array_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _array_declaration_free(struct declaration *declaration);
+void _array_definition_free(struct definition *definition);
void array_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_array *array =
- container_of(declaration, struct declaration_array, p);
+ struct definition_array *array =
+ container_of(definition, struct definition_array, p);
struct type_array *array_type = array->type;
uint64_t i;
fdest->array_begin(dest, array_type);
for (i = 0; i < array_type->len; i++) {
- struct declaration *elem = array->current_element.declaration;
+ struct definition *elem = array->current_element.definition;
elem->type->copy(dest, fdest, src, fsrc, elem);
}
fsrc->array_end(src, array_type);
type->alignment = 1;
type->copy = array_copy;
type->type_free = _array_type_free;
- type->declaration_new = _array_declaration_new;
- type->declaration_free = _array_declaration_free;
+ type->definition_new = _array_definition_new;
+ type->definition_free = _array_definition_free;
type->ref = 1;
return array_type;
}
static
-struct declaration *
- _array_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _array_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_array *array_type =
container_of(type, struct type_array, p);
- struct declaration_array *array;
+ struct definition_array *array;
- array = g_new(struct declaration_array, 1);
+ array = g_new(struct definition_array, 1);
type_ref(&array_type->p);
array->p.type = type;
array->type = array_type;
array->p.ref = 1;
- array->scope = new_declaration_scope(parent_scope);
- array->current_element.declaration =
- array_type->elem->declaration_new(array_type->elem,
+ array->scope = new_definition_scope(parent_scope);
+ array->current_element.definition =
+ array_type->elem->definition_new(array_type->elem,
parent_scope);
return &array->p;
}
static
-void _array_declaration_free(struct declaration *declaration)
+void _array_definition_free(struct definition *definition)
{
- struct declaration_array *array =
- container_of(declaration, struct declaration_array, p);
- struct declaration *elem_declaration =
- array->current_element.declaration;
+ struct definition_array *array =
+ container_of(definition, struct definition_array, p);
+ struct definition *elem_definition =
+ array->current_element.definition;
- elem_declaration->type->declaration_free(elem_declaration);
- free_declaration_scope(array->scope);
+ elem_definition->type->definition_free(elem_definition);
+ free_definition_scope(array->scope);
type_unref(array->p.type);
g_free(array);
}
#include <glib.h>
static
-struct declaration *_enum_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_enum_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _enum_declaration_free(struct declaration *declaration);
+void _enum_definition_free(struct definition *definition);
static
void enum_range_set_free(void *ptr)
void enum_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_enum *_enum =
- container_of(declaration, struct declaration_enum, p);
+ struct definition_enum *_enum =
+ container_of(definition, struct definition_enum, p);
struct type_enum *enum_type= _enum->type;
GArray *array;
GQuark v;
enum_type->p.alignment = 1;
enum_type->p.copy = enum_copy;
enum_type->p.type_free = _enum_type_free;
- enum_type->p.declaration_new = _enum_declaration_new;
- enum_type->p.declaration_free = _enum_declaration_free;
+ enum_type->p.definition_new = _enum_definition_new;
+ enum_type->p.definition_free = _enum_definition_free;
enum_type->p.ref = 1;
return enum_type;
}
static
-struct declaration *
- _enum_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _enum_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_enum *enum_type =
container_of(type, struct type_enum, p);
- struct declaration_enum *_enum;
- struct declaration *declaration_integer_parent;
+ struct definition_enum *_enum;
+ struct definition *definition_integer_parent;
- _enum = g_new(struct declaration_enum, 1);
+ _enum = g_new(struct definition_enum, 1);
type_ref(&enum_type->p);
_enum->p.type = type;
_enum->type = enum_type;
_enum->p.ref = 1;
_enum->value = NULL;
- declaration_integer_parent =
- enum_type->integer_type->p.declaration_new(&enum_type->integer_type->p,
+ definition_integer_parent =
+ enum_type->integer_type->p.definition_new(&enum_type->integer_type->p,
parent_scope);
- _enum->integer = container_of(declaration_integer_parent,
- struct declaration_integer, p);
+ _enum->integer = container_of(definition_integer_parent,
+ struct definition_integer, p);
return &_enum->p;
}
static
-void _enum_declaration_free(struct declaration *declaration)
+void _enum_definition_free(struct definition *definition)
{
- struct declaration_enum *_enum =
- container_of(declaration, struct declaration_enum, p);
+ struct definition_enum *_enum =
+ container_of(definition, struct definition_enum, p);
- declaration_unref(&_enum->integer->p);
+ definition_unref(&_enum->integer->p);
type_unref(_enum->p.type);
if (_enum->value)
g_array_unref(_enum->value);
#include <babeltrace/format.h>
static
-struct declaration *_float_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_float_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _float_declaration_free(struct declaration *declaration);
+void _float_definition_free(struct definition *definition);
void float_copy(struct stream_pos *destp,
const struct format *fdest,
struct stream_pos *srcp,
const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_float *_float =
- container_of(declaration, struct declaration_float, p);
+ struct definition_float *_float =
+ container_of(definition, struct definition_float, p);
struct type_float *float_type = _float->type;
if (fsrc->float_copy == fdest->float_copy) {
type->alignment = alignment;
type->copy = float_copy;
type->type_free = _float_type_free;
- type->declaration_new = _float_declaration_new;
- type->declaration_free = _float_declaration_free;
+ type->definition_new = _float_definition_new;
+ type->definition_free = _float_definition_free;
type->ref = 1;
float_type->byte_order = byte_order;
}
static
-struct declaration *
- _float_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _float_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_float *float_type =
container_of(type, struct type_float, p);
- struct declaration_float *_float;
+ struct definition_float *_float;
- _float = g_new(struct declaration_float, 1);
+ _float = g_new(struct definition_float, 1);
type_ref(&float_type->p);
_float->p.type= type;
_float->type= float_type;
}
static
-void _float_declaration_free(struct declaration *declaration)
+void _float_definition_free(struct definition *definition)
{
- struct declaration_float *_float =
- container_of(declaration, struct declaration_float, p);
+ struct definition_float *_float =
+ container_of(definition, struct definition_float, p);
type_unref(_float->p.type);
g_free(_float);
#include <stdint.h>
static
-struct declaration *_integer_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_integer_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _integer_declaration_free(struct declaration *declaration);
+void _integer_definition_free(struct definition *definition);
void integer_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_integer *integer =
- container_of(declaration, struct declaration_integer, p);
+ struct definition_integer *integer =
+ container_of(definition, struct definition_integer, p);
struct type_integer *integer_type = integer->type;
if (!integer_type->signedness) {
integer_type->p.alignment = alignment;
integer_type->p.copy = integer_copy;
integer_type->p.type_free = _integer_type_free;
- integer_type->p.declaration_free = _integer_declaration_free;
- integer_type->p.declaration_new = _integer_declaration_new;
+ integer_type->p.definition_free = _integer_definition_free;
+ integer_type->p.definition_new = _integer_definition_new;
integer_type->p.ref = 1;
integer_type->len = len;
integer_type->byte_order = byte_order;
}
static
-struct declaration *
- _integer_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _integer_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_integer *integer_type =
container_of(type, struct type_integer, p);
- struct declaration_integer *integer;
+ struct definition_integer *integer;
- integer = g_new(struct declaration_integer, 1);
+ integer = g_new(struct definition_integer, 1);
type_ref(&integer_type->p);
integer->p.type = type;
integer->type = integer_type;
}
static
-void _integer_declaration_free(struct declaration *declaration)
+void _integer_definition_free(struct definition *definition)
{
- struct declaration_integer *integer =
- container_of(declaration, struct declaration_integer, p);
+ struct definition_integer *integer =
+ container_of(definition, struct definition_integer, p);
type_unref(integer->p.type);
g_free(integer);
#endif
static
-struct declaration *_sequence_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_sequence_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _sequence_declaration_free(struct declaration *declaration);
+void _sequence_definition_free(struct definition *definition);
void sequence_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_sequence *sequence =
- container_of(declaration, struct declaration_sequence, p);
+ struct definition_sequence *sequence =
+ container_of(definition, struct definition_sequence, p);
struct type_sequence *sequence_type = sequence->type;
uint64_t i;
&sequence->len->p);
for (i = 0; i < sequence->len->value._unsigned; i++) {
- struct declaration *elem =
- sequence->current_element.declaration;
+ struct definition *elem =
+ sequence->current_element.definition;
elem->type->copy(dest, fdest, src, fsrc, elem);
}
fsrc->sequence_end(src, sequence_type);
type->alignment = max(len_type->p.alignment, elem_type->alignment);
type->copy = sequence_copy;
type->type_free = _sequence_type_free;
- type->declaration_new = _sequence_declaration_new;
- type->declaration_free = _sequence_declaration_free;
+ type->definition_new = _sequence_definition_new;
+ type->definition_free = _sequence_definition_free;
type->ref = 1;
return sequence_type;
}
static
-struct declaration *_sequence_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *_sequence_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_sequence *sequence_type =
container_of(type, struct type_sequence, p);
- struct declaration_sequence *sequence;
- struct declaration *len_parent;
+ struct definition_sequence *sequence;
+ struct definition *len_parent;
- sequence = g_new(struct declaration_sequence, 1);
+ sequence = g_new(struct definition_sequence, 1);
type_ref(&sequence_type->p);
sequence->p.type = type;
sequence->type = sequence_type;
sequence->p.ref = 1;
- sequence->scope = new_declaration_scope(parent_scope);
- len_parent = sequence_type->len_type->p.declaration_new(&sequence_type->len_type->p,
+ sequence->scope = new_definition_scope(parent_scope);
+ len_parent = sequence_type->len_type->p.definition_new(&sequence_type->len_type->p,
parent_scope);
sequence->len =
- container_of(len_parent, struct declaration_integer, p);
- sequence->current_element.declaration =
- sequence_type->elem->declaration_new(sequence_type->elem,
+ container_of(len_parent, struct definition_integer, p);
+ sequence->current_element.definition =
+ sequence_type->elem->definition_new(sequence_type->elem,
parent_scope);
return &sequence->p;
}
static
-void _sequence_declaration_free(struct declaration *declaration)
+void _sequence_definition_free(struct definition *definition)
{
- struct declaration_sequence *sequence =
- container_of(declaration, struct declaration_sequence, p);
- struct declaration *len_declaration = &sequence->len->p;
- struct declaration *elem_declaration =
- sequence->current_element.declaration;
+ struct definition_sequence *sequence =
+ container_of(definition, struct definition_sequence, p);
+ struct definition *len_definition = &sequence->len->p;
+ struct definition *elem_definition =
+ sequence->current_element.definition;
- len_declaration->type->declaration_free(len_declaration);
- elem_declaration->type->declaration_free(elem_declaration);
- free_declaration_scope(sequence->scope);
+ len_definition->type->definition_free(len_definition);
+ elem_definition->type->definition_free(elem_definition);
+ free_definition_scope(sequence->scope);
type_unref(sequence->p.type);
g_free(sequence);
}
#include <babeltrace/format.h>
static
-struct declaration *_string_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_string_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _string_declaration_free(struct declaration *declaration);
+void _string_definition_free(struct definition *definition);
void string_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_string *string =
- container_of(declaration, struct declaration_string, p);
+ struct definition_string *string =
+ container_of(definition, struct definition_string, p);
struct type_string *string_type = string->type;
if (fsrc->string_copy == fdest->string_copy) {
string_type->p.alignment = CHAR_BIT;
string_type->p.copy = string_copy;
string_type->p.type_free = _string_type_free;
- string_type->p.declaration_new = _string_declaration_new;
- string_type->p.declaration_free = _string_declaration_free;
+ string_type->p.definition_new = _string_definition_new;
+ string_type->p.definition_free = _string_definition_free;
string_type->p.ref = 1;
return string_type;
}
static
-struct declaration *
- _string_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _string_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_string *string_type =
container_of(type, struct type_string, p);
- struct declaration_string *string;
+ struct definition_string *string;
- string = g_new(struct declaration_string, 1);
+ string = g_new(struct definition_string, 1);
type_ref(&string_type->p);
string->p.type = type;
string->type = string_type;
}
static
-void _string_declaration_free(struct declaration *declaration)
+void _string_definition_free(struct definition *definition)
{
- struct declaration_string *string =
- container_of(declaration, struct declaration_string, p);
+ struct definition_string *string =
+ container_of(definition, struct definition_string, p);
type_unref(string->p.type);
g_free(string->value);
#endif
static
-struct declaration *_struct_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_struct_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _struct_declaration_free(struct declaration *declaration);
+void _struct_definition_free(struct definition *definition);
void struct_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_struct *_struct =
- container_of(declaration, struct declaration_struct, p);
+ struct definition_struct *_struct =
+ container_of(definition, struct definition_struct, p);
struct type_struct *struct_type = _struct->type;
unsigned long i;
for (i = 0; i < _struct->fields->len; i++) {
struct field *field = &g_array_index(_struct->fields,
struct field, i);
- struct type *field_type = field->declaration->type;
+ struct type *field_type = field->definition->type;
- field_type->copy(dest, fdest, src, fsrc, field->declaration);
+ field_type->copy(dest, fdest, src, fsrc, field->definition);
}
fsrc->struct_end(src, struct_type);
type->alignment = 1;
type->copy = struct_copy;
type->type_free = _struct_type_free;
- type->declaration_new = _struct_declaration_new;
- type->declaration_free = _struct_declaration_free;
+ type->definition_new = _struct_definition_new;
+ type->definition_free = _struct_definition_free;
type->ref = 1;
return struct_type;
}
static
-struct declaration *
- _struct_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _struct_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_struct *struct_type =
container_of(type, struct type_struct, p);
- struct declaration_struct *_struct;
+ struct definition_struct *_struct;
unsigned long i;
int ret;
- _struct = g_new(struct declaration_struct, 1);
+ _struct = g_new(struct definition_struct, 1);
type_ref(&struct_type->p);
_struct->p.type = type;
_struct->type = struct_type;
_struct->p.ref = 1;
- _struct->scope = new_declaration_scope(parent_scope);
+ _struct->scope = new_definition_scope(parent_scope);
_struct->fields = g_array_sized_new(FALSE, TRUE,
sizeof(struct field),
DEFAULT_NR_STRUCT_FIELDS);
struct field, i);
field->name = type_field->name;
- field->declaration =
- type_field->type->declaration_new(type_field->type,
+ field->definition =
+ type_field->type->definition_new(type_field->type,
_struct->scope);
- ret = register_declaration(field->name,
- field->declaration, _struct->scope);
+ ret = register_field_definition(field->name,
+ field->definition,
+ _struct->scope);
assert(!ret);
}
return &_struct->p;
}
static
-void _struct_declaration_free(struct declaration *declaration)
+void _struct_definition_free(struct definition *definition)
{
- struct declaration_struct *_struct =
- container_of(declaration, struct declaration_struct, p);
+ struct definition_struct *_struct =
+ container_of(definition, struct definition_struct, p);
unsigned long i;
assert(_struct->fields->len == _struct->type->fields->len);
for (i = 0; i < _struct->fields->len; i++) {
struct field *field = &g_array_index(_struct->fields,
struct field, i);
- declaration_unref(field->declaration);
+ definition_unref(field->definition);
}
- free_declaration_scope(_struct->scope);
+ free_definition_scope(_struct->scope);
type_unref(_struct->p.type);
g_free(_struct);
}
* field returned only valid as long as the field structure is not appended to.
*/
struct field *
-struct_declaration_get_field_from_index(struct declaration_struct *_struct,
+struct_definition_get_field_from_index(struct definition_struct *_struct,
unsigned long index)
{
return &g_array_index(_struct->fields, struct field, index);
#include <errno.h>
static
-struct declaration *
- lookup_type_declaration_scope(GQuark type_name, struct type_scope *scope)
+struct definition *
+ lookup_type_definition_scope(GQuark type_name, struct type_scope *scope)
{
- return g_hash_table_lookup(scope->type_declarations,
+ return g_hash_table_lookup(scope->type_definitions,
(gconstpointer) (unsigned long) type_name);
}
-struct declaration *lookup_type_declaration(GQuark type_name, struct type_scope *scope)
+struct definition *lookup_type_definition(GQuark type_name, struct type_scope *scope)
{
- struct declaration *declaration;
+ struct definition *definition;
while (scope) {
- declaration = lookup_type_declaration_scope(type_name, scope);
- if (declaration)
- return declaration;
+ definition = lookup_type_definition_scope(type_name, scope);
+ if (definition)
+ return definition;
scope = scope->parent_scope;
}
return NULL;
}
-int register_type_declaration(GQuark name, struct declaration *declaration,
- struct type_scope *scope)
+int register_type_definition(GQuark name, struct definition *definition,
+ struct type_scope *scope)
{
if (!name)
return -EPERM;
/* Only lookup in local scope */
- if (lookup_type_declaration_scope(name, scope))
+ if (lookup_type_definition_scope(name, scope))
return -EEXIST;
- g_hash_table_insert(scope->type_declarations,
+ g_hash_table_insert(scope->type_definitions,
(gpointer) (unsigned long) name,
- declaration);
- declaration_ref(declaration);
+ definition);
+ definition_ref(definition);
return 0;
}
static
-struct declaration *
- lookup_field_declaration_scope(GQuark field_name, struct declaration_scope *scope)
+struct definition *
+ lookup_field_definition_scope(GQuark field_name, struct definition_scope *scope)
{
- return g_hash_table_lookup(scope->declarations,
+ return g_hash_table_lookup(scope->definitions,
(gconstpointer) (unsigned long) field_name);
}
-struct declaration *
- lookup_field_declaration(GQuark field_name, struct declaration_scope *scope)
+struct definition *
+ lookup_field_definition(GQuark field_name, struct definition_scope *scope)
{
- struct declaration *declaration;
+ struct definition *definition;
while (scope) {
- declaration = lookup_field_declaration_scope(field_name, scope);
- if (declaration)
- return declaration;
+ definition = lookup_field_definition_scope(field_name, scope);
+ if (definition)
+ return definition;
scope = scope->parent_scope;
}
return NULL;
}
-int register_field_declaration(GQuark field_name, struct declaration *declaration,
- struct declaration_scope *scope)
+int register_field_definition(GQuark field_name, struct definition *definition,
+ struct definition_scope *scope)
{
if (!field_name)
return -EPERM;
/* Only lookup in local scope */
- if (lookup_field_declaration_scope(field_name, scope))
+ if (lookup_field_definition_scope(field_name, scope))
return -EEXIST;
- g_hash_table_insert(scope->declarations,
+ g_hash_table_insert(scope->definitions,
(gpointer) (unsigned long) field_name,
- declaration);
- declaration_ref(declaration);
+ definition);
+ definition_ref(definition);
return 0;
}
type->type_free(type);
}
-void declaration_ref(struct declaration *declaration)
+void definition_ref(struct definition *definition)
{
- declaration->ref++;
+ definition->ref++;
}
-void declaration_unref(struct declaration *declaration)
+void definition_unref(struct definition *definition)
{
- if (!--declaration->ref)
- declaration->type->declaration_free(declaration);
+ if (!--definition->ref)
+ definition->type->definition_free(definition);
}
struct type_scope *
{
struct type_scope *scope = g_new(struct type_scope, 1);
- scope->type_declarations = g_hash_table_new_full(g_direct_hash,
+ scope->type_definitions = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL,
- (GDestroyNotify) declaration_unref);
+ (GDestroyNotify) definition_unref);
scope->struct_types = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL,
(GDestroyNotify) type_unref);
g_hash_table_destroy(scope->enum_types);
g_hash_table_destroy(scope->variant_types);
g_hash_table_destroy(scope->struct_types);
- g_hash_table_destroy(scope->type_declarations);
+ g_hash_table_destroy(scope->type_definitions);
g_free(scope);
}
return 0;
}
-struct declaration_scope *
- new_declaration_scope(struct declaration_scope *parent_scope)
+struct definition_scope *
+ new_definition_scope(struct definition_scope *parent_scope)
{
- struct declaration_scope *scope = g_new(struct declaration_scope, 1);
+ struct definition_scope *scope = g_new(struct definition_scope, 1);
- scope->declarations = g_hash_table_new_full(g_direct_hash,
+ scope->definitions = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL,
- (GDestroyNotify) declaration_unref);
+ (GDestroyNotify) definition_unref);
scope->parent_scope = parent_scope;
return scope;
}
-void free_declaration_scope(struct declaration_scope *scope)
+void free_definition_scope(struct definition_scope *scope)
{
- g_hash_table_destroy(scope->declarations);
+ g_hash_table_destroy(scope->definitions);
g_free(scope);
}
/*
- * variant.c
+* variant.c
*
* BabelTrace - Variant Type Converter
*
#include <errno.h>
static
-struct declaration *_variant_declaration_new(struct type *type,
- struct declaration_scope *parent_scope);
+struct definition *_variant_definition_new(struct type *type,
+ struct definition_scope *parent_scope);
static
-void _variant_declaration_free(struct declaration *declaration);
+void _variant_definition_free(struct definition *definition);
void variant_copy(struct stream_pos *dest, const struct format *fdest,
struct stream_pos *src, const struct format *fsrc,
- struct declaration *declaration)
+ struct definition *definition)
{
- struct declaration_variant *variant =
- container_of(declaration, struct declaration_variant, p);
+ struct definition_variant *variant =
+ container_of(definition, struct definition_variant, p);
struct type_variant *variant_type = variant->type;
struct field *field;
struct type *field_type;
fdest->variant_begin(dest, variant_type);
field = variant_get_current_field(variant);
- field_type = field->declaration->type;
- field_type->copy(dest, fdest, src, fsrc, field->declaration);
+ field_type = field->definition->type;
+ field_type->copy(dest, fdest, src, fsrc, field->definition);
fsrc->variant_end(src, variant_type);
fdest->variant_end(dest, variant_type);
type->alignment = 1;
type->copy = variant_copy;
type->type_free = _variant_type_free;
- type->declaration_new = _variant_declaration_new;
- type->declaration_free = _variant_declaration_free;
+ type->definition_new = _variant_definition_new;
+ type->definition_free = _variant_definition_free;
type->ref = 1;
return variant_type;
}
static
-struct declaration *
- _variant_declaration_new(struct type *type,
- struct declaration_scope *parent_scope)
+struct definition *
+ _variant_definition_new(struct type *type,
+ struct definition_scope *parent_scope)
{
struct type_variant *variant_type =
container_of(type, struct type_variant, p);
- struct declaration_variant *variant;
+ struct definition_variant *variant;
unsigned long i;
- variant = g_new(struct declaration_variant, 1);
+ variant = g_new(struct definition_variant, 1);
type_ref(&variant_type->p);
variant->p.type = type;
variant->type = variant_type;
variant->p.ref = 1;
- variant->scope = new_declaration_scope(parent_scope);
+ variant->scope = new_definition_scope(parent_scope);
variant->fields = g_array_sized_new(FALSE, TRUE,
sizeof(struct field),
DEFAULT_NR_STRUCT_FIELDS);
struct field, i);
field->name = type_field->name;
- field->declaration =
- type_field->type->declaration_new(type_field->type,
+ field->definition =
+ type_field->type->definition_new(type_field->type,
variant->scope);
}
variant->current_field = NULL;
}
static
-void _variant_declaration_free(struct declaration *declaration)
+void _variant_definition_free(struct definition *definition)
{
- struct declaration_variant *variant =
- container_of(declaration, struct declaration_variant, p);
+ struct definition_variant *variant =
+ container_of(definition, struct definition_variant, p);
unsigned long i;
assert(variant->fields->len == variant->type->fields->len);
for (i = 0; i < variant->fields->len; i++) {
struct field *field = &g_array_index(variant->fields,
struct field, i);
- declaration_unref(field->declaration);
+ definition_unref(field->definition);
}
- free_declaration_scope(variant->scope);
+ free_definition_scope(variant->scope);
type_unref(variant->p.type);
g_free(variant);
}
/*
* tag_instance is assumed to be an enumeration.
*/
-int variant_declaration_set_tag(struct declaration_variant *variant,
- struct declaration *enum_tag)
+int variant_definition_set_tag(struct definition_variant *variant,
+ struct definition *enum_tag)
{
- struct declaration_enum *_enum =
- container_of(variant->enum_tag, struct declaration_enum, p);
+ struct definition_enum *_enum =
+ container_of(variant->enum_tag, struct definition_enum, p);
struct type_enum *enum_type = _enum->type;
int missing_field = 0;
unsigned long i;
/*
* field returned only valid as long as the field structure is not appended to.
*/
-struct field *variant_get_current_field(struct declaration_variant *variant)
+struct field *variant_get_current_field(struct definition_variant *variant)
{
- struct declaration_enum *_enum =
- container_of(variant->enum_tag, struct declaration_enum, p);
+ struct definition_enum *_enum =
+ container_of(variant->enum_tag, struct definition_enum, p);
struct type_variant *variant_type = variant->type;
unsigned long index;
GArray *tag_array;