From: Philippe Proulx Date: Thu, 15 Jun 2017 20:10:23 +0000 (-0400) Subject: Add BT_CTF_INTEGER_BASE_UNSPECIFIED X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=d2bd5ad3da0dba99582f74450e49a34689461d80 Add BT_CTF_INTEGER_BASE_UNSPECIFIED This is in preparation for CTF 2 in which a default base is not specified for integer-like field types. sink.text.pretty defaults to BT_CTF_INTEGER_BASE_DECIMAL when it gets BT_CTF_INTEGER_BASE_UNSPECIFIED. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/ctf-ir/field-types-internal.h b/include/babeltrace/ctf-ir/field-types-internal.h index 4c21cbd4..f408f50b 100644 --- a/include/babeltrace/ctf-ir/field-types-internal.h +++ b/include/babeltrace/ctf-ir/field-types-internal.h @@ -291,6 +291,8 @@ const char *bt_ctf_integer_base_string(enum bt_ctf_integer_base base) switch (base) { case BT_CTF_INTEGER_BASE_UNKNOWN: return "BT_CTF_INTEGER_BASE_UNKNOWN"; + case BT_CTF_INTEGER_BASE_UNSPECIFIED: + return "BT_CTF_INTEGER_BASE_UNSPECIFIED"; case BT_CTF_INTEGER_BASE_BINARY: return "BT_CTF_INTEGER_BASE_BINARY"; case BT_CTF_INTEGER_BASE_OCTAL: diff --git a/include/babeltrace/ctf-ir/field-types.h b/include/babeltrace/ctf-ir/field-types.h index 625a102e..cf332762 100644 --- a/include/babeltrace/ctf-ir/field-types.h +++ b/include/babeltrace/ctf-ir/field-types.h @@ -759,6 +759,9 @@ enum bt_ctf_integer_base { /// Unknown, used for errors. BT_CTF_INTEGER_BASE_UNKNOWN = -1, + /// Unspecified by the tracer. + BT_CTF_INTEGER_BASE_UNSPECIFIED = 0, + /// Binary. BT_CTF_INTEGER_BASE_BINARY = 2, @@ -896,8 +899,9 @@ extern int bt_ctf_field_type_integer_set_is_signed( preferred display base. @returns Preferred display base of the integer fields described by \p int_field_type, - or #BT_CTF_INTEGER_BASE_UNKNOWN on - error. + #BT_CTF_INTEGER_BASE_UNSPECIFIED if + not specified, or + #BT_CTF_INTEGER_BASE_UNKNOWN on error. @prenotnull{int_field_type} @preisintft{int_field_type} @@ -924,9 +928,9 @@ extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base( @prenotnull{int_field_type} @preisintft{int_field_type} @prehot{int_field_type} -@pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL, - #BT_CTF_INTEGER_BASE_DECIMAL, or - #BT_CTF_INTEGER_BASE_HEXADECIMAL. +@pre \p base is #BT_CTF_INTEGER_BASE_UNSPECIFIED, + #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL, + #BT_CTF_INTEGER_BASE_DECIMAL, or #BT_CTF_INTEGER_BASE_HEXADECIMAL. @postrefcountsame{int_field_type} @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 68ae5899..95fdda9f 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -1073,6 +1073,7 @@ int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *type, } switch (base) { + case BT_CTF_INTEGER_BASE_UNSPECIFIED: case BT_CTF_INTEGER_BASE_BINARY: case BT_CTF_INTEGER_BASE_OCTAL: case BT_CTF_INTEGER_BASE_DECIMAL: @@ -3900,6 +3901,7 @@ const char *get_integer_base_string(enum bt_ctf_integer_base base) switch (base) { case BT_CTF_INTEGER_BASE_DECIMAL: + case BT_CTF_INTEGER_BASE_UNSPECIFIED: base_string = "decimal"; break; case BT_CTF_INTEGER_BASE_HEXADECIMAL: diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index 86c088dc..1d941e91 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -693,6 +693,7 @@ enum bt_component_status print_integer(struct pretty_component *pretty, break; } case BT_CTF_INTEGER_BASE_DECIMAL: + case BT_CTF_INTEGER_BASE_UNSPECIFIED: if (!signedness) { g_string_append_printf(pretty->string, "%" PRIu64, v.u); } else {