Skip to content

Commit ae5334a

Browse files
committed
Backed out changeset f9a4c8d67be3 (bug 1582892) for build bustage at build/src/dom/console/ConsoleInstance. On a CLOSED TREE
1 parent f95a2a6 commit ae5334a

File tree

11 files changed

+30
-35
lines changed

11 files changed

+30
-35
lines changed

dom/base/ChromeUtils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,12 @@ void ChromeUtils::ClearRecentJSDevError(GlobalObject&) {
672672
return WebIDLProcType::_webidl
673673

674674
static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) {
675+
// |strings| contains an extra non-enum value, so subtract one.
675676
// Max is the value of the last enum, not the length, so add one.
676-
static_assert(
677-
WebIDLProcTypeValues::Count == static_cast<size_t>(ProcType::Max) + 1,
678-
"In order for this static cast to be okay, "
679-
"WebIDLProcType must match ProcType exactly");
677+
static_assert(ArrayLength(WebIDLProcTypeValues::strings) - 1 ==
678+
static_cast<size_t>(ProcType::Max) + 1,
679+
"In order for this static cast to be okay, "
680+
"WebIDLProcType must match ProcType exactly");
680681

681682
switch (aType) {
682683
PROCTYPE_TO_WEBIDL_CASE(Web, Web);

dom/bindings/Codegen.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10098,25 +10098,17 @@ def __init__(self, enum):
1009810098
"""
1009910099
extern const EnumEntry ${entry_array}[${entry_count}];
1010010100

10101-
static constexpr size_t Count = ${real_entry_count};
10102-
10103-
// Our "${entry_array}" contains an extra entry with a null string.
10104-
static_assert(mozilla::ArrayLength(${entry_array}) - 1 == Count,
10105-
"Mismatch between enum strings and enum count");
10106-
10107-
static_assert(static_cast<size_t>(${name}::EndGuard_) == Count,
10108-
"Mismatch between enum value and enum count");
10101+
static_assert(static_cast<size_t>(${name}::EndGuard_) == ${entry_count} - 1,
10102+
"Mismatch between enum strings and enum values");
1010910103

1011010104
inline Span<const char> GetString(${name} stringId) {
10111-
MOZ_ASSERT(static_cast<${type}>(stringId) < Count);
10105+
MOZ_ASSERT(static_cast<${type}>(stringId) < static_cast<${type}>(${name}::EndGuard_));
1011210106
const EnumEntry& entry = ${entry_array}[static_cast<${type}>(stringId)];
1011310107
return MakeSpan(entry.value, entry.length);
1011410108
}
1011510109
""",
1011610110
entry_array=ENUM_ENTRY_VARIABLE_NAME,
1011710111
entry_count=self.nEnumStrings(),
10118-
# -1 because nEnumStrings() includes a string for EndGuard_
10119-
real_entry_count=self.nEnumStrings() - 1,
1012010112
name=self.enum.identifier.name,
1012110113
type=self.underlyingType())
1012210114
strings = CGNamespace(
@@ -14939,7 +14931,6 @@ def descriptorClearsPropsInSlots(descriptor):
1493914931
cgthings.extend(CGEnum(e) for e in enums)
1494014932

1494114933
bindingDeclareHeaders["mozilla/Span.h"] = enums
14942-
bindingDeclareHeaders["mozilla/ArrayUtils.h"] = enums
1494314934

1494414935
hasCode = (descriptors or callbackDescriptors or dictionaries or
1494514936
callbacks)

dom/cache/CacheStorage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ already_AddRefed<CacheStorage> CacheStorage::Constructor(
470470
static_assert(
471471
CHROME_ONLY_NAMESPACE == (uint32_t)CacheStorageNamespace::Chrome,
472472
"Chrome namespace should match webidl Chrome enum");
473-
static_assert(NUMBER_OF_NAMESPACES == CacheStorageNamespaceValues::Count,
474-
"Number of namespace should match webidl count");
473+
static_assert(
474+
NUMBER_OF_NAMESPACES == (uint32_t)CacheStorageNamespace::EndGuard_,
475+
"Number of namespace should match webidl endguard enum");
475476

476477
Namespace ns = static_cast<Namespace>(aNamespace);
477478
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());

dom/cache/DBSchema.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static_assert(int(HeadersGuardEnum::None) == 0 &&
229229
int(HeadersGuardEnum::Request_no_cors) == 2 &&
230230
int(HeadersGuardEnum::Response) == 3 &&
231231
int(HeadersGuardEnum::Immutable) == 4 &&
232-
HeadersGuardEnumValues::Count == 5,
232+
int(HeadersGuardEnum::EndGuard_) == 5,
233233
"HeadersGuardEnum values are as expected");
234234
static_assert(int(ReferrerPolicy::_empty) == 0 &&
235235
int(ReferrerPolicy::No_referrer) == 1 &&
@@ -240,38 +240,38 @@ static_assert(int(ReferrerPolicy::_empty) == 0 &&
240240
int(ReferrerPolicy::Same_origin) == 6 &&
241241
int(ReferrerPolicy::Strict_origin) == 7 &&
242242
int(ReferrerPolicy::Strict_origin_when_cross_origin) == 8 &&
243-
ReferrerPolicyValues::Count == 9,
243+
int(ReferrerPolicy::EndGuard_) == 9,
244244
"ReferrerPolicy values are as expected");
245245
static_assert(int(RequestMode::Same_origin) == 0 &&
246246
int(RequestMode::No_cors) == 1 &&
247247
int(RequestMode::Cors) == 2 &&
248248
int(RequestMode::Navigate) == 3 &&
249-
RequestModeValues::Count == 4,
249+
int(RequestMode::EndGuard_) == 4,
250250
"RequestMode values are as expected");
251251
static_assert(int(RequestCredentials::Omit) == 0 &&
252252
int(RequestCredentials::Same_origin) == 1 &&
253253
int(RequestCredentials::Include) == 2 &&
254-
RequestCredentialsValues::Count == 3,
254+
int(RequestCredentials::EndGuard_) == 3,
255255
"RequestCredentials values are as expected");
256256
static_assert(int(RequestCache::Default) == 0 &&
257257
int(RequestCache::No_store) == 1 &&
258258
int(RequestCache::Reload) == 2 &&
259259
int(RequestCache::No_cache) == 3 &&
260260
int(RequestCache::Force_cache) == 4 &&
261261
int(RequestCache::Only_if_cached) == 5 &&
262-
RequestCacheValues::Count == 6,
262+
int(RequestCache::EndGuard_) == 6,
263263
"RequestCache values are as expected");
264264
static_assert(int(RequestRedirect::Follow) == 0 &&
265265
int(RequestRedirect::Error) == 1 &&
266266
int(RequestRedirect::Manual) == 2 &&
267-
RequestRedirectValues::Count == 3,
267+
int(RequestRedirect::EndGuard_) == 3,
268268
"RequestRedirect values are as expected");
269269
static_assert(int(ResponseType::Basic) == 0 && int(ResponseType::Cors) == 1 &&
270270
int(ResponseType::Default) == 2 &&
271271
int(ResponseType::Error) == 3 &&
272272
int(ResponseType::Opaque) == 4 &&
273273
int(ResponseType::Opaqueredirect) == 5 &&
274-
ResponseTypeValues::Count == 6,
274+
int(ResponseType::EndGuard_) == 6,
275275
"ResponseType values are as expected");
276276

277277
// If the static_asserts below fails, it means that you have changed the

dom/console/ConsoleInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ConsoleLogLevel PrefToValue(const nsAString& aPref) {
5656
return ConsoleLogLevel::All;
5757
}
5858

59-
MOZ_ASSERT(index < ConsoleLogLevelValues::Count);
59+
MOZ_ASSERT(index < (int)ConsoleLogLevel::EndGuard_);
6060
return static_cast<ConsoleLogLevel>(index);
6161
}
6262

dom/media/mediasession/MediaSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MediaSession final : public nsISupports, public nsWrapperCache {
5151
nsCOMPtr<nsPIDOMWindowInner> mParent;
5252

5353
RefPtr<MediaMetadata> mMediaMetadata;
54-
static const size_t ACTIONS = MediaSessionActionValues::Count;
54+
static const size_t ACTIONS = ArrayLength(MediaSessionActionValues::strings);
5555
RefPtr<MediaSessionActionHandler> mActionHandlers[ACTIONS] = {nullptr};
5656
};
5757

dom/permission/PermissionUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ static const nsLiteralCString kPermissionTypes[] = {
1919
// clang-format on
2020
};
2121

22-
const size_t kPermissionNameCount = PermissionNameValues::Count;
22+
// `-1` for the last null entry.
23+
const size_t kPermissionNameCount =
24+
MOZ_ARRAY_LENGTH(PermissionNameValues::strings) - 1;
2325

2426
static_assert(MOZ_ARRAY_LENGTH(kPermissionTypes) == kPermissionNameCount,
2527
"kPermissionTypes and PermissionName count should match");

dom/serviceworkers/ServiceWorkerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static_assert(nsIServiceWorkerInfo::STATE_REDUNDANT ==
4343
"ServiceWorkerState enumeration value should match state values "
4444
"from nsIServiceWorkerInfo.");
4545
static_assert(nsIServiceWorkerInfo::STATE_UNKNOWN ==
46-
ServiceWorkerStateValues::Count,
46+
static_cast<uint16_t>(ServiceWorkerState::EndGuard_),
4747
"ServiceWorkerState enumeration value should match state values "
4848
"from nsIServiceWorkerInfo.");
4949

dom/serviceworkers/ServiceWorkerManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static_assert(
127127
static_cast<uint32_t>(RequestRedirect::Manual),
128128
"RequestRedirect enumeration value should make Necko Redirect mode value.");
129129
static_assert(
130-
3 == RequestRedirectValues::Count,
130+
3 == static_cast<uint32_t>(RequestRedirect::EndGuard_),
131131
"RequestRedirect enumeration value should make Necko Redirect mode value.");
132132

133133
static_assert(
@@ -155,7 +155,7 @@ static_assert(
155155
static_cast<uint32_t>(RequestCache::Only_if_cached),
156156
"RequestCache enumeration value should match Necko Cache mode value.");
157157
static_assert(
158-
6 == RequestCacheValues::Count,
158+
6 == static_cast<uint32_t>(RequestCache::EndGuard_),
159159
"RequestCache enumeration value should match Necko Cache mode value.");
160160

161161
static_assert(static_cast<uint16_t>(ServiceWorkerUpdateViaCache::Imports) ==

dom/webauthn/WebAuthnManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
539539
NS_ConvertUTF16toUTF8 cStr(str);
540540
int i = FindEnumStringIndexImpl(
541541
cStr.get(), cStr.Length(), AuthenticatorTransportValues::strings);
542-
if (i < 0) {
542+
if (i < 0 ||
543+
i >= static_cast<int>(AuthenticatorTransport::EndGuard_)) {
543544
continue; // Unknown enum
544545
}
545546
AuthenticatorTransport t = static_cast<AuthenticatorTransport>(i);

toolkit/components/extensions/ExtensionPolicyService.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,12 @@ nsresult ExtensionPolicyService::InjectContentScripts(
350350
DocInfo docInfo(win);
351351

352352
using RunAt = dom::ContentScriptRunAt;
353-
namespace RunAtValues = dom::ContentScriptRunAtValues;
354353
using Scripts = AutoTArray<RefPtr<WebExtensionContentScript>, 8>;
355354

356-
Scripts scripts[RunAtValues::Count];
355+
constexpr uint8_t n = uint8_t(RunAt::EndGuard_);
356+
Scripts scripts[n];
357357

358358
auto GetScripts = [&](RunAt aRunAt) -> Scripts&& {
359-
static_assert(sizeof(aRunAt) == 1, "Our cast is wrong");
360359
return std::move(scripts[uint8_t(aRunAt)]);
361360
};
362361

0 commit comments

Comments
 (0)