[wip] Replace mashup! with paste!

This commit is contained in:
Berkus Decker 2020-11-22 02:20:04 +02:00
parent ec7172aded
commit c75db1e2d6
4 changed files with 26 additions and 76 deletions

62
Cargo.lock generated
View File

@ -34,48 +34,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "mashup"
version = "0.1.12"
name = "paste"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e81a2ed9c9879f92f2443fec9e6326c673b0dba3190c902b0371fd1387c4289"
dependencies = [
"mashup-impl",
"proc-macro-hack",
]
[[package]]
name = "mashup-impl"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875a96a1b7ed5bdb76b8676b98a15d8888ee15e68833bb7a42897b59a9a93047"
dependencies = [
"proc-macro-hack",
"proc-macro2 0.4.30",
]
[[package]]
name = "proc-macro-hack"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "463bf29e7f11344e58c9e01f171470ab15c925c6822ad75028cc1c0e1d1eb63b"
dependencies = [
"proc-macro-hack-impl",
]
[[package]]
name = "proc-macro-hack-impl"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38c47dcb1594802de8c02f3b899e2018c78291168a22c281be21ea0fb4796842"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
checksum = "7151b083b0664ed58ed669fcdd92f01c3d2fdbf10af4931a301474950b52bfa9"
[[package]]
name = "proc-macro2"
@ -83,7 +45,7 @@ version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
@ -98,7 +60,7 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.24",
"proc-macro2",
]
[[package]]
@ -132,7 +94,7 @@ version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b"
dependencies = [
"proc-macro2 1.0.24",
"proc-macro2",
"quote",
"syn",
]
@ -143,9 +105,9 @@ version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
dependencies = [
"proc-macro2 1.0.24",
"proc-macro2",
"quote",
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
@ -154,12 +116,6 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f521a79accce68c417c9c77ce22108056b626126da1932f7e2e9b5bbffee0cea"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.1"
@ -186,7 +142,7 @@ dependencies = [
"bitflags",
"cfg-if",
"cortex-a",
"mashup",
"paste",
"qemu-exit",
"r0",
"register",

View File

@ -37,7 +37,7 @@ bit_field = "0.10.0"
bitflags = "1.2.1"
cfg-if = "1.0"
snafu = { version = "0.6", default-features = false }
mashup = "0.1.9" # @todo replace with paste 1.0
paste = "1.0"
#embedded-serial = "0.5.0"
# jlink_rtt = { version = "0.1.0", optional = true }

View File

@ -20,9 +20,11 @@
// pptr_of_cap(); -- extracts cap.pptr from cnode_cap
// deriveCap();
use core::{convert::TryFrom, fmt};
use mashup::*;
use register::LocalRegisterCopy;
use {
core::{convert::TryFrom, fmt},
paste::paste,
register::{register_bitfields, LocalRegisterCopy},
};
//==================
// Caps definitions
@ -251,40 +253,33 @@ pub trait Capability {
macro_rules! capdefs {
($($name:ident),*) => {
mashup! {
paste! {
$(
m[$name "Capability"] = $name Capability;
m[$name "Cap"] = $name Cap;
)*
}
m! {
$(
pub struct $name "Capability"(LocalRegisterCopy<u128, $name "Cap"::Register>);
impl Capability for $name "Capability" {
pub struct [<$name Capability>](LocalRegisterCopy<u128, [<$name Cap>]::Register>);
impl Capability for [<$name Capability>] {
#[inline]
fn as_u128(&self) -> u128 {
self.0.into()
}
#[inline]
fn is_arch(&self) -> bool {
($name "Cap"::Type::Value::value as u8) % 2 != 0
([<$name Cap>]::Type::Value::value as u8) % 2 != 0
}
}
impl TryFrom<u128> for $name "Capability" {
impl TryFrom<u128> for [<$name Capability>] {
type Error = CapError;
fn try_from(v: u128) -> Result<$name "Capability", Self::Error> {
let reg = LocalRegisterCopy::<_, $name "Cap"::Register>::new(v);
if reg.read($name "Cap"::Type) == u128::from($name "Cap"::Type::value) {
Ok($name "Capability"(LocalRegisterCopy::new(v)))
fn try_from(v: u128) -> Result<[<$name Capability>], Self::Error> {
let reg = LocalRegisterCopy::<_, [<$name Cap>]::Register>::new(v);
if reg.read([<$name Cap>]::Type) == u128::from([<$name Cap>]::Type::value) {
Ok([<$name Capability>](LocalRegisterCopy::new(v)))
} else {
Err(Self::Error::InvalidCapabilityType)
}
}
}
impl From<$name "Capability"> for u128 {
impl From<[<$name Capability>]> for u128 {
#[inline]
fn from(v: $name "Capability") -> u128 {
fn from(v: [<$name Capability>]) -> u128 {
v.as_u128()
}
}

View File

@ -19,7 +19,6 @@
#![feature(custom_test_frameworks)]
#![test_runner(crate::tests::test_runner)]
#![reexport_test_harness_main = "test_main"]
#![recursion_limit = "4096"] // for mashup! macro
#![deny(missing_docs)]
#![deny(warnings)]