From 6cb50aa2eb7716c221cbe025c4315f72e3c96511 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Wed, 14 Nov 2018 20:38:43 -0700 Subject: [PATCH] more proc-macro --- Cargo.toml | 2 +- src/io_registers.rs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fe02787..6e0ae5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "Apache-2.0" publish = false [dependencies] -gba-proc-macro = "0.2" +gba-proc-macro = "0.2.1" [profile.release] lto = true diff --git a/src/io_registers.rs b/src/io_registers.rs index f4e8249..120aae7 100644 --- a/src/io_registers.rs +++ b/src/io_registers.rs @@ -15,7 +15,7 @@ // TODO(lokathor): IO Register newtypes. -use gba_proc_macro::register_bit; +use gba_proc_macro::{newtype, register_bit}; use super::*; @@ -24,10 +24,11 @@ use super::*; /// * [gbatek entry](http://problemkaputt.de/gbatek.htm#lcdiodisplaycontrol) pub const DISPCNT: VolatilePtr = VolatilePtr(0x4000000 as *mut u16); -/// A newtype over the various display control options that you have on a GBA. -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] -#[repr(transparent)] -pub struct DisplayControlSetting(u16); +newtype!( + DisplayControlSetting, + u16, + "A newtype over the various display control options that you have on a GBA." +); #[allow(missing_docs)] impl DisplayControlSetting { @@ -388,11 +389,6 @@ pub const SIODATA8: VolatilePtr = VolatilePtr(0x400012A as *mut u16); /// Key Status pub const KEYINPUT: VolatilePtr = VolatilePtr(0x4000130 as *mut u16); -/// A newtype over the key input state of the GBA. -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] -#[repr(transparent)] -pub struct KeyInputSetting(u16); - /// A "tribool" value helps us interpret the arrow pad. #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(i32)] @@ -403,6 +399,8 @@ pub enum TriBool { Plus = 1, } +newtype!(KeyInputSetting, u16, "A newtype over the key input state of the GBA"); + #[allow(missing_docs)] impl KeyInputSetting { register_bit!(A_BIT, u16, 1 << 0, a_pressed);