Skip to content

Commit

Permalink
Fix codestyle, remove redundant comments, implement Chord for Incogni…
Browse files Browse the repository at this point in the history
…tumValue
  • Loading branch information
dnsl48 committed Dec 26, 2022
1 parent 90f2fa1 commit 8921dec
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 360 deletions.
15 changes: 6 additions & 9 deletions src/book/extractor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
pub mod pointer;
pub mod traits;


pub use self::pointer::Pointer;
pub use self::traits::FromPointer;



#[macro_export]
macro_rules! yamlette_reckon {
( book ; $book:expr ; [ $( $rules:tt ),* ] ) => {
let mut _counter: usize = 0;
$(
let volume = $book.volumes.get (_counter);
yamlette_reckon! ( volume ; volume ; $rules );
$crate::yamlette_reckon! ( volume ; volume ; $rules );
_counter += 1;
)*
};
Expand All @@ -22,7 +19,7 @@ macro_rules! yamlette_reckon {
( volume ; $volume:expr ; [ $( $rules:tt ),* ] ) => {
let _pointer = if let Some (volume) = $volume { $crate::book::extractor::pointer::Pointer::new (volume) } else { None };
$(
yamlette_reckon! ( ptr ; _pointer ; $rules );
$crate::yamlette_reckon! ( ptr ; _pointer ; $rules );
let _pointer = if let Some (p) = _pointer { p.next_sibling () } else { None };
)*
};
Expand All @@ -31,7 +28,7 @@ macro_rules! yamlette_reckon {
( ptr ; $pointer:expr ; [ $( $v:tt ),* ] ) => {
let _pointer = if let Some (p) = $pointer { p.into_seq () } else { None };
$(
yamlette_reckon! ( ptr ; _pointer ; $v );
$crate::yamlette_reckon! ( ptr ; _pointer ; $v );
let _pointer = if let Some (p) = _pointer { p.next_sibling () } else { None };
)*
};
Expand All @@ -40,9 +37,9 @@ macro_rules! yamlette_reckon {
( ptr ; $pointer:expr ; { $( $k:tt > $v:tt ),* } ) => {
let _pointer = if let Some (p) = $pointer { p.into_map () } else { None };
$(
yamlette_reckon! ( ptr ; _pointer ; $k );
$crate::yamlette_reckon! ( ptr ; _pointer ; $k );
let _pointer = if let Some (p) = _pointer { p.next_sibling () } else { None };
yamlette_reckon! ( ptr ; _pointer ; $v );
$crate::yamlette_reckon! ( ptr ; _pointer ; $v );
let _pointer = if let Some (p) = _pointer { p.next_sibling () } else { None };
)*
};
Expand Down Expand Up @@ -70,7 +67,7 @@ macro_rules! yamlette_reckon {

if !found { _pointer = None; }
}
yamlette_reckon! ( ptr ; _pointer ; $v );
$crate::yamlette_reckon! ( ptr ; _pointer ; $v );
)*
};

Expand Down
137 changes: 66 additions & 71 deletions src/composer.rs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions src/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ where

#[macro_export]
macro_rules! yamlette {
( read ; $source:expr ; $rules:tt ) => { yamlette! ( read ; $source ; $rules ; {} ) };
( read ; $source:expr ; $rules:tt ) => { $crate::yamlette! ( read ; $source ; $rules ; {} ) };

( read ; $source:expr ; $rules:tt ; $options:tt ) => {
let mut rs = yamlette! ( init ; reader ; $options );
let mut rs = $crate::yamlette! ( init ; reader ; $options );

yamlette! ( read ; warm ; &mut rs ; $source ; $rules ; $options );
$crate::yamlette! ( read ; warm ; &mut rs ; $source ; $rules ; $options );
};

( read ; warm ; $rs:expr ; $source:expr ; $rules:tt ; $options:tt ) => {
Expand All @@ -59,17 +59,17 @@ macro_rules! yamlette {
Err (ref mut err) => Err (Ok (::std::mem::replace (err, $crate::sage::SageError::Error (::std::borrow::Cow::from (String::with_capacity (0))))))
};

yamlette_reckon! ( book ; _book ; $rules );
$crate::yamlette_reckon! ( book ; _book ; $rules );

yamlette! ( options moveout ; _book ; _result ; $options );
$crate::yamlette! ( options moveout ; _book ; _result ; $options );
};

( sage ; $source:expr ; $rules:tt ) => { yamlette! ( sage ; $source ; $rules ; {} ) };
( sage ; $source:expr ; $rules:tt ) => { $crate::yamlette! ( sage ; $source ; $rules ; {} ) };

( sage ; $source:expr ; $rules:tt ; $options:tt ) => {
let mut rs = yamlette! ( init ; sage ; $options );
let mut rs = $crate::yamlette! ( init ; sage ; $options );

yamlette! ( sage ; warm ; &mut rs ; $source ; $rules ; $options );
$crate::yamlette! ( sage ; warm ; &mut rs ; $source ; $rules ; $options );
};

( sage ; warm ; $rs:expr ; $source:expr ; $rules:tt ; $options:tt ) => {
Expand All @@ -91,22 +91,22 @@ macro_rules! yamlette {
Err (ref mut err) => Err (Ok (::std::mem::replace (err, $crate::sage::SageError::Error (::std::borrow::Cow::from (String::with_capacity (0))))))
};

yamlette_reckon! ( book ; _book ; $rules );
$crate::yamlette_reckon! ( book ; _book ; $rules );

yamlette! ( options moveout ; _book ; _result ; $options );
$crate::yamlette! ( options moveout ; _book ; _result ; $options );
};

( write ; $rules:tt ) => {{ yamlette! ( write ; $rules ; {} ) }};
( write ; $rules:tt ) => {{ $crate::yamlette! ( write ; $rules ; {} ) }};

( write ; $rules:tt ; $options:tt ) => {{
match yamlette! ( init ; writer ; $options ) {
match $crate::yamlette! ( init ; writer ; $options ) {
Ok ( mut orch ) => yamlette! ( write ; warm ; &mut orch ; $rules ),
Err ( err ) => Err ( err )
}
}};

( write ; warm ; $orchestra:expr ; $rules:tt ) => {{
yamlette_compose! ( orchestra ; $orchestra ; $rules );
$crate::yamlette_compose! ( orchestra ; $orchestra ; $rules );

match $orchestra.listen () {
Ok (music) => Ok (unsafe { String::from_utf8_unchecked (music) }),
Expand All @@ -115,10 +115,10 @@ macro_rules! yamlette {
}};


( init ; reader ) => {{ yamlette! ( init ; reader ; {} ) }};
( init ; reader ) => {{ $crate::yamlette! ( init ; reader ; {} ) }};

( init ; reader ; $options:tt ) => {{
yamlette! ( options ; $options ; options );
$crate::yamlette! ( options ; $options ; options );

let schema = options.schema.take ().unwrap ();

Expand All @@ -129,10 +129,10 @@ macro_rules! yamlette {
}};


( init ; sage ) => {{ yamlette! ( init ; sage ; {} ) }};
( init ; sage ) => {{ $crate::yamlette! ( init ; sage ; {} ) }};

( init ; sage ; $options:tt ) => {{
yamlette! ( options ; $options ; options );
$crate::yamlette! ( options ; $options ; options );

let schema = options.schema.take ().unwrap ();

Expand All @@ -146,10 +146,10 @@ macro_rules! yamlette {
}
}};

( init ; writer ) => {{ yamlette! ( init ; writer ; {} ) }};
( init ; writer ) => {{ $crate::yamlette! ( init ; writer ; {} ) }};

( init ; writer ; $options:tt ) => {{
yamlette! ( options ; $options ; options );
$crate::yamlette! ( options ; $options ; options );

match $crate::orchestra::Orchestra::new (options.schema.take ().unwrap ()) {
Ok ( orch ) => Ok ( orch ),
Expand All @@ -161,7 +161,7 @@ macro_rules! yamlette {
let mut $var: $crate::face::Options<$crate::model::schema::core::Core> = $crate::face::Options::new ();

$(
$var = yamlette! ( option ; $var ; $key ; $val );
$var = $crate::yamlette! ( option ; $var ; $key ; $val );
)*

$var = if $var.schema.is_none () {
Expand All @@ -182,7 +182,7 @@ macro_rules! yamlette {

( options moveout ; $book:expr ; $result:expr ; { $( $key:ident : $val:ident ),* } ) => {
$(
yamlette! ( option moveout ; $book ; $result ; $key ; $val );
$crate::yamlette! ( option moveout ; $book ; $result ; $key ; $val );
)*
};

Expand Down
Loading

0 comments on commit 8921dec

Please sign in to comment.