New issue
Advanced search Search tips

Issue 860116 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature

Blocked on:
issue 855968


Participants' hotlists:
Hotlist-Bindings-IDLCompiler


Sign in to add a comment

Determine whether or not a dictionary has any members present, or if it is empty

Project Member Reported by yhirano@chromium.org, Jul 4

Issue description

Fetch spec has the check, and we would like each dictionary to have such a predicate. Currently we list (supported) members manually but it's error prone.
 
Cc: peria@chromium.org
Blockedon: 855968
Labels: Hotlist-Bindings-IDLCompiler
Owner: peria@chromium.org
Status: Assigned (was: Untriaged)
JFYI, now from Blink C++ code, you can use
  dict.hasMember() -->  returns true iff the member is present
  dict.member() --> returns nullptr if the member is not present or 'null'
for nullable interface members.
Summary: Determine whether or not a dictionary has any members present, or if it is empty (was: If any of <dictionary>'s members are present...)
Two things:

1.)

> dict.hasMember() -->  returns true iff the member is present

Hmm, this is not my experience given a fresh rebase and build. Like before, `hasMember()` returns false for me when a given nullable interface's developer-provided value is `null`. For example, with `new Request("", {signal: null})`, `init.hasSignal()` returns false for me. This is because the generated code still sets `has_signal_ = false` in the generated `setSignalToNull()`. Will this be fixed peria@?

2.) I think yhirano@'s intention with this issue was to provide a better (more native) way to perform [1]. I've changed the title a bit. Basically we have a situation where we need to know if a dictionary was given any valid values at all, or if is completely empty. With this in mind, it might be nice to have all dictionaries supply a `areAnyMembersSet()` (returns bool). This requires all dictionaries to carry around an extra member, which will probably make the binary bigger, so I'm not sure if it will be accepted.

[1]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/fetch/request.cc?q=fetch/request.cc&sq=package:chromium&g=0&l=82
IDL compiler was updated, and I think it works as #3.
Please let me know again if something works as not intended.
Labels: -Type-Bug Type-Feature
yhirano@ told me that my understanding was wrong. I missed 2) in #4.
My update was only for 1).
Do you have plans to address 2) in #4, or is that a WONTFIX?
Not WONTFIX, but I have no plan to address it at the moment.
This is a FR, so it depends on your request priority.

As you know, current hasFoo() functions do not figure their presences precisely.
So I wonder whether it is good to have a function like anyMemberPresent() using hasFoo().
Makes sense. It'd be nice to have, but not a very high priority at this point, as it is unlikely that more members will be added to RequestInit in the short-term.
Feel free to raise this priority if you think this feature is needed. :)
Technically it is not difficult.

Sign in to add a comment