Rename call_* to invoke_* for callbacks

Fixes #187
This commit is contained in:
Simon Hausmann 2021-03-15 17:01:05 +01:00
parent b27034efa5
commit 8372d3f6d8
27 changed files with 69 additions and 68 deletions

View file

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- `Path::fill-color` was renamed to `fill`, and `Path::stroke-color` was renamed to `stroke`, which are now brushes instead of color - `Path::fill-color` was renamed to `fill`, and `Path::stroke-color` was renamed to `stroke`, which are now brushes instead of color
- Many other color property became brush in order to support gradients - Many other color property became brush in order to support gradients
- the `resource` type was renamed to `image` - the `resource` type was renamed to `image`
- Calling a callback is done from C++/Rust with `invoke_<name>` instead of `call_<name>`
### Added ### Added
- `@linear-gradient` can be used to have gradients on rectangle and paths - `@linear-gradient` can be used to have gradients on rectangle and paths

View file

@ -161,7 +161,7 @@ struct MainWindow {
inline auto get_todo_model () const -> std::shared_ptr<sixtyfps::Model<TodoItem>>; inline auto get_todo_model () const -> std::shared_ptr<sixtyfps::Model<TodoItem>>;
inline void set_todo_model (const std::shared_ptr<sixtyfps::Model<TodoItem>> &value) const; inline void set_todo_model (const std::shared_ptr<sixtyfps::Model<TodoItem>> &value) const;
inline void call_todo_added (sixtyfps::SharedString arg_0) const; inline void invoke_todo_added (sixtyfps::SharedString arg_0) const;
template<typename Functor> inline void on_todo_added (Functor && callback_handler) const; template<typename Functor> inline void on_todo_added (Functor && callback_handler) const;
//... //...

View file

@ -18,7 +18,7 @@ This class will have the following public member functions:
* A getter `get_<property_name>` returning the property type. * A getter `get_<property_name>` returning the property type.
* A setter `set_<property_name>` taking the new value of the property by const reference * A setter `set_<property_name>` taking the new value of the property by const reference
- for each callbacks: - for each callbacks:
* `call_<callback_name>` function which takes the callback argument as parameter and call the callback. * `invoke_<callback_name>` function which takes the callback argument as parameter and call the callback.
* `on_<callback_name>` functin wich takes a functor as an argument and sets the callback handler * `on_<callback_name>` functin wich takes a functor as an argument and sets the callback handler
for this callback. the functor must accept the type parameter of the callback for this callback. the functor must accept the type parameter of the callback
@ -64,7 +64,7 @@ public:
inline void set_user_name (const sixtyfps::SharedString &value) const; inline void set_user_name (const sixtyfps::SharedString &value) const;
/// Call this function to call the `hello` callback /// Call this function to call the `hello` callback
inline void call_hello () const; inline void invoke_hello () const;
/// Sets the callback handler for the `hello` callback. /// Sets the callback handler for the `hello` callback.
template<typename Functor> inline void on_hello (Functor && callback_handler) const; template<typename Functor> inline void on_hello (Functor && callback_handler) const;

View file

@ -81,7 +81,7 @@ require.extensions['.60'] =
c.callbacks().forEach((x: string) => { c.callbacks().forEach((x: string) => {
Object.defineProperty(ret, x, { Object.defineProperty(ret, x, {
get() { get() {
let callback = function () { return comp.call_callback(x, [...arguments]); } as Callback; let callback = function () { return comp.invoke_callback(x, [...arguments]); } as Callback;
callback.setHandler = function (callback) { comp.connect_callback(x, callback) }; callback.setHandler = function (callback) { comp.connect_callback(x, callback) };
return callback; return callback;
}, },

View file

@ -409,7 +409,7 @@ declare_types! {
Ok(JsUndefined::new().as_value(&mut cx)) Ok(JsUndefined::new().as_value(&mut cx))
} }
method call_callback(mut cx) { method invoke_callback(mut cx) {
let callback_name = cx.argument::<JsString>(0)?.value(); let callback_name = cx.argument::<JsString>(0)?.value();
let arguments = cx.argument::<JsArray>(1)?.to_vec(&mut cx)?; let arguments = cx.argument::<JsArray>(1)?.to_vec(&mut cx)?;
let this = cx.this(); let this = cx.this();
@ -444,7 +444,7 @@ declare_types! {
let res = run_scoped(&mut cx,this.downcast().unwrap(), || { let res = run_scoped(&mut cx,this.downcast().unwrap(), || {
component.description() component.description()
.call_callback(component.borrow(), callback_name.as_str(), args.as_slice()) .invoke_callback(component.borrow(), callback_name.as_str(), args.as_slice())
.map_err(|()| "Cannot emit callback".to_string()) .map_err(|()| "Cannot emit callback".to_string())
})?; })?;
to_js_value(res, &mut cx) to_js_value(res, &mut cx)

View file

@ -96,7 +96,7 @@ pub mod generated_code {
/// For each callback declared at the root of the component, a function to call that /// For each callback declared at the root of the component, a function to call that
/// callback is generated. This is the function that calls the `hello` callback declared /// callback is generated. This is the function that calls the `hello` callback declared
/// in the `.60` design markup. /// in the `.60` design markup.
pub fn call_hello(&self) {} pub fn invoke_hello(&self) {}
/// For each callback declared at the root of the component, a function connect to that callback /// For each callback declared at the root of the component, a function connect to that callback
/// is generated. This is the function that registers the function f as callback when the /// is generated. This is the function that registers the function f as callback when the
/// callback `hello` is emitted. In order to access /// callback `hello` is emitted. In order to access

View file

@ -111,7 +111,7 @@ For each top-level property
- A getter [`fn get_<property_name>(&self) -> <PropertyType>`](docs::generated_code::SampleComponent::get_counter) - A getter [`fn get_<property_name>(&self) -> <PropertyType>`](docs::generated_code::SampleComponent::get_counter)
For each top-level callback For each top-level callback
- [`fn call_<callback_name>(&self)`](docs::generated_code::SampleComponent::call_hello): to emit the callback - [`fn invoke_<callback_name>(&self)`](docs::generated_code::SampleComponent::invoke_hello): to invoke the callback
- [`fn on_<callback_name>(&self, callback: impl Fn(<CallbackArgs>) + 'static)`](docs::generated_code::SampleComponent::on_hello): to set the callback handler. - [`fn on_<callback_name>(&self, callback: impl Fn(<CallbackArgs>) + 'static)`](docs::generated_code::SampleComponent::on_hello): to set the callback handler.
After instantiating the component you can call just [`fn run(&self)`] on it, in order to show it and spin the event loop to After instantiating the component you can call just [`fn run(&self)`] on it, in order to show it and spin the event loop to

View file

@ -684,7 +684,7 @@ fn generate_component(
component_struct.members.push(( component_struct.members.push((
Access::Public, Access::Public,
Declaration::Function(Function { Declaration::Function(Function {
name: format!("call_{}", cpp_name), name: format!("invoke_{}", cpp_name),
signature: format!( signature: format!(
"({}) const -> {}", "({}) const -> {}",
param_types param_types

View file

@ -291,7 +291,7 @@ fn generate_component(
let args_name = (0..callback_args.len()) let args_name = (0..callback_args.len())
.map(|i| format_ident!("arg_{}", i)) .map(|i| format_ident!("arg_{}", i))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let caller_ident = format_ident!("call_{}", prop_name); let caller_ident = format_ident!("invoke_{}", prop_name);
property_and_callback_accessors.push( property_and_callback_accessors.push(
quote!( quote!(
#[allow(dead_code)] #[allow(dead_code)]

View file

@ -450,10 +450,10 @@ impl ComponentInstance {
} }
/// Call the given callback with the arguments /// Call the given callback with the arguments
pub fn call_callback(&self, name: &str, args: &[Value]) -> Result<Value, CallCallbackError> { pub fn invoke_callback(&self, name: &str, args: &[Value]) -> Result<Value, CallCallbackError> {
generativity::make_guard!(guard); generativity::make_guard!(guard);
let comp = self.inner.unerase(guard); let comp = self.inner.unerase(guard);
Ok(comp.description().call_callback(comp.borrow(), name, &args).map_err(|()| todo!())?) Ok(comp.description().invoke_callback(comp.borrow(), name, &args).map_err(|()| todo!())?)
} }
/// Marks the window of this component to be shown on the screen. This registers /// Marks the window of this component to be shown on the screen. This registers
@ -545,7 +545,7 @@ pub enum SetCallbackError {
NoSuchCallback, NoSuchCallback,
} }
/// Error returned by [`ComponentInstance::call_callback`] /// Error returned by [`ComponentInstance::invoke_callback`]
pub enum CallCallbackError { pub enum CallCallbackError {
/// There is no callback with the given name /// There is no callback with the given name
NoSuchCallback, NoSuchCallback,

View file

@ -441,7 +441,7 @@ impl<'id> ComponentDescription<'id> {
/// ///
/// Returns an error if the component is not an instance corresponding to this ComponentDescription, /// Returns an error if the component is not an instance corresponding to this ComponentDescription,
/// or if the callback with this name does not exist in this component /// or if the callback with this name does not exist in this component
pub fn call_callback( pub fn invoke_callback(
&self, &self,
component: ComponentRefPin, component: ComponentRefPin,
name: &str, name: &str,

View file

@ -223,7 +223,7 @@ pub fn eval_expression(e: &Expression, local_context: &mut EvalLocalContext) ->
} }
ComponentInstance::GlobalComponent(global) => { ComponentInstance::GlobalComponent(global) => {
let args = arguments.iter().map(|e| eval_expression(e, local_context)); let args = arguments.iter().map(|e| eval_expression(e, local_context));
global.as_ref().call_callback(name.as_ref(), args.collect::<Vec<_>>().as_slice()) global.as_ref().invoke_callback(name.as_ref(), args.collect::<Vec<_>>().as_slice())
} }
} }
} }

View file

@ -18,7 +18,7 @@ use sixtyfps_corelib::{rtti, Callback, Property};
use crate::{api::Value, eval}; use crate::{api::Value, eval};
pub trait GlobalComponent { pub trait GlobalComponent {
fn call_callback(self: Pin<&Self>, _callback_name: &str, _args: &[Value]) -> Value { fn invoke_callback(self: Pin<&Self>, _callback_name: &str, _args: &[Value]) -> Value {
todo!("call callback") todo!("call callback")
} }

View file

@ -81,8 +81,8 @@ assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Text1New"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New"));
instance.call_set_ti1(sixtyfps::SharedString::from("Hallo")); instance.invoke_set_ti1(sixtyfps::SharedString::from("Hallo"));
instance.call_set_ti2(sixtyfps::SharedString::from("Bonjour")); instance.invoke_set_ti2(sixtyfps::SharedString::from("Bonjour"));
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo"));
@ -130,8 +130,8 @@ assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Text1New"));
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Text2New")); assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Text2New"));
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Text2New")); assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Text2New"));
instance.call_set_ti1(sixtyfps::SharedString("Hallo")); instance.invoke_set_ti1(sixtyfps::SharedString("Hallo"));
instance.call_set_ti2(sixtyfps::SharedString("Bonjour")); instance.invoke_set_ti2(sixtyfps::SharedString("Bonjour"));
assert_eq(instance.get_text1(), sixtyfps::SharedString("Hallo")); assert_eq(instance.get_text1(), sixtyfps::SharedString("Hallo"));
assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New")); assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New"));
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hallo")); assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hallo"));

View file

@ -23,12 +23,12 @@ int callback_3_emited = 0;
instance.on_test_callback3([&]{ callback_3_emited++; }); instance.on_test_callback3([&]{ callback_3_emited++; });
instance.set_callback_emission_count(0); instance.set_callback_emission_count(0);
assert_eq(instance.get_callback_emission_count(), 0); assert_eq(instance.get_callback_emission_count(), 0);
instance.call_test_callback(); instance.invoke_test_callback();
assert_eq(instance.get_callback_emission_count(), 1); assert_eq(instance.get_callback_emission_count(), 1);
instance.call_test_callback(); instance.invoke_test_callback();
assert_eq(instance.get_callback_emission_count(), 2); assert_eq(instance.get_callback_emission_count(), 2);
assert_eq(callback_3_emited, 0); assert_eq(callback_3_emited, 0);
instance.call_test_callback2(); instance.invoke_test_callback2();
assert_eq(instance.get_callback_emission_count(), 88); assert_eq(instance.get_callback_emission_count(), 88);
assert_eq(callback_3_emited, 1); assert_eq(callback_3_emited, 1);
``` ```
@ -43,12 +43,12 @@ instance.on_test_callback3({
}); });
instance.set_callback_emission_count(0); instance.set_callback_emission_count(0);
assert_eq!(instance.get_callback_emission_count(), 0); assert_eq!(instance.get_callback_emission_count(), 0);
instance.call_test_callback(); instance.invoke_test_callback();
assert_eq!(instance.get_callback_emission_count(), 1); assert_eq!(instance.get_callback_emission_count(), 1);
instance.call_test_callback(); instance.invoke_test_callback();
assert_eq!(instance.get_callback_emission_count(), 2); assert_eq!(instance.get_callback_emission_count(), 2);
assert_eq!(callback_3_emited.get(), 0); assert_eq!(callback_3_emited.get(), 0);
instance.call_test_callback2(); instance.invoke_test_callback2();
assert_eq!(instance.get_callback_emission_count(), 88); assert_eq!(instance.get_callback_emission_count(), 88);
assert_eq!(callback_3_emited.get(), 1); assert_eq!(callback_3_emited.get(), 1);
``` ```

View file

@ -31,10 +31,10 @@ instance.on_test_callback3([&](int a, auto b) {
}); });
instance.set_callback_emission_count(0); instance.set_callback_emission_count(0);
assert_eq(instance.get_callback_emission_count(), 0); assert_eq(instance.get_callback_emission_count(), 0);
instance.call_test_callback(42); instance.invoke_test_callback(42);
assert_eq(instance.get_callback_emission_count(), 1); assert_eq(instance.get_callback_emission_count(), 1);
assert_eq(callback_3_emited, 0); assert_eq(callback_3_emited, 0);
instance.call_test_callback2("hello"); instance.invoke_test_callback2("hello");
assert_eq(instance.get_callback_emission_count(), 88); assert_eq(instance.get_callback_emission_count(), 88);
assert_eq(callback_3_emited, 1); assert_eq(callback_3_emited, 1);
assert_eq(callback_3_int_value, 55); assert_eq(callback_3_int_value, 55);
@ -50,10 +50,10 @@ instance.on_test_callback3({
}); });
instance.set_callback_emission_count(0); instance.set_callback_emission_count(0);
assert_eq!(instance.get_callback_emission_count(), 0); assert_eq!(instance.get_callback_emission_count(), 0);
instance.call_test_callback(42); instance.invoke_test_callback(42);
assert_eq!(instance.get_callback_emission_count(), 1); assert_eq!(instance.get_callback_emission_count(), 1);
assert_eq!(*callback_3_emited.borrow(), (0, "".into())); assert_eq!(*callback_3_emited.borrow(), (0, "".into()));
instance.call_test_callback2("hello".into()); instance.invoke_test_callback2("hello".into());
assert_eq!(instance.get_callback_emission_count(), 88); assert_eq!(instance.get_callback_emission_count(), 88);
assert_eq!(*callback_3_emited.borrow(), (55, "hello".into())); assert_eq!(*callback_3_emited.borrow(), (55, "hello".into()));
``` ```

View file

@ -33,7 +33,7 @@ instance.set_some_value(2);
assert_eq!(instance.get_test_prop(), 4 + 4); assert_eq!(instance.get_test_prop(), 4 + 4);
assert_eq!(instance.get_test_prop2(), sixtyfps::SharedString::from("hello=44")); assert_eq!(instance.get_test_prop2(), sixtyfps::SharedString::from("hello=44"));
assert_eq!(instance.call_test_func2("xxx".into(), 1), sixtyfps::SharedString::from("xxx=3")); assert_eq!(instance.invoke_test_func2("xxx".into(), 1), sixtyfps::SharedString::from("xxx=3"));
``` ```
```cpp ```cpp
@ -48,7 +48,7 @@ instance.set_some_value(2);
assert_eq(instance.get_test_prop(), 4 + 4); assert_eq(instance.get_test_prop(), 4 + 4);
assert_eq(instance.get_test_prop2(), sixtyfps::SharedString("hello=44")); assert_eq(instance.get_test_prop2(), sixtyfps::SharedString("hello=44"));
assert_eq(instance.call_test_func2("xxx", 1), sixtyfps::SharedString("xxx=3")); assert_eq(instance.invoke_test_func2("xxx", 1), sixtyfps::SharedString("xxx=3"));
``` ```

View file

@ -52,37 +52,37 @@ TestCase := Rectangle {
```cpp ```cpp
auto handle = TestCase::create(); auto handle = TestCase::create();
const TestCase &instance = *handle; const TestCase &instance = *handle;
instance.call_action(); instance.invoke_action();
assert_eq(instance.get_result(), 3); assert_eq(instance.get_result(), 3);
instance.set_value(5); instance.set_value(5);
instance.call_action(); instance.invoke_action();
assert_eq(instance.get_result(), 5); assert_eq(instance.get_result(), 5);
instance.set_value(8); instance.set_value(8);
instance.call_action(); instance.invoke_action();
assert_eq(instance.get_result(), 5+33); assert_eq(instance.get_result(), 5+33);
instance.call_xxx(); instance.invoke_xxx();
assert_eq(instance.get_result(), 5+33-1); assert_eq(instance.get_result(), 5+33-1);
assert_eq(instance.call_elseif(1), 41); assert_eq(instance.invoke_elseif(1), 41);
assert_eq(instance.call_elseif(2), 42); assert_eq(instance.invoke_elseif(2), 42);
assert_eq(instance.call_elseif(3), 43); assert_eq(instance.invoke_elseif(3), 43);
``` ```
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
instance.call_action(); instance.invoke_action();
assert_eq!(instance.get_result(), 3); assert_eq!(instance.get_result(), 3);
instance.set_value(5); instance.set_value(5);
instance.call_action(); instance.invoke_action();
assert_eq!(instance.get_result(), 5); assert_eq!(instance.get_result(), 5);
instance.set_value(8); instance.set_value(8);
instance.call_action(); instance.invoke_action();
assert_eq!(instance.get_result(), 5+33); assert_eq!(instance.get_result(), 5+33);
instance.call_xxx(); instance.invoke_xxx();
assert_eq!(instance.get_result(), 5+33-1); assert_eq!(instance.get_result(), 5+33-1);
assert_eq!(instance.call_elseif(1), 41); assert_eq!(instance.invoke_elseif(1), 41);
assert_eq!(instance.call_elseif(2), 42); assert_eq!(instance.invoke_elseif(2), 42);
assert_eq!(instance.call_elseif(3), 43); assert_eq!(instance.invoke_elseif(3), 43);
``` ```
```js ```js

View file

@ -31,7 +31,7 @@ assert_eq(instance.get_t2(), 500 / 2 * 30 - 1);
instance.set_a(42); instance.set_a(42);
assert_eq(instance.get_t3(), 42 - (3 + 2 * (42 + 2))); assert_eq(instance.get_t3(), 42 - (3 + 2 * (42 + 2)));
assert_eq(instance.get_t4(), 3 + - 5 - 8 - -9 * - - - 120); assert_eq(instance.get_t4(), 3 + - 5 - 8 - -9 * - - - 120);
instance.call_foo(); instance.invoke_foo();
assert_eq(instance.get_a(), (((42 + 8) * 10) / 2) - 3); assert_eq(instance.get_a(), (((42 + 8) * 10) / 2) - 3);
``` ```
@ -43,7 +43,7 @@ assert_eq!(instance.get_t2(), 500 / 2 * 30 - 1);
instance.set_a(42); instance.set_a(42);
assert_eq!(instance.get_t3(), 42 - (3 + 2 * (42 + 2))); assert_eq!(instance.get_t3(), 42 - (3 + 2 * (42 + 2)));
assert_eq!(instance.get_t4(), 3 + - 5 - 8 - -9 * --- 120); assert_eq!(instance.get_t4(), 3 + - 5 - 8 - -9 * --- 120);
instance.call_foo(); instance.invoke_foo();
assert_eq!(instance.get_a(), (((42 + 8) * 10) / 2) - 3); assert_eq!(instance.get_a(), (((42 + 8) * 10) / 2) - 3);
``` ```

View file

@ -34,12 +34,12 @@ assert_eq(instance.get_value(), 100);
instance.set_toggle(true); instance.set_toggle(true);
assert_eq(instance.get_value(), 42); assert_eq(instance.get_value(), 42);
instance.call_test_signal(); instance.invoke_test_signal();
assert(instance.get_signal_handled()); assert(instance.get_signal_handled());
instance.set_signal_handled(false); instance.set_signal_handled(false);
instance.set_block_signal(true); instance.set_block_signal(true);
instance.call_test_signal(); instance.invoke_test_signal();
assert(!instance.get_signal_handled()); assert(!instance.get_signal_handled());
``` ```
@ -49,12 +49,12 @@ assert_eq!(instance.get_value(), 100);
instance.set_toggle(true); instance.set_toggle(true);
assert_eq!(instance.get_value(), 42); assert_eq!(instance.get_value(), 42);
instance.call_test_signal(); instance.invoke_test_signal();
assert!(instance.get_signal_handled()); assert!(instance.get_signal_handled());
instance.set_signal_handled(false); instance.set_signal_handled(false);
instance.set_block_signal(true); instance.set_block_signal(true);
instance.call_test_signal(); instance.invoke_test_signal();
assert!(!instance.get_signal_handled()); assert!(!instance.get_signal_handled());
``` ```

View file

@ -29,7 +29,7 @@ assert_eq(instance.get_s1(), sixtyfps::SharedString("hello1212"));
assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1")); assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242")); assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242"));
instance.call_foo(); instance.invoke_foo();
assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42")); assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42"));
assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx")); assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx"));
``` ```
@ -41,7 +41,7 @@ assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212"));
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1")); assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242")); assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242"));
instance.call_foo(); instance.invoke_foo();
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42")); assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42"));
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx")); assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx"));
``` ```

View file

@ -28,7 +28,7 @@ assert_eq(instance.get_s1(), sixtyfps::SharedString("hello1212"));
assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1")); assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242")); assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242"));
instance.call_foo(); instance.invoke_foo();
assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42")); assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42"));
assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx")); assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx"));
``` ```
@ -40,7 +40,7 @@ assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212"));
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1")); assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242")); assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242"));
instance.call_foo(); instance.invoke_foo();
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42")); assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42"));
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx")); assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx"));
``` ```

View file

@ -40,11 +40,11 @@ let instance = TestCase::new();
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
instance.call_focus_input1(); instance.invoke_focus_input1();
assert!(instance.get_input1_focused()); assert!(instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
instance.call_focus_input2(); instance.invoke_focus_input2();
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused()); assert!(instance.get_input2_focused());
``` ```
@ -55,11 +55,11 @@ const TestCase &instance = *handle;
assert(!instance.get_input1_focused()); assert(!instance.get_input1_focused());
assert(!instance.get_input2_focused()); assert(!instance.get_input2_focused());
instance.call_focus_input1(); instance.invoke_focus_input1();
assert(instance.get_input1_focused()); assert(instance.get_input1_focused());
assert(!instance.get_input2_focused()); assert(!instance.get_input2_focused());
instance.call_focus_input2(); instance.invoke_focus_input2();
assert(!instance.get_input1_focused()); assert(!instance.get_input1_focused());
assert(instance.get_input2_focused()); assert(instance.get_input2_focused());
``` ```

View file

@ -34,7 +34,7 @@ TestCase := Rectangle {
let instance = TestCase::new(); let instance = TestCase::new();
assert!(!instance.get_input_focused()); assert!(!instance.get_input_focused());
instance.call_focus_rectangle(); instance.invoke_focus_rectangle();
assert!(instance.get_input_focused()); assert!(instance.get_input_focused());
``` ```
@ -43,7 +43,7 @@ auto handle = TestCase::create();
const TestCase &instance = *handle; const TestCase &instance = *handle;
assert(!instance.get_input_focused()); assert(!instance.get_input_focused());
instance.call_focus_rectangle(); instance.invoke_focus_rectangle();
assert(instance.get_input_focused()); assert(instance.get_input_focused());
``` ```

View file

@ -24,7 +24,7 @@ TestCase := Rectangle {
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_value1(), 3+3); assert_eq!(instance.get_value1(), 3+3);
instance.call_set_a(4); instance.invoke_set_a(4);
assert_eq!(instance.get_value1(), 4+3); assert_eq!(instance.get_value1(), 4+3);
``` ```
@ -32,7 +32,7 @@ assert_eq!(instance.get_value1(), 4+3);
auto handle = TestCase::create(); auto handle = TestCase::create();
const TestCase &instance = *handle; const TestCase &instance = *handle;
assert_eq(instance.get_value1(), 3+3); assert_eq(instance.get_value1(), 3+3);
instance.call_set_a(4); instance.invoke_set_a(4);
assert_eq(instance.get_value1(), 4+3); assert_eq(instance.get_value1(), 4+3);
``` ```

View file

@ -23,8 +23,8 @@ Foo := Rectangle {
TestCase := Rectangle { TestCase := Rectangle {
callback call_glob; callback invoke_glob;
call_glob => { invoke_glob => {
MyGlobal.glob_callback(); MyGlobal.glob_callback();
} }
Foo {} Foo {}

View file

@ -32,7 +32,7 @@ TestCase := Rectangle {
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_foo_a(), sixtyfps::SharedString::from("444")); assert_eq!(instance.get_foo_a(), sixtyfps::SharedString::from("444"));
assert_eq!(instance.get_foo_b(), 12); assert_eq!(instance.get_foo_b(), 12);
instance.call_change_foo(); instance.invoke_change_foo();
assert_eq!(instance.get_foo_a(), sixtyfps::SharedString::from("hello")); assert_eq!(instance.get_foo_a(), sixtyfps::SharedString::from("hello"));
assert_eq!(instance.get_foo_b(), 20); assert_eq!(instance.get_foo_b(), 20);
assert_eq!(instance.get_obj_cond_merge_b(), 0); assert_eq!(instance.get_obj_cond_merge_b(), 0);
@ -50,7 +50,7 @@ auto handle = TestCase::create();
const TestCase &instance = *handle; const TestCase &instance = *handle;
assert_eq(instance.get_foo_a(), sixtyfps::SharedString("444")); assert_eq(instance.get_foo_a(), sixtyfps::SharedString("444"));
assert_eq(instance.get_foo_b(), 12); assert_eq(instance.get_foo_b(), 12);
instance.call_change_foo(); instance.invoke_change_foo();
assert_eq(instance.get_foo_a(), sixtyfps::SharedString("hello")); assert_eq(instance.get_foo_a(), sixtyfps::SharedString("hello"));
assert_eq(instance.get_foo_b(), 20); assert_eq(instance.get_foo_b(), 20);
assert_eq(instance.get_obj_cond_merge_b(), 0); assert_eq(instance.get_obj_cond_merge_b(), 0);