Add wasm64 as potential target.

This commit is contained in:
Stephen Chung
2021-02-19 15:50:48 +08:00
parent 4e3ab7fa6a
commit 724ad05916
13 changed files with 47 additions and 48 deletions

View File

@@ -184,7 +184,7 @@ def_package!(crate:ArithmeticPackage:"Basic arithmetic", lib, {
reg_functions!(lib += arith_numbers; i8, u8, i16, u16, i32, u32, u64);
reg_functions!(lib += signed_numbers; i8, i16, i32);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
{
reg_functions!(lib += arith_num_128; i128, u128);
reg_functions!(lib += signed_num_128; i128);
@@ -211,7 +211,7 @@ gen_arithmetic_functions!(arith_numbers => i8, u8, i16, u16, i32, u32, u64);
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_arithmetic_functions!(arith_num_128 => i128, u128);
gen_signed_functions!(signed_basic => INT);
@@ -222,7 +222,7 @@ gen_signed_functions!(signed_numbers => i8, i16, i32);
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_signed_functions!(signed_num_128 => i128);
#[cfg(not(feature = "no_float"))]

View File

@@ -71,7 +71,7 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
{
reg_functions!(lib += numbers; i8, u8, i16, u16, i32, i64, u32, u64);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
reg_functions!(lib += num_128; i128, u128);
}
@@ -706,7 +706,7 @@ gen_array_functions!(numbers => i8, u8, i16, u16, i32, i64, u32, u64);
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_array_functions!(num_128 => i128, u128);
#[cfg(not(feature = "no_float"))]

View File

@@ -62,7 +62,7 @@ def_package!(crate:LogicPackage:"Logical operators.", lib, {
{
reg_functions!(lib += numbers; i8, u8, i16, u16, i32, u32, u64);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
reg_functions!(lib += num_128; i128, u128);
}
@@ -98,7 +98,7 @@ gen_cmp_functions!(numbers => i8, u8, i16, u16, i32, u32, u64);
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_cmp_functions!(num_128 => i128, u128);
#[cfg(not(feature = "no_float"))]

View File

@@ -73,7 +73,7 @@ def_package!(crate:BasicMathPackage:"Basic mathematic functions.", lib, {
{
reg_functions!(lib += numbers_to_int::to_int(i8, u8, i16, u16, i32, u32, i64, u64));
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
reg_functions!(lib += num_128_to_int::to_int(i128, u128));
}
@@ -92,7 +92,7 @@ def_package!(crate:BasicMathPackage:"Basic mathematic functions.", lib, {
{
reg_functions!(lib += numbers_to_float::to_float(i8, u8, i16, u16, i32, u32, i64, u32));
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
reg_functions!(lib += num_128_to_float::to_float(i128, u128));
}
}
@@ -452,7 +452,7 @@ gen_conversion_as_functions!(numbers_to_float => to_float (i8, u8, i16, u16, i32
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_conversion_as_functions!(num_128_to_float => to_float (i128, u128) -> FLOAT);
gen_conversion_as_functions!(basic_to_int => to_int (char) -> INT);
@@ -463,7 +463,7 @@ gen_conversion_as_functions!(numbers_to_int => to_int (i8, u8, i16, u16, i32, u3
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_conversion_as_functions!(num_128_to_int => to_int (i128, u128) -> INT);
#[cfg(feature = "decimal")]

View File

@@ -62,7 +62,7 @@ def_package!(crate:BasicStringPackage:"Basic string utilities, including printin
reg_print_functions!(lib += print_numbers; i8, u8, i16, u16, i32, u32, i64, u64);
reg_debug_functions!(lib += debug_numbers; i8, u8, i16, u16, i32, u32, i64, u64);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
{
reg_print_functions!(lib += print_num_128; i128, u128);
reg_debug_functions!(lib += debug_num_128; i128, u128);
@@ -128,12 +128,12 @@ gen_functions!(debug_numbers => to_debug(i8, u8, i16, u16, i32, u32, i64, u64));
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_functions!(print_num_128 => to_string(i128, u128));
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_functions!(debug_num_128 => to_debug(i128, u128));
#[cfg(not(feature = "no_float"))]

View File

@@ -41,7 +41,7 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str
{
reg_functions!(lib += numbers; i8, u8, i16, u16, i32, i64, u32, u64);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
reg_functions!(lib += num_128; i128, u128);
}
@@ -65,7 +65,7 @@ gen_concat_functions!(numbers => i8, u8, i16, u16, i32, i64, u32, u64);
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
gen_concat_functions!(num_128 => i128, u128);
#[cfg(not(feature = "no_float"))]

View File

@@ -8,10 +8,10 @@ use crate::{def_package, Dynamic, EvalAltResult, INT};
#[cfg(not(feature = "no_float"))]
use crate::FLOAT;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
use crate::stdlib::time::{Duration, Instant};
#[cfg(target_arch = "wasm32")]
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
use instant::{Duration, Instant};
def_package!(crate:BasicTimePackage:"Basic timing utilities.", lib, {
@@ -28,12 +28,10 @@ mod time_functions {
#[rhai_fn(name = "elapsed", get = "elapsed", return_raw)]
pub fn elapsed(timestamp: &mut Instant) -> Result<Dynamic, Box<EvalAltResult>> {
#[cfg(not(feature = "no_float"))]
{
if *timestamp > Instant::now() {
Err(make_arithmetic_err("Time-stamp is later than now"))
} else {
Ok((timestamp.elapsed().as_secs_f64() as FLOAT).into())
}
if *timestamp > Instant::now() {
Err(make_arithmetic_err("Time-stamp is later than now"))
} else {
Ok((timestamp.elapsed().as_secs_f64() as FLOAT).into())
}
#[cfg(feature = "no_float")]
@@ -56,14 +54,12 @@ mod time_functions {
#[rhai_fn(return_raw, name = "-")]
pub fn time_diff(ts1: Instant, ts2: Instant) -> Result<Dynamic, Box<EvalAltResult>> {
#[cfg(not(feature = "no_float"))]
{
Ok(if ts2 > ts1 {
-(ts2 - ts1).as_secs_f64() as FLOAT
} else {
(ts1 - ts2).as_secs_f64() as FLOAT
}
.into())
return Ok(if ts2 > ts1 {
-(ts2 - ts1).as_secs_f64() as FLOAT
} else {
(ts1 - ts2).as_secs_f64() as FLOAT
}
.into());
#[cfg(feature = "no_float")]
if ts2 > ts1 {