mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Use a free-standing function for the string_view to slice conversion
This commit is contained in:
parent
0c21008861
commit
3bb4b87bc7
2 changed files with 11 additions and 11 deletions
|
@ -376,14 +376,14 @@ public:
|
|||
{
|
||||
using namespace cbindgen_private;
|
||||
return sixtyfps_interpreter_component_instance_set_property(
|
||||
&inner, Slice<uint8_t>::from_string(name), &value.inner);
|
||||
&inner, sixtyfps::private_api::string_to_slice(name), &value.inner);
|
||||
}
|
||||
std::optional<Value> get_property(std::string_view name) const
|
||||
{
|
||||
using namespace cbindgen_private;
|
||||
ValueOpaque out;
|
||||
if (sixtyfps_interpreter_component_instance_get_property(
|
||||
&inner, Slice<uint8_t>::from_string(name), &out)) {
|
||||
&inner, sixtyfps::private_api::string_to_slice(name), &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -396,7 +396,7 @@ public:
|
|||
Slice<ValueOpaque> args_view { reinterpret_cast<ValueOpaque *>(args.ptr), args.len };
|
||||
ValueOpaque out;
|
||||
if (sixtyfps_interpreter_component_instance_invoke_callback(
|
||||
&inner, Slice<uint8_t>::from_string(name), args_view, &out)) {
|
||||
&inner, sixtyfps::private_api::string_to_slice(name), args_view, &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -413,8 +413,8 @@ public:
|
|||
new (ret) Value(std::move(r));
|
||||
};
|
||||
return cbindgen_private::sixtyfps_interpreter_component_instance_set_callback(
|
||||
&inner, Slice<uint8_t>::from_string(name), actual_cb, new F(std::move(callback)),
|
||||
[](void *data) { delete reinterpret_cast<F *>(data); });
|
||||
&inner, sixtyfps::private_api::string_to_slice(name), actual_cb,
|
||||
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -103,15 +103,15 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
|
|||
|
||||
let mut string_config = config.clone();
|
||||
string_config.export.exclude = vec!["SharedString".into()];
|
||||
string_config.export.body.insert(
|
||||
"Slice".to_owned(),
|
||||
" static Slice<T> from_string(std::string_view str) {
|
||||
return {
|
||||
string_config.trailer = Some(
|
||||
"namespace sixtyfps::private_api {
|
||||
cbindgen_private::Slice<uint8_t> string_to_slice(std::string_view str) {
|
||||
return cbindgen_private::Slice<uint8_t> {
|
||||
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(str.data())),
|
||||
str.size()
|
||||
};
|
||||
}"
|
||||
.to_owned(),
|
||||
}
|
||||
}".to_owned(),
|
||||
);
|
||||
|
||||
cbindgen::Builder::new()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue