mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-11 18:23:07 +02:00
gobject: Clean up logic in property checks
Simplify some of the logic in this function. 1) Simplify flag checks as per Colin's suggestions in https://bugzilla.gnome.org/show_bug.cgi?id=605667 2) Don't repeatedly recheck if class_pspec is NULL.
This commit is contained in:
parent
ebf572cdd8
commit
3af050f6fc
@ -1380,10 +1380,7 @@ object_interface_check_properties (gpointer func_data,
|
|||||||
* the READABLE and WRITABLE flags. We also simplify here
|
* the READABLE and WRITABLE flags. We also simplify here
|
||||||
* by only checking the value type, not the G_PARAM_SPEC_TYPE.
|
* by only checking the value type, not the G_PARAM_SPEC_TYPE.
|
||||||
*/
|
*/
|
||||||
if (class_pspec &&
|
if (g_type_is_a (pspecs[n]->value_type, class_pspec->value_type))
|
||||||
!g_type_is_a (pspecs[n]->value_type,
|
|
||||||
class_pspec->value_type))
|
|
||||||
{
|
|
||||||
g_critical ("Property '%s' on class '%s' has type '%s' "
|
g_critical ("Property '%s' on class '%s' has type '%s' "
|
||||||
"which is different from the type '%s', "
|
"which is different from the type '%s', "
|
||||||
"of the property on interface '%s'\n",
|
"of the property on interface '%s'\n",
|
||||||
@ -1392,7 +1389,6 @@ object_interface_check_properties (gpointer func_data,
|
|||||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (class_pspec)),
|
g_type_name (G_PARAM_SPEC_VALUE_TYPE (class_pspec)),
|
||||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspecs[n])),
|
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspecs[n])),
|
||||||
g_type_name (iface_type));
|
g_type_name (iface_type));
|
||||||
}
|
|
||||||
|
|
||||||
#define SUBSET(a,b,mask) (((a) & ~(b) & (mask)) == 0)
|
#define SUBSET(a,b,mask) (((a) & ~(b) & (mask)) == 0)
|
||||||
|
|
||||||
@ -1400,22 +1396,18 @@ object_interface_check_properties (gpointer func_data,
|
|||||||
* READABLE and WRITABLE remove restrictions. The implementation
|
* READABLE and WRITABLE remove restrictions. The implementation
|
||||||
* paramspec must have less restrictive flags.
|
* paramspec must have less restrictive flags.
|
||||||
*/
|
*/
|
||||||
if (class_pspec &&
|
if (pspecs[n]->flags & G_PARAM_WRITABLE)
|
||||||
(((pspecs[n]->flags & G_PARAM_WRITABLE) &&
|
|
||||||
!SUBSET (class_pspec->flags,
|
|
||||||
pspecs[n]->flags,
|
|
||||||
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) ||
|
|
||||||
!SUBSET (pspecs[n]->flags,
|
|
||||||
class_pspec->flags,
|
|
||||||
G_PARAM_READABLE | G_PARAM_WRITABLE)))
|
|
||||||
{
|
{
|
||||||
g_critical ("Flags for property '%s' on class '%s' "
|
if (!SUBSET (class_pspec->flags, pspecs[n]->flags, G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
|
||||||
"are not compatible with the property on"
|
g_critical ("Flags for property '%s' on class '%s' introduce additional restrictions on "
|
||||||
"interface '%s'\n",
|
"writability compared with the property on interface '%s'\n", pspecs[n]->name,
|
||||||
pspecs[n]->name,
|
g_type_name (G_OBJECT_CLASS_TYPE (class)), g_type_name (iface_type));
|
||||||
g_type_name (G_OBJECT_CLASS_TYPE (class)),
|
|
||||||
g_type_name (iface_type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SUBSET (pspecs[n]->flags, class_pspec->flags, G_PARAM_READABLE | G_PARAM_WRITABLE))
|
||||||
|
g_critical ("Flags for property '%s' on class '%s' remove functionality compared with the "
|
||||||
|
"property on interface '%s'\n", pspecs[n]->name,
|
||||||
|
g_type_name (G_OBJECT_CLASS_TYPE (class)), g_type_name (iface_type));
|
||||||
#undef SUBSET
|
#undef SUBSET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user