Rename the sixtyfps C++ namespaces

This commit is contained in:
Simon Hausmann 2022-02-02 11:39:24 +01:00
parent 5226feab01
commit 7d297da2fc
96 changed files with 747 additions and 753 deletions

View file

@ -25,7 +25,7 @@ fn default_config() -> cbindgen::Config {
cbindgen::Config {
pragma_once: true,
include_version: true,
namespaces: Some(vec!["sixtyfps".into(), "cbindgen_private".into()]),
namespaces: Some(vec!["slint".into(), "cbindgen_private".into()]),
line_length: 100,
tab_width: 4,
// Note: we might need to switch to C if we need to generate bindings for language that needs C headers
@ -59,21 +59,21 @@ fn default_config() -> cbindgen::Config {
fn gen_item_declarations(items: &[&str]) -> String {
format!(
r#"
namespace sixtyfps::private_api {{
#define SIXTYFPS_DECL_ITEM(ItemName) \
namespace slint::private_api {{
#define SLINT_DECL_ITEM(ItemName) \
extern const cbindgen_private::ItemVTable ItemName##VTable; \
extern SIXTYFPS_DLL_IMPORT const cbindgen_private::ItemVTable* sixtyfps_get_##ItemName##VTable();
extern SLINT_DLL_IMPORT const cbindgen_private::ItemVTable* slint_get_##ItemName##VTable();
extern "C" {{
{}
}}
#undef SIXTYFPS_DECL_ITEM
#undef SLINT_DECL_ITEM
}}
"#,
items
.iter()
.map(|item_name| format!("SIXTYFPS_DECL_ITEM({});", item_name))
.map(|item_name| format!("SLINT_DECL_ITEM({});", item_name))
.collect::<Vec<_>>()
.join("\n")
)
@ -179,7 +179,7 @@ fn gen_corelib(
.with_config(string_config)
.with_src(crate_dir.join("string.rs"))
.with_src(crate_dir.join("slice.rs"))
.with_after_include("namespace sixtyfps { struct SharedString; }")
.with_after_include("namespace slint { struct SharedString; }")
.generate()
.context("Unable to generate bindings for sixtyfps_string_internal.h")?
.write_to_file(include_dir.join("sixtyfps_string_internal.h"));
@ -187,7 +187,7 @@ fn gen_corelib(
cbindgen::Builder::new()
.with_config(config.clone())
.with_src(crate_dir.join("sharedvector.rs"))
.with_after_include("namespace sixtyfps { template<typename T> struct SharedVector; }")
.with_after_include("namespace slint { template<typename T> struct SharedVector; }")
.generate()
.context("Unable to generate bindings for sixtyfps_sharedvector_internal.h")?
.write_to_file(include_dir.join("sixtyfps_sharedvector_internal.h"));
@ -205,7 +205,7 @@ fn gen_corelib(
.with_config(properties_config)
.with_src(crate_dir.join("properties.rs"))
.with_src(crate_dir.join("callbacks.rs"))
.with_after_include("namespace sixtyfps { class Color; class Brush; }")
.with_after_include("namespace slint { class Color; class Brush; }")
.generate()
.context("Unable to generate bindings for sixtyfps_properties_internal.h")?
.write_to_file(include_dir.join("sixtyfps_properties_internal.h"));
@ -281,9 +281,9 @@ fn gen_corelib(
special_config.structure.derive_eq = true;
special_config.structure.derive_neq = true;
// Put the rust type in a deeper "types" namespace, so the use of same type in for example generated
// Property<> fields uses the public `sixtyfps::Blah` type
// Property<> fields uses the public `slint::Blah` type
special_config.namespaces =
Some(vec!["sixtyfps".into(), "cbindgen_private".into(), "types".into()]);
Some(vec!["slint".into(), "cbindgen_private".into(), "types".into()]);
cbindgen::Builder::new()
.with_config(special_config)
.with_src(crate_dir.join("graphics.rs"))
@ -302,7 +302,7 @@ fn gen_corelib(
// Generate a header file with some public API (enums, etc.)
let mut public_config = config.clone();
public_config.namespaces = Some(vec!["sixtyfps".into()]);
public_config.namespaces = Some(vec!["slint".into()]);
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
public_config.export.include = vec!["TimerMode".into(), "IntSize".into()];
public_config.export.exclude.clear();
@ -321,13 +321,13 @@ fn gen_corelib(
.with_src(crate_dir.join("graphics.rs"))
.with_after_include(format!(
r"
/// This macro expands to the to the numeric value of the major version of SixtyFPS you're
/// This macro expands to the to the numeric value of the major version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 1.
#define SLINT_VERSION_MAJOR {}
/// This macro expands to the to the numeric value of the minor version of SixtyFPS you're
/// This macro expands to the to the numeric value of the minor version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 5.
#define SLINT_VERSION_MINOR {}
/// This macro expands to the to the numeric value of the patch version of SixtyFPS you're
/// This macro expands to the to the numeric value of the patch version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 2.
#define SLINT_VERSION_PATCH {}
",
@ -386,10 +386,10 @@ fn gen_corelib(
.with_include("sixtyfps_generated_public.h")
.with_after_include(
r"
namespace sixtyfps {
namespace slint {
namespace private_api { class WindowRc; }
namespace cbindgen_private {
using sixtyfps::private_api::WindowRc;
using slint::private_api::WindowRc;
using namespace vtable;
struct KeyEvent; struct PointerEvent;
using private_api::Property;
@ -497,7 +497,7 @@ fn gen_interpreter(
// Generate a header file with some public API (enums, etc.)
let mut public_config = config.clone();
public_config.namespaces = Some(vec!["sixtyfps".into(), "interpreter".into()]);
public_config.namespaces = Some(vec!["slint".into(), "interpreter".into()]);
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
public_config.export.exclude = IntoIterator::into_iter([
@ -528,11 +528,11 @@ fn gen_interpreter(
.with_include("sixtyfps_interpreter_generated_public.h")
.with_after_include(
r"
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
struct Value;
using sixtyfps::interpreter::ValueType;
using sixtyfps::interpreter::PropertyDescriptor;
using sixtyfps::interpreter::Diagnostic;
using slint::interpreter::ValueType;
using slint::interpreter::PropertyDescriptor;
using slint::interpreter::Diagnostic;
}",
)
.generate()
@ -543,7 +543,7 @@ fn gen_interpreter(
}
/// Generate the headers.
/// `root_dir` is the root directory of the sixtyfps git repo
/// `root_dir` is the root directory of the slint git repo
/// `include_dir` is the output directory
/// Returns the list of all paths that contain dependencies to the generated output. If you call this
/// function from build.rs, feed each entry to stdout prefixed with `cargo:rerun-if-changed=`.

View file

@ -28,7 +28,7 @@ author = "info@sixtyfps.io"
# The full version, including alpha/beta/rc tags
version = "0.2.0"
cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
cpp_index_common_prefix = ["slint::", "slint::interpreter::"]
# -- General configuration ---------------------------------------------------
@ -37,8 +37,8 @@ cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
# ones.
extensions = ["breathe", "myst_parser", "exhale", "sphinx_markdown_tables"]
breathe_projects = {"SixtyFPS": "./docs/xml"}
breathe_default_project = "SixtyFPS"
breathe_projects = {"Slint": "./docs/xml"}
breathe_default_project = "Slint"
exhale_args = {
"containmentFolder": "./api",
@ -47,12 +47,12 @@ exhale_args = {
"afterTitleDescription": textwrap.dedent(
"""
The following sections present the C++ API Reference. All types are
within the :ref:`sixtyfps<namespace_sixtyfps>` namespace and are accessible by including
within the :ref:`slint<namespace_slint>` namespace and are accessible by including
the :code:`sixtyfps.h` header file.
If you choose to load :code:`.slint` files dynamically at run-time, then
you can use the classes in :ref:`sixtyfps::interpreter<namespace_sixtyfps__interpreter>`, starting at
:cpp:class:`sixtyfps::interpreter::ComponentCompiler`. You need to include
you can use the classes in :ref:`slint::interpreter<namespace_slint__interpreter>`, starting at
:cpp:class:`slint::interpreter::ComponentCompiler`. You need to include
the :code:`sixtyfps_interpreter.h` header file.
"""
),
@ -60,7 +60,7 @@ exhale_args = {
"createTreeView": True,
"exhaleExecutesDoxygen": True,
"exhaleDoxygenStdin": """INPUT = ../../api/cpp/include generated_include
EXCLUDE_SYMBOLS = sixtyfps::cbindgen_private* sixtyfps::private_api* vtable* SIXTYFPS_DECL_ITEM
EXCLUDE_SYMBOLS = slint::cbindgen_private* slint::private_api* vtable* SLINT_DECL_ITEM
EXCLUDE = ../../api/cpp/include/vtable.h ../../api/sixtyfps-cpp/include/sixtyfps_testing.h
ENABLE_PREPROCESSING = YES
PREDEFINED += DOXYGEN

View file

@ -19,7 +19,7 @@
#include <condition_variable>
#include <span>
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
// Workaround https://github.com/eqrion/cbindgen/issues/43
struct ComponentVTable;
struct ItemVTable;
@ -35,7 +35,7 @@ struct ItemVTable;
/// See the :doc:`Overview <../overview>` documentation for the C++ integration how
/// to load :code:`.slint` designs.
/// \endrst
namespace sixtyfps {
namespace slint {
// Bring opaque structure in scope
namespace private_api {
@ -60,7 +60,7 @@ using cbindgen_private::StandardListViewItem;
/// thread is indeed called from the main thread, or abort the program otherwise
///
/// Most API should be called from the main thread. When using thread one must
/// use sixtyfps::invoke_from_event_loop
/// use slint::invoke_from_event_loop
inline void assert_main_thread()
{
#ifndef NDEBUG
@ -70,7 +70,7 @@ inline void assert_main_thread()
"thread."
<< std::endl;
std::cerr << "Most API should be called from the main thread. When using thread one must "
"use sixtyfps::invoke_from_event_loop."
"use slint::invoke_from_event_loop."
<< std::endl;
std::abort();
}
@ -202,10 +202,9 @@ inline vtable::Layout drop_in_place(ComponentRef component)
// so we have a relocation to a function that returns the address we seek. That
// relocation will be resolved to the locally linked stub library, the implementation of
// which will be patched.
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) \
sixtyfps::private_api::sixtyfps_get_##VTableName()
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) slint::private_api::sixtyfps_get_##VTableName()
# else
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) (&sixtyfps::private_api::VTableName)
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) (&slint::private_api::VTableName)
# endif
#endif // !defined(DOXYGEN)
@ -336,7 +335,7 @@ struct Timer
/// the destructor of the timer is called.
///
/// This is a convenience function and equivalent to calling
/// `start(sixtyfps::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
/// `start(slint::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
template<typename F>
Timer(std::chrono::milliseconds interval, F callback)
: id(cbindgen_private::slint_timer_start(
@ -867,7 +866,7 @@ inline void run_event_loop()
/// Schedules the main event loop for termination. This function is meant
/// to be called from callbacks triggered by the UI. After calling the function,
/// it will return immediately and once control is passed back to the event loop,
/// the initial call to sixtyfps::run_event_loop() will return.
/// the initial call to slint::run_event_loop() will return.
inline void quit_event_loop()
{
cbindgen_private::slint_quit_event_loop();
@ -894,10 +893,10 @@ inline void quit_event_loop()
/// auto ui = NetworkStatusUI::create();
/// ui->set_status_label("Pending");
///
/// sixtyfps::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
/// slint::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
/// std::thread network_thread([=]{
/// std::string message = read_message_blocking_from_network();
/// sixtyfps::invoke_from_event_loop([&]() {
/// slint::invoke_from_event_loop([&]() {
/// if (auto ui = weak_ui_handle.lock()) {
/// ui->set_status_label(message);
/// }
@ -941,7 +940,7 @@ void invoke_from_event_loop(Functor f)
///
/// std::thread worker_thread([ui]{
/// while (...) {
/// auto message = sixtyfps::blocking_invoke_from_event_loop([ui]() {
/// auto message = slint::blocking_invoke_from_event_loop([ui]() {
/// return ui->get_message();
/// }
/// do_something(message);
@ -1020,4 +1019,4 @@ inline std::optional<SharedString> register_font_from_data(const uint8_t *data,
}
} // namespace sixtyfps
} // namespace slint

View file

@ -7,7 +7,7 @@
#include "sixtyfps_brush_internal.h"
#include "sixtyfps_string.h"
namespace sixtyfps {
namespace slint {
namespace private_api {
@ -47,7 +47,7 @@ public:
private:
cbindgen_private::types::LinearGradientBrush inner;
friend class sixtyfps::Brush;
friend class slint::Brush;
static SharedVector<private_api::GradientStop>
make_linear_gradient(float angle, const GradientStop *firstStop, int stopCount)

View file

@ -5,7 +5,7 @@
#include <tuple>
#include "sixtyfps_properties_internal.h"
namespace sixtyfps::private_api {
namespace slint::private_api {
/// 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
@ -109,4 +109,4 @@ struct CallbackSignatureHelper<void, R>
template<typename A, typename R = void>
using CallbackHelper = Callback<typename CallbackSignatureHelper<A, R>::Result>;
} // namespace sixtyfps
} // namespace slint

View file

@ -8,7 +8,7 @@
#include <stdint.h>
namespace sixtyfps {
namespace slint {
namespace private_api {
class LinearGradientBrush;
@ -229,4 +229,4 @@ Property<Color>::set_animated_value(const Color &new_value,
} // namespace private_api
} // namespace sixtyfps
} // namespace slint

View file

@ -13,14 +13,14 @@
#if !defined(DOXYGEN)
# if defined(_MSC_VER)
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
# define SLINT_DLL_IMPORT __declspec(dllimport)
# elif defined(__GNUC__)
# if defined(_WIN32) || defined(_WIN64)
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
# define SLINT_DLL_IMPORT __declspec(dllimport)
# else
# define SIXTYFPS_DLL_IMPORT __attribute__((visibility("default")))
# define SLINT_DLL_IMPORT __attribute__((visibility("default")))
# endif
# else
# define SIXTYFPS_DLL_IMPORT
# define SLINT_DLL_IMPORT
# endif
#endif // !defined(DOXYGEN)

View file

@ -8,7 +8,7 @@
#include "sixtyfps_string.h"
#include "sixtyfps_sharedvector.h"
namespace sixtyfps {
namespace slint {
/// An image type that can be displayed by the Image element
struct Image
@ -36,7 +36,7 @@ public:
IntSize size() const { return cbindgen_private::types::slint_image_size(&data); }
/// Returns the path of the image on disk, if it was constructed via Image::load_from_path().
std::optional<sixtyfps::SharedString> path() const
std::optional<slint::SharedString> path() const
{
if (auto *str = cbindgen_private::types::slint_image_path(&data)) {
return *str;

View file

@ -17,7 +17,7 @@
class QWidget;
#endif
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
// This has to stay opaque, but VRc don't compile if it is just forward declared
struct ErasedComponentBox : vtable::Dyn
{
@ -36,7 +36,7 @@ struct ErasedComponentBox : vtable::Dyn
/// use to create \ref ComponentDefinition instances with the
/// \ref ComponentCompiler::build_from_source() or \ref ComponentCompiler::build_from_path()
/// functions.
namespace sixtyfps::interpreter {
namespace slint::interpreter {
class Value;
@ -216,13 +216,13 @@ public:
inline void set_field(std::string_view name, const Value &value);
/// \private
Struct(const sixtyfps::cbindgen_private::StructOpaque &other)
Struct(const slint::cbindgen_private::StructOpaque &other)
{
cbindgen_private::slint_interpreter_struct_clone(&other, &inner);
}
private:
using StructOpaque = sixtyfps::cbindgen_private::StructOpaque;
using StructOpaque = slint::cbindgen_private::StructOpaque;
StructOpaque inner;
friend class Value;
};
@ -235,7 +235,7 @@ private:
/// It is also possible to query the type the value holds by calling the Value::type()
/// function.
///
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
/// Note that models are only represented in one direction: You can create a slint::Model<Value>
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
/// property in your .slint code that was declared to be either an array (`property <[sometype]>
/// foo;`) or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
@ -246,7 +246,7 @@ private:
///
/// Value some_value = ...;
/// // Check if the value has a string
/// if (std::optional<sixtyfps::SharedString> string_value = some_value.to_string())
/// if (std::optional<slint::SharedString> string_value = some_value.to_string())
/// do_something(*string_value); // Extract the string by de-referencing
/// ```
class Value
@ -303,7 +303,7 @@ public:
/// Returns a std::optional that contains a string if the type of this Value is
/// Type::String, otherwise an empty optional is returned.
std::optional<sixtyfps::SharedString> to_string() const
std::optional<slint::SharedString> to_string() const
{
if (auto *str = cbindgen_private::slint_interpreter_value_to_string(&inner)) {
return *str;
@ -327,11 +327,11 @@ public:
/// Type::Model, otherwise an empty optional is returned.
///
/// The vector will be constructed by serializing all the elements of the model.
inline std::optional<sixtyfps::SharedVector<Value>> to_array() const;
inline std::optional<slint::SharedVector<Value>> to_array() const;
/// Returns a std::optional that contains a brush if the type of this Value is
/// Type::Brush, otherwise an empty optional is returned.
std::optional<sixtyfps::Brush> to_brush() const
std::optional<slint::Brush> to_brush() const
{
if (auto *brush = cbindgen_private::slint_interpreter_value_to_brush(&inner)) {
return *brush;
@ -376,9 +376,9 @@ public:
/// Constructs a new Value that holds the value vector \a v as a model.
inline Value(const SharedVector<Value> &v);
/// Constructs a new Value that holds the value model \a m.
Value(const std::shared_ptr<sixtyfps::Model<Value>> &m);
Value(const std::shared_ptr<slint::Model<Value>> &m);
/// Constructs a new Value that holds the brush \a b.
Value(const sixtyfps::Brush &brush)
Value(const slint::Brush &brush)
{
cbindgen_private::slint_interpreter_value_new_brush(&brush, &inner);
}
@ -402,7 +402,7 @@ public:
private:
inline Value(const void *) = delete; // Avoid that for example Value("foo") turns to Value(bool)
using ValueOpaque = sixtyfps::cbindgen_private::ValueOpaque;
using ValueOpaque = slint::cbindgen_private::ValueOpaque;
ValueOpaque inner;
friend struct Struct;
friend class ComponentInstance;
@ -410,29 +410,29 @@ private:
explicit Value(ValueOpaque &inner) : inner(inner) { }
};
inline Value::Value(const sixtyfps::SharedVector<Value> &array)
inline Value::Value(const slint::SharedVector<Value> &array)
{
cbindgen_private::slint_interpreter_value_new_array_model(
&reinterpret_cast<const sixtyfps::SharedVector<ValueOpaque> &>(array), &inner);
&reinterpret_cast<const slint::SharedVector<ValueOpaque> &>(array), &inner);
}
inline std::optional<sixtyfps::SharedVector<Value>> Value::to_array() const
inline std::optional<slint::SharedVector<Value>> Value::to_array() const
{
sixtyfps::SharedVector<Value> array;
slint::SharedVector<Value> array;
if (cbindgen_private::slint_interpreter_value_to_array(
&inner, &reinterpret_cast<sixtyfps::SharedVector<ValueOpaque> &>(array))) {
&inner, &reinterpret_cast<slint::SharedVector<ValueOpaque> &>(array))) {
return array;
} else {
return {};
}
}
inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
{
using cbindgen_private::ModelAdaptorVTable;
using vtable::VRef;
struct ModelWrapper : private_api::AbstractRepeaterView
{
std::shared_ptr<sixtyfps::Model<Value>> model;
std::shared_ptr<slint::Model<Value>> model;
cbindgen_private::ModelNotifyOpaque notify;
// This kind of mean that the rust code has ownership of "this" until the drop function is
// called
@ -533,7 +533,7 @@ class ComponentInstance : vtable::Dyn
// ComponentHandle<ComponentInstance> is in fact a VRc<ComponentVTable, ErasedComponentBox>
const cbindgen_private::ErasedComponentBox *inner() const
{
sixtyfps::private_api::assert_main_thread();
slint::private_api::assert_main_thread();
return reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(this);
}
@ -541,7 +541,7 @@ public:
/// Marks the window of this component to be shown on the screen. This registers
/// the window with the windowing system. In order to react to events from the windowing system,
/// such as draw requests or mouse/touch input, it is still necessary to spin the event loop,
/// using sixtyfps::run_event_loop().
/// using slint::run_event_loop().
void show() const
{
cbindgen_private::slint_interpreter_component_instance_show(inner(), true);
@ -555,14 +555,14 @@ public:
/// Returns the Window associated with this component. The window API can be used
/// to control different aspects of the integration into the windowing system,
/// such as the position on the screen.
const sixtyfps::Window &window()
const slint::Window &window()
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
return *reinterpret_cast<const sixtyfps::Window *>(win_ptr);
return *reinterpret_cast<const slint::Window *>(win_ptr);
}
/// This is a convenience function that first calls show(), followed by
/// sixtyfps::run_event_loop() and hide().
/// slint::run_event_loop() and hide().
void run() const
{
show();
@ -588,7 +588,7 @@ public:
/// For example, if the component has a `property <string> hello;`,
/// we can set this property
/// ```
/// instance->set_property("hello", sixtyfps::SharedString("world"));
/// instance->set_property("hello", slint::SharedString("world"));
/// ```
///
/// Returns true if the property was correctly set. Returns false if the property
@ -598,7 +598,7 @@ public:
{
using namespace cbindgen_private;
return slint_interpreter_component_instance_set_property(
inner(), sixtyfps::private_api::string_to_slice(name), &value.inner);
inner(), slint::private_api::string_to_slice(name), &value.inner);
}
/// Returns the value behind a property declared in .slint.
std::optional<Value> get_property(std::string_view name) const
@ -606,7 +606,7 @@ public:
using namespace cbindgen_private;
ValueOpaque out;
if (slint_interpreter_component_instance_get_property(
inner(), sixtyfps::private_api::string_to_slice(name), &out)) {
inner(), slint::private_api::string_to_slice(name), &out)) {
return Value(out);
} else {
return {};
@ -620,7 +620,7 @@ public:
/// ```
/// Then one can call it with this function
/// ```
/// sixtyfps::Value args[] = { SharedString("Hello"), 42. };
/// slint::Value args[] = { SharedString("Hello"), 42. };
/// instance->invoke_callback("foo", { args, 2 });
/// ```
///
@ -635,7 +635,7 @@ public:
args.size() };
ValueOpaque out;
if (slint_interpreter_component_instance_invoke_callback(
inner(), sixtyfps::private_api::string_to_slice(name), args_view, &out)) {
inner(), slint::private_api::string_to_slice(name), args_view, &out)) {
return Value(out);
} else {
return {};
@ -674,7 +674,7 @@ public:
new (ret) Value(std::move(r));
};
return cbindgen_private::slint_interpreter_component_instance_set_callback(
inner(), sixtyfps::private_api::string_to_slice(name), actual_cb,
inner(), slint::private_api::string_to_slice(name), actual_cb,
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -694,8 +694,8 @@ public:
{
using namespace cbindgen_private;
return slint_interpreter_component_instance_set_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &value.inner);
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(prop_name), &value.inner);
}
/// Returns the value behind a property in an exported global singleton.
std::optional<Value> get_global_property(std::string_view global,
@ -704,8 +704,8 @@ public:
using namespace cbindgen_private;
ValueOpaque out;
if (slint_interpreter_component_instance_get_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &out)) {
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(prop_name), &out)) {
return Value(out);
} else {
return {};
@ -739,8 +739,8 @@ public:
new (ret) Value(std::move(r));
};
return cbindgen_private::slint_interpreter_component_instance_set_global_callback(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -755,8 +755,8 @@ public:
args.size() };
ValueOpaque out;
if (slint_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)) {
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(callback_name), args_view, &out)) {
return Value(out);
} else {
return {};
@ -776,7 +776,7 @@ class ComponentDefinition
{
friend class ComponentCompiler;
using ComponentDefinitionOpaque = sixtyfps::cbindgen_private::ComponentDefinitionOpaque;
using ComponentDefinitionOpaque = slint::cbindgen_private::ComponentDefinitionOpaque;
ComponentDefinitionOpaque inner;
ComponentDefinition() = delete;
@ -792,7 +792,7 @@ public:
/// Assigns \a other to this ComponentDefinition.
ComponentDefinition &operator=(const ComponentDefinition &other)
{
using namespace sixtyfps::cbindgen_private;
using namespace slint::cbindgen_private;
if (this == &other)
return *this;
@ -820,34 +820,34 @@ public:
/// Returns a vector of that contains PropertyDescriptor instances that describe the list of
/// public properties that can be read and written using ComponentInstance::set_property and
/// ComponentInstance::get_property.
sixtyfps::SharedVector<PropertyDescriptor> properties() const
slint::SharedVector<PropertyDescriptor> properties() const
{
sixtyfps::SharedVector<PropertyDescriptor> props;
slint::SharedVector<PropertyDescriptor> props;
cbindgen_private::slint_interpreter_component_definition_properties(&inner, &props);
return props;
}
/// Returns a vector of strings that describe the list of public callbacks that can be invoked
/// using ComponentInstance::invoke_callback and set using ComponentInstance::set_callback.
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks() const
slint::SharedVector<slint::SharedString> callbacks() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks;
slint::SharedVector<slint::SharedString> callbacks;
cbindgen_private::slint_interpreter_component_definition_callbacks(&inner, &callbacks);
return callbacks;
}
/// Returns the name of this Component as written in the .slint file
sixtyfps::SharedString name() const
slint::SharedString name() const
{
sixtyfps::SharedString name;
slint::SharedString name;
cbindgen_private::slint_interpreter_component_definition_name(&inner, &name);
return name;
}
/// Returns a vector of strings with the names of all exported global singletons.
sixtyfps::SharedVector<sixtyfps::SharedString> globals() const
slint::SharedVector<slint::SharedString> globals() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
slint::SharedVector<slint::SharedString> names;
cbindgen_private::slint_interpreter_component_definition_globals(&inner, &names);
return names;
}
@ -855,12 +855,12 @@ public:
/// Returns a vector of the property descriptors of the properties of the specified
/// publicly exported global singleton. An empty optional is returned if there exists no
/// exported global singleton under the specified name.
std::optional<sixtyfps::SharedVector<PropertyDescriptor>>
std::optional<slint::SharedVector<PropertyDescriptor>>
global_properties(std::string_view global_name) const
{
sixtyfps::SharedVector<PropertyDescriptor> properties;
slint::SharedVector<PropertyDescriptor> properties;
if (cbindgen_private::slint_interpreter_component_definition_global_properties(
&inner, sixtyfps::private_api::string_to_slice(global_name), &properties)) {
&inner, slint::private_api::string_to_slice(global_name), &properties)) {
return properties;
}
return {};
@ -869,12 +869,12 @@ public:
/// Returns a vector of the names of the callbacks of the specified publicly exported global
/// singleton. An empty optional is returned if there exists no exported global singleton
/// under the specified name.
std::optional<sixtyfps::SharedVector<sixtyfps::SharedString>>
std::optional<slint::SharedVector<slint::SharedString>>
global_callbacks(std::string_view global_name) const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
slint::SharedVector<slint::SharedString> names;
if (cbindgen_private::slint_interpreter_component_definition_global_callbacks(
&inner, sixtyfps::private_api::string_to_slice(global_name), &names)) {
&inner, slint::private_api::string_to_slice(global_name), &names)) {
return names;
}
return {};
@ -903,7 +903,7 @@ public:
/// Sets the include paths used for looking up `.slint` imports to the specified vector of
/// paths.
void set_include_paths(const sixtyfps::SharedVector<sixtyfps::SharedString> &paths)
void set_include_paths(const slint::SharedVector<slint::SharedString> &paths)
{
cbindgen_private::slint_interpreter_component_compiler_set_include_paths(&inner, &paths);
}
@ -912,30 +912,30 @@ public:
void set_style(std::string_view style)
{
cbindgen_private::slint_interpreter_component_compiler_set_style(
&inner, sixtyfps::private_api::string_to_slice(style));
&inner, slint::private_api::string_to_slice(style));
}
/// Returns the widget style the compiler is currently using when compiling .slint files.
sixtyfps::SharedString style() const
slint::SharedString style() const
{
sixtyfps::SharedString s;
slint::SharedString s;
cbindgen_private::slint_interpreter_component_compiler_get_style(&inner, &s);
return s;
}
/// Returns the include paths the component compiler is currently configured with.
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
slint::SharedVector<slint::SharedString> include_paths() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
slint::SharedVector<slint::SharedString> paths;
cbindgen_private::slint_interpreter_component_compiler_get_include_paths(&inner, &paths);
return paths;
}
/// Returns the diagnostics that were produced in the last call to build_from_path() or
/// build_from_source().
sixtyfps::SharedVector<Diagnostic> diagnostics() const
slint::SharedVector<Diagnostic> diagnostics() const
{
sixtyfps::SharedVector<Diagnostic> result;
slint::SharedVector<Diagnostic> result;
cbindgen_private::slint_interpreter_component_compiler_get_diagnostics(&inner, &result);
return result;
}
@ -954,8 +954,8 @@ public:
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::slint_interpreter_component_compiler_build_from_source(
&inner, sixtyfps::private_api::string_to_slice(source_code),
sixtyfps::private_api::string_to_slice(path), &result)) {
&inner, slint::private_api::string_to_slice(source_code),
slint::private_api::string_to_slice(path), &result)) {
return ComponentDefinition(result);
} else {
@ -977,7 +977,7 @@ public:
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::slint_interpreter_component_compiler_build_from_path(
&inner, sixtyfps::private_api::string_to_slice(path), &result)) {
&inner, slint::private_api::string_to_slice(path), &result)) {
return ComponentDefinition(result);
} else {
@ -988,13 +988,13 @@ public:
}
namespace sixtyfps::testing {
namespace slint::testing {
using cbindgen_private::KeyboardModifiers;
/// Send a key events to the given component instance
inline void send_keyboard_string_sequence(const sixtyfps::interpreter::ComponentInstance *component,
const sixtyfps::SharedString &str,
inline void send_keyboard_string_sequence(const slint::interpreter::ComponentInstance *component,
const slint::SharedString &str,
KeyboardModifiers modifiers = {})
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;

View file

@ -7,10 +7,10 @@
#include "sixtyfps_pathdata_internal.h"
// The C++ code generator assumes that enums are in the cbindgen_private namespace
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
using cbindgen_private::types::PathEvent;
}
namespace sixtyfps::private_api {
namespace slint::private_api {
using cbindgen_private::types::PathArcTo;
using cbindgen_private::types::PathCubicTo;
using cbindgen_private::types::PathElement;

View file

@ -5,13 +5,13 @@
#include <string_view>
#include <memory>
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
struct PropertyAnimation;
}
#include "sixtyfps_properties_internal.h"
namespace sixtyfps::private_api {
namespace slint::private_api {
using cbindgen_private::StateInfo;
@ -166,11 +166,11 @@ struct Property
return true;
};
cbindgen_private::slint_property_set_binding(&p1->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
new TwoWayBinding { common_property }, del_fn,
intercept_fn, intercept_binding_fn);
cbindgen_private::slint_property_set_binding(&p2->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
new TwoWayBinding { common_property }, del_fn,
intercept_fn, intercept_binding_fn);
}
/// Internal (private) constructor used by link_two_way
@ -191,7 +191,7 @@ inline void Property<int32_t>::set_animated_value(
const int32_t &new_value, const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::slint_property_set_animated_value_int(&inner, value, new_value,
&animation_data);
&animation_data);
}
template<>
@ -200,7 +200,7 @@ Property<float>::set_animated_value(const float &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::slint_property_set_animated_value_float(&inner, value, new_value,
&animation_data);
&animation_data);
}
template<typename F>
@ -292,4 +292,4 @@ private:
cbindgen_private::PropertyTrackerOpaque inner;
};
} // namespace sixtyfps::private_api
} // namespace slint::private_api

View file

@ -7,7 +7,7 @@
#include <algorithm>
#include <initializer_list>
namespace sixtyfps {
namespace slint {
/// SharedVector is a vector template class similar to std::vector that's primarily used for passing
/// data in and out of the SixtyFPS run-time library. It uses implicit-sharing to make creating
@ -174,9 +174,9 @@ private:
it->~T();
}
cbindgen_private::slint_shared_vector_free(reinterpret_cast<uint8_t *>(inner),
sizeof(SharedVectorHeader)
+ inner->capacity * sizeof(T),
alignof(SharedVectorHeader));
sizeof(SharedVectorHeader)
+ inner->capacity * sizeof(T),
alignof(SharedVectorHeader));
}
}

View file

@ -5,7 +5,7 @@
#include <string_view>
#include "sixtyfps_string_internal.h"
namespace sixtyfps {
namespace slint {
/// A string type used by the SixtyFPS run-time.
///
@ -36,14 +36,14 @@ struct SharedString
#if defined(__cpp_char8_t) || __cplusplus >= 202002L
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied.
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char*>(s)) { }
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char *>(s)) { }
#endif
#ifdef __cpp_lib_char8_t
/// Creates a new SharedString from the string view \a s. The underlying string data is copied.
SharedString(std::u8string_view s)
{
cbindgen_private::slint_shared_string_from_bytes(
this, reinterpret_cast<const char*>(s.data()), s.size());
this, reinterpret_cast<const char *>(s.data()), s.size());
}
#endif
/// Creates a new SharedString from \a other.
@ -83,16 +83,10 @@ struct SharedString
/// Provides a view to the string data. The returned view is only valid as long as at
/// least this SharedString exists.
operator std::string_view() const
{
return cbindgen_private::slint_shared_string_bytes(this);
}
operator std::string_view() const { return cbindgen_private::slint_shared_string_bytes(this); }
/// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
/// least this SharedString exists.
auto data() const -> const char *
{
return cbindgen_private::slint_shared_string_bytes(this);
}
auto data() const -> const char * { return cbindgen_private::slint_shared_string_bytes(this); }
/// Returns a pointer to the first character. It is only safe to dereference the pointer if the
/// string contains at least one character.
@ -126,8 +120,8 @@ struct SharedString
///
/// For example:
/// \code
/// auto str = sixtyfps::SharedString::from_number(42); // creates "42"
/// auto str2 = sixtyfps::SharedString::from_number(100.5) // creates "100.5"
/// auto str = slint::SharedString::from_number(42); // creates "42"
/// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5"
/// \endcode
static SharedString from_number(double n) { return SharedString(n); }
@ -191,10 +185,7 @@ struct SharedString
private:
/// Use SharedString::from_number
explicit SharedString(double n)
{
cbindgen_private::slint_shared_string_from_number(this, n);
}
explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
void *inner; // opaque
};

View file

@ -5,7 +5,7 @@
#include "sixtyfps.h"
#include <iostream>
namespace sixtyfps::testing {
namespace slint::testing {
inline void init()
{
@ -25,7 +25,7 @@ inline void send_mouse_click(const Component *component, float x, float y)
template<typename Component>
inline void send_keyboard_string_sequence(const Component *component,
const sixtyfps::SharedString &str,
const slint::SharedString &str,
cbindgen_private::KeyboardModifiers modifiers = {})
{
cbindgen_private::send_keyboard_string_sequence(&str, modifiers,
@ -33,7 +33,7 @@ inline void send_keyboard_string_sequence(const Component *component,
}
#define assert_eq(A, B) \
sixtyfps::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
slint::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
namespace private_api {
template<typename A, typename B>
@ -49,4 +49,4 @@ void assert_eq_impl(const A &a, const B &b, const char *a_str, const char *b_str
}
}
} // namespace sixtyfps
} // namespace slint

View file

@ -10,7 +10,7 @@
SCENARIO("SharedString API")
{
sixtyfps::SharedString str;
slint::SharedString str;
REQUIRE(str.empty());
REQUIRE(str == "");
@ -35,7 +35,7 @@ SCENARIO("SharedString API")
{
str = "Hello";
str += " ";
str += sixtyfps::SharedString("🦊") + sixtyfps::SharedString("!");
str += slint::SharedString("🦊") + slint::SharedString("!");
REQUIRE(str == "Hello 🦊!");
REQUIRE(std::string_view(str.data()) == "Hello 🦊!");
}
@ -43,12 +43,12 @@ SCENARIO("SharedString API")
TEST_CASE("Basic SharedVector API", "[vector]")
{
sixtyfps::SharedVector<int> vec;
slint::SharedVector<int> vec;
REQUIRE(vec.empty());
SECTION("Initializer list")
{
sixtyfps::SharedVector<int> vec({ 1, 4, 10 });
slint::SharedVector<int> vec({ 1, 4, 10 });
REQUIRE(vec.size() == 3);
REQUIRE(vec[0] == 1);
REQUIRE(vec[1] == 4);
@ -58,7 +58,7 @@ TEST_CASE("Basic SharedVector API", "[vector]")
TEST_CASE("Property Tracker")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
PropertyTracker tracker1;
PropertyTracker tracker2;
Property<int> prop(42);
@ -80,9 +80,9 @@ TEST_CASE("Property Tracker")
TEST_CASE("Model row changes")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
auto model = std::make_shared<sixtyfps::VectorModel<int>>();
auto model = std::make_shared<slint::VectorModel<int>>();
PropertyTracker tracker;
@ -109,9 +109,9 @@ TEST_CASE("Model row changes")
TEST_CASE("Track model row data changes")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
auto model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
auto model = std::make_shared<slint::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
PropertyTracker tracker;
@ -149,7 +149,7 @@ TEST_CASE("Track model row data changes")
TEST_CASE("Image")
{
using namespace sixtyfps;
using namespace slint;
// ensure a backend exists, using private api
private_api::WindowRc wnd;
@ -179,7 +179,7 @@ TEST_CASE("Image")
TEST_CASE("SharedVector")
{
using namespace sixtyfps;
using namespace slint;
SharedVector<SharedString> vec;
vec.clear();

View file

@ -9,35 +9,35 @@
TEST_CASE("C++ Singleshot Timers")
{
using namespace sixtyfps;
using namespace slint;
int called = 0;
Timer testTimer(std::chrono::milliseconds(16), [&]() {
sixtyfps::quit_event_loop();
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
TEST_CASE("C++ Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -46,32 +46,32 @@ TEST_CASE("C++ Repeated Timer")
TEST_CASE("C++ Restart Singleshot Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::SingleShot, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::SingleShot, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
timer_triggered = 0;
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
@ -80,21 +80,21 @@ TEST_CASE("C++ Restart Singleshot Timer")
TEST_CASE("C++ Restart Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -102,12 +102,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer_was_running = false;
timer_triggered = 0;
timer.stop();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 0);
REQUIRE(!timer_was_running);
@ -117,12 +117,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -131,12 +131,12 @@ TEST_CASE("C++ Restart Repeated Timer")
TEST_CASE("Quit from event")
{
int called = 0;
sixtyfps::invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::invoke_from_event_loop([&] {
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
@ -145,13 +145,13 @@ TEST_CASE("Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
called += 10;
sixtyfps::invoke_from_event_loop([&] {
slint::invoke_from_event_loop([&] {
called += 100;
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 110);
t.join();
}
@ -161,18 +161,18 @@ TEST_CASE("Blocking Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
// test returning a, unique_ptr because it is movable-only
std::unique_ptr foo = sixtyfps::blocking_invoke_from_event_loop(
[&] { return std::make_unique<int>(42); });
std::unique_ptr foo =
slint::blocking_invoke_from_event_loop([&] { return std::make_unique<int>(42); });
called = *foo;
int xxx = 123;
sixtyfps::blocking_invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::blocking_invoke_from_event_loop([&] {
slint::quit_event_loop();
xxx = 888999;
});
REQUIRE(xxx == 888999);
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 42);
t.join();
}

View file

@ -9,7 +9,7 @@
SCENARIO("Value API")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Value value;
REQUIRE(value.type() == Value::Type::Void);
@ -17,7 +17,7 @@ SCENARIO("Value API")
SECTION("Construct a string")
{
REQUIRE(!value.to_string().has_value());
sixtyfps::SharedString cpp_str("Hello World");
slint::SharedString cpp_str("Hello World");
value = Value(cpp_str);
REQUIRE(value.type() == Value::Type::String);
@ -52,7 +52,7 @@ SCENARIO("Value API")
SECTION("Construct an array")
{
REQUIRE(!value.to_array().has_value());
sixtyfps::SharedVector<Value> array { Value(42.0), Value(true) };
slint::SharedVector<Value> array { Value(42.0), Value(true) };
value = Value(array);
REQUIRE(value.type() == Value::Type::Model);
@ -68,7 +68,7 @@ SCENARIO("Value API")
SECTION("Construct a brush")
{
REQUIRE(!value.to_brush().has_value());
sixtyfps::Brush brush(sixtyfps::Color::from_rgb_uint8(255, 0, 255));
slint::Brush brush(slint::Color::from_rgb_uint8(255, 0, 255));
value = Value(brush);
REQUIRE(value.type() == Value::Type::Brush);
@ -80,7 +80,7 @@ SCENARIO("Value API")
SECTION("Construct a struct")
{
REQUIRE(!value.to_struct().has_value());
sixtyfps::interpreter::Struct struc;
slint::interpreter::Struct struc;
value = Value(struc);
REQUIRE(value.type() == Value::Type::Struct);
@ -91,10 +91,10 @@ SCENARIO("Value API")
SECTION("Construct an image")
{
// ensure a backend exists, using private api
sixtyfps::private_api::WindowRc wnd;
slint::private_api::WindowRc wnd;
REQUIRE(!value.to_image().has_value());
sixtyfps::Image image = sixtyfps::Image::load_from_path(
slint::Image image = slint::Image::load_from_path(
SOURCE_DIR "/../../vscode_extension/extension-logo.png");
REQUIRE(image.size().width == 128);
value = Value(image);
@ -109,7 +109,7 @@ SCENARIO("Value API")
SECTION("Construct a model")
{
// And test that it is properly destroyed when the value is destroyed
struct M : sixtyfps::VectorModel<Value>
struct M : slint::VectorModel<Value>
{
bool *destroyed;
explicit M(bool *destroyed) : destroyed(destroyed) { }
@ -139,8 +139,8 @@ SCENARIO("Value API")
SECTION("Compare Values")
{
Value str1 { sixtyfps::SharedString("Hello1") };
Value str2 { sixtyfps::SharedString("Hello2") };
Value str1 { slint::SharedString("Hello1") };
Value str2 { slint::SharedString("Hello2") };
Value fl1 { 10. };
Value fl2 { 12. };
@ -151,22 +151,22 @@ SCENARIO("Value API")
REQUIRE(fl1 != fl2);
REQUIRE(Value() == Value());
REQUIRE(Value() != str1);
REQUIRE(str1 == sixtyfps::SharedString("Hello1"));
REQUIRE(str1 != sixtyfps::SharedString("Hello2"));
REQUIRE(sixtyfps::SharedString("Hello2") == str2);
REQUIRE(fl1 != sixtyfps::SharedString("Hello2"));
REQUIRE(str1 == slint::SharedString("Hello1"));
REQUIRE(str1 != slint::SharedString("Hello2"));
REQUIRE(slint::SharedString("Hello2") == str2);
REQUIRE(fl1 != slint::SharedString("Hello2"));
REQUIRE(fl2 == 12.);
}
}
SCENARIO("Struct API")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc;
REQUIRE(!struc.get_field("not_there"));
struc.set_field("field_a", Value(sixtyfps::SharedString("Hallo")));
struc.set_field("field_a", Value(slint::SharedString("Hallo")));
auto value_opt = struc.get_field("field_a");
REQUIRE(value_opt.has_value());
@ -182,20 +182,20 @@ SCENARIO("Struct API")
REQUIRE(value.to_string().value() == "Hallo");
}
struc.set_field("field_b", Value(sixtyfps::SharedString("World")));
std::map<std::string, sixtyfps::SharedString> map;
struc.set_field("field_b", Value(slint::SharedString("World")));
std::map<std::string, slint::SharedString> map;
for (auto [k, value] : struc)
map[std::string(k)] = *value.to_string();
REQUIRE(map
== std::map<std::string, sixtyfps::SharedString> {
{ "field-a", sixtyfps::SharedString("Hallo") },
{ "field-b", sixtyfps::SharedString("World") } });
== std::map<std::string, slint::SharedString> {
{ "field-a", slint::SharedString("Hallo") },
{ "field-b", slint::SharedString("World") } });
}
SCENARIO("Struct Iterator Constructor")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
std::vector<std::pair<std::string_view, Value>> values = { { "field_a", Value(true) },
{ "field_b", Value(42.0) } };
@ -210,7 +210,7 @@ SCENARIO("Struct Iterator Constructor")
SCENARIO("Struct Initializer List Constructor")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
@ -222,14 +222,14 @@ SCENARIO("Struct Initializer List Constructor")
SCENARIO("Struct empty field iteration")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc;
REQUIRE(struc.begin() == struc.end());
}
SCENARIO("Struct field iteration")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
@ -257,8 +257,8 @@ SCENARIO("Struct field iteration")
SCENARIO("Component Compiler")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -313,8 +313,8 @@ SCENARIO("Component Compiler")
SCENARIO("Component Definition Properties")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
@ -331,8 +331,8 @@ SCENARIO("Component Definition Properties")
SCENARIO("Component Definition Properties / Two-way bindings")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
@ -348,8 +348,8 @@ SCENARIO("Component Definition Properties / Two-way bindings")
SCENARIO("Invoke callback")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -387,8 +387,8 @@ SCENARIO("Invoke callback")
SCENARIO("Array between .slint and C++")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -404,12 +404,12 @@ SCENARIO("Array between .slint and C++")
REQUIRE(maybe_array->type() == Value::Type::Model);
auto array = *maybe_array;
REQUIRE(array.to_array() == sixtyfps::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
REQUIRE(array.to_array() == slint::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
}
SECTION("C++ to .slint")
{
sixtyfps::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
slint::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
instance->set_property("array", Value(cpp_array));
auto maybe_array = instance->get_property("array");
@ -423,8 +423,8 @@ SCENARIO("Array between .slint and C++")
SCENARIO("Angle between .slint and C++")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -456,8 +456,8 @@ SCENARIO("Angle between .slint and C++")
SCENARIO("Component Definition Name")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source("export IHaveAName := Rectangle { }", "");
@ -466,8 +466,8 @@ SCENARIO("Component Definition Name")
SCENARIO("Send key events")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = compiler.build_from_source(R"(
@ -485,14 +485,14 @@ SCENARIO("Send key events")
"");
REQUIRE(comp_def.has_value());
auto instance = comp_def->create();
sixtyfps::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
slint::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
REQUIRE(*instance->get_property("result")->to_string() == "Hello keys!");
}
SCENARIO("Global properties")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;