use super::{ComponentParse, ComponentSourceError, parse_component};
use vize_l0::{Allocator, SourceBlock};
mod child;
mod element;
mod interpolation;
mod operand;
mod selected;
pub use child::{NativeChild, NativeChildren};
pub use element::{NativeAttribute, NativeAttributes, NativeElement};
pub use interpolation::{
NativeInterpolationError, NativeInterpolationFailure, NativeInterpolationOperand,
NativeInterpolationView,
};
pub use operand::{
NativeAttributeExpression, NativeAttributeExpressionFailure, NativeAttributeExpressionView,
NativeAttributeForHead, NativeAttributeForHeadFailure, NativeAttributeForHeadView,
NativeAttributeOperandError, NativeConditionKind,
};
pub use selected::{NativeScriptSelection, NativeTemplateComponent, NativeTemplateGrammar};
pub struct NativeComponent<'a> {
allocator: &'a Allocator,
block: SourceBlock<'a>,
component: ComponentParse<'a>,
}
impl core::fmt::Debug for NativeComponent<'_> {
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
formatter
.debug_struct("NativeComponent")
.field("block", &self.block)
.field("component", &self.component)
.finish_non_exhaustive()
}
}
impl<'a> NativeComponent<'a> {
pub fn parse_in(
allocator: &'a Allocator,
block: SourceBlock<'a>,
) -> Result<Self, ComponentSourceError> {
Ok(Self {
allocator,
block,
component: parse_component(allocator, block.source())?,
})
}
#[must_use]
pub fn allocator(&self) -> &'a Allocator {
self.allocator
}
#[must_use]
pub fn block(&self) -> SourceBlock<'a> {
self.block
}
#[must_use]
pub fn carrier(&self) -> &ComponentParse<'a> {
&self.component
}
#[must_use]
pub fn children(&self) -> NativeChildren<'_, 'a> {
NativeChildren::root(self)
}
#[must_use]
pub fn into_carrier(self) -> ComponentParse<'a> {
self.component
}
}
#[cfg(test)]
mod reborrow_tests;
#[cfg(test)]
mod tests;