Nicer formatting/less indentation of module plugin blocks.

This commit is contained in:
Stephen Chung
2020-08-28 23:13:38 +08:00
parent b72a6355fd
commit 75ca495199
6 changed files with 280 additions and 312 deletions

View File

@@ -22,17 +22,15 @@ type Unit = ();
macro_rules! gen_functions {
($root:ident => $fn_name:ident ( $($arg_type:ident),+ )) => {
pub mod $root { $(
pub mod $arg_type {
use super::super::*;
pub mod $root { $(pub mod $arg_type {
use super::super::*;
#[export_fn]
#[inline(always)]
pub fn to_string_func(x: &mut $arg_type) -> ImmutableString {
super::super::$fn_name(x)
}
#[export_fn]
#[inline(always)]
pub fn to_string_func(x: &mut $arg_type) -> ImmutableString {
super::super::$fn_name(x)
}
)* }
})* }
}
}
@@ -128,12 +126,12 @@ gen_functions!(print_array => to_debug(Array));
#[export_fn]
#[inline(always)]
fn print_empty_string() -> ImmutableString {
"".to_string().into()
String::new().into()
}
#[export_fn]
#[inline(always)]
fn print_unit(_x: ()) -> ImmutableString {
"".to_string().into()
String::new().into()
}
#[export_fn]
#[inline(always)]
@@ -143,7 +141,7 @@ fn print_string(s: ImmutableString) -> ImmutableString {
#[export_fn]
#[inline(always)]
fn debug_fn_ptr(f: &mut FnPtr) -> ImmutableString {
f.to_string().into()
to_string(f)
}
#[inline(always)]
fn to_string<T: Display>(x: &mut T) -> ImmutableString {