Closed Bug 1582892 Opened 4 months ago Closed 3 months ago

Expose the size of the enum items in the webidl

Categories

(Core :: DOM: Bindings (WebIDL), enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: chunmin, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

Sometime we would like to know the number of the enum items in the webidl. For now we can only use EndGuard_ or ArrayLength(*Values::strings)to get this value. It would be good if this value can be defined in the binding header.

For example, to know the number of items in num CacheStorageNamespace, we would use CacheStorageNamespace::EndGuard_ or ArrayLength(CacheStorageNamespaceValues::strings)

Priority: -- → P3
Depends on: 1589285

or ArrayLength(*Values::strings)

And that doesn't even give the right answer (it's 1 too big)...

Assignee: nobody → bzbarsky
Priority: P3 → P1
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f9a4c8d67be3
Expose the number of strings in a Web IDL enum in a nice way.  r=edgar

Backed out changeset f9a4c8d67be3 (Bug 1582892) for build bustage at build/src/dom/console/ConsoleInstance.

Push with failure: https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=272512689&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&revision=f9a4c8d67be3cbd983306cd90af9737a04cd50f1

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=272512767&repo=autoland&lineNumber=33539

Backout link: https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=272512689&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&revision=368720d0e3ddff1961fb5aee4a22917ee5ce9033

[task 2019-10-23T03:13:31.565Z] 03:13:31     INFO -  make[4]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/dom/serviceworkers/test/gtest'
[task 2019-10-23T03:13:31.566Z] 03:13:31     INFO -  make[4]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/dom/serviceworkers/test/gtest'
[task 2019-10-23T03:13:31.567Z] 03:13:31     INFO -  dom/serviceworkers/test/gtest/Unified_cpp_test_gtest0.o
[task 2019-10-23T03:13:31.568Z] 03:13:31     INFO -  make[4]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/dom/serviceworkers/test/gtest'
[task 2019-10-23T03:13:33.074Z] 03:13:33     INFO -  make[4]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/dom/console'
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ -m32 -o Unified_cpp_dom_console0.o -c  -I/builds/worker/workspace/build/src/obj-firefox/dist/stl_wrappers -I/builds/worker/workspace/build/src/obj-firefox/dist/system_wrappers -include /builds/worker/workspace/build/src/config/gcc_hidden.h -DDEBUG=1 -DOS_POSIX=1 -DOS_LINUX=1 -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -I/builds/worker/workspace/build/src/dom/console -I/builds/worker/workspace/build/src/obj-firefox/dom/console -I/builds/worker/workspace/build/src/docshell/base -I/builds/worker/workspace/build/src/dom/base -I/builds/worker/workspace/build/src/js/xpconnect/src -I/builds/worker/workspace/build/src/obj-firefox/ipc/ipdl/_ipdlheaders -I/builds/worker/workspace/build/src/ipc/chromium/src -I/builds/worker/workspace/build/src/ipc/glue -I/builds/worker/workspace/build/src/obj-firefox/dist/include -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nspr -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /builds/worker/workspace/build/src/obj-firefox/mozilla-config.h -Qunused-arguments -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wc++1z-compat -Wc++2a-compat -Wcomma -Wimplicit-fallthrough -Werror=non-literal-null-conversion -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-unknown-warning-option -Wno-return-type-c-linkage -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -fno-aligned-new -fcrash-diagnostics-dir=/builds/worker/artifacts -march=pentium-m -msse -msse2 -mfpmath=sse -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -Xclang -load -Xclang /builds/worker/workspace/build/src/obj-firefox/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -Os -fno-omit-frame-pointer -funwind-tables -Werror  -MD -MP -MF .deps/Unified_cpp_dom_console0.o.pp   Unified_cpp_dom_console0.cpp
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -  In file included from Unified_cpp_dom_console0.cpp:11:
[task 2019-10-23T03:13:33.078Z] 03:13:33    ERROR -  /builds/worker/workspace/build/src/dom/console/ConsoleInstance.cpp:59:20: error: comparison of integers of different signs: 'int' and 'const size_t' (aka 'const unsigned int') [-Werror,-Wsign-compare]
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -    MOZ_ASSERT(index < ConsoleLogLevelValues::Count);
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -               ~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/Assertions.h:492:24: note: expanded from macro 'MOZ_ASSERT'
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -          ("MOZ_ASSERT", __VA_ARGS__))
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -                         ^~~~~~~~~~~
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/Assertions.h:482:33: note: expanded from macro 'MOZ_ASSERT_GLUE'
[task 2019-10-23T03:13:33.078Z] 03:13:33     INFO -  #define MOZ_ASSERT_GLUE(a, b) a b
[task 2019-10-23T03:13:33.080Z] 03:13:33     INFO -                                  ^
[task 2019-10-23T03:13:33.080Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/Assertions.h:464:51: note: expanded from macro 'MOZ_ASSERT_HELPER1'
[task 2019-10-23T03:13:33.080Z] 03:13:33     INFO -      if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) {    \
[task 2019-10-23T03:13:33.080Z] 03:13:33     INFO -                                                    ^~~~
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/StaticAnalysisFunctions.h:61:73: note: expanded from macro 'MOZ_CHECK_ASSERT_ASSIGNMENT'
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -  #  define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) MOZ_AssertAssignmentTest(!!(expr))
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -                                                                          ^~~~
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/Likely.h:17:48: note: expanded from macro 'MOZ_UNLIKELY'
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -  #  define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0))
[task 2019-10-23T03:13:33.081Z] 03:13:33     INFO -                                                 ^
[task 2019-10-23T03:13:33.082Z] 03:13:33     INFO -  1 error generated.
[task 2019-10-23T03:13:33.082Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/config/rules.mk:787: recipe for target 'Unified_cpp_dom_console0.o' failed
[task 2019-10-23T03:13:33.083Z] 03:13:33    ERROR -  make[4]: *** [Unified_cpp_dom_console0.o] Error 1
[task 2019-10-23T03:13:33.083Z] 03:13:33     INFO -  make[4]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/dom/console'
[task 2019-10-23T03:13:33.086Z] 03:13:33     INFO -  /builds/worker/workspace/build/src/config/recurse.mk:74: recipe for target 'dom/console/target-objects' failed
[task 2019-10-23T03:13:33.086Z] 03:13:33    ERROR -  make[3]: *** [dom/console/target-objects] Error 2
[task 2019-10-23T03:13:33.086Z] 03:13:33     INFO -  make[3]: *** Waiting for unfinished jobs....
[task 2019-10-23T03:13:33.086Z] 03:13:33     INFO -  make[4]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/dom/serviceworkers'
[task 2019-10-23T03:13:33.086Z] 03:13:33     INFO -  dom/serviceworkers/Unified_cpp_dom_serviceworkers1.o
[task 2019-10-23T03:13:33.086Z] 03:13:33     INFO -  make[4]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/dom/serviceworkers'
[task 2019-10-23T03:13:34.121Z] 03:13:34     INFO -  make[4]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/dom/xslt/xslt'
Flags: needinfo?(bzbarsky)

Gah, warnings as errors and different platforms...

Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a821d19de073
Expose the number of strings in a Web IDL enum in a nice way.  r=edgar
Flags: needinfo?(bzbarsky)
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.