|
@ -342,6 +342,7 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { |
|
|
let args = parse_macro_input!(attr as syn::AttributeArgs);
|
|
|
let args = parse_macro_input!(attr as syn::AttributeArgs);
|
|
|
let mut cmd = 0;
|
|
|
let mut cmd = 0;
|
|
|
let mut flag = true;
|
|
|
let mut flag = true;
|
|
|
|
|
|
let mut manual_flag = false;
|
|
|
for a in args {
|
|
|
for a in args {
|
|
|
match &a {
|
|
|
match &a {
|
|
|
NestedMeta::Lit(lit) => {
|
|
|
NestedMeta::Lit(lit) => {
|
|
@ -353,6 +354,10 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { |
|
|
if let syn::Meta::Path(syn::Path {segments, ..}) = k {
|
|
|
if let syn::Meta::Path(syn::Path {segments, ..}) = k {
|
|
|
match segments[0].ident.to_string().as_str() {
|
|
|
match segments[0].ident.to_string().as_str() {
|
|
|
"no_flag" => flag = false,
|
|
|
"no_flag" => flag = false,
|
|
|
|
|
|
"manual_flag" => {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
manual_flag = true;
|
|
|
|
|
|
},
|
|
|
_ => {
|
|
|
_ => {
|
|
|
return syn::Error::new(segments[0].ident.span(), "unknown macro param").to_compile_error().into();
|
|
|
return syn::Error::new(segments[0].ident.span(), "unknown macro param").to_compile_error().into();
|
|
|
}
|
|
|
}
|
|
@ -368,6 +373,29 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { |
|
|
Err(err) => return err
|
|
|
Err(err) => return err
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if manual_flag {
|
|
|
|
|
|
let mut found_flag = false;
|
|
|
|
|
|
for attr in attrs.iter() {
|
|
|
|
|
|
match attr {
|
|
|
|
|
|
AttrType::Array(_, ident, _, _) => {
|
|
|
|
|
|
if ident.to_string() == "flag" {
|
|
|
|
|
|
found_flag = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
AttrType::Value(_, ident, _) => {
|
|
|
|
|
|
if ident.to_string() == "flag" {
|
|
|
|
|
|
found_flag = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if !found_flag {
|
|
|
|
|
|
return syn::Error::new(pkt_struct.ident.span(), "struct must have flag if manual_flag is set").to_compile_error().into();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
let struct_def = generate_struct_def(pkt_struct.ident.clone(), &attrs);
|
|
|
let struct_def = generate_struct_def(pkt_struct.ident.clone(), &attrs);
|
|
|
let psopacket_impl = generate_psopacket_impl(cmd, pkt_struct.ident.clone(), &attrs, flag);
|
|
|
let psopacket_impl = generate_psopacket_impl(cmd, pkt_struct.ident.clone(), &attrs, flag);
|
|
|
let debug_impl = generate_debug_impl(pkt_struct.ident.clone(), &attrs);
|
|
|
let debug_impl = generate_debug_impl(pkt_struct.ident.clone(), &attrs);
|
|
|