File: gitypeinfo.c

package info (click to toggle)
gobject-introspection 1.84.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 72,336 kB
  • sloc: ansic: 562,269; python: 23,692; xml: 16,240; yacc: 1,711; perl: 1,624; sh: 1,139; lex: 510; cpp: 487; makefile: 182; javascript: 15; lisp: 1
file content (643 lines) | stat: -rw-r--r-- 20,122 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
 * GObject introspection: Type implementation
 *
 * Copyright (C) 2005 Matthias Clasen
 * Copyright (C) 2008,2009 Red Hat, Inc.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <glib.h>

#include <girepository/girepository.h>
#include "gibaseinfo-private.h"
#include "girepository-private.h"
#include "gitypelib-internal.h"
#include "gitypeinfo.h"

/**
 * GITypeInfo:
 *
 * `GITypeInfo` represents a type, including information about direction and
 * transfer.
 *
 * You can retrieve a type info from an argument (see
 * [class@GIRepository.ArgInfo]), a function’s return value (see
 * [class@GIRepository.FunctionInfo]), a field (see
 * [class@GIRepository.FieldInfo]), a property (see
 * [class@GIRepository.PropertyInfo]), a constant (see
 * [class@GIRepository.ConstantInfo]) or for a union discriminator (see
 * [class@GIRepository.UnionInfo]).
 *
 * A type can either be a of a basic type which is a standard C primitive
 * type or an interface type. For interface types you need to call
 * [method@GIRepository.TypeInfo.get_interface] to get a reference to the base
 * info for that interface.
 *
 * Since: 2.80
 */

/**
 * gi_type_info_is_pointer:
 * @info: a #GITypeInfo
 *
 * Obtain if the type is passed as a reference.
 *
 * Note that the types of `GI_DIRECTION_OUT` and `GI_DIRECTION_INOUT` parameters
 * will only be pointers if the underlying type being transferred is a pointer
 * (i.e. only if the type of the C function’s formal parameter is a pointer to a
 * pointer).
 *
 * Returns: `TRUE` if it is a pointer
 * Since: 2.80
 */
gboolean
gi_type_info_is_pointer (GITypeInfo *info)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, FALSE);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), FALSE);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (type->flags.reserved == 0 && type->flags.reserved2 == 0)
    return type->flags.pointer;
  else
    {
      InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      return iface->pointer;
    }
}

/**
 * gi_type_info_get_tag:
 * @info: a #GITypeInfo
 *
 * Obtain the type tag for the type.
 *
 * See [type@GIRepository.TypeTag] for a list of type tags.
 *
 * Returns: the type tag
 * Since: 2.80
 */
GITypeTag
gi_type_info_get_tag (GITypeInfo *info)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, GI_TYPE_TAG_BOOLEAN);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), GI_TYPE_TAG_BOOLEAN);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (rinfo->type_is_embedded)
    return GI_TYPE_TAG_INTERFACE;
  else if (type->flags.reserved == 0 && type->flags.reserved2 == 0)
    return type->flags.tag;
  else
    {
      InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      return iface->tag;
    }
}

/**
 * gi_type_info_get_param_type:
 * @info: a #GITypeInfo
 * @n: index of the parameter
 *
 * Obtain the parameter type @n, or `NULL` if the type is not an array.
 *
 * Returns: (transfer full) (nullable): the param type info, or `NULL` if the
 *   type is not an array
 * Since: 2.80
 */
GITypeInfo *
gi_type_info_get_param_type (GITypeInfo  *info,
                             unsigned int n)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, NULL);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), NULL);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
    {
      ParamTypeBlob *param = (ParamTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      switch (param->tag)
        {
          case GI_TYPE_TAG_ARRAY:
          case GI_TYPE_TAG_GLIST:
          case GI_TYPE_TAG_GSLIST:
          case GI_TYPE_TAG_GHASH:
            return gi_type_info_new ((GIBaseInfo*)info, rinfo->typelib,
                                     rinfo->offset + sizeof (ParamTypeBlob)
                                     + sizeof (SimpleTypeBlob) * n);
            break;
          default:
            break;
        }
    }

  return NULL;
}

/**
 * gi_type_info_get_interface:
 * @info: a #GITypeInfo
 *
 * For types which have `GI_TYPE_TAG_INTERFACE` such as [class@GObject.Object]s
 * and boxed values, this function returns full information about the referenced
 * type.
 *
 * You can then inspect the type of the returned [class@GIRepository.BaseInfo]
 * to further query whether it is a concrete [class@GObject.Object], an
 * interface, a structure, etc., using
 * [method@GIRepository.BaseInfo.get_info_type].
 *
 * Returns: (transfer full) (nullable): The [class@GIRepository.BaseInfo], or
 *   `NULL`. Free it with gi_base_info_unref() when done.
 * Since: 2.80
 */
GIBaseInfo *
gi_type_info_get_interface (GITypeInfo *info)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;

  g_return_val_if_fail (info != NULL, NULL);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), NULL);

  /* For embedded types, the given offset is a pointer to the actual blob,
   * after the end of the field.  In that case we know it's a "subclass" of
   * CommonBlob, so use that to determine the info type.
   */
  if (rinfo->type_is_embedded)
    {
      CommonBlob *common = (CommonBlob *)&rinfo->typelib->data[rinfo->offset];
      GIInfoType info_type;

      switch (common->blob_type)
        {
          case BLOB_TYPE_CALLBACK:
            info_type = GI_INFO_TYPE_CALLBACK;
            break;
          default:
            g_assert_not_reached ();
            return NULL;
        }
      return (GIBaseInfo *) gi_info_new (info_type, (GIBaseInfo*)info, rinfo->typelib,
                                         rinfo->offset);
    }
  else
    {
      SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
      if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
        {
          InterfaceTypeBlob *blob = (InterfaceTypeBlob *)&rinfo->typelib->data[rinfo->offset];

          if (blob->tag == GI_TYPE_TAG_INTERFACE)
            return gi_info_from_entry (rinfo->repository, rinfo->typelib, blob->interface);
        }
    }

  return NULL;
}

/**
 * gi_type_info_get_array_length_index:
 * @info: a #GITypeInfo
 * @out_length_index: (out) (optional): return location for the length argument
 *
 * Obtain the position of the argument which gives the array length of the type.
 *
 * The type tag must be a `GI_TYPE_TAG_ARRAY` with a length argument, or `FALSE`
 * will be returned.
 *
 * Returns: `TRUE` if the type is an array and has a length argument
 * Since: 2.80
 */
gboolean
gi_type_info_get_array_length_index (GITypeInfo   *info,
                                     unsigned int *out_length_index)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, FALSE);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), FALSE);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
    {
      ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      if (blob->tag == GI_TYPE_TAG_ARRAY)
        {
          if (blob->has_length)
            {
              if (out_length_index != NULL)
                *out_length_index = blob->dimensions.length;
              return TRUE;
            }
        }
    }

  if (out_length_index != NULL)
    *out_length_index = 0;
  return FALSE;
}

/**
 * gi_type_info_get_array_fixed_size:
 * @info: a #GITypeInfo
 * @out_size: (out) (optional): return location for the array size
 *
 * Obtain the fixed array size of the type, in number of elements (not bytes).
 *
 * The type tag must be a `GI_TYPE_TAG_ARRAY` with a fixed size, or `FALSE` will
 * be returned.
 *
 * Returns: `TRUE` if the type is an array and has a fixed size
 * Since: 2.80
 */
gboolean
gi_type_info_get_array_fixed_size (GITypeInfo *info,
                                   size_t     *out_size)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, FALSE);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), FALSE);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
    {
      ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      if (blob->tag == GI_TYPE_TAG_ARRAY)
        {
          if (blob->has_size)
            {
              if (out_size != NULL)
                *out_size = blob->dimensions.size;
              return TRUE;
            }
        }
    }

  if (out_size != NULL)
    *out_size = 0;
  return FALSE;
}

/**
 * gi_type_info_is_zero_terminated:
 * @info: a #GITypeInfo
 *
 * Obtain if the last element of the array is `NULL`.
 *
 * The type tag must be a `GI_TYPE_TAG_ARRAY` or `FALSE` will be returned.
 *
 * Returns: `TRUE` if zero terminated
 * Since: 2.80
 */
gboolean
gi_type_info_is_zero_terminated (GITypeInfo *info)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, FALSE);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), FALSE);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
    {
      ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];

      if (blob->tag == GI_TYPE_TAG_ARRAY)
        return blob->zero_terminated;
    }

  return FALSE;
}

/**
 * gi_type_info_get_array_type:
 * @info: a #GITypeInfo
 *
 * Obtain the array type for this type.
 *
 * See [enum@GIRepository.ArrayType] for a list of possible values.
 *
 * It is an error to call this on an @info which is not an array type. Use
 * [method@GIRepository.TypeInfo.get_tag] to check.
 *
 * Returns: the array type
 * Since: 2.80
 */
GIArrayType
gi_type_info_get_array_type (GITypeInfo *info)
{
  GIRealInfo *rinfo = (GIRealInfo *)info;
  SimpleTypeBlob *type;

  g_return_val_if_fail (info != NULL, -1);
  g_return_val_if_fail (GI_IS_TYPE_INFO (info), -1);

  type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];

  if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
    {
      ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];
      g_return_val_if_fail (blob->tag == GI_TYPE_TAG_ARRAY, -1);

      return blob->array_type;
    }

  /* Not an array type */
  g_assert_not_reached ();
}

/**
 * gi_type_info_get_storage_type:
 * @info: a #GITypeInfo
 *
 * Obtain the type tag corresponding to the underlying storage type in C for
 * the type.
 *
 * See [type@GIRepository.TypeTag] for a list of type tags.
 *
 * Returns: the type tag
 * Since: 2.80
 */
GITypeTag
gi_type_info_get_storage_type (GITypeInfo *info)
{
  GITypeTag type_tag = gi_type_info_get_tag (info);

  if (type_tag == GI_TYPE_TAG_INTERFACE)
    {
      GIBaseInfo *interface = gi_type_info_get_interface (info);
      GIInfoType info_type = gi_base_info_get_info_type (interface);
      if (info_type == GI_INFO_TYPE_ENUM || info_type == GI_INFO_TYPE_FLAGS)
        type_tag = gi_enum_info_get_storage_type ((GIEnumInfo *) interface);
      gi_base_info_unref (interface);
    }

  return type_tag;
}

/**
 * gi_type_tag_argument_from_hash_pointer:
 * @storage_type: a [type@GIRepository.TypeTag] obtained from
 *   [method@GIRepository.TypeInfo.get_storage_type]
 * @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer
 * @arg: (out caller-allocates) (not nullable): a [type@GIRepository.Argument]
 *   to fill in
 *
 * Convert a data pointer from a GLib data structure to a
 * [type@GIRepository.Argument].
 *
 * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
 * [type@GLib.HashTable], all store data pointers.
 *
 * In the case where the list or hash table is storing single types rather than
 * structs, these data pointers may have values stuffed into them via macros
 * such as `GPOINTER_TO_INT`.
 *
 * Use this function to ensure that all values are correctly extracted from
 * stuffed pointers, regardless of the machine’s architecture or endianness.
 *
 * This function fills in the appropriate field of @arg with the value extracted
 * from @hash_pointer, depending on @storage_type.
 *
 * Since: 2.80
 */
void
gi_type_tag_argument_from_hash_pointer (GITypeTag   storage_type,
                                        void       *hash_pointer,
                                        GIArgument *arg)
{
  switch (storage_type)
    {
      case GI_TYPE_TAG_BOOLEAN:
        arg->v_boolean = !!GPOINTER_TO_INT (hash_pointer);
        break;
      case GI_TYPE_TAG_INT8:
        arg->v_int8 = (int8_t) GPOINTER_TO_INT (hash_pointer);
        break;
      case GI_TYPE_TAG_UINT8:
        arg->v_uint8 = (uint8_t) GPOINTER_TO_UINT (hash_pointer);
        break;
      case GI_TYPE_TAG_INT16:
        arg->v_int16 = (int16_t) GPOINTER_TO_INT (hash_pointer);
        break;
      case GI_TYPE_TAG_UINT16:
        arg->v_uint16 = (uint16_t) GPOINTER_TO_UINT (hash_pointer);
        break;
      case GI_TYPE_TAG_INT32:
        arg->v_int32 = (int32_t) GPOINTER_TO_INT (hash_pointer);
        break;
      case GI_TYPE_TAG_UINT32:
      case GI_TYPE_TAG_UNICHAR:
        arg->v_uint32 = (uint32_t) GPOINTER_TO_UINT (hash_pointer);
        break;
      case GI_TYPE_TAG_GTYPE:
        arg->v_size = GPOINTER_TO_SIZE (hash_pointer);
        break;
      case GI_TYPE_TAG_UTF8:
      case GI_TYPE_TAG_FILENAME:
      case GI_TYPE_TAG_INTERFACE:
      case GI_TYPE_TAG_ARRAY:
      case GI_TYPE_TAG_GLIST:
      case GI_TYPE_TAG_GSLIST:
      case GI_TYPE_TAG_GHASH:
      case GI_TYPE_TAG_ERROR:
        arg->v_pointer = hash_pointer;
        break;
      case GI_TYPE_TAG_INT64:
      case GI_TYPE_TAG_UINT64:
      case GI_TYPE_TAG_FLOAT:
      case GI_TYPE_TAG_DOUBLE:
      default:
        g_critical ("Unsupported storage type for pointer-stuffing: %s",
                    gi_type_tag_to_string (storage_type));
        arg->v_pointer = hash_pointer;
    }
}

/**
 * gi_type_info_argument_from_hash_pointer:
 * @info: a #GITypeInfo
 * @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer
 * @arg: (out caller-allocates): a [type@GIRepository.Argument] to fill in
 *
 * Convert a data pointer from a GLib data structure to a
 * [type@GIRepository.Argument].
 *
 * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
 * [type@GLib.HashTable], all store data pointers.
 *
 * In the case where the list or hash table is storing single types rather than
 * structs, these data pointers may have values stuffed into them via macros
 * such as `GPOINTER_TO_INT`.
 *
 * Use this function to ensure that all values are correctly extracted from
 * stuffed pointers, regardless of the machine’s architecture or endianness.
 *
 * This function fills in the appropriate field of @arg with the value extracted
 * from @hash_pointer, depending on the storage type of @info.
 *
 * Since: 2.80
 */
void
gi_type_info_argument_from_hash_pointer (GITypeInfo *info,
                                         void       *hash_pointer,
                                         GIArgument *arg)
{
    GITypeTag storage_type = gi_type_info_get_storage_type (info);
    gi_type_tag_argument_from_hash_pointer (storage_type, hash_pointer,
                                            arg);
}

/**
 * gi_type_tag_hash_pointer_from_argument:
 * @storage_type: a [type@GIRepository.TypeTag] obtained from
 *   [method@GIRepository.TypeInfo.get_storage_type]
 * @arg: a [type@GIRepository.Argument] with the value to stuff into a pointer
 *
 * Convert a [type@GIRepository.Argument] to data pointer for use in a GLib
 * data structure.
 *
 * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
 * [type@GLib.HashTable], all store data pointers.
 *
 * In the case where the list or hash table is storing single types rather than
 * structs, these data pointers may have values stuffed into them via macros
 * such as `GPOINTER_TO_INT`.
 *
 * Use this function to ensure that all values are correctly stuffed into
 * pointers, regardless of the machine’s architecture or endianness.
 *
 * This function returns a pointer stuffed with the appropriate field of @arg,
 * depending on @storage_type.
 *
 * Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable],
 *   for example
 * Since: 2.80
 */
void *
gi_type_tag_hash_pointer_from_argument (GITypeTag   storage_type,
                                        GIArgument *arg)
{
  switch (storage_type)
    {
      case GI_TYPE_TAG_BOOLEAN:
        return GINT_TO_POINTER (arg->v_boolean);
      case GI_TYPE_TAG_INT8:
        return GINT_TO_POINTER (arg->v_int8);
      case GI_TYPE_TAG_UINT8:
        return GUINT_TO_POINTER (arg->v_uint8);
      case GI_TYPE_TAG_INT16:
        return GINT_TO_POINTER (arg->v_int16);
      case GI_TYPE_TAG_UINT16:
        return GUINT_TO_POINTER (arg->v_uint16);
      case GI_TYPE_TAG_INT32:
        return GINT_TO_POINTER (arg->v_int32);
      case GI_TYPE_TAG_UINT32:
      case GI_TYPE_TAG_UNICHAR:
        return GUINT_TO_POINTER (arg->v_uint32);
      case GI_TYPE_TAG_GTYPE:
        return GSIZE_TO_POINTER (arg->v_size);
      case GI_TYPE_TAG_UTF8:
      case GI_TYPE_TAG_FILENAME:
      case GI_TYPE_TAG_INTERFACE:
      case GI_TYPE_TAG_ARRAY:
      case GI_TYPE_TAG_GLIST:
      case GI_TYPE_TAG_GSLIST:
      case GI_TYPE_TAG_GHASH:
      case GI_TYPE_TAG_ERROR:
        return arg->v_pointer;
      case GI_TYPE_TAG_INT64:
      case GI_TYPE_TAG_UINT64:
      case GI_TYPE_TAG_FLOAT:
      case GI_TYPE_TAG_DOUBLE:
      default:
        g_critical ("Unsupported storage type for pointer-stuffing: %s",
                    gi_type_tag_to_string (storage_type));
        return arg->v_pointer;
    }
}

/**
 * gi_type_info_hash_pointer_from_argument:
 * @info: a #GITypeInfo
 * @arg: a [struct@GIRepository.Argument] with the value to stuff into a pointer
 *
 * Convert a [type@GIRepository.Argument] to data pointer for use in a GLib
 * data structure.
 *
 * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and
 * [type@GLib.HashTable], all store data pointers.
 *
 * In the case where the list or hash table is storing single types rather than
 * structs, these data pointers may have values stuffed into them via macros
 * such as `GPOINTER_TO_INT`.
 *
 * Use this function to ensure that all values are correctly stuffed into
 * pointers, regardless of the machine’s architecture or endianness.
 *
 * This function returns a pointer stuffed with the appropriate field of @arg,
 * depending on the storage type of @info.
 *
 * Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable],
 *   for example
 * Since: 2.80
 */
void *
gi_type_info_hash_pointer_from_argument (GITypeInfo *info,
                                         GIArgument *arg)
{
  GITypeTag storage_type = gi_type_info_get_storage_type (info);
  return gi_type_tag_hash_pointer_from_argument (storage_type, arg);
}

void
gi_type_info_class_init (gpointer g_class,
                         gpointer class_data)
{
  GIBaseInfoClass *info_class = g_class;

  info_class->info_type = GI_INFO_TYPE_TYPE;
}