Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "bitfield" | ||
version = "0.0.0" | ||
edition = "2018" | ||
autotests = false | ||
publish = false | ||
|
||
[[test]] | ||
name = "tests" | ||
path = "tests/progress.rs" | ||
|
||
[dev-dependencies] | ||
workshop-test-runner = { path = "../test-runner" } | ||
|
||
[dependencies] | ||
bitfield-impl = { path = "impl" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "bitfield-impl" | ||
version = "0.0.0" | ||
edition = "2018" | ||
publish = false | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
# TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn bitfield(args: TokenStream, input: TokenStream) -> TokenStream { | ||
let _ = args; | ||
let _ = input; | ||
|
||
unimplemented!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Crates that have the "proc-macro" crate type are only allowed to export | ||
// procedural macros. So we cannot have one crate that defines procedural macros | ||
// alongside other types of public APIs like traits and structs. | ||
// | ||
// For this project we are going to need a #[bitfield] macro but also a trait | ||
// and some structs. We solve this by defining the trait and structs in this | ||
// crate, defining the attribute macro in a separate bitfield-impl crate, and | ||
// then re-exporting the macro from this crate so that users only have one crate | ||
// that they need to import. | ||
// | ||
// From the perspective of a user of this crate, they get all the necessary APIs | ||
// (macro, trait, struct) through the one bitfield crate. | ||
pub use bitfield_impl::bitfield; | ||
|
||
// TODO other things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This test suite needs more work and explanations... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use bitfield::*; | ||
|
||
#[bitfield] | ||
pub struct MyFourBytes { | ||
a: B1, | ||
b: B3, | ||
c: B4, | ||
d: B24, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[test] | ||
fn tests() { | ||
let t = workshop::TestCases::new(); | ||
//t.pass("tests/01-parse.rs"); | ||
} |