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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
|
/* GObject introspection: Repository implementation
*
* Copyright (C) 2005 Matthias Clasen
* Copyright (C) 2008,2009 Red Hat, Inc.
*
* 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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "gtypelib.h"
#include "ginfo.h"
typedef struct _GIRealInfo GIRealInfo;
/*
* We just use one structure for all of the info object
* types; in general, we should be reading data directly
* from the typelib, and not having computed data in
* per-type structures.
*/
struct _GIRealInfo
{
/* Keep this part in sync with GIUnresolvedInfo below */
gint32 type;
gint32 ref_count;
GIRepository *repository;
GIBaseInfo *container;
/* Resolved specific */
GTypelib *typelib;
guint32 offset;
guint32 type_is_embedded : 1; /* Used by GITypeInfo */
guint32 reserved : 31;
gpointer reserved2[4];
};
struct _GIUnresolvedInfo
{
/* Keep this part in sync with GIBaseInfo above */
gint32 type;
gint32 ref_count;
GIRepository *repository;
GIBaseInfo *container;
/* Unresolved specific */
const gchar *name;
const gchar *namespace;
};
#define INVALID_REFCOUNT 0x7FFFFFFF
static void
g_info_init (GIRealInfo *info,
GIInfoType type,
GIRepository *repository,
GIBaseInfo *container,
GTypelib *typelib,
guint32 offset)
{
memset (info, 0, sizeof (GIRealInfo));
/* Invalid refcount used to flag stack-allocated infos */
info->ref_count = INVALID_REFCOUNT;
info->type = type;
info->typelib = typelib;
info->offset = offset;
if (container)
info->container = container;
g_assert (G_IS_IREPOSITORY (repository));
info->repository = repository;
}
/* info creation */
GIBaseInfo *
g_info_new_full (GIInfoType type,
GIRepository *repository,
GIBaseInfo *container,
GTypelib *typelib,
guint32 offset)
{
GIRealInfo *info;
g_return_val_if_fail (container != NULL || repository != NULL, NULL);
info = g_slice_new (GIRealInfo);
g_info_init (info, type, repository, container, typelib, offset);
info->ref_count = 1;
if (container && ((GIRealInfo *) container)->ref_count != INVALID_REFCOUNT)
g_base_info_ref (info->container);
g_object_ref (info->repository);
return (GIBaseInfo*)info;
}
GIBaseInfo *
g_info_new (GIInfoType type,
GIBaseInfo *container,
GTypelib *typelib,
guint32 offset)
{
return g_info_new_full (type, ((GIRealInfo*)container)->repository, container, typelib, offset);
}
static GIBaseInfo *
g_info_from_entry (GIRepository *repository,
GTypelib *typelib,
guint16 index)
{
GIBaseInfo *result;
DirEntry *entry = g_typelib_get_dir_entry (typelib, index);
if (entry->local)
result = g_info_new_full (entry->blob_type, repository, NULL, typelib, entry->offset);
else
{
const gchar *namespace = g_typelib_get_string (typelib, entry->offset);
const gchar *name = g_typelib_get_string (typelib, entry->name);
result = g_irepository_find_by_name (repository, namespace, name);
if (result == NULL)
{
GIUnresolvedInfo *unresolved;
unresolved = g_slice_new0 (GIUnresolvedInfo);
unresolved->type = GI_INFO_TYPE_UNRESOLVED;
unresolved->ref_count = 1;
unresolved->repository = g_object_ref (repository);
unresolved->container = NULL;
unresolved->name = name;
unresolved->namespace = namespace;
return (GIBaseInfo *)unresolved;
}
return (GIBaseInfo *)result;
}
return (GIBaseInfo *)result;
}
/* GIBaseInfo functions */
/**
* SECTION:gibaseinfo
* @Short_description: Base struct for all GTypelib structs
* @Title: GIBaseInfo
*
* GIBaseInfo is the common base struct of all other *Info structs
* accessible through the #GIRepository API.
* All other structs can be casted to a #GIBaseInfo, for instance:
* <example>
* <title>Casting a #GIFunctionInfo to #GIBaseInfo</title>
* <programlisting>
* GIFunctionInfo *function_info = ...;
* GIBaseInfo *info = (GIBaseInfo*)function_info;
* </programlisting>
* </example>
* Most #GIRepository APIs returning a #GIBaseInfo is actually creating a new struct, in other
* words, g_base_info_unref() has to be called when done accessing the data.
* GIBaseInfos are normally accessed by calling either
* g_irepository_find_by_name(), g_irepository_find_by_gtype() or g_irepository_get_info().
*
* <example>
* <title>Getting the Button of the Gtk typelib</title>
* <programlisting>
* GIBaseInfo *button_info = g_irepository_find_by_name(NULL, "Gtk", "Button");
* ... use button_info ...
* g_base_info_unref(button_info);
* </programlisting>
* </example>
*
*/
/**
* g_base_info_ref:
* @info: a #GIBaseInfo
*
* Increases the reference count of @info.
*
* Returns: the same @info.
*/
GIBaseInfo *
g_base_info_ref (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*)info;
g_assert (rinfo->ref_count != INVALID_REFCOUNT);
((GIRealInfo*)info)->ref_count++;
return info;
}
/**
* g_base_info_unref:
* @info: a #GIBaseInfo
*
* Decreases the reference count of @info. When its reference count
* drops to 0, the info is freed.
*/
void
g_base_info_unref (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*)info;
g_assert (rinfo->ref_count > 0 && rinfo->ref_count != INVALID_REFCOUNT);
rinfo->ref_count--;
if (!rinfo->ref_count)
{
if (rinfo->container && ((GIRealInfo *) rinfo->container)->ref_count != INVALID_REFCOUNT)
g_base_info_unref (rinfo->container);
if (rinfo->repository)
g_object_unref (rinfo->repository);
g_slice_free (GIRealInfo, rinfo);
}
}
/**
* g_base_info_get_type:
* @info: a #GIBaseInfo
*
* Obtain the info type of the GIBaseInfo.
*
* Returns: the info type of @info
*/
GIInfoType
g_base_info_get_type (GIBaseInfo *info)
{
return ((GIRealInfo*)info)->type;
}
/**
* g_base_info_get_name:
* @info: a #GIBaseInfo
*
* Obtain the name of the @info. What the name represents depends on
* the #GIInfoType of the @info. For instance for #GIFunctionInfo it is
* the name of the function.
*
* Returns: the name of @info or %NULL if it lacks a name.
*/
const gchar *
g_base_info_get_name (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*)info;
g_assert (rinfo->ref_count > 0);
switch (rinfo->type)
{
case GI_INFO_TYPE_FUNCTION:
case GI_INFO_TYPE_CALLBACK:
case GI_INFO_TYPE_STRUCT:
case GI_INFO_TYPE_BOXED:
case GI_INFO_TYPE_ENUM:
case GI_INFO_TYPE_FLAGS:
case GI_INFO_TYPE_OBJECT:
case GI_INFO_TYPE_INTERFACE:
case GI_INFO_TYPE_CONSTANT:
case GI_INFO_TYPE_ERROR_DOMAIN:
case GI_INFO_TYPE_UNION:
{
CommonBlob *blob = (CommonBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_VALUE:
{
ValueBlob *blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_SIGNAL:
{
SignalBlob *blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_PROPERTY:
{
PropertyBlob *blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_VFUNC:
{
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_FIELD:
{
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_ARG:
{
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_UNRESOLVED:
{
GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info;
return unresolved->name;
}
break;
case GI_INFO_TYPE_TYPE:
default: ;
g_assert_not_reached ();
/* unnamed */
}
return NULL;
}
/**
* g_base_info_get_namespace:
* @info: a #GIBaseInfo
*
* Obtain the namespace of @info.
*
* Returns: the namespace
*/
const gchar *
g_base_info_get_namespace (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
Header *header = (Header *)rinfo->typelib->data;
g_assert (rinfo->ref_count > 0);
if (rinfo->type == GI_INFO_TYPE_UNRESOLVED)
{
GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info;
return unresolved->namespace;
}
return g_typelib_get_string (rinfo->typelib, header->namespace);
}
/**
* g_base_info_is_deprecated:
* @info: a #GIBaseInfo
*
* Obtain whether the @info is represents a metadata which is
* deprecated or not.
*
* Returns: %TRUE if deprecated
*/
gboolean
g_base_info_is_deprecated (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
switch (rinfo->type)
{
case GI_INFO_TYPE_FUNCTION:
case GI_INFO_TYPE_CALLBACK:
case GI_INFO_TYPE_STRUCT:
case GI_INFO_TYPE_BOXED:
case GI_INFO_TYPE_ENUM:
case GI_INFO_TYPE_FLAGS:
case GI_INFO_TYPE_OBJECT:
case GI_INFO_TYPE_INTERFACE:
case GI_INFO_TYPE_CONSTANT:
case GI_INFO_TYPE_ERROR_DOMAIN:
{
CommonBlob *blob = (CommonBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->deprecated;
}
break;
case GI_INFO_TYPE_VALUE:
{
ValueBlob *blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->deprecated;
}
break;
case GI_INFO_TYPE_SIGNAL:
{
SignalBlob *blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->deprecated;
}
break;
case GI_INFO_TYPE_PROPERTY:
{
PropertyBlob *blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->deprecated;
}
break;
case GI_INFO_TYPE_VFUNC:
case GI_INFO_TYPE_FIELD:
case GI_INFO_TYPE_ARG:
case GI_INFO_TYPE_TYPE:
default: ;
/* no deprecation flag for these */
}
return FALSE;
}
/**
* g_base_info_get_attribute:
* @info: a #GIBaseInfo
* @name: a freeform string naming an attribute
*
* Retrieve an arbitrary attribute associated with this node.
*
* Returns: The value of the attribute, or %NULL if no such attribute exists
*/
const gchar *
g_base_info_get_attribute (GIBaseInfo *info,
const gchar *name)
{
GIAttributeIter iter = { 0, };
gchar *curname, *curvalue;
while (g_base_info_iterate_attributes (info, &iter, &curname, &curvalue))
{
if (strcmp (name, curname) == 0)
return (const gchar*) curvalue;
}
return NULL;
}
static int
cmp_attribute (const void *av,
const void *bv)
{
const AttributeBlob *a = av;
const AttributeBlob *b = bv;
if (a->offset < b->offset)
return -1;
else if (a->offset == b->offset)
return 0;
else
return 1;
}
static AttributeBlob *
find_first_attribute (GIRealInfo *rinfo)
{
Header *header = (Header *)rinfo->typelib->data;
AttributeBlob blob, *first, *res, *previous;
blob.offset = rinfo->offset;
first = (AttributeBlob *) &rinfo->typelib->data[header->attributes];
res = bsearch (&blob, first, header->n_attributes,
header->attribute_blob_size, cmp_attribute);
if (res == NULL)
return NULL;
previous = res - 1;
while (previous >= first && previous->offset == rinfo->offset)
{
res = previous;
previous = res - 1;
}
return res;
}
/**
* g_base_info_iterate_attributes:
* @info: a #GIBaseInfo
* @iterator: a #GIAttributeIter structure, must be initialized; see below
* @name: (out) (transfer none): Returned name, must not be freed
* @value: (out) (transfer none): Returned name, must not be freed
*
* Iterate over all attributes associated with this node. The iterator
* structure is typically stack allocated, and must have its first
* member initialized to %NULL.
*
* Both the @name and @value should be treated as constants
* and must not be freed.
*
* <example>
* <title>Iterating over attributes</title>
* <programlisting>
* void
* print_attributes (GIBaseInfo *info)
* {
* GIAttributeIter iter = { 0, };
* char *name;
* char *value;
* while (g_base_info_iterate_attributes (info, &iter, &name, &value))
* {
* g_print ("attribute name: %s value: %s", name, value);
* }
* }
* </programlisting>
* </example>
*
* Returns: %TRUE if there are more attributes
*/
gboolean
g_base_info_iterate_attributes (GIBaseInfo *info,
GIAttributeIter *iterator,
gchar **name,
gchar **value)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
AttributeBlob *next, *after;
after = (AttributeBlob *) &rinfo->typelib->data[header->attributes +
header->n_attributes * header->attribute_blob_size];
if (iterator->data != NULL)
next = (AttributeBlob *) iterator->data;
else
next = find_first_attribute (rinfo);
if (next == NULL || next->offset != rinfo->offset || next >= after)
return FALSE;
*name = (gchar*) g_typelib_get_string (rinfo->typelib, next->name);
*value = (gchar*) g_typelib_get_string (rinfo->typelib, next->value);
iterator->data = next + 1;
return TRUE;
}
/**
* g_base_info_get_container:
* @info: a #GIBaseInfo
*
* Obtain the container of the @info. The container is the parent
* GIBaseInfo. For instance, the parent of a #GIFunctionInfo is an
* #GIObjectInfo or #GIInterfaceInfo.
*
* Returns: (transfer none): the container
*/
GIBaseInfo *
g_base_info_get_container (GIBaseInfo *info)
{
return ((GIRealInfo*)info)->container;
}
/**
* g_base_info_get_typelib:
* @info: a #GIBaseInfo
*
* Obtain the typelib this @info belongs to
*
* Returns: (transfer none): the typelib.
*/
GTypelib *
g_base_info_get_typelib (GIBaseInfo *info)
{
return ((GIRealInfo*)info)->typelib;
}
/**
* g_base_info_equal:
* @info1: a #GIBaseInfo
* @info2: a #GIBaseInfo
*
* Compare two #GIBaseInfo.
*
* Using pointer comparison is not practical since many functions return
* different instances of #GIBaseInfo that refers to the same part of the
* TypeLib; use this function instead to do #GIBaseInfo comparisons.
*
* Returns: %TRUE if and only if @info1 equals @info2.
*/
gboolean
g_base_info_equal (GIBaseInfo *info1, GIBaseInfo *info2)
{
/* Compare the TypeLib pointers, which are mmapped. */
GIRealInfo *rinfo1 = (GIRealInfo*)info1;
GIRealInfo *rinfo2 = (GIRealInfo*)info2;
return rinfo1->typelib->data + rinfo1->offset == rinfo2->typelib->data + rinfo2->offset;
}
/* GIFunctionInfo functions */
/**
* SECTION:gifunctioninfo
* @Short_description: Struct representing a function
* @Title: GIFunctionInfo
*
* GIFunctionInfo represents a function, method or constructor.
* To find out what kind of entity a #GIFunctionInfo represents, call
* g_function_info_get_flags().
*
* See also #GICallableInfo for information on how to retreive arguments and
* other metadata.
*/
/**
* g_function_info_get_symbol:
* @info: a #GIFunctionInfo
*
* Obtain the symbol of the function. The symbol is the name of the
* exported function, suitable to be used as an argument to
* g_module_symbol().
*
* Returns: the symbol
*/
const gchar *
g_function_info_get_symbol (GIFunctionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->symbol);
}
/**
* g_function_info_get_flags:
* @info: a #GIFunctionInfo
*
* Obtain the #GIFunctionInfoFlags for the @info.
*
* Returns: the flags
*/
GIFunctionInfoFlags
g_function_info_get_flags (GIFunctionInfo *info)
{
GIFunctionInfoFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
/* Make sure we don't flag Constructors as methods */
if (!blob->constructor && !blob->is_static)
flags = flags | GI_FUNCTION_IS_METHOD;
if (blob->constructor)
flags = flags | GI_FUNCTION_IS_CONSTRUCTOR;
if (blob->getter)
flags = flags | GI_FUNCTION_IS_GETTER;
if (blob->setter)
flags = flags | GI_FUNCTION_IS_SETTER;
if (blob->wraps_vfunc)
flags = flags | GI_FUNCTION_WRAPS_VFUNC;
if (blob->throws)
flags = flags | GI_FUNCTION_THROWS;
return flags;
}
/**
* g_function_info_get_property:
* @info: a #GIFunctionInfo
*
* Obtain the property associated with this #GIFunctionInfo.
* Only #GIFunctionInfo with the flag %GI_FUNCTION_IS_GETTER or
* %GI_FUNCTION_IS_SETTER have a property set. For other cases,
* %NULL will be returned.
*
* Returns: (transfer full): the property or %NULL if not set. Free it with
* g_base_info_unref() when done.
*/
GIPropertyInfo *
g_function_info_get_property (GIFunctionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
return g_interface_info_get_property (container, blob->index);
}
/**
* g_function_info_get_vfunc:
* @info: a #GIFunctionInfo
*
* Obtain the virtual function associated with this #GIFunctionInfo.
* Only #GIFunctionInfo with the flag %GI_FUNCTION_WRAPS_VFUNC has
* a virtual function set. For other cases, %NULL will be returned.
*
* Returns: (transfer full): the virtual function or %NULL if not set.
* Free it by calling g_base_info_unref() when done.
*/
GIVFuncInfo *
g_function_info_get_vfunc (GIFunctionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
return g_interface_info_get_vfunc (container, blob->index);
}
/* GICallableInfo functions */
/**
* SECTION:gicallableinfo
* @Short_description: Struct representing a callable
* @Title: GICallableInfo
*
* GICallableInfo represents an entity which is callable.
* Currently a function (#GIFunctionInfo), virtual function,
* (#GIVirtualFunc) or callback (#GICallbackInfo).
*
* A callable has a list of arguments (#GIArgInfo), a return type,
* direction and a flag which decides if it returns null.
*
*/
static guint32
signature_offset (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*)info;
int sigoff = -1;
switch (rinfo->type)
{
case GI_INFO_TYPE_FUNCTION:
sigoff = G_STRUCT_OFFSET (FunctionBlob, signature);
break;
case GI_INFO_TYPE_VFUNC:
sigoff = G_STRUCT_OFFSET (VFuncBlob, signature);
break;
case GI_INFO_TYPE_CALLBACK:
sigoff = G_STRUCT_OFFSET (CallbackBlob, signature);
break;
case GI_INFO_TYPE_SIGNAL:
sigoff = G_STRUCT_OFFSET (SignalBlob, signature);
break;
}
if (sigoff >= 0)
return *(guint32 *)&rinfo->typelib->data[rinfo->offset + sigoff];
return 0;
}
GITypeInfo *
g_type_info_new (GIBaseInfo *container,
GTypelib *typelib,
guint32 offset)
{
SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset];
return (GITypeInfo *) g_info_new (GI_INFO_TYPE_TYPE, container, typelib,
(type->flags.reserved == 0 && type->flags.reserved2 == 0) ? offset : type->offset);
}
static void
g_type_info_init (GIBaseInfo *info,
GIBaseInfo *container,
GTypelib *typelib,
guint32 offset)
{
GIRealInfo *rinfo = (GIRealInfo*)container;
SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset];
g_info_init ((GIRealInfo*)info, GI_INFO_TYPE_TYPE, rinfo->repository, container, typelib,
(type->flags.reserved == 0 && type->flags.reserved2 == 0) ? offset : type->offset);
}
/**
* g_callable_info_get_return_type:
* @info: a #GICallableInfo
*
* Obtain the return type of a callable item as a #GITypeInfo.
*
* Returns: (transfer full): the #GITypeInfo. Free the struct by calling
* g_base_info_unref() when done.
*/
GITypeInfo *
g_callable_info_get_return_type (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
guint32 offset;
offset = signature_offset (info);
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, offset);
}
/**
* g_callable_info_load_return_type:
* @info: a #GICallableInfo
* @type: (out caller-allocates): Initialized with return type of @info
*
* Obtain information about a return value of callable; this
* function is a variant of g_callable_info_get_return_type() designed for stack
* allocation.
*
* The initialized @type must not be referenced after @info is deallocated.
*/
void
g_callable_info_load_return_type (GICallableInfo *info,
GITypeInfo *type)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
guint32 offset;
offset = signature_offset (info);
g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, offset);
}
/**
* g_callable_info_may_return_null:
* @info: a #GICallableInfo
*
* See if a callable could return %NULL.
*
* Returns: %TRUE if callable could return %NULL
*/
gboolean
g_callable_info_may_return_null (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SignatureBlob *blob = (SignatureBlob *)&rinfo->typelib->data[signature_offset (info)];
return blob->may_return_null;
}
/**
* g_callable_info_get_caller_owns:
* @info: a #GICallableInfo
*
* See whether the caller owns the return value of this callable.
* #GITransfer contains a list of possible transfer values.
*
* Returns: %TRUE if the caller owns the return value, %FALSE otherwise.
*/
GITransfer
g_callable_info_get_caller_owns (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
SignatureBlob *blob = (SignatureBlob *)&rinfo->typelib->data[signature_offset (info)];
if (blob->caller_owns_return_value)
return GI_TRANSFER_EVERYTHING;
else if (blob->caller_owns_return_container)
return GI_TRANSFER_CONTAINER;
else
return GI_TRANSFER_NOTHING;
}
/**
* g_callable_info_get_n_args:
* @info: a #GICallableInfo
*
* Obtain the number of arguments (both IN and OUT) for this callable.
*
* Returns: The number of arguments this callable expects.
*/
gint
g_callable_info_get_n_args (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
gint offset;
SignatureBlob *blob;
offset = signature_offset (info);
blob = (SignatureBlob *)&rinfo->typelib->data[offset];
return blob->n_arguments;
}
/**
* g_callable_info_get_arg:
* @info: a #GICallableInfo
* @n: the argument index to fetch
*
* Obtain information about a particular argument of this callable.
*
* Returns: (transfer full): the #GIArgInfo. Free it with
* g_base_info_unref() when done.
*/
GIArgInfo *
g_callable_info_get_arg (GICallableInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = signature_offset (info);
return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, (GIBaseInfo*)info, rinfo->typelib,
offset + header->signature_blob_size + n * header->arg_blob_size);
}
/**
* g_callable_info_load_arg:
* @info: a #GICallableInfo
* @n: the argument index to fetch
* @arg: (out caller-allocates): Initialize with argument number @n
*
* Obtain information about a particular argument of this callable; this
* function is a variant of g_callable_info_get_arg() designed for stack
* allocation.
*
* The initialized @arg must not be referenced after @info is deallocated.
*/
void
g_callable_info_load_arg (GICallableInfo *info,
gint n,
GIArgInfo *arg)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = signature_offset (info);
g_info_init ((GIRealInfo*)arg, GI_INFO_TYPE_ARG, rinfo->repository, (GIBaseInfo*)info, rinfo->typelib,
offset + header->signature_blob_size + n * header->arg_blob_size);
}
/* GIArgInfo function */
/**
* SECTION:giarginfo
* @Short_description: Struct representing an argument
* @Title: GIArgInfo
*
* GIArgInfo represents an argument. An argument is always
* part of a #GICallableInfo.
*
*
*/
/**
* g_arg_info_get_direction:
* @info: a #GIArgInfo
*
* Obtain the direction of the argument. Check #GIDirection for possible
* direction values.
*
* Returns: the direction
*/
GIDirection
g_arg_info_get_direction (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->in && blob->out)
return GI_DIRECTION_INOUT;
else if (blob->out)
return GI_DIRECTION_OUT;
else
return GI_DIRECTION_IN;
}
/**
* g_arg_info_is_return_value:
* @info: a #GIArgInfo
*
* Obtain if the argument is a return value. It can either be a
* parameter or a return value.
*
* Returns: %TRUE if it is a return value
*/
gboolean
g_arg_info_is_return_value (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->return_value;
}
/**
* g_arg_info_is_dipper:
* @info: a #GIArgInfo
*
* Obtain if the argument is a pointer to a struct or object that will
* receive an output of a function.
*
* Returns: %TRUE if it is a dipper argument
*/
gboolean
g_arg_info_is_dipper (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->dipper;
}
/**
* g_arg_info_is_optional:
* @info: a #GIArgInfo
*
* Obtain if the argument is optional.
*
* Returns: %TRUE if it is an optional argument
*/
gboolean
g_arg_info_is_optional (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->optional;
}
/**
* g_arg_info_may_be_null:
* @info: a #GIArgInfo
*
* Obtain if the argument accepts %NULL.
*
* Returns: %TRUE if it accepts %NULL
*/
gboolean
g_arg_info_may_be_null (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->allow_none;
}
/**
* g_arg_info_get_ownership_transfer:
* @info: a #GIArgInfo
*
* Obtain the ownership transfer for this argument.
* #GITransfer contains a list of possible values.
*
* Returns: the transfer
*/
GITransfer
g_arg_info_get_ownership_transfer (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->transfer_ownership)
return GI_TRANSFER_EVERYTHING;
else if (blob->transfer_container_ownership)
return GI_TRANSFER_CONTAINER;
else
return GI_TRANSFER_NOTHING;
}
/**
* g_arg_info_get_scope:
* @info: a #GIArgInfo
*
* Obtain the scope type for this argument. The scope type explains
* how a callback is going to be invoked, most importantly when
* the resources required to invoke it can be freed.
* #GIScopeType contains a list of possible values.
*
* Returns: the scope type
*/
GIScopeType
g_arg_info_get_scope (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->scope;
}
/**
* g_arg_info_get_closure:
* @info: a #GIArgInfo
*
* Obtains the index of the user data argument. This is only valid
* for arguments which are callbacks.
*
* Returns: index of the user data argument or -1 if there is none
*/
gint
g_arg_info_get_closure (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->closure;
}
/**
* g_arg_info_get_destroy:
* @info: a #GIArgInfo
*
* Obtains the index of the #GDestroyNotify argument. This is only valid
* for arguments which are callbacks.
*
* Returns: index of the #GDestroyNotify argument or -1 if there is none
*/
gint
g_arg_info_get_destroy (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->destroy;
}
/**
* g_arg_info_get_type:
* @info: a #GIArgInfo
*
* Obtain the type information for @info.
*
* Returns: (transfer full): the #GIArgInfo, free it with
* g_base_info_unref() when done.
*/
GITypeInfo *
g_arg_info_get_type (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
}
/**
* g_arg_info_load_type:
* @info: a #GIArgInfo
* @type: (out caller-allocates): Initialized with information about type of @info
*
* Get information about a the type of given argument @info; this
* function is a variant of g_arg_info_get_type() designed for stack
* allocation.
*
* The initialized @type must not be referenced after @info is deallocated.
*/
void
g_arg_info_load_type (GIArgInfo *info,
GITypeInfo *type)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
}
/* GITypeInfo functions */
gboolean
g_type_info_is_pointer (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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;
}
}
GITypeTag
g_type_info_get_tag (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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;
}
}
GITypeInfo *
g_type_info_get_param_type (GITypeInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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 g_type_info_new ((GIBaseInfo*)info, rinfo->typelib,
rinfo->offset + sizeof (ParamTypeBlob)
+ sizeof (SimpleTypeBlob) * n);
break;
default:
break;
}
}
return NULL;
}
/**
* g_type_info_get_interface:
* @info: a #GITypeInfo
*
* For types which have #GI_TYPE_TAG_INTERFACE such as GObjects and boxed values,
* this function returns full information about the referenced type. You can then
* inspect the type of the returned #GIBaseInfo to further query whether it is
* a concrete GObject, a GInterface, a structure, etc. using g_base_info_get_type().
*
* Returns: (transfer full): the #GIBaseInfo, or %NULL. Free it with
* g_base_info_unref() when done.
*/
GIBaseInfo *
g_type_info_get_interface (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
/* 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 *) g_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 g_info_from_entry (rinfo->repository, rinfo->typelib, blob->interface);
}
}
return NULL;
}
gint
g_type_info_get_array_length (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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)
return blob->dimensions.length;
}
}
return -1;
}
gint
g_type_info_get_array_fixed_size (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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)
return blob->dimensions.size;
}
}
return -1;
}
gboolean
g_type_info_is_zero_terminated (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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;
}
GIArrayType
g_type_info_get_array_type (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *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;
}
return -1;
}
gint
g_type_info_get_n_error_domains (GITypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->tag == GI_TYPE_TAG_ERROR)
return blob->n_domains;
}
return 0;
}
GIErrorDomainInfo *
g_type_info_get_error_domain (GITypeInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->tag == GI_TYPE_TAG_ERROR)
return (GIErrorDomainInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib,
blob->domains[n]);
}
return NULL;
}
/* GIErrorDomainInfo functions */
const gchar *
g_error_domain_info_get_quark (GIErrorDomainInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->get_quark);
}
GIInterfaceInfo *
g_error_domain_info_get_codes (GIErrorDomainInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset];
return (GIInterfaceInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->error_codes);
}
/* GIValueInfo functions */
glong
g_value_info_get_value (GIValueInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ValueBlob *blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
return (glong)blob->value;
}
/* GIFieldInfo functions */
GIFieldInfoFlags
g_field_info_get_flags (GIFieldInfo *info)
{
GIFieldInfoFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
if (blob->readable)
flags = flags | GI_FIELD_IS_READABLE;
if (blob->writable)
flags = flags | GI_FIELD_IS_WRITABLE;
return flags;
}
gint
g_field_info_get_size (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->bits;
}
gint
g_field_info_get_offset (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->struct_offset;
}
GITypeInfo *
g_field_info_get_type (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
GIRealInfo *type_info;
if (blob->has_embedded_type)
{
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
(GIBaseInfo*)info, rinfo->typelib,
rinfo->offset + header->field_blob_size);
type_info->type_is_embedded = TRUE;
}
else
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (FieldBlob, type));
return (GIBaseInfo*)type_info;
}
/* GIRegisteredTypeInfo functions */
const gchar *
g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_name)
return g_typelib_get_string (rinfo->typelib, blob->gtype_name);
return NULL;
}
const gchar *
g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_init)
return g_typelib_get_string (rinfo->typelib, blob->gtype_init);
return NULL;
}
GType
g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info)
{
const char *type_init;
GType (* get_type_func) (void);
GIRealInfo *rinfo = (GIRealInfo*)info;
type_init = g_registered_type_info_get_type_init (info);
if (type_init == NULL)
return G_TYPE_NONE;
else if (!strcmp (type_init, "intern"))
return G_TYPE_OBJECT;
get_type_func = NULL;
if (!g_typelib_symbol (rinfo->typelib,
type_init,
(void**) &get_type_func))
return G_TYPE_NONE;
return (* get_type_func) ();
}
/* GIStructInfo functions */
gint
g_struct_info_get_n_fields (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_fields;
}
static gint32
g_struct_get_field_offset (GIStructInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
guint32 offset = rinfo->offset + header->struct_blob_size;
gint i;
FieldBlob *field_blob;
for (i = 0; i < n; i++)
{
field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
offset += header->field_blob_size;
if (field_blob->has_embedded_type)
offset += header->callback_blob_size;
}
return offset;
}
GIFieldInfo *
g_struct_info_get_field (GIStructInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
g_struct_get_field_offset (info, n));
}
gint
g_struct_info_get_n_methods (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_methods;
}
GIFunctionInfo *
g_struct_info_get_method (GIStructInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = g_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
static GIFunctionInfo *
find_method (GIBaseInfo *base,
guint32 offset,
gint n_methods,
const gchar *name)
{
/* FIXME hash */
GIRealInfo *rinfo = (GIRealInfo*)base;
Header *header = (Header *)rinfo->typelib->data;
gint i;
for (i = 0; i < n_methods; i++)
{
FunctionBlob *fblob = (FunctionBlob *)&rinfo->typelib->data[offset];
const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name];
if (strcmp (name, fname) == 0)
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
rinfo->typelib, offset);
offset += header->function_blob_size;
}
return NULL;
}
GIFunctionInfo *
g_struct_info_find_method (GIStructInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->struct_blob_size
+ blob->n_fields * header->field_blob_size;
return find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
}
gsize
g_struct_info_get_size (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->size;
}
gsize
g_struct_info_get_alignment (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->alignment;
}
gboolean
g_struct_info_is_foreign (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->foreign;
}
/**
* g_struct_info_is_gtype_struct:
* @info: a #GIStructInfo
*
* Return true if this structure represents the "class structure" for some
* #GObject or #GInterface. This function is mainly useful to hide this kind of structure
* from generated public APIs.
*
* Returns: %TRUE if this is a class struct, %FALSE otherwise
*/
gboolean
g_struct_info_is_gtype_struct (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->is_gtype_struct;
}
gint
g_enum_info_get_n_values (GIEnumInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
EnumBlob *blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_values;
}
GIValueInfo *
g_enum_info_get_value (GIEnumInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = rinfo->offset + header->enum_blob_size
+ n * header->value_blob_size;
return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, (GIBaseInfo*)info, rinfo->typelib, offset);
}
/**
* g_enum_info_get_storage_type:
* @info: a #GIEnumInfo
*
* Gets the tag of the type used for the enum in the C ABI. This will
* will be a signed or unsigned integral type.
* Note that in the current implementation the width of the type is
* computed correctly, but the signed or unsigned nature of the type
* may not match the sign of the type used by the C compiler.
*
* Return Value: the storage type for the enumeration
*/
GITypeTag
g_enum_info_get_storage_type (GIEnumInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
EnumBlob *blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->storage_type;
}
/* GIObjectInfo functions */
GIObjectInfo *
g_object_info_get_parent (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->parent)
return (GIObjectInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->parent);
else
return NULL;
}
gboolean
g_object_info_get_abstract (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->abstract != 0;
}
const gchar *
g_object_info_get_type_name (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->gtype_name);
}
const gchar *
g_object_info_get_type_init (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return g_typelib_get_string (rinfo->typelib, blob->gtype_init);
}
gint
g_object_info_get_n_interfaces (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_interfaces;
}
GIInterfaceInfo *
g_object_info_get_interface (GIObjectInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return (GIInterfaceInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->interfaces[n]);
}
gint
g_object_info_get_n_fields (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_fields;
}
GIFieldInfo *
g_object_info_get_field (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->field_blob_size;
return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, offset);
}
gint
g_object_info_get_n_properties (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_properties;
}
GIPropertyInfo *
g_object_info_get_property (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ n * header->property_blob_size;
return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
gint
g_object_info_get_n_methods (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_methods;
}
GIFunctionInfo *
g_object_info_get_method (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
GIFunctionInfo *
g_object_info_find_method (GIObjectInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size +
+ blob->n_properties * header->property_blob_size;
return find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
}
gint
g_object_info_get_n_signals (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_signals;
}
GISignalInfo *
g_object_info_get_signal (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ n * header->signal_blob_size;
return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
gint
g_object_info_get_n_vfuncs (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_vfuncs;
}
GIVFuncInfo *
g_object_info_get_vfunc (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
+ n * header->vfunc_blob_size;
return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
static GIVFuncInfo *
find_vfunc (GIRealInfo *rinfo,
guint32 offset,
gint n_vfuncs,
const gchar *name)
{
/* FIXME hash */
Header *header = (Header *)rinfo->typelib->data;
gint i;
for (i = 0; i < n_vfuncs; i++)
{
VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset];
const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name];
if (strcmp (name, fname) == 0)
return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*) rinfo,
rinfo->typelib, offset);
offset += header->vfunc_blob_size;
}
return NULL;
}
/**
* g_object_info_find_vfunc:
* @info: a #GIObjectInfo
* @name: The name of a virtual function to find.
*
* Locate a virtual function slot with name @name. Note that the namespace
* for virtuals is distinct from that of methods; there may or may not be
* a concrete method associated for a virtual. If there is one, it may
* be retrieved using g_vfunc_info_get_invoker(), otherwise %NULL will be
* returned.
* See the documentation for g_vfunc_info_get_invoker() for more
* information on invoking virtuals.
*
* Returns: (transfer full): the #GIVFuncInfo, or %NULL. Free it with
* g_base_info_unref() when done.
*/
GIVFuncInfo *
g_object_info_find_vfunc (GIObjectInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size;
return find_vfunc (rinfo, offset, blob->n_vfuncs, name);
}
gint
g_object_info_get_n_constants (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_constants;
}
GIConstantInfo *
g_object_info_get_constant (GIObjectInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
+ blob->n_vfuncs * header->vfunc_blob_size
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
/**
* g_object_info_get_class_struct:
* @info: a #GIObjectInfo
*
* Every #GObject has two structures; an instance structure and a class
* structure. This function returns the metadata for the class structure.
*
* Returns: (transfer full): the #GIStructInfo or %NULL. Free with
* g_base_info_unref() when done.
*/
GIStructInfo *
g_object_info_get_class_struct (GIObjectInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_struct)
return (GIStructInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->gtype_struct);
else
return NULL;
}
/* GIInterfaceInfo functions */
gint
g_interface_info_get_n_prerequisites (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_prerequisites;
}
GIBaseInfo *
g_interface_info_get_prerequisite (GIInterfaceInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->prerequisites[n]);
}
gint
g_interface_info_get_n_properties (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_properties;
}
GIPropertyInfo *
g_interface_info_get_property (GIInterfaceInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->property_blob_size;
return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
gint
g_interface_info_get_n_methods (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_methods;
}
GIFunctionInfo *
g_interface_info_get_method (GIInterfaceInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
GIFunctionInfo *
g_interface_info_find_method (GIInterfaceInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size;
return find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
}
gint
g_interface_info_get_n_signals (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_signals;
}
GISignalInfo *
g_interface_info_get_signal (GIInterfaceInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ n * header->signal_blob_size;
return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
gint
g_interface_info_get_n_vfuncs (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_vfuncs;
}
GIVFuncInfo *
g_interface_info_get_vfunc (GIInterfaceInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
+ n * header->vfunc_blob_size;
return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
/**
* g_interface_info_find_vfunc:
* @info: a #GIObjectInfo
* @name: The name of a virtual function to find.
*
* Locate a virtual function slot with name @name. See the documentation
* for g_object_info_find_vfunc() for more information on virtuals.
*
* Returns: (transfer full): the #GIVFuncInfo, or %NULL. Free it with
* g_base_info_unref() when done.
*/
GIVFuncInfo *
g_interface_info_find_vfunc (GIInterfaceInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + blob->n_prerequisites % 2) * 2
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size;
return find_vfunc (rinfo, offset, blob->n_vfuncs, name);
}
gint
g_interface_info_get_n_constants (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_constants;
}
GIConstantInfo *
g_interface_info_get_constant (GIInterfaceInfo *info,
gint n)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
+ blob->n_vfuncs * header->vfunc_blob_size
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
/**
* g_interface_info_get_iface_struct:
* @info: a #GIInterfaceInfo
*
* Returns the layout C structure associated with this #GInterface.
*
* Returns: (transfer full): the #GIStructInfo or %NULL. Free it with
* g_base_info_unref() when done.
*/
GIStructInfo *
g_interface_info_get_iface_struct (GIInterfaceInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_struct)
return (GIStructInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->gtype_struct);
else
return NULL;
}
/* GIPropertyInfo functions */
GParamFlags
g_property_info_get_flags (GIPropertyInfo *info)
{
GParamFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
PropertyBlob *blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
if (blob->readable)
flags = flags | G_PARAM_READABLE;
if (blob->writable)
flags = flags | G_PARAM_WRITABLE;
if (blob->construct)
flags = flags | G_PARAM_CONSTRUCT;
if (blob->construct_only)
flags = flags | G_PARAM_CONSTRUCT_ONLY;
return flags;
}
GITypeInfo *
g_property_info_get_type (GIPropertyInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (PropertyBlob, type));
}
/* GISignalInfo functions */
GSignalFlags
g_signal_info_get_flags (GISignalInfo *info)
{
GSignalFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
SignalBlob *blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
if (blob->run_first)
flags = flags | G_SIGNAL_RUN_FIRST;
if (blob->run_last)
flags = flags | G_SIGNAL_RUN_LAST;
if (blob->run_cleanup)
flags = flags | G_SIGNAL_RUN_CLEANUP;
if (blob->no_recurse)
flags = flags | G_SIGNAL_NO_RECURSE;
if (blob->detailed)
flags = flags | G_SIGNAL_DETAILED;
if (blob->action)
flags = flags | G_SIGNAL_ACTION;
if (blob->no_hooks)
flags = flags | G_SIGNAL_NO_HOOKS;
return flags;
}
GIVFuncInfo *
g_signal_info_get_class_closure (GISignalInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SignalBlob *blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->has_class_closure)
return g_interface_info_get_vfunc ((GIInterfaceInfo *)rinfo->container, blob->class_closure);
return NULL;
}
gboolean
g_signal_info_true_stops_emit (GISignalInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SignalBlob *blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->true_stops_emit;
}
/* GIVFuncInfo functions */
GIVFuncInfoFlags
g_vfunc_info_get_flags (GIVFuncInfo *info)
{
GIVFuncInfoFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
if (blob->must_chain_up)
flags = flags | GI_VFUNC_MUST_CHAIN_UP;
if (blob->must_be_implemented)
flags = flags | GI_VFUNC_MUST_OVERRIDE;
if (blob->must_not_be_implemented)
flags = flags | GI_VFUNC_MUST_NOT_OVERRIDE;
return flags;
}
gint
g_vfunc_info_get_offset (GIVFuncInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->struct_offset;
}
GISignalInfo *
g_vfunc_info_get_signal (GIVFuncInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->class_closure)
return g_interface_info_get_signal ((GIInterfaceInfo *)rinfo->container, blob->signal);
return NULL;
}
/**
* g_vfunc_info_get_invoker:
* @info: a #GIVFuncInfo
*
* If this virtual function has an associated invoker method, this
* method will return it. An invoker method is a C entry point.
*
* Not all virtuals will have invokers.
*
* Returns: (transfer full): the #GIVFuncInfo or %NULL. Free it with
* g_base_info_unref() when done.
*/
GIFunctionInfo *
g_vfunc_info_get_invoker (GIVFuncInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
GIBaseInfo *container = rinfo->container;
GIInfoType parent_type;
/* 1023 = 0x3ff is the maximum of the 10 bits for invoker index */
if (blob->invoker == 1023)
return NULL;
parent_type = g_base_info_get_type (container);
if (parent_type == GI_INFO_TYPE_OBJECT)
return g_object_info_get_method ((GIObjectInfo*)container, blob->invoker);
else if (parent_type == GI_INFO_TYPE_INTERFACE)
return g_interface_info_get_method ((GIInterfaceInfo*)container, blob->invoker);
else
g_assert_not_reached ();
}
/* GIConstantInfo functions */
GITypeInfo *
g_constant_info_get_type (GIConstantInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 8);
}
gint
g_constant_info_get_value (GIConstantInfo *info,
GArgument *value)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ConstantBlob *blob = (ConstantBlob *)&rinfo->typelib->data[rinfo->offset];
/* FIXME non-basic types ? */
if (blob->type.flags.reserved == 0 && blob->type.flags.reserved2 == 0)
{
if (blob->type.flags.pointer)
value->v_pointer = g_memdup (&rinfo->typelib->data[blob->offset], blob->size);
else
{
switch (blob->type.flags.tag)
{
case GI_TYPE_TAG_BOOLEAN:
value->v_boolean = *(gboolean*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT8:
value->v_int8 = *(gint8*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT8:
value->v_uint8 = *(guint8*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT16:
value->v_int16 = *(gint16*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT16:
value->v_uint16 = *(guint16*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT32:
value->v_int32 = *(gint32*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT32:
value->v_uint32 = *(guint32*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT64:
value->v_int64 = *(gint64*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT64:
value->v_uint64 = *(guint64*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_FLOAT:
value->v_float = *(gfloat*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_DOUBLE:
value->v_double = *(gdouble*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_TIME_T:
value->v_long = *(long*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_SHORT:
value->v_short = *(gshort*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_USHORT:
value->v_ushort = *(gushort*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT:
value->v_int = *(gint*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT:
value->v_uint = *(guint*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_LONG:
value->v_long = *(glong*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_ULONG:
value->v_ulong = *(gulong*)&rinfo->typelib->data[blob->offset];
break;
}
}
}
return blob->size;
}
/* GIUnionInfo functions */
gint
g_union_info_get_n_fields (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_fields;
}
GIFieldInfo *
g_union_info_get_field (GIUnionInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
rinfo->offset + header->union_blob_size +
n * header->field_blob_size);
}
gint
g_union_info_get_n_methods (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->n_functions;
}
GIFunctionInfo *
g_union_info_get_method (GIUnionInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = rinfo->offset + header->union_blob_size
+ blob->n_fields * header->field_blob_size
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
gboolean
g_union_info_is_discriminated (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->discriminated;
}
gint
g_union_info_get_discriminator_offset (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->discriminator_offset;
}
GITypeInfo *
g_union_info_get_discriminator_type (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 24);
}
GIConstantInfo *
g_union_info_get_discriminator (GIUnionInfo *info,
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->discriminated)
{
Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = rinfo->offset + header->union_blob_size
+ blob->n_fields * header->field_blob_size
+ blob->n_functions * header->function_blob_size
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
return NULL;
}
GIFunctionInfo *
g_union_info_find_method (GIUnionInfo *info,
const gchar *name)
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->union_blob_size
+ blob->n_fields * header->field_blob_size;
return find_method ((GIBaseInfo*)info, offset, blob->n_functions, name);
}
gsize
g_union_info_get_size (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->size;
}
gsize
g_union_info_get_alignment (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->alignment;
}
|