@@ -56,6 +56,8 @@ $(GNAME TraitsKeyword):
56
56
$(RELATIVE_LINK2 fullyQualifiedName, $(D fullyQualifiedName))
57
57
$(RELATIVE_LINK2 getAliasThis, $(D getAliasThis))
58
58
$(RELATIVE_LINK2 getAttributes, $(D getAttributes))
59
+ $(RELATIVE_LINK2 getBitfieldOffset, $(D getBitfieldOffset))
60
+ $(RELATIVE_LINK2 getBitfieldWidth, $(D getBitfieldWidth))
59
61
$(RELATIVE_LINK2 getFunctionAttributes, $(D getFunctionAttributes))
60
62
$(RELATIVE_LINK2 getFunctionVariadicStyle, $(D getFunctionVariadicStyle))
61
63
$(RELATIVE_LINK2 getLinkage, $(D getLinkage))
@@ -1351,6 +1353,55 @@ tuple((Foo))
1351
1353
)
1352
1354
)
1353
1355
1356
+ $(SECTION3 $(GNAME getBitfieldOffset),
1357
+ $(P Takes one argument, a qualified name that resolve to a field in a struct or class.
1358
+ )
1359
+ $(P If the field is a bitfield, it returns as a `uint` the bit number of the least significant
1360
+ bit in the field. The rightmost bit is at offset 0, the leftmost bit is at offset 31 (for
1361
+ 32 bit int fields).
1362
+ )
1363
+ $(P If the field is a not bitfield, it returns as a `uint` the number 0.
1364
+ )
1365
+
1366
+ $(SPEC_RUNNABLE_EXAMPLE_FAIL
1367
+ ---
1368
+ // OK with -preview=bitfields
1369
+ struct S
1370
+ {
1371
+ int a,b;
1372
+ int :2, c:3;
1373
+ }
1374
+
1375
+ static assert(__traits(getBitfieldOffset, S.b) == 0);
1376
+ static assert(__traits(getBitfieldOffset, S.c) == 2);
1377
+ ---
1378
+ )
1379
+
1380
+ )
1381
+
1382
+ $(SECTION3 $(GNAME getBitfieldWidth),
1383
+ $(P Takes one argument, a qualified name that resolve to a field in a struct or class.
1384
+ )
1385
+ $(P If the field is a bitfield, it returns as a `uint` the width of the bit field as
1386
+ a number of bits.
1387
+ )
1388
+ $(P If the field is a not bitfield, it returns the number of bits in the type.
1389
+ )
1390
+ $(SPEC_RUNNABLE_EXAMPLE_FAIL
1391
+ ---
1392
+ // OK with -preview=bitfields
1393
+ struct S
1394
+ {
1395
+ int a,b;
1396
+ int :2, c:3;
1397
+ }
1398
+
1399
+ static assert(__traits(getBitfieldWidth, S.b) == 32);
1400
+ static assert(__traits(getBitfieldWidth, S.c) == 3);
1401
+ ---
1402
+ )
1403
+ )
1404
+
1354
1405
$(H3 $(GNAME getLinkage))
1355
1406
1356
1407
$(P Takes one argument, which is a declaration symbol, or the type of a function, delegate,
0 commit comments