mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-13 03:05:12 +01:00
girepository: Read static vfunc attribute exposing via callable is_method()
Read the static attribute for virtual functions, and make sure that g_callable_info_is_method() returns false for such cases.
This commit is contained in:
parent
fe142e3b32
commit
7ea9840cf4
@ -135,10 +135,12 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info)
|
||||
*
|
||||
* Determines if the callable info is a method.
|
||||
*
|
||||
* For [class@GIRepository.VFuncInfo]s and [class@GIRepository.SignalInfo]s,
|
||||
* this is always true, and for [class@GIRepository.CallbackInfo]s always false.
|
||||
* Otherwise, this looks at the `GI_FUNCTION_IS_METHOD` flag on the
|
||||
* [class@GIRepository.FunctionInfo].
|
||||
* For [class@GIRepository.SignalInfo]s, this is always true, and for
|
||||
* [class@GIRepository.CallbackInfo]s always false.
|
||||
* For [class@GIRepository.FunctionInfo]s this looks at the
|
||||
* `GI_FUNCTION_IS_METHOD` flag on the [class@GIRepository.FunctionInfo].
|
||||
* For [class@GIRepository.VFuncInfo]s this is true when the virtual function
|
||||
* has an instance parameter.
|
||||
*
|
||||
* Concretely, this function returns whether
|
||||
* [method@GIRepository.CallableInfo.get_n_args] matches the number of arguments
|
||||
@ -160,6 +162,11 @@ gi_callable_info_is_method (GICallableInfo *info)
|
||||
return (!blob->constructor && !blob->is_static);
|
||||
}
|
||||
case GI_INFO_TYPE_VFUNC:
|
||||
{
|
||||
VFuncBlob *blob;
|
||||
blob = (VFuncBlob *) &rinfo->typelib->data[rinfo->offset];
|
||||
return !blob->is_static;
|
||||
}
|
||||
case GI_INFO_TYPE_SIGNAL:
|
||||
return TRUE;
|
||||
case GI_INFO_TYPE_CALLBACK:
|
||||
|
@ -243,6 +243,8 @@ struct _GIIrNodeVFunc
|
||||
uint8_t instance_transfer_full : 1;
|
||||
uint8_t is_async : 1;
|
||||
|
||||
uint8_t is_static : 1;
|
||||
|
||||
char *invoker; /* (owned) */
|
||||
char *finish_func; /* (owned) */
|
||||
char *sync_func; /* (owned) */
|
||||
|
@ -2029,6 +2029,7 @@ gi_ir_node_build_typelib (GIIrNode *node,
|
||||
blob->struct_offset = vfunc->offset;
|
||||
blob->reserved2 = 0;
|
||||
blob->signature = signature;
|
||||
blob->is_static = vfunc->is_static;
|
||||
|
||||
gi_ir_node_build_typelib ((GIIrNode *)vfunc->result->type,
|
||||
node, build, &signature, offset2, NULL);
|
||||
|
@ -2660,6 +2660,7 @@ start_vfunc (GMarkupParseContext *context,
|
||||
const char *offset;
|
||||
const char *invoker;
|
||||
const char *throws;
|
||||
const char *is_static;
|
||||
const char *finish_func;
|
||||
const char *async_func;
|
||||
const char *sync_func;
|
||||
@ -2682,6 +2683,7 @@ start_vfunc (GMarkupParseContext *context,
|
||||
offset = find_attribute ("offset", attribute_names, attribute_values);
|
||||
invoker = find_attribute ("invoker", attribute_names, attribute_values);
|
||||
throws = find_attribute ("throws", attribute_names, attribute_values);
|
||||
is_static = find_attribute ("glib:static", attribute_names, attribute_values);
|
||||
finish_func = find_attribute ("glib:finish-func", attribute_names, attribute_values);
|
||||
sync_func = find_attribute ("glib:sync-func", attribute_names, attribute_values);
|
||||
async_func = find_attribute ("glib:async-func", attribute_names, attribute_values);
|
||||
@ -2728,6 +2730,11 @@ start_vfunc (GMarkupParseContext *context,
|
||||
else
|
||||
vfunc->throws = FALSE;
|
||||
|
||||
if (is_static && strcmp (is_static, "1") == 0)
|
||||
vfunc->is_static = TRUE;
|
||||
else
|
||||
vfunc->is_static = FALSE;
|
||||
|
||||
if (offset == NULL)
|
||||
vfunc->offset = 0xFFFF;
|
||||
else if (g_ascii_string_to_unsigned (offset, 10, 0, G_MAXSIZE, &parsed_offset, error))
|
||||
|
@ -1117,6 +1117,7 @@ typedef struct {
|
||||
* @invoker: If a method invoker for this virtual exists, this is the offset
|
||||
* in the class structure of the method. If no method is known, this value
|
||||
* will be 0x3ff.
|
||||
* @is_static: True if the vfunc has no instance parameter.
|
||||
* @reserved: Reserved for future use.
|
||||
* @finish: The index of the finish function if is_async is TRUE, otherwise ASYNC_SENTINEL
|
||||
* @reserved2: Reserved for future use.
|
||||
@ -1142,7 +1143,8 @@ typedef struct {
|
||||
|
||||
uint16_t struct_offset;
|
||||
uint16_t invoker : 10; /* Number of bits matches @index in FunctionBlob */
|
||||
uint16_t reserved : 6;
|
||||
uint16_t is_static : 1;
|
||||
uint16_t reserved : 5;
|
||||
|
||||
uint16_t finish : 10;
|
||||
uint16_t reserved2 : 6;
|
||||
|
Loading…
x
Reference in New Issue
Block a user