lib: make bt_field_is_*() and bt_field_type_is_*() static inline
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 1 Aug 2018 21:11:22 +0000 (17:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:07:36 +0000 (00:07 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.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 13d9b6b4b19659d3dd4d4d73c9f3312c254004aa..951fb48b5563456f48b632ec6da4c513c0bfed36 100644 (file)
@@ -323,8 +323,12 @@ extern enum bt_field_type_id bt_field_type_get_type_id(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_integer(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_integer(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) ==
+               BT_FIELD_TYPE_ID_INTEGER;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @floatft.
@@ -340,8 +344,11 @@ extern bt_bool bt_field_type_is_integer(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_floating_point(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_floating_point(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) == BT_FIELD_TYPE_ID_FLOAT;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @enumft.
@@ -356,8 +363,11 @@ extern bt_bool bt_field_type_is_floating_point(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_enumeration(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_enumeration(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) == BT_FIELD_TYPE_ID_ENUM;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @stringft.
@@ -372,8 +382,11 @@ extern bt_bool bt_field_type_is_enumeration(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_string(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_string(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) == BT_FIELD_TYPE_ID_STRING;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @structft.
@@ -388,8 +401,11 @@ extern bt_bool bt_field_type_is_string(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_structure(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_structure(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) == BT_FIELD_TYPE_ID_STRUCT;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @arrayft.
@@ -404,8 +420,11 @@ extern bt_bool bt_field_type_is_structure(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_array(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_array(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) == BT_FIELD_TYPE_ID_ARRAY;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @seqft.
@@ -420,8 +439,12 @@ extern bt_bool bt_field_type_is_array(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_sequence(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_sequence(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) ==
+               BT_FIELD_TYPE_ID_SEQUENCE;
+}
 
 /**
 @brief Returns whether or not the @ft \p field_type is a @varft.
@@ -436,8 +459,12 @@ extern bt_bool bt_field_type_is_sequence(
 @sa bt_field_type_get_type_id(): Returns the type ID of a given
        field type.
 */
-extern bt_bool bt_field_type_is_variant(
-               struct bt_field_type *field_type);
+static inline
+bt_bool bt_field_type_is_variant(struct bt_field_type *field_type)
+{
+       return bt_field_type_get_type_id(field_type) ==
+               BT_FIELD_TYPE_ID_VARIANT;
+}
 
 /** @} */
 
index 7d811c96fcd511c568ba48a4150e093f57f048d3..f975e530b32c1e66d5d23732d82263f87923457a 100644 (file)
@@ -39,6 +39,9 @@
 /* For bt_bool */
 #include <babeltrace/types.h>
 
+/* For BT_FIELD_TYPE_ID_* */
+#include <babeltrace/ctf-ir/field-types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -219,7 +222,11 @@ extern enum bt_field_type_id bt_field_get_type_id(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_integer(struct bt_field *field);
+static inline
+bt_bool bt_field_is_integer(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_INTEGER;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @floatfield.
@@ -235,7 +242,11 @@ extern bt_bool bt_field_is_integer(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_floating_point(struct bt_field *field);
+static inline
+bt_bool bt_field_is_floating_point(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_FLOAT;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @enumfield.
@@ -251,7 +262,11 @@ extern bt_bool bt_field_is_floating_point(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_enumeration(struct bt_field *field);
+static inline
+bt_bool bt_field_is_enumeration(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_ENUM;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @stringfield.
@@ -267,7 +282,11 @@ extern bt_bool bt_field_is_enumeration(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_string(struct bt_field *field);
+static inline
+bt_bool bt_field_is_string(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_STRING;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @structfield.
@@ -283,7 +302,11 @@ extern bt_bool bt_field_is_string(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_structure(struct bt_field *field);
+static inline
+bt_bool bt_field_is_structure(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_STRUCT;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @arrayfield.
@@ -299,7 +322,11 @@ extern bt_bool bt_field_is_structure(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_array(struct bt_field *field);
+static inline
+bt_bool bt_field_is_array(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_ARRAY;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @seqfield.
@@ -315,7 +342,11 @@ extern bt_bool bt_field_is_array(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_sequence(struct bt_field *field);
+static inline
+bt_bool bt_field_is_sequence(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_SEQUENCE;
+}
 
 /**
 @brief Returns whether or not the @field \p field is a @varfield.
@@ -331,7 +362,11 @@ extern bt_bool bt_field_is_sequence(struct bt_field *field);
 @sa bt_field_get_type_id(): Returns the type ID of a given
        field's type.
 */
-extern bt_bool bt_field_is_variant(struct bt_field *field);
+static inline
+bt_bool bt_field_is_variant(struct bt_field *field)
+{
+       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_VARIANT;
+}
 
 /** @} */
 
index c880d30657ab2300e0f7d75b3acac27304970b22..4e808b938e5faa22072af00dbb7d2eea080d1b85 100644 (file)
@@ -3390,46 +3390,6 @@ enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
        return bt_field_type_common_get_type_id((void *) ft);
 }
 
-int bt_field_type_is_integer(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_INTEGER;
-}
-
-int bt_field_type_is_floating_point(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_FLOAT;
-}
-
-int bt_field_type_is_enumeration(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_ENUM;
-}
-
-int bt_field_type_is_string(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_STRING;
-}
-
-int bt_field_type_is_structure(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_STRUCT;
-}
-
-int bt_field_type_is_array(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_ARRAY;
-}
-
-int bt_field_type_is_sequence(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_SEQUENCE;
-}
-
-int bt_field_type_is_variant(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_VARIANT;
-}
-
 BT_HIDDEN
 void bt_field_type_common_freeze(struct bt_field_type_common *ft)
 {
index 3a0e063bf0cdac83b41364e884c409d5f5e9bbb0..7ed1d73844a546d57afa48bf386e0008e6ff639e 100644 (file)
@@ -217,46 +217,6 @@ enum bt_field_type_id bt_field_get_type_id(struct bt_field *field)
        return field_common->type->id;
 }
 
-bt_bool bt_field_is_integer(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_INTEGER;
-}
-
-bt_bool bt_field_is_floating_point(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_FLOAT;
-}
-
-bt_bool bt_field_is_enumeration(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_ENUM;
-}
-
-bt_bool bt_field_is_string(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_STRING;
-}
-
-bt_bool bt_field_is_structure(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_STRUCT;
-}
-
-bt_bool bt_field_is_array(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_ARRAY;
-}
-
-bt_bool bt_field_is_sequence(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_SEQUENCE;
-}
-
-bt_bool bt_field_is_variant(struct bt_field *field)
-{
-       return bt_field_get_type_id(field) == BT_FIELD_TYPE_ID_VARIANT;
-}
-
 int64_t bt_field_sequence_get_length(struct bt_field *field)
 {
        return bt_field_common_sequence_get_length((void *) field);
This page took 0.02915 seconds and 4 git commands to generate.