Doc fixes

Try to use the term "global singleton" consistently. That's also the
term we use in the language reference.
This commit is contained in:
Simon Hausmann 2021-08-27 13:46:44 +02:00
parent 26a63fcf22
commit 4b8259017b
4 changed files with 18 additions and 18 deletions

View file

@ -710,10 +710,10 @@ public:
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); }); new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
} }
/// Set the value for a property within an exported global /// Set the value for a property within an exported global singleton.
/// ///
/// For example, if the main file has an exported global `TheGlobal` with a `property <int> hello`, /// For example, if the main file has an exported global `TheGlobal` with a `property <int>
/// we can set this property /// hello`, we can set this property
/// ``` /// ```
/// instance->set_global_property("TheGlobal", "hello", 42); /// instance->set_global_property("TheGlobal", "hello", 42);
/// ``` /// ```
@ -729,7 +729,7 @@ public:
inner(), sixtyfps::private_api::string_to_slice(global), inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &value.inner); sixtyfps::private_api::string_to_slice(prop_name), &value.inner);
} }
/// Returns the value behind a property in an exported global. /// Returns the value behind a property in an exported global singleton.
std::optional<Value> get_global_property(std::string_view global, std::optional<Value> get_global_property(std::string_view global,
std::string_view prop_name) const std::string_view prop_name) const
{ {
@ -744,7 +744,7 @@ public:
} }
} }
/// Like `set_callback()` but on a callback in the specified exported global /// Like `set_callback()` but on a callback in the specified exported global singleton.
/// ///
/// Example: imagine the .60 file contains the given global: /// Example: imagine the .60 file contains the given global:
/// ```60 /// ```60
@ -776,7 +776,7 @@ public:
} }
// FIXME! Slice in public API? Should be std::span (c++20) or we need to improve the Slice API // FIXME! Slice in public API? Should be std::span (c++20) or we need to improve the Slice API
/// Invoke the specified callback declared in an exported global /// Invoke the specified callback declared in an exported global singleton
std::optional<Value> invoke_global_callback(std::string_view global, std::optional<Value> invoke_global_callback(std::string_view global,
std::string_view callback_name, std::string_view callback_name,
Slice<Value> args) const Slice<Value> args) const

View file

@ -158,7 +158,7 @@ pub mod generated_code {
unimplemented!(); unimplemented!();
} }
/// This function provides access to instances of global structures exported in `.60`. /// This function provides access to instances of global singletons exported in `.60`.
fn global<'a, T: Global<'a, Self>>(&'a self) -> T { fn global<'a, T: Global<'a, Self>>(&'a self) -> T {
unimplemented!() unimplemented!()
} }

View file

@ -421,13 +421,13 @@ pub fn invoke_from_event_loop(func: impl FnOnce() + Send + 'static) {
sixtyfps_rendering_backend_default::backend().post_event(Box::new(func)) sixtyfps_rendering_backend_default::backend().post_event(Box::new(func))
} }
/// This trait is used to obtain references to global structures exported in `.60` /// This trait is used to obtain references to global singletons exported in `.60`
/// markup. Alternatively, you can use [`ComponentHandle::global`] to obtain access. /// markup. Alternatively, you can use [`ComponentHandle::global`] to obtain access.
/// ///
/// This trait is implemented by the compiler for each global that's exported. /// This trait is implemented by the compiler for each global singleton that's exported.
/// ///
/// # Example /// # Example
/// The following example of `.60` markup defines a global called `Palette`, exports /// The following example of `.60` markup defines a global singleton called `Palette`, exports
/// it and modifies it from Rust code: /// it and modifies it from Rust code:
/// ```rust /// ```rust
/// sixtyfps::sixtyfps!{ /// sixtyfps::sixtyfps!{
@ -448,11 +448,11 @@ pub fn invoke_from_event_loop(func: impl FnOnce() + Send + 'static) {
/// let app = App::new(); /// let app = App::new();
/// app.global::<Palette>().set_background_color(sixtyfps::Color::from_rgb_u8(0, 0, 0)); /// app.global::<Palette>().set_background_color(sixtyfps::Color::from_rgb_u8(0, 0, 0));
/// ///
/// // alternate way to access the global: /// // alternate way to access the global singleton:
/// Palette::get(&app).set_foreground_color(sixtyfps::Color::from_rgb_u8(255, 255, 255)); /// Palette::get(&app).set_foreground_color(sixtyfps::Color::from_rgb_u8(255, 255, 255));
/// ``` /// ```
/// ///
/// See also the [language reference for globals](docs/langref/index.html#global-singletons) for more information. /// See also the [language reference for global singletons](docs/langref/index.html#global-singletons) for more information.
pub trait Global<'a, Component> { pub trait Global<'a, Component> {
/// Returns a reference that's tied to the life time of the provided component. /// Returns a reference that's tied to the life time of the provided component.
fn get(component: &'a Component) -> Self; fn get(component: &'a Component) -> Self;
@ -498,7 +498,7 @@ pub trait ComponentHandle {
/// and [`Self::hide`]. /// and [`Self::hide`].
fn run(&self); fn run(&self);
/// This function provides access to instances of global structures exported in `.60`. /// This function provides access to instances of global singletons exported in `.60`.
/// See [`Global`] for an example how to export and access globals from `.60` markup. /// See [`Global`] for an example how to export and access globals from `.60` markup.
fn global<'a, T: Global<'a, Self>>(&'a self) -> T fn global<'a, T: Global<'a, Self>>(&'a self) -> T
where where

View file

@ -788,9 +788,9 @@ impl ComponentInstance {
.map_err(|()| CallCallbackError::NoSuchCallback) .map_err(|()| CallCallbackError::NoSuchCallback)
} }
/// Return the value for a property within an exported global used by this component. /// Return the value for a property within an exported global singleton used by this component.
/// ///
/// The `global` parameter is the exported name of the global. The `property` argument /// The `global` parameter is the exported name of the global singleton. The `property` argument
/// is the name of the property /// is the name of the property
/// ///
/// ## Examples /// ## Examples
@ -827,7 +827,7 @@ impl ComponentInstance {
.map_err(|()| GetPropertyError::NoSuchProperty) .map_err(|()| GetPropertyError::NoSuchProperty)
} }
/// Set the value for a property within an exported global used by this component. /// Set the value for a property within an exported global singleton used by this component.
pub fn set_global_property( pub fn set_global_property(
&self, &self,
global: &str, global: &str,
@ -843,7 +843,7 @@ impl ComponentInstance {
.set_property(&normalize_identifier(property), value) .set_property(&normalize_identifier(property), value)
} }
/// Set a handler for the callback in the exported global. A callback with that /// Set a handler for the callback in the exported global singleton. A callback with that
/// name must be defined in the specified global and the global must be exported from the /// name must be defined in the specified global and the global must be exported from the
/// main document otherwise an error will be returned. /// main document otherwise an error will be returned.
/// ///
@ -892,7 +892,7 @@ impl ComponentInstance {
.map_err(|()| SetCallbackError::NoSuchCallback) .map_err(|()| SetCallbackError::NoSuchCallback)
} }
/// Call the given callback within a global with the arguments /// Call the given callback within a global singleton with the arguments
/// ///
/// ## Examples /// ## Examples
/// See the documentation of [`Self::set_global_callback`] for an example /// See the documentation of [`Self::set_global_callback`] for an example