aboutsummaryrefslogtreecommitdiff
path: root/derive
diff options
context:
space:
mode:
Diffstat (limited to 'derive')
-rw-r--r--derive/src/lib.rs6
-rw-r--r--derive/src/sync/mod.rs43
2 files changed, 49 insertions, 0 deletions
diff --git a/derive/src/lib.rs b/derive/src/lib.rs
index f3608eb..606e8e3 100644
--- a/derive/src/lib.rs
+++ b/derive/src/lib.rs
@@ -2,6 +2,7 @@ use syn;
mod from;
mod network;
+mod sync;
#[proc_macro_derive(NetworkList, attributes(network))]
pub fn network_list(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
@@ -17,3 +18,8 @@ pub fn network_map(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
pub fn from(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
from::from(input)
}
+
+#[proc_macro]
+pub fn sync(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
+ sync::sync(input)
+}
diff --git a/derive/src/sync/mod.rs b/derive/src/sync/mod.rs
new file mode 100644
index 0000000..40dea74
--- /dev/null
+++ b/derive/src/sync/mod.rs
@@ -0,0 +1,43 @@
+use quote::quote;
+use syn::{
+ self, bracketed,
+ parse::{Parse, ParseStream},
+ parse_macro_input,
+ punctuated::Punctuated,
+ token, Expr, Result, Token,
+};
+
+#[derive(Debug)]
+struct Sync {
+ name: Expr,
+ token: Token![,],
+ brace_token: token::Bracket,
+ fields: Punctuated<Expr, Token![,]>,
+}
+
+impl Parse for Sync {
+ fn parse(input: ParseStream) -> Result<Self> {
+ let content;
+ Ok(Sync {
+ name: input.parse()?,
+ token: input.parse()?,
+ brace_token: bracketed!(content in input),
+ fields: content.parse_terminated(Expr::parse)?,
+ })
+ }
+}
+
+pub fn sync(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
+ let input = parse_macro_input!(input as Sync);
+ let name = input.name;
+ let values = input.fields.iter();
+
+ let gen = quote! {
+ self.send_sync(
+ #name,
+ vec![#(#values.into()),*],
+ )
+ };
+
+ gen.into()
+}
td>-99/+0 2021-10-01migrate to separated NetworkMap and NetworkList macrosMax Audron-196/+371 2021-09-28adapt Sync* typesMax Audron-15/+57 2021-09-28add handle_syncmessage to aliasmanagerMax Audron-4/+23 2021-09-28make initdata fields publicMax Audron-3/+3 2021-09-28convert Init struct's methods to builder styleMax Audron-4/+6 2021-09-28switch AliasManager to use split network translation traitsMax Audron-10/+17 2021-09-28add NetworkList and NetworkMap derive macrosMax Audron-25/+101 this is an ongoing effort to generalize the parsing/serialization. With this NetworkList and NetworkMap can be used both at the same time to allow the de-/serialization of objects into both formats 2021-09-28add statetracker to workspaceMax Audron-1/+1 2021-09-28statetracker: cleanup codeMax Audron-29/+86 2021-09-28statetracker: first iteration of working rpc objectMax Audron-0/+709 2021-09-28rename override_type to typeMax Audron-7/+7 2021-07-31fix trailing semicolon match_variant macroMax Audron-1/+1 2021-07-31add doc for network translationMax Audron-0/+93 2021-07-25add Traits for syncable objectsMax Audron-48/+114 2021-07-21cleanup objects::TypesMax Audron-5/+35 2021-07-21add IgnoreListManagerMax Audron-0/+165 2021-07-21add cert-managerMax Audron-0/+32 2021-07-21add BufferViewManager and BufferViewConfigMax Audron-0/+95 2021-07-21migrate BufferSyncer to use Network derive and add to central TypesMax Audron-143/+22 2021-07-21rewrite network derive to work more consistentlyMax Audron-78/+90 this mainly ensures that the network and override_type / variant options work across the board 2021-07-21fix wrong capitalization for HighlightRuleListMax Audron-2/+2 2021-07-21implement the Network trait generically for all inner Variant TypesMax Audron-1/+66 2021-07-21change IRC MessageType to be a bitflag instead of enumMax Audron-54/+94 the BufferSyncer object uses this type in a bitflag manner to indicate all the kinds of change that happened. bitflag still allows very enum esque usage so the change is okay for the Message object. 2021-07-21fix network objectMax Audron-18/+24 2021-07-21minor docs and cleanupMax Audron-4/+8 2021-04-05WIP: impl more signalproxy objectsMax Audron-1000/+1621 2021-03-09WIP: impl signalproxy typesMax Audron-253/+376 2021-01-21add to and from network deriveMax Audron-42/+2767 2021-01-21reorganize tests and add quassel featuresMax Audron-551/+850 2021-01-04add example program: quasselproxyclientMax Audron-0/+280 and inspection proxy for quassel 2021-01-04random stuffMax Audron-2/+9 2021-01-04add more signalproxy objectsMax Audron-40/+120 2021-01-04add message parsing feature flagsMax Audron-43/+96 2021-01-04fix parsing of datetime when value is -1Max Audron-1/+9 2021-01-02update dependenciesMax Audron-267/+27 2021-01-02rework handshakemessage parsingMax Audron-141/+278 2020-10-16updateMax Audron-1553/+294 2020-10-16update paperworkMax Audron-487/+391