forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor xsupport pallet * Optimize using try_for_each * Rename to as_string and as_string_hex * . * Rename to as_addr() * Remove useless Str
- Loading branch information
1 parent
1a5b419
commit d40999d
Showing
6 changed files
with
188 additions
and
190 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
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
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
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,131 @@ | ||
pub use log::*; | ||
|
||
#[cfg(feature = "std")] | ||
#[macro_export] | ||
macro_rules! str { | ||
( $x:expr ) => { | ||
$crate::x_std::as_string(&$x) | ||
}; | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
#[macro_export] | ||
macro_rules! str { | ||
( $x:expr ) => { | ||
&x | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! token { | ||
( $x:expr ) => { | ||
$crate::str!($x) | ||
}; | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
#[macro_export] | ||
macro_rules! try_addr { | ||
( $x:expr ) => {{ | ||
$crate::x_std::as_addr(&$x) | ||
}}; | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
#[macro_export] | ||
macro_rules! try_addr { | ||
( $x:expr ) => {{ | ||
&$x | ||
}}; | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
#[macro_export] | ||
macro_rules! try_hex { | ||
( $x:expr ) => {{ | ||
$crate::x_std::try_hex_or_str(&$x) | ||
}}; | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
#[macro_export] | ||
macro_rules! try_hex { | ||
( $x:expr ) => {{ | ||
&$x | ||
}}; | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
#[macro_export] | ||
macro_rules! ensure_with_errorlog { | ||
( $x:expr, $y:expr, $($arg:tt)*) => {{ | ||
if !$x { | ||
$crate::error!("{:?}|{}", $y, format!($($arg)*)); | ||
$crate::fail!($y); | ||
} | ||
}} | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
#[macro_export] | ||
macro_rules! ensure_with_errorlog { | ||
( $x:expr, $y:expr, $($arg:tt)*) => {{ | ||
if !$x { | ||
$crate::fail!($y); | ||
} | ||
}}; | ||
} | ||
|
||
mod log { | ||
pub const RUNTIME_TARGET: &str = "runtime"; | ||
|
||
#[macro_export] | ||
macro_rules! error { | ||
(target: $target:expr, $($arg:tt)+) => ( | ||
frame_support::debug::error!(target: $target, $($arg)+); | ||
); | ||
($($arg:tt)+) => ( | ||
$crate::error!(target: "runtime", $($arg)+); | ||
) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! warn { | ||
(target: $target:expr, $($arg:tt)+) => ( | ||
frame_support::debug::warn!(target: $target, $($arg)+); | ||
); | ||
($($arg:tt)+) => ( | ||
$crate::warn!(target: "runtime", $($arg)+); | ||
) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! info { | ||
(target: $target:expr, $($arg:tt)+) => ( | ||
frame_support::debug::info!(target: $target, $($arg)+); | ||
); | ||
($($arg:tt)+) => ( | ||
$crate::info!(target: "runtime", $($arg)+); | ||
) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! debug { | ||
(target: $target:expr, $($arg:tt)+) => ( | ||
frame_support::debug::debug!(target: $target, $($arg)+); | ||
); | ||
($($arg:tt)+) => ( | ||
$crate::debug!(target: "runtime", $($arg)+); | ||
) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! trace { | ||
(target: $target:expr, $($arg:tt)+) => ( | ||
frame_support::debug::trace!(target: $target, $($arg)+); | ||
); | ||
($($arg:tt)+) => ( | ||
$crate::trace!(target: "runtime", $($arg)+); | ||
) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.