Skip to main content

xamlx/
lib.rs

1//! Rust port of the backend-independent part of XamlX, the XAML compiler library by
2//! Nikita Tsukanov (MIT, see `external/XamlX/NOTICE.md`).
3//!
4//! The crate mirrors the upstream layout module for module:
5//!
6//! | Module | Upstream | Contents |
7//! |---|---|---|
8//! | [`ast`] | `Ast/` | AST nodes, visitors, type/property references, intrinsics |
9//! | [`parsers`] | `Parsers/` | XML based XAML parser and the markup extension parser |
10//! | [`type_system`] | `TypeSystem/` | the type system abstraction and its helpers |
11//! | [`transform`] | `Transform/` | transformation context, configuration and all AST transformers |
12//! | [`emit`] | `Emit/` | backend-agnostic emit contracts |
13//! | [`compiler`] | `Compiler/` | the backend-independent compiler driver |
14//! | [`diagnostics`] | `Diagnostics/` | diagnostics and their severity |
15//! | [`exceptions`] | `Exceptions.cs` | the error type |
16//!
17//! The IL backend (`IL/`) is not part of the port. Upstream AST nodes implement the IL
18//! emitting interfaces directly; here the nodes carry only their data, and a backend supplies
19//! node emitters ([`emit::IXamlAstNodeEmitter`]) for them.
20//!
21//! # Conventions
22//!
23//! * C# interfaces keep their `I` prefix as trait names and are used through `Rc<dyn ...>`
24//!   handles; a C# property named `Type` becomes `type_`.
25//! * Nodes are mutable through `Cell`/`RefCell` fields, which keeps the upstream in-place
26//!   visitor semantics and node identity.
27//! * Exceptions become [`XamlResult`] values carrying an [`XamlError`].
28
29#![forbid(unsafe_code)]
30// The port keeps the upstream shapes (tuple lists, callback signatures, module names).
31#![allow(clippy::type_complexity, clippy::module_inception)]
32
33pub mod ast;
34pub mod compiler;
35pub mod diagnostics;
36pub mod emit;
37pub mod exceptions;
38pub mod extensions;
39pub mod parsers;
40pub mod transform;
41pub mod type_system;
42pub mod xaml_namespaces;
43
44/// An in-memory type system for tests of transformers and emitter backends.
45#[cfg(any(test, feature = "testing"))]
46pub mod testing;
47
48#[cfg(test)]
49mod tests;
50
51pub use diagnostics::{XamlDiagnostic, XamlDiagnosticSeverity, XamlXWellKnownDiagnosticCodes};
52pub use exceptions::{XamlError, XamlParseException, XamlResult, XamlTypeSystemException};
53pub use xaml_namespaces::XamlNamespaces;