diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-01 16:30:58 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-01 16:33:28 +0100 |
| commit | 6ab7760822ccd24b4ef126d4737d41f1be15fe19 (patch) | |
| tree | 49905f91d292ceefe4f9878ead43f117c4b1fec0 /macros | |
| parent | ab841188e3d2687ee8f436336e6fde337985a83e (diff) | |
Split up `model` module
Diffstat (limited to 'macros')
| -rw-r--r-- | macros/src/castable.rs | 34 | ||||
| -rw-r--r-- | macros/src/func.rs | 20 | ||||
| -rw-r--r-- | macros/src/node.rs | 16 | ||||
| -rw-r--r-- | macros/src/symbols.rs | 4 |
4 files changed, 37 insertions, 37 deletions
diff --git a/macros/src/castable.rs b/macros/src/castable.rs index 6738ee1d..c39df90a 100644 --- a/macros/src/castable.rs +++ b/macros/src/castable.rs @@ -18,20 +18,20 @@ pub fn castable(stream: TokenStream) -> Result<TokenStream> { let describe_func = create_describe_func(&castable); let dynamic_impls = castable.name.as_ref().map(|name| { quote! { - impl ::typst::model::Type for #ty { + impl ::typst::eval::Type for #ty { const TYPE_NAME: &'static str = #name; } - impl From<#ty> for ::typst::model::Value { + impl From<#ty> for ::typst::eval::Value { fn from(v: #ty) -> Self { - ::typst::model::Value::Dyn(::typst::model::Dynamic::new(v)) + ::typst::eval::Value::Dyn(::typst::eval::Dynamic::new(v)) } } } }); Ok(quote! { - impl ::typst::model::Cast for #ty { + impl ::typst::eval::Cast for #ty { #is_func #cast_func #describe_func @@ -53,7 +53,7 @@ fn create_is_func(castable: &Castable) -> TokenStream { } Pattern::Ty(_, ty) => { cast_checks.push(quote! { - if <#ty as ::typst::model::Cast>::is(value) { + if <#ty as ::typst::eval::Cast>::is(value) { return true; } }); @@ -63,7 +63,7 @@ fn create_is_func(castable: &Castable) -> TokenStream { let dynamic_check = castable.name.is_some().then(|| { quote! { - if let ::typst::model::Value::Dyn(dynamic) = &value { + if let ::typst::eval::Value::Dyn(dynamic) = &value { if dynamic.is::<Self>() { return true; } @@ -73,7 +73,7 @@ fn create_is_func(castable: &Castable) -> TokenStream { let str_check = (!string_arms.is_empty()).then(|| { quote! { - if let ::typst::model::Value::Str(string) = &value { + if let ::typst::eval::Value::Str(string) = &value { match string.as_str() { #(#string_arms,)* _ => {} @@ -83,7 +83,7 @@ fn create_is_func(castable: &Castable) -> TokenStream { }); quote! { - fn is(value: &typst::model::Value) -> bool { + fn is(value: &::typst::eval::Value) -> bool { #dynamic_check #str_check #(#cast_checks)* @@ -105,8 +105,8 @@ fn create_cast_func(castable: &Castable) -> TokenStream { } Pattern::Ty(binding, ty) => { cast_checks.push(quote! { - if <#ty as ::typst::model::Cast>::is(&value) { - let #binding = <#ty as ::typst::model::Cast>::cast(value)?; + if <#ty as ::typst::eval::Cast>::is(&value) { + let #binding = <#ty as ::typst::eval::Cast>::cast(value)?; return Ok(#expr); } }); @@ -116,7 +116,7 @@ fn create_cast_func(castable: &Castable) -> TokenStream { let dynamic_check = castable.name.is_some().then(|| { quote! { - if let ::typst::model::Value::Dyn(dynamic) = &value { + if let ::typst::eval::Value::Dyn(dynamic) = &value { if let Some(concrete) = dynamic.downcast::<Self>() { return Ok(concrete.clone()); } @@ -126,7 +126,7 @@ fn create_cast_func(castable: &Castable) -> TokenStream { let str_check = (!string_arms.is_empty()).then(|| { quote! { - if let ::typst::model::Value::Str(string) = &value { + if let ::typst::eval::Value::Str(string) = &value { match string.as_str() { #(#string_arms,)* _ => {} @@ -136,11 +136,11 @@ fn create_cast_func(castable: &Castable) -> TokenStream { }); quote! { - fn cast(value: ::typst::model::Value) -> ::typst::diag::StrResult<Self> { + fn cast(value: ::typst::eval::Value) -> ::typst::diag::StrResult<Self> { #dynamic_check #str_check #(#cast_checks)* - <Self as ::typst::model::Cast>::error(value) + <Self as ::typst::eval::Cast>::error(value) } } } @@ -153,10 +153,10 @@ fn create_describe_func(castable: &Castable) -> TokenStream { let docs = documentation(&cast.attrs); infos.push(match &cast.pattern { Pattern::Str(lit) => { - quote! { ::typst::model::CastInfo::Value(#lit.into(), #docs) } + quote! { ::typst::eval::CastInfo::Value(#lit.into(), #docs) } } Pattern::Ty(_, ty) => { - quote! { <#ty as ::typst::model::Cast>::describe() } + quote! { <#ty as ::typst::eval::Cast>::describe() } } }); } @@ -168,7 +168,7 @@ fn create_describe_func(castable: &Castable) -> TokenStream { } quote! { - fn describe() -> ::typst::model::CastInfo { + fn describe() -> ::typst::eval::CastInfo { #(#infos)+* } } diff --git a/macros/src/func.rs b/macros/src/func.rs index 41504b20..f65c135e 100644 --- a/macros/src/func.rs +++ b/macros/src/func.rs @@ -21,7 +21,7 @@ pub fn func(item: syn::Item) -> Result<TokenStream> { let docs = docs.trim(); let info = quote! { - ::typst::model::FuncInfo { + ::typst::eval::FuncInfo { name, display: #display, category: #category, @@ -54,9 +54,9 @@ pub fn func(item: syn::Item) -> Result<TokenStream> { #[doc(hidden)] #vis enum #ty {} - impl::typst::model::FuncType for #ty { - fn create_func(name: &'static str) -> ::typst::model::Func { - ::typst::model::Func::from_fn(#full, #info) + impl::typst::eval::FuncType for #ty { + fn create_func(name: &'static str) -> ::typst::eval::Func { + ::typst::eval::Func::from_fn(#full, #info) } } }) @@ -72,9 +72,9 @@ pub fn func(item: syn::Item) -> Result<TokenStream> { Ok(quote! { #item - impl #params ::typst::model::FuncType for #ident #args #clause { - fn create_func(name: &'static str) -> ::typst::model::Func { - ::typst::model::Func::from_node::<Self>(#info) + impl #params ::typst::eval::FuncType for #ident #args #clause { + fn create_func(name: &'static str) -> ::typst::eval::Func { + ::typst::eval::Func::from_node::<Self>(#info) } } }) @@ -159,11 +159,11 @@ fn params(docs: &mut String) -> Result<(Vec<TokenStream>, Vec<String>)> { let docs = docs.trim(); infos.push(quote! { - ::typst::model::ParamInfo { + ::typst::eval::ParamInfo { name: #name, docs: #docs, - cast: <#ty as ::typst::model::Cast< - ::typst::syntax::Spanned<::typst::model::Value> + cast: <#ty as ::typst::eval::Cast< + ::typst::syntax::Spanned<::typst::eval::Value> >>::describe(), named: #named, positional: #positional, diff --git a/macros/src/node.rs b/macros/src/node.rs index b551182f..0d59a402 100644 --- a/macros/src/node.rs +++ b/macros/src/node.rs @@ -270,8 +270,8 @@ fn create_node_construct_func(node: &Node) -> syn::ImplItemMethod { node.construct.clone().unwrap_or_else(|| { parse_quote! { fn construct( - _: &::typst::model::Vm, - args: &mut ::typst::model::Args, + _: &::typst::eval::Vm, + args: &mut ::typst::eval::Args, ) -> ::typst::diag::SourceResult<::typst::model::Content> { ::typst::diag::bail!(args.span, "cannot be constructed manually"); } @@ -317,7 +317,7 @@ fn create_node_set_func(node: &Node) -> syn::ImplItemMethod { parse_quote! { fn set( - args: &mut ::typst::model::Args, + args: &mut ::typst::eval::Args, constructor: bool, ) -> ::typst::diag::SourceResult<::typst::model::StyleMap> { let mut styles = ::typst::model::StyleMap::new(); @@ -340,11 +340,11 @@ fn create_node_properties_func(node: &Node) -> syn::ImplItemMethod { let docs = docs.trim(); quote! { - ::typst::model::ParamInfo { + ::typst::eval::ParamInfo { name: #name, docs: #docs, - cast: <#value_ty as ::typst::model::Cast< - ::typst::syntax::Spanned<::typst::model::Value> + cast: <#value_ty as ::typst::eval::Cast< + ::typst::syntax::Spanned<::typst::eval::Value> >>::describe(), named: true, positional: #shorthand, @@ -356,7 +356,7 @@ fn create_node_properties_func(node: &Node) -> syn::ImplItemMethod { }); parse_quote! { - fn properties() -> ::std::vec::Vec<::typst::model::ParamInfo> + fn properties() -> ::std::vec::Vec<::typst::eval::ParamInfo> where Self: Sized { @@ -372,7 +372,7 @@ fn create_node_field_method(node: &Node) -> syn::ImplItemMethod { fn field( &self, _: &str, - ) -> ::std::option::Option<::typst::model::Value> { + ) -> ::std::option::Option<::typst::eval::Value> { None } } diff --git a/macros/src/symbols.rs b/macros/src/symbols.rs index fb120883..efa4834d 100644 --- a/macros/src/symbols.rs +++ b/macros/src/symbols.rs @@ -62,11 +62,11 @@ impl Parse for Kind { impl Kind { fn expand(&self) -> TokenStream { match self { - Self::Single(c) => quote! { typst::model::Symbol::new(#c), }, + Self::Single(c) => quote! { typst::eval::Symbol::new(#c), }, Self::Multiple(variants) => { let variants = variants.iter().map(Variant::expand); quote! { - typst::model::Symbol::list(&[#(#variants),*]) + typst::eval::Symbol::list(&[#(#variants),*]) } } } |
