value: simplify GST_VALUE_HOLDS for our boxed and fundamental types

Boxed types can't be derived from, and we don't support
deriving from our special fundamental types (the code
checks for GType equality in most places.
This commit is contained in:
Tim-Philipp Müller 2014-06-17 22:45:57 +01:00
parent 77db6bf3d6
commit 89a5b89388
3 changed files with 15 additions and 17 deletions

View file

@ -1926,8 +1926,6 @@ gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
if (!gst_tag_list_copy_value (&v, list, tag)) if (!gst_tag_list_copy_value (&v, list, tag))
return FALSE; return FALSE;
g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
*value = (GstDateTime *) g_value_dup_boxed (&v); *value = (GstDateTime *) g_value_dup_boxed (&v);
g_value_unset (&v); g_value_unset (&v);
return (*value != NULL); return (*value != NULL);

View file

@ -150,7 +150,7 @@ gst_util_set_object_arg (GObject * object, const gchar * name,
g_value_init (&v, value_type); g_value_init (&v, value_type);
/* special case for element <-> xml (de)serialisation */ /* special case for element <-> xml (de)serialisation */
if (GST_VALUE_HOLDS_STRUCTURE (&v) && strcmp (value, "NULL") == 0) { if (value_type == GST_TYPE_STRUCTURE && strcmp (value, "NULL") == 0) {
g_value_set_boxed (&v, NULL); g_value_set_boxed (&v, NULL);
goto done; goto done;
} }

View file

@ -92,7 +92,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value. * Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value.
*/ */
#define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS((x), gst_int_range_get_type ())) #define GST_VALUE_HOLDS_INT_RANGE(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_int_range_type)
/** /**
* GST_VALUE_HOLDS_INT64_RANGE: * GST_VALUE_HOLDS_INT64_RANGE:
@ -100,7 +100,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_INT64_RANGE value. * Checks if the given #GValue contains a #GST_TYPE_INT64_RANGE value.
*/ */
#define GST_VALUE_HOLDS_INT64_RANGE(x) (G_VALUE_HOLDS((x), gst_int64_range_get_type ())) #define GST_VALUE_HOLDS_INT64_RANGE(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_int64_range_type)
/** /**
* GST_VALUE_HOLDS_DOUBLE_RANGE: * GST_VALUE_HOLDS_DOUBLE_RANGE:
@ -108,7 +108,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value. * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
*/ */
#define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS((x), gst_double_range_get_type ())) #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_double_range_type)
/** /**
* GST_VALUE_HOLDS_FRACTION_RANGE: * GST_VALUE_HOLDS_FRACTION_RANGE:
@ -116,7 +116,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_FRACTION_RANGE value. * Checks if the given #GValue contains a #GST_TYPE_FRACTION_RANGE value.
*/ */
#define GST_VALUE_HOLDS_FRACTION_RANGE(x) (G_VALUE_HOLDS((x), gst_fraction_range_get_type ())) #define GST_VALUE_HOLDS_FRACTION_RANGE(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_fraction_range_type)
/** /**
* GST_VALUE_HOLDS_LIST: * GST_VALUE_HOLDS_LIST:
@ -124,7 +124,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_LIST value. * Checks if the given #GValue contains a #GST_TYPE_LIST value.
*/ */
#define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS((x), gst_value_list_get_type ())) #define GST_VALUE_HOLDS_LIST(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_value_list_type)
/** /**
* GST_VALUE_HOLDS_ARRAY: * GST_VALUE_HOLDS_ARRAY:
@ -132,7 +132,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_ARRAY value. * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
*/ */
#define GST_VALUE_HOLDS_ARRAY(x) (G_VALUE_HOLDS((x), gst_value_array_get_type ())) #define GST_VALUE_HOLDS_ARRAY(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_value_array_type)
/** /**
* GST_VALUE_HOLDS_CAPS: * GST_VALUE_HOLDS_CAPS:
@ -140,7 +140,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_CAPS value. * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
*/ */
#define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS)) #define GST_VALUE_HOLDS_CAPS(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_caps_type)
/** /**
* GST_VALUE_HOLDS_STRUCTURE: * GST_VALUE_HOLDS_STRUCTURE:
@ -148,7 +148,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_STRUCTURE value. * Checks if the given #GValue contains a #GST_TYPE_STRUCTURE value.
*/ */
#define GST_VALUE_HOLDS_STRUCTURE(x) (G_VALUE_HOLDS((x), GST_TYPE_STRUCTURE)) #define GST_VALUE_HOLDS_STRUCTURE(x) (G_VALUE_HOLDS((x), _gst_structure_type))
/** /**
* GST_VALUE_HOLDS_CAPS_FEATURES: * GST_VALUE_HOLDS_CAPS_FEATURES:
@ -156,7 +156,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_CAPS_FEATURES value. * Checks if the given #GValue contains a #GST_TYPE_CAPS_FEATURES value.
*/ */
#define GST_VALUE_HOLDS_CAPS_FEATURES(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS_FEATURES)) #define GST_VALUE_HOLDS_CAPS_FEATURES(x) (G_VALUE_HOLDS((x), _gst_caps_features_type))
/** /**
* GST_VALUE_HOLDS_BUFFER: * GST_VALUE_HOLDS_BUFFER:
@ -164,7 +164,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_BUFFER value. * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
*/ */
#define GST_VALUE_HOLDS_BUFFER(x) (G_VALUE_HOLDS((x), GST_TYPE_BUFFER)) #define GST_VALUE_HOLDS_BUFFER(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_buffer_type)
/** /**
* GST_VALUE_HOLDS_SAMPLE: * GST_VALUE_HOLDS_SAMPLE:
@ -172,7 +172,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_SAMPLE value. * Checks if the given #GValue contains a #GST_TYPE_SAMPLE value.
*/ */
#define GST_VALUE_HOLDS_SAMPLE(x) (G_VALUE_HOLDS((x), GST_TYPE_SAMPLE)) #define GST_VALUE_HOLDS_SAMPLE(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_sample_type)
/** /**
* GST_VALUE_HOLDS_FRACTION: * GST_VALUE_HOLDS_FRACTION:
@ -180,7 +180,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_FRACTION value. * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
*/ */
#define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS((x), gst_fraction_get_type ())) #define GST_VALUE_HOLDS_FRACTION(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_fraction_type)
/** /**
* GST_VALUE_HOLDS_DATE_TIME: * GST_VALUE_HOLDS_DATE_TIME:
@ -188,7 +188,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_DATE_TIME value. * Checks if the given #GValue contains a #GST_TYPE_DATE_TIME value.
*/ */
#define GST_VALUE_HOLDS_DATE_TIME(x) (G_VALUE_HOLDS((x), gst_date_time_get_type ())) #define GST_VALUE_HOLDS_DATE_TIME(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_date_time_type)
/** /**
* GST_VALUE_HOLDS_BITMASK: * GST_VALUE_HOLDS_BITMASK:
@ -196,7 +196,7 @@ G_BEGIN_DECLS
* *
* Checks if the given #GValue contains a #GST_TYPE_BITMASK value. * Checks if the given #GValue contains a #GST_TYPE_BITMASK value.
*/ */
#define GST_VALUE_HOLDS_BITMASK(x) (G_VALUE_HOLDS((x), gst_bitmask_get_type ())) #define GST_VALUE_HOLDS_BITMASK(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_bitmask_type)
GST_EXPORT GType _gst_int_range_type; GST_EXPORT GType _gst_int_range_type;