From: Philippe Proulx Date: Mon, 8 Feb 2016 08:43:06 +0000 (-0500) Subject: ir: rename ctf_string_encoding -> bt_ctf_string_encoding X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=87b41f95af464c19d4fe9898cdca6bd53338ef04 ir: rename ctf_string_encoding -> bt_ctf_string_encoding Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index f4ac0ecf..67200dac 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -662,7 +662,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size) integer->parent.declaration->id = CTF_TYPE_INTEGER; integer->declaration.len = size; integer->declaration.base = BT_CTF_INTEGER_BASE_DECIMAL; - integer->declaration.encoding = CTF_STRING_NONE; + integer->declaration.encoding = BT_CTF_STRING_ENCODING_NONE; bt_ctf_field_type_init(&integer->parent, TRUE); return &integer->parent; } @@ -762,10 +762,10 @@ end: return ret; } -enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding( +enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding( struct bt_ctf_field_type *type) { - enum ctf_string_encoding ret = CTF_STRING_UNKNOWN; + enum bt_ctf_string_encoding ret = BT_CTF_STRING_ENCODING_UNKNOWN; struct bt_ctf_field_type_integer *integer; if (!type || type->declaration->id != CTF_TYPE_INTEGER) { @@ -779,15 +779,15 @@ end: } int bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *type, - enum ctf_string_encoding encoding) + enum bt_ctf_string_encoding encoding) { int ret = 0; struct bt_ctf_field_type_integer *integer; if (!type || type->frozen || (type->declaration->id != CTF_TYPE_INTEGER) || - (encoding < CTF_STRING_NONE) || - (encoding >= CTF_STRING_UNKNOWN)) { + (encoding < BT_CTF_STRING_ENCODING_NONE) || + (encoding >= BT_CTF_STRING_ENCODING_UNKNOWN)) { ret = -1; goto end; } @@ -1922,16 +1922,16 @@ struct bt_ctf_field_type *bt_ctf_field_type_string_create(void) string->parent.declaration = &string->declaration.p; string->parent.declaration->id = CTF_TYPE_STRING; bt_ctf_field_type_init(&string->parent, TRUE); - string->declaration.encoding = CTF_STRING_UTF8; + string->declaration.encoding = BT_CTF_STRING_ENCODING_UTF8; string->parent.declaration->alignment = CHAR_BIT; return &string->parent; } -enum ctf_string_encoding bt_ctf_field_type_string_get_encoding( +enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding( struct bt_ctf_field_type *type) { struct bt_ctf_field_type_string *string; - enum ctf_string_encoding ret = CTF_STRING_UNKNOWN; + enum bt_ctf_string_encoding ret = BT_CTF_STRING_ENCODING_UNKNOWN; if (!type || (type->declaration->id != CTF_TYPE_STRING)) { goto end; @@ -1945,14 +1945,14 @@ end: } int bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *type, - enum ctf_string_encoding encoding) + enum bt_ctf_string_encoding encoding) { int ret = 0; struct bt_ctf_field_type_string *string; if (!type || type->declaration->id != CTF_TYPE_STRING || - (encoding != CTF_STRING_UTF8 && - encoding != CTF_STRING_ASCII)) { + (encoding != BT_CTF_STRING_ENCODING_UTF8 && + encoding != BT_CTF_STRING_ENCODING_ASCII)) { ret = -1; goto end; } @@ -2740,18 +2740,18 @@ void bt_ctf_field_type_sequence_freeze(struct bt_ctf_field_type *type) } static -const char *get_encoding_string(enum ctf_string_encoding encoding) +const char *get_encoding_string(enum bt_ctf_string_encoding encoding) { const char *encoding_string; switch (encoding) { - case CTF_STRING_NONE: + case BT_CTF_STRING_ENCODING_NONE: encoding_string = "none"; break; - case CTF_STRING_ASCII: + case BT_CTF_STRING_ENCODING_ASCII: encoding_string = "ASCII"; break; - case CTF_STRING_UTF8: + case BT_CTF_STRING_ENCODING_UTF8: encoding_string = "UTF8"; break; default: diff --git a/include/babeltrace/ctf-ir/event-types.h b/include/babeltrace/ctf-ir/event-types.h index a07d5e56..054615f1 100644 --- a/include/babeltrace/ctf-ir/event-types.h +++ b/include/babeltrace/ctf-ir/event-types.h @@ -64,6 +64,13 @@ enum bt_ctf_byte_order { BT_CTF_BYTE_ORDER_NETWORK, }; +enum bt_ctf_string_encoding { + BT_CTF_STRING_ENCODING_NONE = CTF_STRING_NONE, + BT_CTF_STRING_ENCODING_UTF8 = CTF_STRING_UTF8, + BT_CTF_STRING_ENCODING_ASCII = CTF_STRING_ASCII, + BT_CTF_STRING_ENCODING_UNKNOWN = CTF_STRING_UNKNOWN, +}; + enum bt_ctf_scope { BT_CTF_SCOPE_UNKNOWN = -1, BT_CTF_SCOPE_ENV = 0, @@ -156,9 +163,10 @@ extern int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, * * @param integer Integer type. * - * Returns the string field's encoding on success, CTF_STRING_UNKNOWN on error. + * Returns the string field's encoding on success, + * BT_CTF_STRING_ENCODING_UNKNOWN on error. */ -extern enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding( +extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding( struct bt_ctf_field_type *integer); /* @@ -168,13 +176,14 @@ extern enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding( * a text character. * * @param integer Integer type. - * @param encoding Integer output encoding, defaults to CTF_STRING_ENCODING_NONE + * @param encoding Integer output encoding, defaults to + * BT_CTF_STRING_ENCODING_NONE * * Returns 0 on success, a negative value on error. */ extern int bt_ctf_field_type_integer_set_encoding( struct bt_ctf_field_type *integer, - enum ctf_string_encoding encoding); + enum bt_ctf_string_encoding encoding); /** * bt_ctf_field_type_integer_get_mapped_clock: get an integer type's mapped clock. @@ -682,9 +691,10 @@ extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void); * * @param string_type String type. * - * Returns the string's encoding on success, a CTF_STRING_UNKNOWN on error. + * Returns the string's encoding on success, a BT_CTF_STRING_ENCODING_UNKNOWN + * on error. */ -extern enum ctf_string_encoding bt_ctf_field_type_string_get_encoding( +extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding( struct bt_ctf_field_type *string_type); /* @@ -693,14 +703,15 @@ extern enum ctf_string_encoding bt_ctf_field_type_string_get_encoding( * Set the string type's encoding. * * @param string_type String type. - * @param encoding String field encoding, default CTF_STRING_ENCODING_ASCII. - * Valid values are CTF_STRING_ENCODING_ASCII and CTF_STRING_ENCODING_UTF8. + * @param encoding String field encoding, default BT_CTF_STRING_ENCODING_ASCII. + * Valid values are BT_CTF_STRING_ENCODING_ASCII and + * BT_CTF_STRING_ENCODING_UTF8. * * Returns 0 on success, a negative value on error. */ extern int bt_ctf_field_type_string_set_encoding( struct bt_ctf_field_type *string_type, - enum ctf_string_encoding encoding); + enum bt_ctf_string_encoding encoding); /* * bt_ctf_field_type_get_alignment: get a field type's alignment. diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index f75daba9..86940d2d 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -1961,17 +1961,20 @@ void type_field_tests() BT_CTF_INTEGER_BASE_HEXADECIMAL, "bt_ctf_field_type_integer_get_base returns a correct value"); - ok(bt_ctf_field_type_integer_set_encoding(NULL, CTF_STRING_ASCII) < 0, + ok(bt_ctf_field_type_integer_set_encoding(NULL, + BT_CTF_STRING_ENCODING_ASCII) < 0, "bt_ctf_field_type_integer_set_encoding handles NULL correctly"); ok(bt_ctf_field_type_integer_set_encoding(uint_12_type, - (enum ctf_string_encoding) 123) < 0, + (enum bt_ctf_string_encoding) 123) < 0, "bt_ctf_field_type_integer_set_encoding handles invalid encodings correctly"); ok(bt_ctf_field_type_integer_set_encoding(uint_12_type, - CTF_STRING_UTF8) == 0, + BT_CTF_STRING_ENCODING_UTF8) == 0, "Set integer type encoding to UTF8"); - ok(bt_ctf_field_type_integer_get_encoding(NULL) == CTF_STRING_UNKNOWN, + ok(bt_ctf_field_type_integer_get_encoding(NULL) == + BT_CTF_STRING_ENCODING_UNKNOWN, "bt_ctf_field_type_integer_get_encoding handles NULL correctly"); - ok(bt_ctf_field_type_integer_get_encoding(uint_12_type) == CTF_STRING_UTF8, + ok(bt_ctf_field_type_integer_get_encoding(uint_12_type) == + BT_CTF_STRING_ENCODING_UTF8, "bt_ctf_field_type_integer_get_encoding returns a correct value"); int_16_type = bt_ctf_field_type_integer_create(16); @@ -2003,20 +2006,20 @@ void type_field_tests() string_type = bt_ctf_field_type_string_create(); ok(string_type, "Create a string type"); ok(bt_ctf_field_type_string_set_encoding(string_type, - CTF_STRING_NONE), + BT_CTF_STRING_ENCODING_NONE), "Reject invalid \"None\" string encoding"); ok(bt_ctf_field_type_string_set_encoding(string_type, 42), "Reject invalid string encoding"); ok(bt_ctf_field_type_string_set_encoding(string_type, - CTF_STRING_ASCII) == 0, + BT_CTF_STRING_ENCODING_ASCII) == 0, "Set string encoding to ASCII"); ok(bt_ctf_field_type_string_get_encoding(NULL) == - CTF_STRING_UNKNOWN, + BT_CTF_STRING_ENCODING_UNKNOWN, "bt_ctf_field_type_string_get_encoding handles NULL correctly"); ok(bt_ctf_field_type_string_get_encoding(string_type) == - CTF_STRING_ASCII, + BT_CTF_STRING_ENCODING_ASCII, "bt_ctf_field_type_string_get_encoding returns the correct value"); structure_seq_type = bt_ctf_field_type_structure_create();