1
0
mirror of https://github.com/Sebekerga/native_api_1c.git synced 2025-07-03 00:27:04 +02:00

prop parsing converted to darling

This commit is contained in:
Kozlov Maxim
2023-11-03 09:29:57 +06:00
parent 693bf08fd7
commit 1d5ed1ae87
2 changed files with 76 additions and 75 deletions
native_api_1c_macro/src
props_processing
utils.rs

@ -5,7 +5,7 @@ use syn::{Ident, Type};
use crate::types_1c::ParamType;
use self::macros::tkn_err;
use self::macros::{tkn_err, tkn_err_inner};
pub mod macros {
macro_rules! tkn_err_inner {
@ -24,6 +24,16 @@ pub mod macros {
pub(crate) use tkn_err_inner;
}
const IDENT_OPTION_ERR: &str = "Unable to get ident from option";
pub fn ident_option_to_token_err(ident: Option<&Ident>) -> Result<&Ident, TokenStream> {
ident.ok_or(tkn_err_inner!(IDENT_OPTION_ERR, Span::call_site()))
}
pub fn ident_option_to_darling_err(ident: Option<&Ident>) -> Result<&Ident, darling::Error> {
ident.ok_or_else(|| darling::Error::custom(IDENT_OPTION_ERR))
}
pub fn convert_ty_to_param_type(ty: &Type, span: Span) -> Result<ParamType, TokenStream> {
match ty {
Type::Path(path_type) => {