mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Add invoke_global_callback to the C++ interpreter API
This commit is contained in:
parent
00cc8ec693
commit
70c57844b7
3 changed files with 65 additions and 1 deletions
|
@ -774,6 +774,24 @@ public:
|
|||
sixtyfps::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
|
||||
[](void *data) { delete reinterpret_cast<F *>(data); });
|
||||
}
|
||||
|
||||
// FIXME! Slice in public API? Should be std::span (c++20) or we need to improve the Slice API
|
||||
/// Invoke the specified callback declared in an exported global
|
||||
std::optional<Value> invoke_global_callback(std::string_view global,
|
||||
std::string_view callback_name,
|
||||
Slice<Value> args) const
|
||||
{
|
||||
using namespace cbindgen_private;
|
||||
Slice<ValueOpaque> args_view { reinterpret_cast<ValueOpaque *>(args.ptr), args.len };
|
||||
ValueOpaque out;
|
||||
if (sixtyfps_interpreter_component_instance_invoke_global_callback(
|
||||
inner(), sixtyfps::private_api::string_to_slice(global),
|
||||
sixtyfps::private_api::string_to_slice(callback_name), args_view, &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(DOXYGEN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue