|
|
@ -374,26 +374,18 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { |
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
match &attrs[0] {
|
|
|
|
AttrType::Array(_, ident, _, _) => {
|
|
|
|
if ident.to_string() != "flag" {
|
|
|
|
return syn::Error::new(pkt_struct.ident.span(), "struct must have flag as the first field if manual_flag is set").to_compile_error().into();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
AttrType::Value(_, ident, _) => {
|
|
|
|
if ident.to_string() != "flag" {
|
|
|
|
return syn::Error::new(pkt_struct.ident.span(), "struct must have flag as the first field if manual_flag is set").to_compile_error().into();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|