Port everything over to AsXml

This commit is contained in:
Jonas Schäfer 2024-07-09 17:01:42 +02:00
commit ccf38cdf9b
64 changed files with 848 additions and 371 deletions

View file

@ -9,6 +9,8 @@
use proc_macro2::Span;
use syn::*;
use crate::types::ref_ty;
/// Container struct for various identifiers used throughout the parser code.
///
/// This struct is passed around from the [`crate::compound::Compound`]
@ -80,19 +82,24 @@ impl FromEventsScope {
/// same page about which identifiers are used for what.
///
/// See [`FromEventsScope`] for recommendations on the usage.
pub(crate) struct IntoEventsScope {
/// Accesses the `AttrMap` from code in
/// [`crate::field::FieldIteratorPart::Header`].
pub(crate) attrs: Ident,
pub(crate) struct AsItemsScope {
/// Lifetime for data borrowed by the implementation.
pub(crate) lifetime: Lifetime,
}
impl IntoEventsScope {
impl AsItemsScope {
/// Create a fresh scope with all necessary identifiers.
pub(crate) fn new() -> Self {
pub(crate) fn new(lifetime: &Lifetime) -> Self {
Self {
attrs: Ident::new("attrs", Span::call_site()),
lifetime: lifetime.clone(),
}
}
/// Create a reference to `ty`, borrowed for the lifetime of the AsXml
/// impl.
pub(crate) fn borrow(&self, ty: Type) -> Type {
ref_ty(ty, self.lifetime.clone())
}
}
pub(crate) fn mangle_member(member: &Member) -> Ident {