mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Upgrade WebKit to d5bd162d9ab2 (#25958)
This commit is contained in:
@@ -6,8 +6,7 @@ To do that:
|
|||||||
- git fetch upstream
|
- git fetch upstream
|
||||||
- git merge upstream main
|
- git merge upstream main
|
||||||
- Fix the merge conflicts
|
- Fix the merge conflicts
|
||||||
- cd ../../ (back to bun)
|
- bun build.ts debug
|
||||||
- make jsc-build (this will take about 7 minutes)
|
|
||||||
- While it compiles, in another task review the JSC commits between the last version of Webkit and the new version. Write up a summary of the webkit changes in a file called "webkit-changes.md"
|
- While it compiles, in another task review the JSC commits between the last version of Webkit and the new version. Write up a summary of the webkit changes in a file called "webkit-changes.md"
|
||||||
- bun run build:local (build a build of Bun with the new Webkit, make sure it compiles)
|
- bun run build:local (build a build of Bun with the new Webkit, make sure it compiles)
|
||||||
- After making sure it compiles, run some code to make sure things work. something like ./build/debug-local/bun-debug --print '42' should be all you need
|
- After making sure it compiles, run some code to make sure things work. something like ./build/debug-local/bun-debug --print '42' should be all you need
|
||||||
@@ -21,3 +20,7 @@ To do that:
|
|||||||
- commit + push (without adding the webkit-changes.md file)
|
- commit + push (without adding the webkit-changes.md file)
|
||||||
- create PR titled "Upgrade Webkit to the <commit-sha>", paste your webkit-changes.md into the PR description
|
- create PR titled "Upgrade Webkit to the <commit-sha>", paste your webkit-changes.md into the PR description
|
||||||
- delete the webkit-changes.md file
|
- delete the webkit-changes.md file
|
||||||
|
|
||||||
|
Things to check for a successful upgrade:
|
||||||
|
- Did JSType in vendor/WebKit/Source/JavaScriptCore have any recent changes? Does the enum values align with whats present in src/bun.js/bindings/JSType.zig?
|
||||||
|
- Were there any changes to the webcore code generator? If there are C++ compilation errors, check for differences in some of the generated code in like vendor/WebKit/source/WebCore/bindings/scripts/test/JS/
|
||||||
|
|||||||
@@ -1310,6 +1310,9 @@ if(WIN32)
|
|||||||
wsock32 # ws2_32 required by TransmitFile aka sendfile on windows
|
wsock32 # ws2_32 required by TransmitFile aka sendfile on windows
|
||||||
delayimp.lib
|
delayimp.lib
|
||||||
)
|
)
|
||||||
|
# Required for static ICU linkage - without this, ICU headers expect DLL linkage
|
||||||
|
# which causes ABI mismatch and crashes (STATUS_STACK_BUFFER_OVERRUN)
|
||||||
|
target_compile_definitions(${bun} PRIVATE U_STATIC_IMPLEMENTATION)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Packaging ---
|
# --- Packaging ---
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use")
|
|||||||
option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading")
|
option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading")
|
||||||
|
|
||||||
if(NOT WEBKIT_VERSION)
|
if(NOT WEBKIT_VERSION)
|
||||||
set(WEBKIT_VERSION 1d0216219a3c52cb85195f48f19ba7d5db747ff7)
|
set(WEBKIT_VERSION c4d4cae03ecef2791f7ad5dd795f722d8be87d41)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX)
|
string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX)
|
||||||
@@ -33,8 +33,8 @@ if(WEBKIT_LOCAL)
|
|||||||
${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders
|
${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders
|
||||||
${WEBKIT_PATH}/bmalloc/Headers
|
${WEBKIT_PATH}/bmalloc/Headers
|
||||||
${WEBKIT_PATH}/WTF/Headers
|
${WEBKIT_PATH}/WTF/Headers
|
||||||
${WEBKIT_PATH}/JavaScriptCore/DerivedSources/inspector
|
|
||||||
${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders/JavaScriptCore
|
${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders/JavaScriptCore
|
||||||
|
${WEBKIT_PATH}/JavaScriptCore/DerivedSources/inspector
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace WebCore {
|
|||||||
class JSHeapData;
|
class JSHeapData;
|
||||||
|
|
||||||
class DOMGCOutputConstraint : public JSC::MarkingConstraint {
|
class DOMGCOutputConstraint : public JSC::MarkingConstraint {
|
||||||
WTF_DEPRECATED_MAKE_FAST_ALLOCATED(DOMEGCOutputConstraint);
|
WTF_DEPRECATED_MAKE_FAST_ALLOCATED(DOMGCOutputConstraint);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DOMGCOutputConstraint(JSC::VM&, JSHeapData&);
|
DOMGCOutputConstraint(JSC::VM&, JSHeapData&);
|
||||||
|
|||||||
@@ -730,13 +730,18 @@ JSC::ScriptExecutionStatus Zig::GlobalObject::scriptExecutionStatus(JSC::JSGloba
|
|||||||
|
|
||||||
void unsafeEvalNoop(JSGlobalObject*, const WTF::String&) {}
|
void unsafeEvalNoop(JSGlobalObject*, const WTF::String&) {}
|
||||||
|
|
||||||
|
static void queueMicrotaskToEventLoop(JSGlobalObject& globalObject, QueuedTask&& task)
|
||||||
|
{
|
||||||
|
globalObject.vm().queueMicrotask(WTF::move(task));
|
||||||
|
}
|
||||||
|
|
||||||
const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable()
|
const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable()
|
||||||
{
|
{
|
||||||
static const JSC::GlobalObjectMethodTable table = {
|
static const JSC::GlobalObjectMethodTable table = {
|
||||||
&supportsRichSourceInfo,
|
&supportsRichSourceInfo,
|
||||||
&shouldInterruptScript,
|
&shouldInterruptScript,
|
||||||
&javaScriptRuntimeFlags,
|
&javaScriptRuntimeFlags,
|
||||||
nullptr, // &queueMicrotaskToEventLoop, // queueTaskToEventLoop
|
&queueMicrotaskToEventLoop,
|
||||||
nullptr, // &shouldInterruptScriptBeforeTimeout,
|
nullptr, // &shouldInterruptScriptBeforeTimeout,
|
||||||
&moduleLoaderImportModule, // moduleLoaderImportModule
|
&moduleLoaderImportModule, // moduleLoaderImportModule
|
||||||
&moduleLoaderResolve, // moduleLoaderResolve
|
&moduleLoaderResolve, // moduleLoaderResolve
|
||||||
@@ -765,8 +770,7 @@ const JSC::GlobalObjectMethodTable& EvalGlobalObject::globalObjectMethodTable()
|
|||||||
&supportsRichSourceInfo,
|
&supportsRichSourceInfo,
|
||||||
&shouldInterruptScript,
|
&shouldInterruptScript,
|
||||||
&javaScriptRuntimeFlags,
|
&javaScriptRuntimeFlags,
|
||||||
// &queueMicrotaskToEventLoop, // queueTaskToEventLoop
|
&queueMicrotaskToEventLoop,
|
||||||
nullptr,
|
|
||||||
nullptr, // &shouldInterruptScriptBeforeTimeout,
|
nullptr, // &shouldInterruptScriptBeforeTimeout,
|
||||||
&moduleLoaderImportModule, // moduleLoaderImportModule
|
&moduleLoaderImportModule, // moduleLoaderImportModule
|
||||||
&moduleLoaderResolve, // moduleLoaderResolve
|
&moduleLoaderResolve, // moduleLoaderResolve
|
||||||
@@ -1072,7 +1076,7 @@ JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask,
|
|||||||
// BunPerformMicrotaskJob accepts a variable number of arguments (up to: performMicrotask, job, asyncContext, arg0, arg1).
|
// BunPerformMicrotaskJob accepts a variable number of arguments (up to: performMicrotask, job, asyncContext, arg0, arg1).
|
||||||
// The runtime inspects argumentCount to determine which arguments are present, so callers may pass only the subset they need.
|
// The runtime inspects argumentCount to determine which arguments are present, so callers may pass only the subset they need.
|
||||||
// Here we pass: function, callback, asyncContext.
|
// Here we pass: function, callback, asyncContext.
|
||||||
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, globalObject, function, callback, asyncContext };
|
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, 0, globalObject, function, callback, asyncContext };
|
||||||
globalObject->vm().queueMicrotask(WTF::move(task));
|
globalObject->vm().queueMicrotask(WTF::move(task));
|
||||||
|
|
||||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||||
@@ -3103,7 +3107,7 @@ extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Zig::GlobalObject* g
|
|||||||
|
|
||||||
// Do not use JSCell* here because the GC will try to visit it.
|
// Do not use JSCell* here because the GC will try to visit it.
|
||||||
// Use BunInvokeJobWithArguments to pass the two arguments (ptr and callback) to the trampoline function
|
// Use BunInvokeJobWithArguments to pass the two arguments (ptr and callback) to the trampoline function
|
||||||
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunInvokeJobWithArguments, globalObject, function, JSValue(std::bit_cast<double>(reinterpret_cast<uintptr_t>(ptr))), JSValue(std::bit_cast<double>(reinterpret_cast<uintptr_t>(callback))) };
|
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunInvokeJobWithArguments, 0, globalObject, function, JSValue(std::bit_cast<double>(reinterpret_cast<uintptr_t>(ptr))), JSValue(std::bit_cast<double>(reinterpret_cast<uintptr_t>(callback))) };
|
||||||
globalObject->vm().queueMicrotask(WTF::move(task));
|
globalObject->vm().queueMicrotask(WTF::move(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3540,7 +3540,7 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC::JSPromise* promise, JSC::J
|
|||||||
value = jsUndefined();
|
value = jsUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, globalObject, microtaskFunction, rejectPromiseFunction, globalObject->m_asyncContextData.get()->getInternalField(0), promise, value };
|
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, 0, globalObject, microtaskFunction, rejectPromiseFunction, globalObject->m_asyncContextData.get()->getInternalField(0), promise, value };
|
||||||
globalObject->vm().queueMicrotask(WTF::move(task));
|
globalObject->vm().queueMicrotask(WTF::move(task));
|
||||||
RETURN_IF_EXCEPTION(scope, );
|
RETURN_IF_EXCEPTION(scope, );
|
||||||
}
|
}
|
||||||
@@ -5428,7 +5428,7 @@ extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC::JSGlobalObject* arg0
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, globalObject, microTaskFunction, WTF::move(microtaskArgs[0]), WTF::move(microtaskArgs[1]), WTF::move(microtaskArgs[2]), WTF::move(microtaskArgs[3]) };
|
JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, 0, globalObject, microTaskFunction, WTF::move(microtaskArgs[0]), WTF::move(microtaskArgs[1]), WTF::move(microtaskArgs[2]), WTF::move(microtaskArgs[3]) };
|
||||||
globalObject->vm().queueMicrotask(WTF::move(task));
|
globalObject->vm().queueMicrotask(WTF::move(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ JSC_DECLARE_HOST_FUNCTION(jsVerifyOneShot);
|
|||||||
static const unsigned int NoDsaSignature = static_cast<unsigned int>(-1);
|
static const unsigned int NoDsaSignature = static_cast<unsigned int>(-1);
|
||||||
|
|
||||||
struct SignJobCtx {
|
struct SignJobCtx {
|
||||||
WTF_MAKE_TZONE_ALLOCATED(name);
|
WTF_MAKE_TZONE_ALLOCATED(SignJobCtx);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ struct EventInit {
|
|||||||
bool composed { false };
|
bool composed { false };
|
||||||
|
|
||||||
template<class Encoder> void encode(Encoder&) const;
|
template<class Encoder> void encode(Encoder&) const;
|
||||||
template<class Decoder> WARN_UNUSED_RETURN static bool decode(Decoder&, EventInit&);
|
template<class Decoder> [[nodiscard]] static bool decode(Decoder&, EventInit&);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Encoder>
|
template<class Encoder>
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Encoder> void encode(Encoder &) const;
|
template<class Encoder> void encode(Encoder &) const;
|
||||||
template<class Decoder> WARN_UNUSED_RETURN static bool decode(Decoder &, HTTPHeaderMap &);
|
template<class Decoder> [[nodiscard]] static bool decode(Decoder &, HTTPHeaderMap &);
|
||||||
void setUncommonHeader(const String &name, const String &value);
|
void setUncommonHeader(const String &name, const String &value);
|
||||||
void setUncommonHeaderCloneName(const StringView name, const String &value);
|
void setUncommonHeaderCloneName(const StringView name, const String &value);
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace WebCore {
|
|||||||
|
|
||||||
using NavigationTimingFunction = unsigned long long (PerformanceTiming::*)() const;
|
using NavigationTimingFunction = unsigned long long (PerformanceTiming::*)() const;
|
||||||
|
|
||||||
static constexpr std::array<std::pair<ComparableASCIILiteral, NavigationTimingFunction>, 21> restrictedMarkMappings { {
|
static constexpr SortedArrayMap restrictedMarkFunctions { std::to_array<std::pair<ComparableASCIILiteral, NavigationTimingFunction>>({
|
||||||
{ "connectEnd"_s, &PerformanceTiming::connectEnd },
|
{ "connectEnd"_s, &PerformanceTiming::connectEnd },
|
||||||
{ "connectStart"_s, &PerformanceTiming::connectStart },
|
{ "connectStart"_s, &PerformanceTiming::connectStart },
|
||||||
{ "domComplete"_s, &PerformanceTiming::domComplete },
|
{ "domComplete"_s, &PerformanceTiming::domComplete },
|
||||||
@@ -65,8 +65,7 @@ static constexpr std::array<std::pair<ComparableASCIILiteral, NavigationTimingFu
|
|||||||
{ "secureConnectionStart"_s, &PerformanceTiming::secureConnectionStart },
|
{ "secureConnectionStart"_s, &PerformanceTiming::secureConnectionStart },
|
||||||
{ "unloadEventEnd"_s, &PerformanceTiming::unloadEventEnd },
|
{ "unloadEventEnd"_s, &PerformanceTiming::unloadEventEnd },
|
||||||
{ "unloadEventStart"_s, &PerformanceTiming::unloadEventStart },
|
{ "unloadEventStart"_s, &PerformanceTiming::unloadEventStart },
|
||||||
} };
|
}) };
|
||||||
static constexpr SortedArrayMap restrictedMarkFunctions { restrictedMarkMappings };
|
|
||||||
|
|
||||||
bool PerformanceUserTiming::isRestrictedMarkName(const String& markName)
|
bool PerformanceUserTiming::isRestrictedMarkName(const String& markName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,12 +87,11 @@ template<> JSString* convertEnumerationToJS(JSGlobalObject& lexicalGlobalObject,
|
|||||||
template<> std::optional<CryptoKey::Type> parseEnumeration<CryptoKey::Type>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
template<> std::optional<CryptoKey::Type> parseEnumeration<CryptoKey::Type>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
||||||
{
|
{
|
||||||
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
||||||
static constexpr std::array<std::pair<ComparableASCIILiteral, CryptoKey::Type>, 3> mappings { {
|
static constexpr SortedArrayMap enumerationMapping { std::to_array<std::pair<ComparableASCIILiteral, CryptoKey::Type>>({
|
||||||
{ "private"_s, CryptoKey::Type::Private },
|
{ "private"_s, CryptoKey::Type::Private },
|
||||||
{ "public"_s, CryptoKey::Type::Public },
|
{ "public"_s, CryptoKey::Type::Public },
|
||||||
{ "secret"_s, CryptoKey::Type::Secret },
|
{ "secret"_s, CryptoKey::Type::Secret },
|
||||||
} };
|
}) };
|
||||||
static constexpr SortedArrayMap enumerationMapping { mappings };
|
|
||||||
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
||||||
return *enumerationValue;
|
return *enumerationValue;
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ template<> JSString* convertEnumerationToJS(JSGlobalObject& lexicalGlobalObject,
|
|||||||
template<> std::optional<CryptoKeyUsage> parseEnumeration<CryptoKeyUsage>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
template<> std::optional<CryptoKeyUsage> parseEnumeration<CryptoKeyUsage>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
||||||
{
|
{
|
||||||
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
||||||
static constexpr std::array<std::pair<ComparableASCIILiteral, CryptoKeyUsage>, 8> mappings { {
|
static constexpr SortedArrayMap enumerationMapping { std::to_array<std::pair<ComparableASCIILiteral, CryptoKeyUsage>>({
|
||||||
{ "decrypt"_s, CryptoKeyUsage::Decrypt },
|
{ "decrypt"_s, CryptoKeyUsage::Decrypt },
|
||||||
{ "deriveBits"_s, CryptoKeyUsage::DeriveBits },
|
{ "deriveBits"_s, CryptoKeyUsage::DeriveBits },
|
||||||
{ "deriveKey"_s, CryptoKeyUsage::DeriveKey },
|
{ "deriveKey"_s, CryptoKeyUsage::DeriveKey },
|
||||||
@@ -73,8 +73,7 @@ template<> std::optional<CryptoKeyUsage> parseEnumeration<CryptoKeyUsage>(JSGlob
|
|||||||
{ "unwrapKey"_s, CryptoKeyUsage::UnwrapKey },
|
{ "unwrapKey"_s, CryptoKeyUsage::UnwrapKey },
|
||||||
{ "verify"_s, CryptoKeyUsage::Verify },
|
{ "verify"_s, CryptoKeyUsage::Verify },
|
||||||
{ "wrapKey"_s, CryptoKeyUsage::WrapKey },
|
{ "wrapKey"_s, CryptoKeyUsage::WrapKey },
|
||||||
} };
|
}) };
|
||||||
static constexpr SortedArrayMap enumerationMapping { mappings };
|
|
||||||
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
||||||
return *enumerationValue;
|
return *enumerationValue;
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
@@ -96,13 +96,12 @@ template<> JSString* convertEnumerationToJS(JSGlobalObject& lexicalGlobalObject,
|
|||||||
template<> std::optional<SubtleCrypto::KeyFormat> parseEnumeration<SubtleCrypto::KeyFormat>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
template<> std::optional<SubtleCrypto::KeyFormat> parseEnumeration<SubtleCrypto::KeyFormat>(JSGlobalObject& lexicalGlobalObject, JSValue value)
|
||||||
{
|
{
|
||||||
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
auto stringValue = value.toWTFString(&lexicalGlobalObject);
|
||||||
static constexpr std::array<std::pair<ComparableASCIILiteral, SubtleCrypto::KeyFormat>, 4> mappings { {
|
static constexpr SortedArrayMap enumerationMapping { std::to_array<std::pair<ComparableASCIILiteral, SubtleCrypto::KeyFormat>>({
|
||||||
{ "jwk"_s, SubtleCrypto::KeyFormat::Jwk },
|
{ "jwk"_s, SubtleCrypto::KeyFormat::Jwk },
|
||||||
{ "pkcs8"_s, SubtleCrypto::KeyFormat::Pkcs8 },
|
{ "pkcs8"_s, SubtleCrypto::KeyFormat::Pkcs8 },
|
||||||
{ "raw"_s, SubtleCrypto::KeyFormat::Raw },
|
{ "raw"_s, SubtleCrypto::KeyFormat::Raw },
|
||||||
{ "spki"_s, SubtleCrypto::KeyFormat::Spki },
|
{ "spki"_s, SubtleCrypto::KeyFormat::Spki },
|
||||||
} };
|
}) };
|
||||||
static constexpr SortedArrayMap enumerationMapping { mappings };
|
|
||||||
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]
|
||||||
return *enumerationValue;
|
return *enumerationValue;
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
@@ -755,13 +755,12 @@ function emitConvertEnumFunction(w: CodeWriter, type: TypeImpl) {
|
|||||||
w.line(`template<> std::optional<${name}> parseEnumerationFromString<${name}>(const String& stringValue)`);
|
w.line(`template<> std::optional<${name}> parseEnumerationFromString<${name}>(const String& stringValue)`);
|
||||||
w.line(`{`);
|
w.line(`{`);
|
||||||
w.line(
|
w.line(
|
||||||
` static constexpr std::array<std::pair<ComparableASCIILiteral, ${name}>, ${type.data.length}> mappings { {`,
|
` static constexpr SortedArrayMap enumerationMapping { std::to_array<std::pair<ComparableASCIILiteral, ${name}>>({`,
|
||||||
);
|
);
|
||||||
for (const value of type.data) {
|
for (const value of type.data) {
|
||||||
w.line(` { ${str(value)}_s, ${name}::${pascal(value)} },`);
|
w.line(` { ${str(value)}_s, ${name}::${pascal(value)} },`);
|
||||||
}
|
}
|
||||||
w.line(` } };`);
|
w.line(` }) };`);
|
||||||
w.line(` static constexpr SortedArrayMap enumerationMapping { mappings };`);
|
|
||||||
w.line(` if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]`);
|
w.line(` if (auto* enumerationValue = enumerationMapping.tryGet(stringValue); enumerationValue) [[likely]]`);
|
||||||
w.line(` return *enumerationValue;`);
|
w.line(` return *enumerationValue;`);
|
||||||
w.line(` return std::nullopt;`);
|
w.line(` return std::nullopt;`);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export function enumeration(
|
|||||||
template<> std::optional<${qualifiedName}>
|
template<> std::optional<${qualifiedName}>
|
||||||
WebCore::parseEnumerationFromString<${qualifiedName}>(const WTF::String& stringVal)
|
WebCore::parseEnumerationFromString<${qualifiedName}>(const WTF::String& stringVal)
|
||||||
{
|
{
|
||||||
static constexpr ::std::array<${pairType}, ${valueMap.size}> mappings {
|
static constexpr ::WTF::SortedArrayMap enumerationMapping { ::std::to_array<${pairType}>({
|
||||||
${joinIndented(
|
${joinIndented(
|
||||||
12,
|
12,
|
||||||
Array.from(valueMap.entries())
|
Array.from(valueMap.entries())
|
||||||
@@ -155,8 +155,7 @@ export function enumeration(
|
|||||||
},`;
|
},`;
|
||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
};
|
}) };
|
||||||
static constexpr ::WTF::SortedArrayMap enumerationMapping { mappings };
|
|
||||||
if (auto* enumerationValue = enumerationMapping.tryGet(stringVal)) [[likely]] {
|
if (auto* enumerationValue = enumerationMapping.tryGet(stringVal)) [[likely]] {
|
||||||
return *enumerationValue;
|
return *enumerationValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,7 +325,9 @@ $$capture_start$$(${fn.async ? "async " : ""}${
|
|||||||
directives: fn.directives,
|
directives: fn.directives,
|
||||||
source: finalReplacement,
|
source: finalReplacement,
|
||||||
params: fn.params,
|
params: fn.params,
|
||||||
visibility: fn.directives.visibility ?? (fn.directives.linkTimeConstant ? "Private" : "Public"),
|
// Async functions automatically get Private visibility because the parser
|
||||||
|
// upgrades them when they use await (see Parser.cpp parseFunctionBody)
|
||||||
|
visibility: fn.directives.visibility ?? (fn.directives.linkTimeConstant || fn.async ? "Private" : "Public"),
|
||||||
isGetter: !!fn.directives.getter,
|
isGetter: !!fn.directives.getter,
|
||||||
constructAbility: fn.directives.ConstructAbility ?? "CannotConstruct",
|
constructAbility: fn.directives.ConstructAbility ?? "CannotConstruct",
|
||||||
constructKind: fn.directives.ConstructKind ?? "None",
|
constructKind: fn.directives.ConstructKind ?? "None",
|
||||||
|
|||||||
Reference in New Issue
Block a user