OK, I'm stumped on this one: dstep, struct, mixin, bitfields
Russel Winder
russel at winder.org.uk
Wed Mar 21 18:00:38 UTC 2018
The code I am playing with generated by DStep involves lots of lots of
structs with mixin bitfields. All of them seem to compile file, except
one. How is it that:
mixin(bitfields!(
ubyte, "current_next", 1,
ubyte, "version", 5,
ubyte, "one2", 2)); /* TS ID */
can result in the following error. The line for "version" is 141 and
the one for "one2" is 142.
source/libdvbv5_d/header.d-mixin-139(141): Error: no identifier for declarator `ubyte`
source/libdvbv5_d/header.d-mixin-139(141): Error: identifier or integer expected inside version(...), not `)`
source/libdvbv5_d/header.d-mixin-139(141): Error: found `@` when expecting `)`
source/libdvbv5_d/header.d-mixin-139(141): Error: no identifier for declarator `safe`
source/libdvbv5_d/header.d-mixin-139(141): Error: declaration expected, not `return`
source/libdvbv5_d/header.d-mixin-139(142): Error: no identifier for declarator `void`
source/libdvbv5_d/header.d-mixin-139(142): Error: identifier or integer expected inside version(...), not `ubyte`
source/libdvbv5_d/header.d-mixin-139(142): Error: found `v` when expecting `)`
source/libdvbv5_d/header.d-mixin-139(142): Error: declaration expected, not `)`
source/libdvbv5_d/header.d-mixin-139(142): Error: declaration expected, not `assert`
source/libdvbv5_d/header.d-mixin-139(142): Error: no identifier for declarator `_current_next_version_one2`
source/libdvbv5_d/header.d-mixin-139(142): Error: declaration expected, not `=`
source/libdvbv5_d/header.d(139): Error: incomplete mixin declaration `"private ubyte _current_next_version_one2;@property ubyte current_next() @safe pure nothrow @nogc const { auto result = (_current_next_version_one2 & 1U) >>0U; return cast(ubyte) result;}\x0a at property void current_next(ubyte v) @safe pure nothrow @nogc { assert(v >= current_next_min, \"Value is smaller than the minimum value of bitfield 'current_next'\"); assert(v <= current_next_max, \"Value is greater than the maximum value of bitfield 'current_next'\"); _current_next_version_one2 = cast(typeof(_current_next_version_one2)) ((_current_next_version_one2 & (-1-cast(typeof(_current_next_version_one2))1U)) | ((cast(typeof(_current_next_version_one2)) v << 0U) & 1U));}\x0aenum ubyte current_next_min = cast(ubyte)0U; enum ubyte current_next_max = cast(ubyte)1U; @property ubyte version() @safe pure nothrow @nogc const { auto result = (_current_next_version_one2 & 62U) >>1U; return cast(ubyte) result;}\x0a at property void version(ubyte v) @safe pure nothrow @nogc { assert(v >= version_min, \"Value is smaller than the minimum value of bitfield 'version'\"); assert(v <= version_max, \"Value is greater than the maximum value of bitfield 'version'\"); _current_next_version_one2 = cast(typeof(_current_next_version_one2)) ((_current_next_version_one2 & (-1-cast(typeof(_current_next_version_one2))62U)) | ((cast(typeof(_current_next_version_one2)) v << 1U) & 62U));}\x0aenum ubyte version_min = cast(ubyte)0U; enum ubyte version_max = cast(ubyte)31U; @property ubyte one2() @safe pure nothrow @nogc const { auto result = (_current_next_version_one2 & 192U) >>6U; return cast(ubyte) result;}\x0a at property void one2(ubyte v) @safe pure nothrow @nogc { assert(v >= one2_min, \"Value is smaller than the minimum value of bitfield 'one2'\"); assert(v <= one2_max, \"Value is greater than the maximum value of bitfield 'one2'\"); _current_next_version_one2 = cast(typeof(_current_next_version_one2)) ((_current_next_version_one2 & (-1-cast(typeof(_current_next_version_one2))192U)) | ((cast(typeof(_current_next_version_one2)) v << 6U) & 192U));}\x0aenum ubyte one2_min = cast(ubyte)0U; enum ubyte one2_max = cast(ubyte)3U; "`
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180321/35da8baa/attachment.sig>
More information about the Digitalmars-d-learn
mailing list