mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Better handling of union types in IDL code generation
First check if a string is a member of the enum before attempting
numeric conversion. This generates correct code for fields like:
AudioContextOptions {
latencyHint: AudioContextLatencyCategory | double;
}
This commit is contained in:
committed by
Shannon Booth
parent
b69ec8757f
commit
4e48ba36bd
Notes:
github-actions[bot]
2026-02-06 11:05:11 +00:00
Author: https://github.com/jonbgamble Commit: https://github.com/LadybirdBrowser/ladybird/commit/4e48ba36bd4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7567 Reviewed-by: https://github.com/shannonbooth ✅
@@ -59,19 +59,26 @@ WebIDL::ExceptionOr<GC::Ref<AudioContext>> AudioContext::construct_impl(JS::Real
|
||||
// 1. If sinkId is specified, let sinkId be the value of contextOptions.sinkId and run the following substeps:
|
||||
|
||||
// 2. Set the internal latency of context according to contextOptions.latencyHint, as described in latencyHint.
|
||||
switch (context_options->latency_hint) {
|
||||
case Bindings::AudioContextLatencyCategory::Balanced:
|
||||
// FIXME: Determine optimal settings for balanced.
|
||||
break;
|
||||
case Bindings::AudioContextLatencyCategory::Interactive:
|
||||
// FIXME: Determine optimal settings for interactive.
|
||||
break;
|
||||
case Bindings::AudioContextLatencyCategory::Playback:
|
||||
// FIXME: Determine optimal settings for playback.
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
context_options->latency_hint.visit(
|
||||
[&](Bindings::AudioContextLatencyCategory category) {
|
||||
switch (category) {
|
||||
case Bindings::AudioContextLatencyCategory::Balanced:
|
||||
// FIXME: Determine optimal settings for balanced.
|
||||
break;
|
||||
case Bindings::AudioContextLatencyCategory::Interactive:
|
||||
// FIXME: Determine optimal settings for interactive.
|
||||
break;
|
||||
case Bindings::AudioContextLatencyCategory::Playback:
|
||||
// FIXME: Determine optimal settings for playback.
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
},
|
||||
[&](double latency_seconds) {
|
||||
// FIXME: Determine optimal settings for numeric latency hint.
|
||||
(void)latency_seconds;
|
||||
});
|
||||
|
||||
// 3: If contextOptions.sampleRate is specified, set the sampleRate of context to this value.
|
||||
if (context_options->sample_rate.has_value()) {
|
||||
|
||||
Reference in New Issue
Block a user