Skip to content

Newsyn #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Improve field enum docs

### Changed

- Bump dependencies: `syn`, `quote` and `proc_macro2` v1.0.

## [v0.16.0] - 2019-08-05

### Added
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ env_logger = "~0.5"
error-chain = "0.11.0"
inflections = "1.1.0"
log = { version = "~0.4", features = ["std"] }
quote = "0.3.15"
quote = "1.0"
svd-parser = "0.7"
proc-macro2 = "1.0"

[dependencies.syn]
version = "0.11.11"
features = ["full"]
version = "1.0"
features = ["full","extra-traits"]
18 changes: 9 additions & 9 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use quote::{Tokens, ToTokens};
use quote::ToTokens;
use proc_macro2::{TokenStream, Ident, Span};
use std::fs::File;
use std::io::Write;
use crate::svd::Device;
use syn::Ident;

use crate::errors::*;
use crate::util::{self, ToSanitizedUpperCase};
Expand All @@ -17,7 +17,7 @@ pub fn render(
nightly: bool,
generic_mod: bool,
device_x: &mut String,
) -> Result<Vec<Tokens>> {
) -> Result<Vec<TokenStream>> {
let mut out = vec![];

let doc = format!(
Expand Down Expand Up @@ -143,8 +143,7 @@ pub fn render(
if generic_mod {
writeln!(File::create("generic.rs").unwrap(), "{}", generic_file).unwrap();
} else {
let mut tokens = Tokens::new();
(syn::parse_crate(generic_file)?).to_tokens(&mut tokens);
let tokens = syn::parse_file(generic_file).unwrap().into_token_stream();

out.push(quote! {
#[allow(unused_imports)]
Expand Down Expand Up @@ -177,18 +176,19 @@ pub fn render(
}

let p = p.name.to_sanitized_upper_case();
let id = Ident::from(&*p);
let id = Ident::new(&p, Span::call_site());
fields.push(quote! {
#[doc = #p]
pub #id: #id
});
exprs.push(quote!(#id: #id { _marker: PhantomData }));
}

let span = Span::call_site();
let take = match target {
Target::CortexM => Some(Ident::from("cortex_m")),
Target::Msp430 => Some(Ident::from("msp430")),
Target::RISCV => Some(Ident::from("riscv")),
Target::CortexM => Some(Ident::new("cortex_m", span)),
Target::Msp430 => Some(Ident::new("msp430", span)),
Target::RISCV => Some(Ident::new("riscv", span)),
Target::None => None,
}
.map(|krate| {
Expand Down
7 changes: 3 additions & 4 deletions src/generate/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use std::collections::HashMap;
use std::fmt::Write;

use cast::u64;
use quote::Tokens;
use proc_macro2::{TokenStream, Ident, Span};
use crate::svd::Peripheral;
use syn::Ident;

use crate::errors::*;
use crate::util::{self, ToSanitizedUpperCase};
Expand All @@ -15,7 +14,7 @@ pub fn render(
target: Target,
peripherals: &[Peripheral],
device_x: &mut String,
) -> Result<Vec<Tokens>> {
) -> Result<Vec<TokenStream>> {
let interrupts = peripherals
.iter()
.flat_map(|p| p.interrupt.iter())
Expand All @@ -42,7 +41,7 @@ pub fn render(
}
pos += 1;

let name_uc = Ident::from(interrupt.name.to_sanitized_upper_case());
let name_uc = Ident::new(&interrupt.name.to_sanitized_upper_case(), Span::call_site());
let description = format!(
"{} - {}",
interrupt.value,
Expand Down
Loading