Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sr-support: add back json generation
  • Loading branch information
Guanqun Lu committed Sep 16, 2018
commit 5bdd1ae45a6f1d566715c030e49045b18cf52f46
45 changes: 36 additions & 9 deletions srml/support/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ macro_rules! decl_module {
d.dispatch(origin)
}
}
// __dispatch_impl_json_metadata! {
// $mod_type $trait_instance $trait_name $call_type $origin_type
// {$( $(#[doc = $doc_attr])* fn $fn_name($from $(, $param_name : $param )*) -> $result; )*}
// }
__dispatch_impl_json_metadata! {
$mod_type $trait_instance $trait_name $call_type $origin_type
{$( $(#[doc = $doc_attr])* fn $fn_name(($top_origin $sub_origin $origin_param) $(, $param_name : $param )*) -> $result; )*}
}
}
}

Expand Down Expand Up @@ -529,7 +529,7 @@ macro_rules! __call_to_json {
$call_type:ident $origin_type:ty
{$(
$(#[doc = $doc_attr:tt])*
fn $fn_name:ident($from:ident
fn $fn_name:ident(($top_origin:ident $sub_origin:ident $origin_param:ident)
$(
, $param_name:ident : $param:ty
)*
Expand All @@ -540,7 +540,7 @@ macro_rules! __call_to_json {
r#"{ "name": ""#, stringify!($call_type),
r#"", "functions": {"#,
__functions_to_json!(""; 0; $origin_type; $(
fn $fn_name($from $(, $param_name: $param )* ) -> $result;
fn $fn_name(($top_origin $sub_origin $origin_param) $(, $param_name: $param )* ) -> $result;
__function_doc_to_json!(""; $($doc_attr)*);
)*), " } }"
)
Expand All @@ -556,7 +556,8 @@ macro_rules! __functions_to_json {
$prefix_str:tt;
$fn_id:expr;
$origin_type:ty;
fn $fn_name:ident(root
fn $fn_name:ident(
(root root root)
$(
, $param_name:ident : $param:ty
)*
Expand All @@ -574,12 +575,13 @@ macro_rules! __functions_to_json {
), __functions_to_json!(","; $fn_id + 1; $origin_type; $($rest)*)
)
};
// NON ROOT
// ORIGIN
(
$prefix_str:tt;
$fn_id:expr;
$origin_type:ty;
fn $fn_name:ident(origin
fn $fn_name:ident(
(origin origin origin)
$(
, $param_name:ident : $param:ty
)*
Expand All @@ -598,6 +600,31 @@ macro_rules! __functions_to_json {
), __functions_to_json!(","; $fn_id + 1; $origin_type; $($rest)*)
)
};
// system signed who
(
$prefix_str:tt;
$fn_id:expr;
$origin_type:ty;
fn $fn_name:ident(
(system signed $who:ident)
$(
, $param_name:ident : $param:ty
)*
) -> $result:ty;
$fn_doc:expr;
$($rest:tt)*
) => {
concat!($prefix_str, " ",
__function_to_json!(
fn $fn_name(
$who: $origin_type // TODO: fix this.
$( , $param_name : $param )*
) -> $result;
$fn_doc;
$fn_id;
), __functions_to_json!(","; $fn_id + 1; $origin_type; $($rest)*)
)
};
// BASE CASE
(
$prefix_str:tt;
Expand Down