Browse Source

syn: Rename derive related modules anchor -> accounts

armaniferrante 4 years ago
parent
commit
7f02eb13af

+ 3 - 3
derive/src/lib.rs

@@ -1,13 +1,13 @@
 extern crate proc_macro;
 
-use anchor_syn::codegen::anchor as anchor_codegen;
-use anchor_syn::parser::anchor as anchor_parser;
+use anchor_syn::codegen::accounts as accounts_codegen;
+use anchor_syn::parser::accounts as accounts_parser;
 use proc_macro::TokenStream;
 use syn::parse_macro_input;
 
 #[proc_macro_derive(Accounts, attributes(account))]
 pub fn derive_anchor_deserialize(item: TokenStream) -> TokenStream {
     let strct = parse_macro_input!(item as syn::ItemStruct);
-    let tts = anchor_codegen::generate(anchor_parser::parse(&strct));
+    let tts = accounts_codegen::generate(accounts_parser::parse(&strct));
     proc_macro::TokenStream::from(tts)
 }

+ 1 - 2
examples/tutorial/basic-0/programs/basic-0/Cargo.toml

@@ -12,5 +12,4 @@ name = "basic_0"
 borsh = { git = "https://github.com/project-serum/borsh", branch = "serum", features = ["serum-program"] }
 solana-program = "1.4.3"
 solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
-# anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
-anchor = { path = "/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor", features = ["derive"] }
+anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

+ 1 - 2
examples/tutorial/basic-1/programs/basic-1/Cargo.toml

@@ -12,5 +12,4 @@ name = "basic_1"
 borsh = { git = "https://github.com/project-serum/borsh", branch = "serum", features = ["serum-program"] }
 solana-program = "1.4.3"
 solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
-# anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
-anchor = { path = "/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor", features = ["derive"] }
+anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

+ 1 - 2
examples/tutorial/basic-2/programs/basic-2/Cargo.toml

@@ -12,5 +12,4 @@ name = "basic_2"
 borsh = { git = "https://github.com/project-serum/borsh", branch = "serum", features = ["serum-program"] }
 solana-program = "1.4.3"
 solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
-# anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
-anchor = { path = "/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor", features = ["derive"] }
+anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }

+ 6 - 10
syn/src/codegen/anchor.rs → syn/src/codegen/accounts.rs

@@ -61,16 +61,12 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
 
     let name = &accs.ident;
     let (combined_generics, trait_generics, strct_generics) = match accs.generics.lt_token {
-				None => (
-						quote!{<'info>},
-						quote!{<'info>},
-						quote!{},
-				),
-				Some(_) => {
-						let g = &accs.generics;
-						(quote!{#g}, quote!{#g}, quote!{#g})
-				}
-		};
+        None => (quote! {<'info>}, quote! {<'info>}, quote! {}),
+        Some(_) => {
+            let g = &accs.generics;
+            (quote! {#g}, quote! {#g}, quote! {#g})
+        }
+    };
 
     quote! {
         impl#combined_generics Accounts#trait_generics for #name#strct_generics {

+ 1 - 1
syn/src/codegen/mod.rs

@@ -1,2 +1,2 @@
-pub mod anchor;
+pub mod accounts;
 pub mod program;

+ 0 - 0
syn/src/parser/anchor.rs → syn/src/parser/accounts.rs


+ 2 - 2
syn/src/parser/file.rs

@@ -1,5 +1,5 @@
 use crate::idl::*;
-use crate::parser::anchor;
+use crate::parser::accounts;
 use crate::parser::program;
 use crate::AccountsStruct;
 use anyhow::Result;
@@ -133,7 +133,7 @@ fn parse_accounts(f: &syn::File) -> HashMap<String, AccountsStruct> {
             syn::Item::Struct(i_strct) => {
                 for attr in &i_strct.attrs {
                     if attr.tokens.to_string().contains(DERIVE_NAME) {
-                        let strct = anchor::parse(i_strct);
+                        let strct = accounts::parse(i_strct);
                         return Some((strct.ident.to_string(), strct));
                     }
                 }

+ 1 - 1
syn/src/parser/mod.rs

@@ -1,4 +1,4 @@
-pub mod anchor;
+pub mod accounts;
 #[cfg(feature = "idl")]
 pub mod file;
 pub mod program;