mirror of
https://git.proxmox.com/git/proxmox
synced 2025-07-09 15:36:42 +00:00
macro: functions: call verify() on all parameters
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3d15cca7d6
commit
bb937395f7
@ -3,7 +3,7 @@
|
|||||||
use proc_macro2::{Ident, Span, TokenStream};
|
use proc_macro2::{Ident, Span, TokenStream};
|
||||||
|
|
||||||
use failure::{bail, format_err, Error};
|
use failure::{bail, format_err, Error};
|
||||||
use quote::{quote, ToTokens};
|
use quote::{quote, quote_spanned, ToTokens};
|
||||||
use syn::{spanned::Spanned, Expr, Token};
|
use syn::{spanned::Spanned, Expr, Token};
|
||||||
|
|
||||||
use crate::parsing::{Expression, Object};
|
use crate::parsing::{Expression, Object};
|
||||||
@ -117,6 +117,9 @@ pub fn handle_function(
|
|||||||
.remove(&name_str)
|
.remove(&name_str)
|
||||||
.ok_or_else(|| format_err!("missing parameter '{}' in api defintion", name_str))?;
|
.ok_or_else(|| format_err!("missing parameter '{}' in api defintion", name_str))?;
|
||||||
|
|
||||||
|
parameter_verifiers.extend(quote_spanned! { name.span() =>
|
||||||
|
::proxmox::api::ApiType::verify(&#name)?;
|
||||||
|
});
|
||||||
match info {
|
match info {
|
||||||
Expression::Expr(Expr::Lit(lit)) => {
|
Expression::Expr(Expr::Lit(lit)) => {
|
||||||
parameter_entries.extend(quote! {
|
parameter_entries.extend(quote! {
|
||||||
@ -349,6 +352,7 @@ pub fn handle_function(
|
|||||||
Ok(body)
|
Ok(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Unify with the struct version of this to avoid duplicate code!
|
||||||
fn make_parameter_verifier(
|
fn make_parameter_verifier(
|
||||||
var: &Ident,
|
var: &Ident,
|
||||||
var_str: &str,
|
var_str: &str,
|
||||||
|
Loading…
Reference in New Issue
Block a user