handle quote in names in kills

This commit is contained in:
Robin Appelman 2023-03-16 22:07:43 +01:00
commit a18068e957
2 changed files with 8 additions and 2 deletions

View file

@ -158,6 +158,7 @@ pub struct EventParam {
optional: bool,
skip_after: u64,
quoted: bool,
subject: bool,
}
impl EventParam {
@ -190,6 +191,7 @@ impl EventParam {
}
let quoted =
get_attribute_value(&input.attrs, &["event", "quoted"]).unwrap_or(param_name.is_none());
let subject = contains_attribute(&input.attrs, &["event", "subject"]);
Ok(EventParam {
span: input.span(),
@ -198,6 +200,7 @@ impl EventParam {
optional,
skip_after,
quoted,
subject,
})
}
@ -206,7 +209,9 @@ impl EventParam {
}
fn field_parser(&self) -> TokenStream {
if self.quoted {
if self.subject {
quote_spanned!(self.span() => subject_parser)
} else if self.quoted {
quote_spanned!(self.span() => quoted(parse_field))
} else {
quote_spanned!(self.span() => parse_field)

View file

@ -1,6 +1,6 @@
use crate::common::{Class, Team};
use crate::event::{param_parse_with, parse_field, quoted, ParamIter};
use crate::raw_event::RawSubject;
use crate::raw_event::{subject_parser, RawSubject};
use crate::{Error, Event, Result};
use std::net::SocketAddr;
use std::num::NonZeroU32;
@ -28,6 +28,7 @@ pub struct DamageEvent<'a> {
#[derive(Debug, Event)]
pub struct KillEvent<'a> {
#[event(unnamed)]
#[event(subject)]
#[event(skip_after = 1)]
pub target: RawSubject<'a>,
#[event(name = "with")]