mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +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;
|
using namespace cbindgen_private;
|
||||||
return sixtyfps_interpreter_component_instance_set_property(
|
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
|
std::optional<Value> get_property(std::string_view name) const
|
||||||
{
|
{
|
||||||
using namespace cbindgen_private;
|
using namespace cbindgen_private;
|
||||||
ValueOpaque out;
|
ValueOpaque out;
|
||||||
if (sixtyfps_interpreter_component_instance_get_property(
|
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);
|
return Value(out);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
|
@ -396,7 +396,7 @@ public:
|
||||||
Slice<ValueOpaque> args_view { reinterpret_cast<ValueOpaque *>(args.ptr), args.len };
|
Slice<ValueOpaque> args_view { reinterpret_cast<ValueOpaque *>(args.ptr), args.len };
|
||||||
ValueOpaque out;
|
ValueOpaque out;
|
||||||
if (sixtyfps_interpreter_component_instance_invoke_callback(
|
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);
|
return Value(out);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
|
@ -413,8 +413,8 @@ public:
|
||||||
new (ret) Value(std::move(r));
|
new (ret) Value(std::move(r));
|
||||||
};
|
};
|
||||||
return cbindgen_private::sixtyfps_interpreter_component_instance_set_callback(
|
return cbindgen_private::sixtyfps_interpreter_component_instance_set_callback(
|
||||||
&inner, Slice<uint8_t>::from_string(name), actual_cb, new F(std::move(callback)),
|
&inner, sixtyfps::private_api::string_to_slice(name), actual_cb,
|
||||||
[](void *data) { delete reinterpret_cast<F *>(data); });
|
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();
|
let mut string_config = config.clone();
|
||||||
string_config.export.exclude = vec!["SharedString".into()];
|
string_config.export.exclude = vec!["SharedString".into()];
|
||||||
string_config.export.body.insert(
|
string_config.trailer = Some(
|
||||||
"Slice".to_owned(),
|
"namespace sixtyfps::private_api {
|
||||||
" static Slice<T> from_string(std::string_view str) {
|
cbindgen_private::Slice<uint8_t> string_to_slice(std::string_view str) {
|
||||||
return {
|
return cbindgen_private::Slice<uint8_t> {
|
||||||
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(str.data())),
|
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(str.data())),
|
||||||
str.size()
|
str.size()
|
||||||
};
|
};
|
||||||
}"
|
}
|
||||||
.to_owned(),
|
}".to_owned(),
|
||||||
);
|
);
|
||||||
|
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue