Skip to main content

ferroui_markup_xaml/
lib.rs

1//! ferroui-markup-xaml
2//!
3//! The XAML runtime library: what compiled and interpreted markup documents
4//! call into. Markup extensions, templates, includes, type converters, the
5//! runtime helpers of the XAML compiler (service providers, deferred content,
6//! parent stacks) and the loader entry point.
7
8pub mod converters;
9pub mod data;
10pub mod diagnostics;
11pub mod markup_extensions;
12pub mod parsers;
13pub mod styling;
14pub mod templates;
15pub mod xaml_il;
16pub mod xamlx_runtime;
17
18mod eager_parent_stack_enumerator;
19mod extensions;
20mod ferro_xaml_loader;
21mod markup_extension;
22mod object_casts;
23mod register_types;
24mod rust_paths;
25mod runtime_xaml_loader_configuration;
26mod runtime_xaml_loader_document;
27mod xaml_load_exception;
28mod xaml_types;
29
30pub use eager_parent_stack_enumerator::EagerParentStackEnumerator;
31pub use extensions::ServiceProviderExtensions;
32pub use ferro_xaml_loader::{CompiledXamlLoader, FerroXamlLoader, IRuntimeXamlLoader};
33pub use markup_extension::MarkupExtension;
34pub use object_casts::{FromXamlObject, XamlResourceNode};
35pub use register_types::{register_types, ASSEMBLY};
36pub use runtime_xaml_loader_configuration::{
37    RuntimeXamlDiagnostic, RuntimeXamlDiagnosticSeverity, RuntimeXamlLoaderConfiguration, XamlDiagnosticFunc,
38};
39pub use runtime_xaml_loader_document::RuntimeXamlLoaderDocument;
40pub use xaml_load_exception::XamlLoadException;
41pub use xaml_types::{IProvideValueTarget, IRootObjectProvider, IUriContext, IXamlTypeResolver};
42
43/// Includes the compiled markup the build script of the crate generated
44/// (`ferroui_build::Build::run`, docs/porting/xaml.md 9.6.2), at the root of the
45/// crate: one public module per group of documents (`compiled_xaml` for the
46/// default group) and the module `compiled_markup` with the embedded assets
47/// (`ASSETS`), the loader table of the crate (`try_load`) and `register()`,
48/// which the `register_types()` of the crate calls.
49#[macro_export]
50macro_rules! include_compiled_xaml {
51    () => {
52        include!(concat!(env!("OUT_DIR"), "/xaml/mod.rs"));
53    };
54}
55
56/// Gives a shared plain type identity equality (the reference equality of a
57/// class instance), so that it can be held in untyped values.
58macro_rules! identity_eq {
59    ($($type_:ty),* $(,)?) => {$(
60        impl PartialEq for $type_ {
61            fn eq(&self, other: &Self) -> bool {
62                ::std::ptr::addr_eq(self, other)
63            }
64        }
65    )*};
66}
67pub(crate) use identity_eq;
68
69/// The equivalent of an exception thrown through an untyped (metadata)
70/// call: metadata invokers have no error channel for methods, so the error
71/// of a fallible member surfaces as a panic that carries its message.
72pub(crate) fn throw<T>(result: Result<T, XamlLoadException>) -> T {
73    match result {
74        Ok(value) => value,
75        Err(error) => panic!("{error}"),
76    }
77}
78
79#[cfg(test)]
80mod test_support;