Better Mojo support for bitfield and/or enum bitfield |
|||
Issue descriptionWhen converting to mojo FramePolicy I faced 2 bitfields (http://crrev/c/784372): - WebInsecureRequestPolicy [1] - A plain uint8_t bitfield, serialized as uint8 on Mojo interface [2]. - WebSandboxFlags [3] - An enum class bitfield with some constexpr for overloading some operators. In Mojo represented as a duplicated [[Extensible]] enum [4]. This bug is to track possibility to improve Mojo support for this sort of types because the typemap felt as unnecessary work and duplicated some definitions. A simplistic assessment brings the number of potential candidates to ~150 types; enum/enum class with bit shifts (likely to be bitfield): $ git ls-files | grep -E '*\.(cc|cpp|h)$' | xargs egrep -A 7 "^\s*enum (class .* : .*int.*)?" | egrep "k.* = 1 << 1" |wc -l 152 [1] - https://cs.chromium.org/chromium/src/third_party/WebKit/public/platform/WebInsecureRequestPolicy.h [2] - https://cs.chromium.org/chromium/src/content/common/frame.mojom [3] - https://cs.chromium.org/chromium/src/third_party/WebKit/common/sandbox_flags.h [4] - https://cs.chromium.org/chromium/src/third_party/WebKit/common/feature_policy/feature_policy.mojom
,
Jan 9 2018
,
Dec 3
Mojoms should not use bitfields, they should use structs with explicit bool fields. The serialized packing is efficient, and this is a much less error-prone way of expressing the same thing. |
|||
►
Sign in to add a comment |
|||
Comment 1 by yzshen@chromium.org
, Dec 19 2017