Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / web_idl / overload_resolution.lucb

#==============================================================================================
#
#   overload_resolution - WebIDL overload resolution for the generated bindings
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/WebIDL/OverloadResolution.cpp (lines 1-465) and
#       OverloadResolution.h (lines 1-30): the overload resolution algorithm the generated
#       bindings run on the JS arguments of a call, over LibIDL's effective overload sets. Both
#       the arguments (JS values) and the overload sets (LibIDL, used by the bindings generator)
#       are phase 3.
#
#       Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
#       Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/WebIDL/OverloadResolution.cpp:19 Web::WebIDL::convert_ecmascript_type_to_idl_value.
## https://webidl.spec.whatwg.org/#dfn-convert-ecmascript-to-idl-value
## (Internal linkage in C++; public until resolve_overload, its caller, is ported in phase 3.)
pub func idl_convert_ecmascript_type_to_idl_value(value: JsValue, arg1: IdlType) -> JsValue:
    # FIXME: We have this code already in the code generator, in `generate_to_cpp()`, but how do we use it here?
    return value

## Ported from Libraries/LibWeb/WebIDL/OverloadResolution.cpp:26 Web::WebIDL::has_overload_with_argument_type_or_subtype_matching.
## (Internal linkage in C++; public until resolve_overload, its caller, is ported in phase 3.)
pub func idl_has_overload_with_argument_type_or_subtype_matching[TMatch](overloads: IdlEffectiveOverloadSet*, argument_index: usize, match_: TMatch) -> bool:
    trap("unported (P3): Web::WebIDL::has_overload_with_argument_type_or_subtype_matching (LibIDL overload sets)")

## Ported from Libraries/LibWeb/WebIDL/OverloadResolution.cpp:58 Web::WebIDL::resolve_overload.
## https://webidl.spec.whatwg.org/#es-overloads
pub func idl_resolve_overload(vm: Vm*, overloads: IdlEffectiveOverloadSet*, dictionary_types: const ak.StringView[]) -> IdlResolvedOverload!:
    trap("unported (P3): Web::WebIDL::resolve_overload (JS arguments, LibIDL overload sets)")