mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
girepository: Add GI_VFUNC_THROWS
Virtual functions can definitely throw an error. Right now the scanner omits the GError parameter for them and adds throws="1", but g-ir-compiler ignores this. https://bugzilla.gnome.org/show_bug.cgi?id=669332
This commit is contained in:
parent
3aaf08b49d
commit
b9d0981460
@ -1784,6 +1784,7 @@ _g_ir_node_build_typelib (GIrNode *node,
|
||||
blob->must_be_implemented = 0; /* FIXME */
|
||||
blob->must_not_be_implemented = 0; /* FIXME */
|
||||
blob->class_closure = 0; /* FIXME */
|
||||
blob->throws = vfunc->throws;
|
||||
blob->reserved = 0;
|
||||
|
||||
if (vfunc->invoker)
|
||||
|
@ -206,6 +206,7 @@ struct _GIrNodeVFunc
|
||||
gboolean must_be_implemented;
|
||||
gboolean must_not_be_implemented;
|
||||
gboolean is_class_closure;
|
||||
gboolean throws;
|
||||
|
||||
char *invoker;
|
||||
|
||||
|
@ -2345,6 +2345,7 @@ start_vfunc (GMarkupParseContext *context,
|
||||
const gchar *is_class_closure;
|
||||
const gchar *offset;
|
||||
const gchar *invoker;
|
||||
const gchar *throws;
|
||||
GIrNodeInterface *iface;
|
||||
GIrNodeVFunc *vfunc;
|
||||
|
||||
@ -2362,6 +2363,7 @@ start_vfunc (GMarkupParseContext *context,
|
||||
is_class_closure = find_attribute ("is-class-closure", attribute_names, attribute_values);
|
||||
offset = find_attribute ("offset", attribute_names, attribute_values);
|
||||
invoker = find_attribute ("invoker", attribute_names, attribute_values);
|
||||
throws = find_attribute ("throws", attribute_names, attribute_values);
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
@ -2400,6 +2402,11 @@ start_vfunc (GMarkupParseContext *context,
|
||||
else
|
||||
vfunc->is_class_closure = FALSE;
|
||||
|
||||
if (throws && strcmp (throws, "1") == 0)
|
||||
vfunc->throws = TRUE;
|
||||
else
|
||||
vfunc->throws = FALSE;
|
||||
|
||||
if (offset)
|
||||
vfunc->offset = atoi (offset);
|
||||
else
|
||||
|
@ -916,6 +916,9 @@ write_vfunc_info (const gchar *namespace,
|
||||
else if (flags & GI_VFUNC_MUST_NOT_OVERRIDE)
|
||||
xml_printf (file, " override=\"never\"");
|
||||
|
||||
if (flags & GI_VFUNC_THROWS)
|
||||
xml_printf (file, " throws=\"1\"");
|
||||
|
||||
xml_printf (file, " offset=\"%d\"", offset);
|
||||
|
||||
if (invoker)
|
||||
|
@ -925,7 +925,8 @@ typedef struct {
|
||||
guint16 must_be_implemented : 1;
|
||||
guint16 must_not_be_implemented : 1;
|
||||
guint16 class_closure : 1;
|
||||
guint16 reserved :12;
|
||||
guint16 throws : 1;
|
||||
guint16 reserved :11;
|
||||
guint16 signal;
|
||||
|
||||
guint16 struct_offset;
|
||||
|
@ -403,6 +403,7 @@ typedef enum
|
||||
* @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type
|
||||
* @GI_VFUNC_MUST_OVERRIDE: overrides
|
||||
* @GI_VFUNC_MUST_NOT_OVERRIDE: does not override
|
||||
* @GI_VFUNC_THROWS: Includes a #GError
|
||||
*
|
||||
* Flags of a #GIVFuncInfo struct.
|
||||
*/
|
||||
@ -410,7 +411,8 @@ typedef enum
|
||||
{
|
||||
GI_VFUNC_MUST_CHAIN_UP = 1 << 0,
|
||||
GI_VFUNC_MUST_OVERRIDE = 1 << 1,
|
||||
GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2
|
||||
GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2,
|
||||
GI_VFUNC_THROWS = 1 << 3
|
||||
} GIVFuncInfoFlags;
|
||||
|
||||
/**
|
||||
|
@ -104,6 +104,9 @@ g_vfunc_info_get_flags (GIVFuncInfo *info)
|
||||
if (blob->must_not_be_implemented)
|
||||
flags = flags | GI_VFUNC_MUST_NOT_OVERRIDE;
|
||||
|
||||
if (blob->throws)
|
||||
flags = flags | GI_VFUNC_THROWS;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user