ir: fields/field-types: use `bt_bool` instead of `int` where appropriate
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 11 May 2017 21:40:55 +0000 (17:40 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:42 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/field-types.h
include/babeltrace/ctf-ir/fields.h
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c

index 6609018416efa7915b050a5b75e58a0ecf1746cd..45e2836b9021d8d36da302537bc48602dbd4e9a6 100644 (file)
@@ -30,6 +30,7 @@
  * http://www.efficios.com/ctf
  */
 
+#include <babeltrace/types.h>
 #include <stdint.h>
 #include <stddef.h>
 
@@ -342,8 +343,8 @@ extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
 @brief Returns whether or not the @ft \p field_type is a @intft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is an integer field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is an integer field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @prenotnull{field_type}
@@ -352,14 +353,15 @@ extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_integer(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @floatft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is a floating point
-                       number field type,
+@returns               #BT_TRUE if \p field_type is a floating point
+                       #BT_FALSE field type,
                        or 0 otherwise (including if \p field_type is
                        \c NULL).
 
@@ -368,14 +370,15 @@ extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *field_type);
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_floating_point(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @enumft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is an enumeration field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is an enumeration field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -383,14 +386,15 @@ extern int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *field_t
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_enumeration(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @stringft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is a string field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is a string field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -398,14 +402,15 @@ extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *field_type
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_string(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @structft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is a structure field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is a structure field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -413,14 +418,15 @@ extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type *field_type);
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_structure(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @arrayft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is an array field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is an array field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -428,14 +434,15 @@ extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *field_type);
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_array(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @seqft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is a sequence field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is a sequence field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -443,14 +450,15 @@ extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type *field_type);
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_sequence(
+               struct bt_ctf_field_type *field_type);
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @varft.
 
 @param[in] field_type  Field type to check (can be \c NULL).
-@returns               1 if \p field_type is a variant field type,
-                       or 0 otherwise (including if \p field_type is
+@returns               #BT_TRUE if \p field_type is a variant field type,
+                       or #BT_FALSE otherwise (including if \p field_type is
                        \c NULL).
 
 @postrefcountsame{field_type}
@@ -458,7 +466,8 @@ extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *field_type);
 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type *field_type);
+extern bt_bool bt_ctf_field_type_is_variant(
+               struct bt_ctf_field_type *field_type);
 
 /** @} */
 
@@ -825,10 +834,9 @@ extern int bt_ctf_field_type_integer_set_size(
 @param[in] int_field_type      Integer field type which describes the
                                integer fields of which to get the
                                signedness.
-@returns                       1 if the integer fields described by
-                               \p int_field_type are signed, 0 if they
-                               are unsigned, or a negative value on
-                               error.
+@returns                       #BT_TRUE if the integer fields described by
+                               \p int_field_type are signed, #BT_FALSE if they
+                               are unsigned.
 
 @prenotnull{int_field_type}
 @preisintft{int_field_type}
@@ -837,11 +845,15 @@ extern int bt_ctf_field_type_integer_set_size(
 @sa bt_ctf_field_type_integer_set_is_signed(): Sets the signedness of the
        integer fields described by a given integer field type.
 */
-extern int bt_ctf_field_type_integer_is_signed(
+extern bt_bool bt_ctf_field_type_integer_is_signed(
                struct bt_ctf_field_type *int_field_type);
 
-/* Pre-2.0 CTF writer compatibility */
-#define bt_ctf_field_type_integer_get_signed bt_ctf_field_type_integer_is_signed
+/** @cond DOCUMENT */
+
+extern int bt_ctf_field_type_integer_get_signed(
+               struct bt_ctf_field_type *int_field_type);
+
+/** @endcond */
 
 /**
 @brief Sets whether or not the @intfields described by
@@ -851,21 +863,20 @@ extern int bt_ctf_field_type_integer_is_signed(
                                integer fields of which to set the
                                signedness.
 @param[in] is_signed           Signedness of the integer fields
-                               described by \p int_field_type; 0 means
-                               \em unsigned, 1 means \em signed.
+                               described by \p int_field_type; #BT_FALSE means
+                               \em unsigned, #BT_TRUE means \em signed.
 @returns                       0 on success, or a negative value on error.
 
 @prenotnull{int_field_type}
 @preisintft{int_field_type}
 @prehot{int_field_type}
-@pre \p is_signed is 0 or 1.
 @postrefcountsame{int_field_type}
 
 @sa bt_ctf_field_type_integer_is_signed(): Returns the signedness of
        the integer fields described by a given integer field type.
 */
 extern int bt_ctf_field_type_integer_set_is_signed(
-               struct bt_ctf_field_type *int_field_type, int is_signed);
+               struct bt_ctf_field_type *int_field_type, bt_bool is_signed);
 
 /* Pre-2.0 CTF writer compatibility */
 #define bt_ctf_field_type_integer_set_signed bt_ctf_field_type_integer_set_is_signed
index 5a030b356e7d4454b32c7c0d892291c3016b3dc5..144b1e31773b296a7396708ed7716e8f9909f869 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -230,8 +231,8 @@ extern int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer,
 @brief Returns whether or not the @field \p field is a @intfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is an integer field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is an integer field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -240,14 +241,14 @@ extern int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer,
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_integer(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_integer(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @floatfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is a floating point number field,
-                       or 0 otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is a floating point number fiel
+                       #BT_FALSE or 0 otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -256,14 +257,14 @@ extern int bt_ctf_field_is_integer(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_floating_point(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_floating_point(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @enumfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is an enumeration field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is an enumeration field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -272,14 +273,14 @@ extern int bt_ctf_field_is_floating_point(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_enumeration(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_enumeration(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @stringfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is a string field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is a string field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -288,14 +289,14 @@ extern int bt_ctf_field_is_enumeration(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_string(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_string(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @structfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is a structure field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is a structure field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -304,14 +305,14 @@ extern int bt_ctf_field_is_string(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_structure(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_structure(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @arrayfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is an array field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is an array field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -320,14 +321,14 @@ extern int bt_ctf_field_is_structure(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_array(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_array(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @seqfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is a sequence field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is a sequence field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -336,14 +337,14 @@ extern int bt_ctf_field_is_array(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_sequence(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_sequence(struct bt_ctf_field *field);
 
 /**
 @brief Returns whether or not the @field \p field is a @varfield.
 
 @param[in] field       Field to check (can be \c NULL).
-@returns                1 if \p field is a variant field, or 0
-                       otherwise (including if \p field is
+@returns                #BT_TRUE if \p field is a variant field, or
+                       #BT_FALSE otherwise (including if \p field is
                        \c NULL).
 
 @prenotnull{field}
@@ -352,7 +353,7 @@ extern int bt_ctf_field_is_sequence(struct bt_ctf_field *field);
 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern int bt_ctf_field_is_variant(struct bt_ctf_field *field);
+extern bt_bool bt_ctf_field_is_variant(struct bt_ctf_field *field);
 
 /** @} */
 
index 6f46f2cb70ce45a7dea9d786c8752c71507f49a6..d152c8e607020f25c4cca9b49f75d1658f750449 100644 (file)
@@ -827,8 +827,15 @@ end:
        return ret;
 }
 
+bt_bool bt_ctf_field_type_integer_is_signed(
+               struct bt_ctf_field_type *int_field_type)
+{
+       return bt_ctf_field_type_integer_get_signed(int_field_type) ?
+               BT_TRUE : BT_FALSE;
+}
+
 int bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *type,
-               int is_signed)
+               bt_bool is_signed)
 {
        int ret = 0;
        struct bt_ctf_field_type_integer *integer;
index 5223d778ffbcda1101726d3a96ed8e1d7f36acde..173aa3358d05f6afb0f2e00e64dffba38aa90327 100644 (file)
@@ -356,42 +356,42 @@ end:
        return ret;
 }
 
-int bt_ctf_field_is_integer(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_integer(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_INTEGER;
 }
 
-int bt_ctf_field_is_floating_point(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_floating_point(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_FLOAT;
 }
 
-int bt_ctf_field_is_enumeration(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_enumeration(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_ENUM;
 }
 
-int bt_ctf_field_is_string(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_string(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_STRING;
 }
 
-int bt_ctf_field_is_structure(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_structure(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_STRUCT;
 }
 
-int bt_ctf_field_is_array(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_array(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_ARRAY;
 }
 
-int bt_ctf_field_is_sequence(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_sequence(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_SEQUENCE;
 }
 
-int bt_ctf_field_is_variant(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_variant(struct bt_ctf_field *field)
 {
        return bt_ctf_field_get_type_id(field) == BT_CTF_FIELD_TYPE_ID_VARIANT;
 }
This page took 0.033511 seconds and 4 git commands to generate.