mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Move Callback and internal Models to the private_api namespace
This commit is contained in:
parent
61d533812d
commit
daff9e8e65
3 changed files with 7 additions and 7 deletions
|
@ -427,6 +427,7 @@ private:
|
||||||
std::vector<private_api::ModelPeer> peers;
|
std::vector<private_api::ModelPeer> peers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace private_api {
|
||||||
/// A Model backed by a std::array of constant size
|
/// A Model backed by a std::array of constant size
|
||||||
template<int Count, typename ModelData>
|
template<int Count, typename ModelData>
|
||||||
class ArrayModel : public Model<ModelData>
|
class ArrayModel : public Model<ModelData>
|
||||||
|
@ -459,6 +460,7 @@ struct IntModel : Model<int>
|
||||||
int row_count() const override { return data; }
|
int row_count() const override { return data; }
|
||||||
int row_data(int value) const override { return value; }
|
int row_data(int value) const override { return value; }
|
||||||
};
|
};
|
||||||
|
} // namespace pricate_api
|
||||||
|
|
||||||
/// A Model backed by a SharedVector
|
/// A Model backed by a SharedVector
|
||||||
template<typename ModelData>
|
template<typename ModelData>
|
||||||
|
|
|
@ -11,7 +11,7 @@ LICENSE END */
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "sixtyfps_properties_internal.h"
|
#include "sixtyfps_properties_internal.h"
|
||||||
|
|
||||||
namespace sixtyfps {
|
namespace sixtyfps::private_api {
|
||||||
|
|
||||||
/// A Callback stores a function pointer with no parameters and no return value.
|
/// A Callback stores a function pointer with no parameters and no return value.
|
||||||
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
|
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
|
||||||
|
@ -102,7 +102,6 @@ private:
|
||||||
cbindgen_private::CallbackOpaque inner;
|
cbindgen_private::CallbackOpaque inner;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace private_api {
|
|
||||||
template<typename A, typename R>
|
template<typename A, typename R>
|
||||||
struct CallbackSignatureHelper
|
struct CallbackSignatureHelper
|
||||||
{
|
{
|
||||||
|
@ -115,6 +114,5 @@ struct CallbackSignatureHelper<void, R>
|
||||||
};
|
};
|
||||||
template<typename A, typename R = void>
|
template<typename A, typename R = void>
|
||||||
using CallbackHelper = Callback<typename CallbackSignatureHelper<A, R>::Result>;
|
using CallbackHelper = Callback<typename CallbackSignatureHelper<A, R>::Result>;
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sixtyfps
|
} // namespace sixtyfps
|
||||||
|
|
|
@ -476,7 +476,7 @@ fn handle_repeater(
|
||||||
if repeated.is_conditional_element {
|
if repeated.is_conditional_element {
|
||||||
// bool converts to int
|
// bool converts to int
|
||||||
// FIXME: don't do a heap allocation here
|
// FIXME: don't do a heap allocation here
|
||||||
model = format!("std::make_shared<sixtyfps::IntModel>({})", model)
|
model = format!("std::make_shared<sixtyfps::private_api::IntModel>({})", model)
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: optimize if repeated.model.is_constant()
|
// FIXME: optimize if repeated.model.is_constant()
|
||||||
|
@ -715,7 +715,7 @@ fn generate_component(
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
format!("sixtyfps::Callback<{}({})>", return_type, param_types.join(", "))
|
format!("sixtyfps::private_api::Callback<{}({})>", return_type, param_types.join(", "))
|
||||||
} else {
|
} else {
|
||||||
let cpp_type = get_cpp_type(&property_decl.property_type, property_decl, diag);
|
let cpp_type = get_cpp_type(&property_decl.property_type, property_decl, diag);
|
||||||
|
|
||||||
|
@ -1496,7 +1496,7 @@ fn compile_expression(
|
||||||
format!("sixtyfps::SharedString::from_number({})", f)
|
format!("sixtyfps::SharedString::from_number({})", f)
|
||||||
}
|
}
|
||||||
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => {
|
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => {
|
||||||
format!("std::make_shared<sixtyfps::IntModel>({})", f)
|
format!("std::make_shared<sixtyfps::private_api::IntModel>({})", f)
|
||||||
}
|
}
|
||||||
(Type::Array(_), Type::Model) => f,
|
(Type::Array(_), Type::Model) => f,
|
||||||
(Type::Float32, Type::Color) => {
|
(Type::Float32, Type::Color) => {
|
||||||
|
@ -1651,7 +1651,7 @@ fn compile_expression(
|
||||||
Expression::Array { element_ty, values } => {
|
Expression::Array { element_ty, values } => {
|
||||||
let ty = element_ty.cpp_type().unwrap_or_else(|| "FIXME: report error".to_owned());
|
let ty = element_ty.cpp_type().unwrap_or_else(|| "FIXME: report error".to_owned());
|
||||||
format!(
|
format!(
|
||||||
"std::make_shared<sixtyfps::ArrayModel<{count},{ty}>>({val})",
|
"std::make_shared<sixtyfps::private_api::ArrayModel<{count},{ty}>>({val})",
|
||||||
count = values.len(),
|
count = values.len(),
|
||||||
ty = ty,
|
ty = ty,
|
||||||
val = values
|
val = values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue