New issue
Advanced search Search tips

Issue 796052 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 3
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Better Mojo support for bitfield and/or enum bitfield

Project Member Reported by lucmult@chromium.org, Dec 19 2017

Issue description

When 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


 

Comment 1 by yzshen@chromium.org, Dec 19 2017

In the WebSandboxFlags case, Mojo doesn't prevent you from using the mojom-defined enum directly and optionally adding operator overloads yourself [*], right?

What improvements do you have in mind?

============================================
[*] The generated type is just a simple C++ enum class. You could 
define operator overloads with that generated type as you like.
Labels: -Type-Bug Type-Feature
Owner: ----
Status: WontFix (was: Untriaged)
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