giobjectinfo: Fix int signedness in APIs

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
This commit is contained in:
Philip Withnall 2023-12-12 18:07:25 +00:00
parent 693f11cd42
commit 030f4f003c
3 changed files with 39 additions and 42 deletions

View File

@ -60,19 +60,18 @@
*/ */
static gint32 static gint32
gi_object_info_get_field_offset (GIObjectInfo *info, gi_object_info_get_field_offset (GIObjectInfo *info,
gint n) guint n)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data; Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
guint32 offset; guint32 offset;
gint i;
FieldBlob *field_blob; FieldBlob *field_blob;
offset = rinfo->offset + header->object_blob_size offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2; + (blob->n_interfaces + blob->n_interfaces % 2) * 2;
for (i = 0; i < n; i++) for (guint i = 0; i < n; i++)
{ {
field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
offset += header->field_blob_size; offset += header->field_blob_size;
@ -234,7 +233,7 @@ gi_object_info_get_type_init_function_name (GIObjectInfo *info)
* *
* Returns: number of interfaces * Returns: number of interfaces
*/ */
gint guint
gi_object_info_get_n_interfaces (GIObjectInfo *info) gi_object_info_get_n_interfaces (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -260,7 +259,7 @@ gi_object_info_get_n_interfaces (GIObjectInfo *info)
*/ */
GIInterfaceInfo * GIInterfaceInfo *
gi_object_info_get_interface (GIObjectInfo *info, gi_object_info_get_interface (GIObjectInfo *info,
gint n) guint n)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob; ObjectBlob *blob;
@ -282,7 +281,7 @@ gi_object_info_get_interface (GIObjectInfo *info,
* *
* Returns: number of fields * Returns: number of fields
*/ */
gint guint
gi_object_info_get_n_fields (GIObjectInfo *info) gi_object_info_get_n_fields (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -308,7 +307,7 @@ gi_object_info_get_n_fields (GIObjectInfo *info)
*/ */
GIFieldInfo * GIFieldInfo *
gi_object_info_get_field (GIObjectInfo *info, gi_object_info_get_field (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -329,7 +328,7 @@ gi_object_info_get_field (GIObjectInfo *info,
* *
* Returns: number of properties * Returns: number of properties
*/ */
gint guint
gi_object_info_get_n_properties (GIObjectInfo *info) gi_object_info_get_n_properties (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -354,7 +353,7 @@ gi_object_info_get_n_properties (GIObjectInfo *info)
*/ */
GIPropertyInfo * GIPropertyInfo *
gi_object_info_get_property (GIObjectInfo *info, gi_object_info_get_property (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -385,7 +384,7 @@ gi_object_info_get_property (GIObjectInfo *info,
* *
* Returns: number of methods * Returns: number of methods
*/ */
gint guint
gi_object_info_get_n_methods (GIObjectInfo *info) gi_object_info_get_n_methods (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -411,7 +410,7 @@ gi_object_info_get_n_methods (GIObjectInfo *info)
*/ */
GIFunctionInfo * GIFunctionInfo *
gi_object_info_get_method (GIObjectInfo *info, gi_object_info_get_method (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -536,7 +535,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
* *
* Returns: number of signals * Returns: number of signals
*/ */
gint guint
gi_object_info_get_n_signals (GIObjectInfo *info) gi_object_info_get_n_signals (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -562,7 +561,7 @@ gi_object_info_get_n_signals (GIObjectInfo *info)
*/ */
GISignalInfo * GISignalInfo *
gi_object_info_get_signal (GIObjectInfo *info, gi_object_info_get_signal (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -600,11 +599,10 @@ GISignalInfo *
gi_object_info_find_signal (GIObjectInfo *info, gi_object_info_find_signal (GIObjectInfo *info,
const gchar *name) const gchar *name)
{ {
gint n_signals; guint n_signals;
gint i;
n_signals = gi_object_info_get_n_signals (info); n_signals = gi_object_info_get_n_signals (info);
for (i = 0; i < n_signals; i++) for (guint i = 0; i < n_signals; i++)
{ {
GISignalInfo *siginfo = gi_object_info_get_signal (info, i); GISignalInfo *siginfo = gi_object_info_get_signal (info, i);
@ -628,7 +626,7 @@ gi_object_info_find_signal (GIObjectInfo *info,
* *
* Returns: number of virtual functions * Returns: number of virtual functions
*/ */
gint guint
gi_object_info_get_n_vfuncs (GIObjectInfo *info) gi_object_info_get_n_vfuncs (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -654,7 +652,7 @@ gi_object_info_get_n_vfuncs (GIObjectInfo *info)
*/ */
GIVFuncInfo * GIVFuncInfo *
gi_object_info_get_vfunc (GIObjectInfo *info, gi_object_info_get_vfunc (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -790,7 +788,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
* *
* Returns: number of constants * Returns: number of constants
*/ */
gint guint
gi_object_info_get_n_constants (GIObjectInfo *info) gi_object_info_get_n_constants (GIObjectInfo *info)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
@ -816,7 +814,7 @@ gi_object_info_get_n_constants (GIObjectInfo *info)
*/ */
GIConstantInfo * GIConstantInfo *
gi_object_info_get_constant (GIObjectInfo *info, gi_object_info_get_constant (GIObjectInfo *info,
gint n) guint n)
{ {
gint offset; gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;

View File

@ -98,32 +98,32 @@ GI_AVAILABLE_IN_ALL
GIObjectInfo * gi_object_info_get_parent (GIObjectInfo *info); GIObjectInfo * gi_object_info_get_parent (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_interfaces (GIObjectInfo *info); guint gi_object_info_get_n_interfaces (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_fields (GIObjectInfo *info); guint gi_object_info_get_n_fields (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_properties (GIObjectInfo *info); guint gi_object_info_get_n_properties (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_methods (GIObjectInfo *info); guint gi_object_info_get_n_methods (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info,
@ -137,11 +137,11 @@ GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *in
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_signals (GIObjectInfo *info); guint gi_object_info_get_n_signals (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
@ -150,11 +150,11 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info,
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_vfuncs (GIObjectInfo *info); guint gi_object_info_get_n_vfuncs (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info,
@ -166,11 +166,11 @@ GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *inf
GIObjectInfo **implementor); GIObjectInfo **implementor);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
gint gi_object_info_get_n_constants (GIObjectInfo *info); guint gi_object_info_get_n_constants (GIObjectInfo *info);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info,
gint n); guint n);
GI_AVAILABLE_IN_ALL GI_AVAILABLE_IN_ALL
GIStructInfo * gi_object_info_get_class_struct (GIObjectInfo *info); GIStructInfo * gi_object_info_get_class_struct (GIObjectInfo *info);

View File

@ -1040,7 +1040,6 @@ write_object_info (const gchar *ns,
gboolean is_final; gboolean is_final;
GIObjectInfo *pnode; GIObjectInfo *pnode;
GIStructInfo *class_struct; GIStructInfo *class_struct;
gint i;
name = gi_base_info_get_name ((GIBaseInfo *)info); name = gi_base_info_get_name ((GIBaseInfo *)info);
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info); deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
@ -1101,7 +1100,7 @@ write_object_info (const gchar *ns,
if (gi_object_info_get_n_interfaces (info) > 0) if (gi_object_info_get_n_interfaces (info) > 0)
{ {
for (i = 0; i < gi_object_info_get_n_interfaces (info); i++) for (guint i = 0; i < gi_object_info_get_n_interfaces (info); i++)
{ {
GIInterfaceInfo *imp = gi_object_info_get_interface (info, i); GIInterfaceInfo *imp = gi_object_info_get_interface (info, i);
xml_start_element (file, "implements"); xml_start_element (file, "implements");
@ -1111,42 +1110,42 @@ write_object_info (const gchar *ns,
} }
} }
for (i = 0; i < gi_object_info_get_n_fields (info); i++) for (guint i = 0; i < gi_object_info_get_n_fields (info); i++)
{ {
GIFieldInfo *field = gi_object_info_get_field (info, i); GIFieldInfo *field = gi_object_info_get_field (info, i);
write_field_info (ns, field, NULL, file); write_field_info (ns, field, NULL, file);
gi_base_info_unref ((GIBaseInfo *)field); gi_base_info_unref ((GIBaseInfo *)field);
} }
for (i = 0; i < gi_object_info_get_n_methods (info); i++) for (guint i = 0; i < gi_object_info_get_n_methods (info); i++)
{ {
GIFunctionInfo *function = gi_object_info_get_method (info, i); GIFunctionInfo *function = gi_object_info_get_method (info, i);
write_function_info (ns, function, file); write_function_info (ns, function, file);
gi_base_info_unref ((GIBaseInfo *)function); gi_base_info_unref ((GIBaseInfo *)function);
} }
for (i = 0; i < gi_object_info_get_n_properties (info); i++) for (guint i = 0; i < gi_object_info_get_n_properties (info); i++)
{ {
GIPropertyInfo *prop = gi_object_info_get_property (info, i); GIPropertyInfo *prop = gi_object_info_get_property (info, i);
write_property_info (ns, prop, file); write_property_info (ns, prop, file);
gi_base_info_unref ((GIBaseInfo *)prop); gi_base_info_unref ((GIBaseInfo *)prop);
} }
for (i = 0; i < gi_object_info_get_n_signals (info); i++) for (guint i = 0; i < gi_object_info_get_n_signals (info); i++)
{ {
GISignalInfo *signal = gi_object_info_get_signal (info, i); GISignalInfo *signal = gi_object_info_get_signal (info, i);
write_signal_info (ns, signal, file); write_signal_info (ns, signal, file);
gi_base_info_unref ((GIBaseInfo *)signal); gi_base_info_unref ((GIBaseInfo *)signal);
} }
for (i = 0; i < gi_object_info_get_n_vfuncs (info); i++) for (guint i = 0; i < gi_object_info_get_n_vfuncs (info); i++)
{ {
GIVFuncInfo *vfunc = gi_object_info_get_vfunc (info, i); GIVFuncInfo *vfunc = gi_object_info_get_vfunc (info, i);
write_vfunc_info (ns, vfunc, file); write_vfunc_info (ns, vfunc, file);
gi_base_info_unref ((GIBaseInfo *)vfunc); gi_base_info_unref ((GIBaseInfo *)vfunc);
} }
for (i = 0; i < gi_object_info_get_n_constants (info); i++) for (guint i = 0; i < gi_object_info_get_n_constants (info); i++)
{ {
GIConstantInfo *constant = gi_object_info_get_constant (info, i); GIConstantInfo *constant = gi_object_info_get_constant (info, i);
write_constant_info (ns, constant, file); write_constant_info (ns, constant, file);