Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Fix nightly to the 'demos are green' condition #271

Merged
merged 32 commits into from
Jan 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0df0d1f
New Box::new syntax
farcaller Jan 9, 2015
d0b9742
New closure syntax
farcaller Jan 9, 2015
3d2d6e6
Features cleanup
farcaller Jan 9, 2015
d548504
ioreg: feature(associated_types) now unnecessary
bgamari Jan 10, 2015
03772d3
ioreg: Validate bit offsets
bgamari Jan 10, 2015
48b39fd
ioreg: int renaming fallout
bgamari Jan 10, 2015
ac15313
ioreg: Allow(unstable)
bgamari Jan 10, 2015
4b72bd2
Switch to #[macro_use]
bgamari Jan 10, 2015
78a3db8
Add feature(plugin)
bgamari Jan 10, 2015
f2cdb21
Removed std crate, why did we have it anyway?
farcaller Jan 11, 2015
26ed252
core::kinds::marker moved to core::marker
farcaller Jan 11, 2015
67d24f4
Removed Copy impls from ioreg
farcaller Jan 11, 2015
a9c4fda
expr_u64 now returns size for whatever reason.
farcaller Jan 11, 2015
b287fb6
Box::new fixes for PT
farcaller Jan 11, 2015
a4328ea
Various closure fixes to make things work
farcaller Jan 11, 2015
0ae08de
hash::hash fix
farcaller Jan 11, 2015
8900158
Some strange thing that seems to compile and work
farcaller Jan 11, 2015
0e674c9
Replaced feature phase with plugin
farcaller Jan 11, 2015
89ed470
Moved rlibc crate in tree, it's reasonably tiny
farcaller Jan 11, 2015
3e049cf
Fixed all the other demo apps
farcaller Jan 11, 2015
fe84f5a
ioreg::test: Fix imports
bgamari Jan 13, 2015
fff9930
ioreg::test: Fix uint and int references
bgamari Jan 13, 2015
bcf26a8
ioreg::builder::union: Give unions Copy impls
bgamari Jan 13, 2015
f71928b
ioreg: Fix integer overflow
bgamari Jan 13, 2015
2cbfdef
ioreg: Add Copy impl for primitive register structs
bgamari Jan 13, 2015
604347d
platformtree: Use Box::new instead of box
bgamari Jan 13, 2015
21f5ad8
platformtree: deriving_hash_type_parameter no longer exists
bgamari Jan 13, 2015
077c207
bluenrg: macro_use instead of phase(plugin)
bgamari Jan 13, 2015
03a8cf7
platformtree: Fix usize literal suffix in test
bgamari Jan 14, 2015
dd46e7f
Return std that is used in tests
farcaller Jan 14, 2015
110c5ab
"Fixed" bluenrg demo to compile.
farcaller Jan 14, 2015
0b0a412
Fixed missing plugin feature in tiva_c demo
farcaller Jan 14, 2015
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: 2 additions & 2 deletions apps/app_blink.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

platformtree!(
lpc17xx@mcu {
Expand Down
2 changes: 1 addition & 1 deletion apps/app_blink_k20.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

Expand Down
2 changes: 1 addition & 1 deletion apps/app_blink_k20_isr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(phase)]
#![feature(plugin)]
#![feature(asm)]
#![crate_type="staticlib"]
#![no_std]
Expand Down
2 changes: 1 addition & 1 deletion apps/app_blink_stm32f4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

Expand Down
2 changes: 1 addition & 1 deletion apps/app_blink_stm32l1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

Expand Down
4 changes: 2 additions & 2 deletions apps/app_blink_tiva_c.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

platformtree!(
tiva_c@mcu {
Expand Down
39 changes: 24 additions & 15 deletions apps/app_bluenrg_stm32l1.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

//! Sample application for BlueNRG communication over SPI in X-NUCLEO-IDB04A1
//! extension board for NUCLEO-L152RE

#[phase(plugin, link)]
#[macro_use] #[plugin]
extern crate core;
extern crate zinc;

Expand Down Expand Up @@ -97,23 +97,32 @@ pub unsafe fn main() {
pin::PullType::PullUp);

bnrg_reset.set_low();
let _ = write!(&mut uart, "SPI created, status = {}\n",
map_byte(spi.get_status()));
let status_s = map_byte(spi.get_status());
let _ = write!(&mut uart, "SPI created, status = {}{}\n", status_s.0, status_s.1);
bnrg_reset.set_high();

let blue = bluenrg::BlueNrg::new(spi_csn, spi);

let _ = match blue.wakeup(100) {
Result::Ok((size_write, size_read)) => write!(&mut uart,
"BlueNRG is ready, write size = {}, read size = {}\n",
map_byte(size_write as u8), map_byte(size_read as u8)),
Result::Err(bluenrg::Error::Sleeping) => write!(&mut uart,
"BlueNRG is sleeping\n"),
Result::Err(bluenrg::Error::Allocating) => write!(&mut uart,
"BlueNRG is allocating buffers\n"),
Result::Err(bluenrg::Error::Unknown(status)) => write!(&mut uart,
"BlueNRG unknown status = {}\n", map_byte(status)),
Result::Err(bluenrg::Error::BufferSize(_)) => write!(&mut uart, ""),
match blue.wakeup(100) {
Result::Ok((size_write, size_read)) => {
let size_write_s = map_byte(size_write as u8);
let size_read_s = map_byte(size_read as u8);
write!(&mut uart,
"BlueNRG is ready, write size = {}{}, read size = {}{}\n",
size_write_s.0, size_write_s.1, size_read_s.0, size_read_s.1);
},
Result::Err(bluenrg::Error::Sleeping) => {
write!(&mut uart, "BlueNRG is sleeping\n");
},
Result::Err(bluenrg::Error::Allocating) => {
write!(&mut uart, "BlueNRG is allocating buffers\n");
},
Result::Err(bluenrg::Error::Unknown(status)) => {
let status_s = map_byte(status);
write!(&mut uart,
"BlueNRG unknown status = {}{}\n", status_s.0, status_s.1);
},
Result::Err(bluenrg::Error::BufferSize(_)) => { write!(&mut uart, ""); }
};

loop {}
Expand Down
4 changes: 2 additions & 2 deletions apps/app_dht22.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

use core::option::Option::{Some, None};

Expand Down
4 changes: 2 additions & 2 deletions apps/app_empty.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase, asm)]
#![feature(plugin, asm)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

platformtree!(
lpc17xx@mcu {
Expand Down
4 changes: 2 additions & 2 deletions apps/app_lcd_tiva_c.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

use zinc::drivers::chario::CharIO;
use zinc::drivers::lcd::hd44780u::{Hd44780u, Font};
Expand Down
4 changes: 2 additions & 2 deletions apps/app_uart.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

platformtree!(
lpc17xx@mcu {
Expand Down
4 changes: 2 additions & 2 deletions apps/app_uart_tiva_c.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

extern crate core;
extern crate zinc;
#[phase(plugin)] extern crate macro_platformtree;
#[macro_use] #[plugin] #[no_link] extern crate macro_platformtree;

use zinc::drivers::chario::CharIO;

Expand Down
2 changes: 1 addition & 1 deletion apps/app_usart_stm32l1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(phase)]
#![feature(plugin)]
#![crate_type="staticlib"]
#![no_std]

Expand Down
6 changes: 3 additions & 3 deletions src/ioreg/builder/accessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn build_field_set_fn(cx: &ExtCtxt, path: &Vec<String>,
} else {
quote_method!(cx,
#[allow(dead_code, missing_docs)]
pub fn $fn_name<'a>(&'a self, idx: uint, new_value: $field_ty) -> $setter_ty<'a> {
pub fn $fn_name<'a>(&'a self, idx: usize, new_value: $field_ty) -> $setter_ty<'a> {
let mut setter: $setter_ty = $setter_ty::new(self);
setter.$fn_name(idx, new_value);
setter
Expand All @@ -170,7 +170,7 @@ fn build_field_get_fn(cx: &ExtCtxt, path: &Vec<String>,
} else {
quote_method!(cx,
#[allow(dead_code, missing_docs)]
pub fn $fn_name(&self, idx: uint) -> $field_ty {
pub fn $fn_name(&self, idx: usize) -> $field_ty {
$getter_ty::new(self).$fn_name(idx)
}
)
Expand All @@ -196,7 +196,7 @@ fn build_field_clear_fn(cx: &ExtCtxt, path: &Vec<String>,
} else {
quote_method!(cx,
#[allow(dead_code, missing_docs)]
pub fn $fn_name<'a>(&'a self, idx: uint) -> $setter_ty<'a> {
pub fn $fn_name<'a>(&'a self, idx: usize) -> $setter_ty<'a> {
let mut setter: $setter_ty = $setter_ty::new(self);
setter.$fn_name(idx);
setter
Expand Down
4 changes: 2 additions & 2 deletions src/ioreg/builder/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'a> node::RegVisitor for BuildGetters<'a> {
// Build Copy impl
let ty_name = utils::getter_name(self.cx, path);
let it = quote_item!(self.cx,
impl ::core::kinds::Copy for $ty_name {});
impl ::core::marker::Copy for $ty_name {});
self.builder.push_item(it.unwrap());
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ fn build_field_get_fn(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
quote_expr!(cx, (self.value >> $shift) & $mask));
quote_method!(cx,
$doc_attr
pub fn $fn_name(&self, idx: uint) -> $field_ty {
pub fn $fn_name(&self, idx: usize) -> $field_ty {
$value
}
)
Expand Down
5 changes: 2 additions & 3 deletions src/ioreg/builder/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
attrs: attrs,
span: field.ty.span,
});
let copy_impl = quote_item!(cx, impl ::core::kinds::Copy for $name {}).unwrap();
vec!(ty_item, copy_impl)
vec!(ty_item)
},
_ => Vec::new()
}
Expand Down Expand Up @@ -123,7 +122,7 @@ fn build_reg_struct(cx: &ExtCtxt, path: &Vec<String>,
);
let mut item: ast::Item = item.unwrap().deref().clone();
item.span = reg.name.span;
let copy_impl = quote_item!(cx, impl ::core::kinds::Copy for $ty_name {}).unwrap();
let copy_impl = quote_item!(cx, impl ::core::marker::Copy for $ty_name {}).unwrap();
vec!(P(item), copy_impl)
}

Expand Down
10 changes: 2 additions & 8 deletions src/ioreg/builder/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ impl<'a> node::RegVisitor for BuildSetters<'a> {

let it = build_impl(self.cx, path, reg, fields);
self.builder.push_item(it);

// Build Copy impl
let ty_name = utils::setter_name(self.cx, path);
let it = quote_item!(self.cx,
impl<'a> ::core::kinds::Copy for $ty_name<'a> {});
self.builder.push_item(it.unwrap());
}
}
}
Expand Down Expand Up @@ -237,7 +231,7 @@ fn build_field_set_fn(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
let shift = utils::shift(cx, Some(quote_expr!(cx, idx)), field);
quote_method!(cx,
$doc_attr
pub fn $fn_name<'b>(&'b mut self, idx: uint, new_value: $field_ty)
pub fn $fn_name<'b>(&'b mut self, idx: usize, new_value: $field_ty)
-> &'b mut $setter_ty<'a> {
self.value |= (self.value & ! $mask) | ((new_value as $unpacked_ty) & $mask) << $shift;
self.mask |= $mask << $shift;
Expand Down Expand Up @@ -278,7 +272,7 @@ fn build_field_clear_fn(cx: &ExtCtxt, path: &Vec<String>,
let shift = utils::shift(cx, Some(quote_expr!(cx, idx)), field);
quote_method!(cx,
$doc_attr
pub fn $fn_name<'b>(&'b mut self, idx: uint) -> &'b mut $setter_ty<'a> {
pub fn $fn_name<'b>(&'b mut self, idx: usize) -> &'b mut $setter_ty<'a> {
self.value |= $mask << $shift;
self.mask |= $mask << $shift;
self
Expand Down
42 changes: 21 additions & 21 deletions src/ioreg/builder/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ enum RegOrPadding<'a> {
/// A register
Reg(&'a node::Reg),
/// A given number of bytes of padding
Pad(uint)
Pad(u64)
}

/// An iterator which takes a potentially unsorted list of registers,
/// sorts them, and adds padding to make offsets correct
struct PaddedRegsIterator<'a> {
sorted_regs: &'a Vec<node::Reg>,
index: uint,
last_offset: uint,
index: usize,
last_offset: u64,
}

impl<'a> PaddedRegsIterator<'a> {
Expand Down Expand Up @@ -86,6 +86,10 @@ impl<'a> BuildUnionTypes<'a> {
}
}

fn expr_u64(cx: &ExtCtxt, n: u64) -> P<ast::Expr> {
cx.expr_lit(DUMMY_SP, ast::LitInt(n as u64, ast::UnsignedIntLit(ast::TyUs(false))))
}

/// Returns the type of the field representing the given register
/// within a `RegGroup` struct
fn reg_struct_type(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg)
Expand All @@ -96,22 +100,18 @@ fn reg_struct_type(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg)
1 => base_ty,
n =>
cx.ty(DUMMY_SP,
ast::TyFixedLengthVec(base_ty,
cx.expr_uint(DUMMY_SP, n))),
ast::TyFixedLengthVec(base_ty, expr_u64(cx, n as u64))),
}
}


impl<'a> node::RegVisitor for BuildUnionTypes<'a> {
fn visit_union_reg<'b>(&'b mut self, path: &Vec<String>, reg: &'b node::Reg,
subregs: Rc<Vec<node::Reg>>) {
let union_type = self.build_union_type(path, reg, &*subregs);
let ty_name = union_type.ident.clone();
self.builder.push_item(union_type);

let copy_impl = quote_item!(self.cx,
impl ::core::kinds::Copy for $ty_name {});
self.builder.push_item(copy_impl.unwrap());
let items = self.build_union_type(path, reg, &*subregs);
for item in items.into_iter() {
self.builder.push_item(item);
}
}
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'a> BuildUnionTypes<'a> {

/// Build field for padding or a register
fn build_pad_or_reg(&self, path: &Vec<String>, reg_or_pad: RegOrPadding,
index: uint) -> ast::StructField {
index: usize) -> ast::StructField {
match reg_or_pad {
RegOrPadding::Reg(reg) => self.build_reg_union_field(path, reg),
RegOrPadding::Pad(length) => {
Expand All @@ -150,8 +150,7 @@ impl<'a> BuildUnionTypes<'a> {
let ty: P<ast::Ty> =
self.cx.ty(
DUMMY_SP,
ast::TyFixedLengthVec(u8_ty,
self.cx.expr_uint(DUMMY_SP, length)));
ast::TyFixedLengthVec(u8_ty, expr_u64(self.cx, length)));
dummy_spanned(
ast::StructField_ {
kind: ast::NamedField(
Expand All @@ -168,9 +167,8 @@ impl<'a> BuildUnionTypes<'a> {

/// Build the type associated with a register group
fn build_union_type(&self, path: &Vec<String>, reg: &node::Reg,
regs: &Vec<node::Reg>) -> P<ast::Item> {
let name = String::from_str(
token::get_ident(utils::path_ident(self.cx, path)).get());
regs: &Vec<node::Reg>) -> Vec<P<ast::Item>> {
let name = utils::path_ident(self.cx, path);
// Registers are already sorted by parser
let mut regs = regs.clone();
let padded_regs = PaddedRegsIterator::new(&mut regs);
Expand All @@ -192,13 +190,15 @@ impl<'a> BuildUnionTypes<'a> {
utils::doc_attribute(self.cx, token::get_ident(docstring.node))),
None => (),
}
P(ast::Item {
ident: self.cx.ident_of(name.as_slice()),
let struct_item = P(ast::Item {
ident: name,
attrs: attrs,
id: ast::DUMMY_NODE_ID,
node: ast::ItemStruct(P(struct_def), empty_generics()),
vis: ast::Public,
span: reg.name.span,
})
});
let copy_impl = quote_item!(self.cx, impl ::core::marker::Copy for $name {}).unwrap();
vec!(struct_item, copy_impl)
}
}
2 changes: 1 addition & 1 deletion src/ioreg/builder/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn field_type_path(cx: &ExtCtxt, path: &Vec<String>,

/// Build an expression for the mask of a field
pub fn mask(cx: &ExtCtxt, field: &node::Field) -> P<ast::Expr> {
expr_int(cx, ((1i << field.width) - 1) as i64)
expr_int(cx, ((1 << field.width as u64) - 1))
}

/// Build an expression for the shift of a field (including the array
Expand Down
Loading