Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / web_idl / tracing.lucb

#==============================================================================================
#
#   tracing - WebIDL tracing: logging the calls the bindings make, with their arguments
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/WebIDL/Tracing.cpp (lines 1-54) and Tracing.h (lines 1-18).
#       The generated bindings call log_trace on entry; with tracing enabled it prints the
#       function and its JS arguments (phase 3: the arguments of the running execution context).
#
#       Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/WebIDL/Tracing.cpp:17 Web::WebIDL::log_trace_impl.
func idl_log_trace_impl(vm: Vm*, function: str):
    if not idl_g_enable_idl_tracing:
        return

    # `for (size_t i = 0; i < vm.argument_count(); ++i)`: each argument, quoted when a string,
    # as to_string_without_side_effects, control characters as \uXXXX: the JS arguments of the
    # running execution context (phase 3).
    trap("unported (P3): Web::WebIDL::log_trace_impl (the JS arguments)")

## Ported from Libraries/LibWeb/WebIDL/Tracing.cpp:43 Web::WebIDL::log_trace.
pub func idl_log_trace(vm: Vm*, function: str):
    if idl_g_enable_idl_tracing:
        idl_log_trace_impl(vm, function)

## Ported from Libraries/LibWeb/WebIDL/Tracing.cpp:49 Web::WebIDL::set_enable_idl_tracing.
pub func idl_set_enable_idl_tracing(enabled: bool):
    idl_g_enable_idl_tracing = enabled