ferro_class_info
macro · ferroui-base · v0.5.0
macro_rules! ferro_class_info
Declares the facts about a class that untyped code (markup, untyped bindings) needs and cannot derive: its default constructor, the interface handles its handle converts to and its markup metadata. Every part is optional; the parts may be written in any order.
ferro_class!(SolidColorBrush: Brush);
ferro_class_info!(SolidColorBrush {
new: SolidColorBrush::new,
interfaces: [Rc<dyn IBrush>],
});
ferro_class!(Panel: Control);
ferro_class_info!(Panel {
new: Panel::new,
markup: {
content: Children,
properties: [
Children: Rc<Controls> { get: Panel::children },
],
},
});
newis a function without parameters that returns the handle of a new instance. It implementsDefaultConstructiblefor the class, the static path to the constructor, and becomesTypeInfo::default_constructorwith the tables of types (the featuretype-tables; seeTypeInfo::with_constructor).interfaceslists the handle typesIthatRef<Class>converts to withInto<I>, or, asI => function, with the givenfn(Ref<Class>) -> I(for an interface of another crate, for which the conversion trait cannot be implemented). They are registered with the untyped value conversions when the class is initialised, for the class and every class deriving from it (a more derived class that lists the same interface takes precedence for its own instances), and are listed byTypeInfo::interfaces.markupstates what markup needs beyond the registered properties of the class, which need no declaration: the content property, plain (non-registered) properties and collections, constructors with arguments, methods, static values, events and attributes. The parts are the ones offerro_markup_type!(withouthandles,thisandbase, which follow from the class); instance members are called with&Ref<Class>, soClass::methodpaths work as callables. It becomesTypeInfo::markup: constant data that costs nothing until it is read.
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.