Code structure refactor.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::def_package;
|
||||
use crate::parser::INT;
|
||||
use crate::plugin::*;
|
||||
use crate::INT;
|
||||
|
||||
use crate::{result::EvalAltResult, token::Position};
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::parser::FLOAT;
|
||||
use crate::FLOAT;
|
||||
|
||||
#[cfg(feature = "no_std")]
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
|
@@ -5,10 +5,11 @@ use crate::def_package;
|
||||
use crate::dynamic::Dynamic;
|
||||
use crate::engine::Array;
|
||||
use crate::fn_native::{FnPtr, NativeCallContext};
|
||||
use crate::parser::{ImmutableString, INT};
|
||||
use crate::plugin::*;
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::token::Position;
|
||||
use crate::utils::ImmutableString;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
use crate::engine::Map;
|
||||
@@ -40,12 +41,12 @@ macro_rules! gen_array_functions {
|
||||
}
|
||||
|
||||
#[rhai_fn(return_raw)]
|
||||
pub fn pad(context: NativeCallContext, list: &mut Array, len: INT, item: $arg_type) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
pub fn pad(_context: NativeCallContext, list: &mut Array, len: INT, item: $arg_type) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
// Check if array will be over max size limit
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if context.engine().max_array_size() > 0 && len > 0 && (len as usize) > context.engine().max_array_size() {
|
||||
if _context.engine().max_array_size() > 0 && len > 0 && (len as usize) > _context.engine().max_array_size() {
|
||||
return EvalAltResult::ErrorDataTooLarge(
|
||||
"Size of array".to_string(), context.engine().max_array_size(), len as usize, Position::none(),
|
||||
"Size of array".to_string(), _context.engine().max_array_size(), len as usize, Position::none(),
|
||||
).into();
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use crate::def_package;
|
||||
use crate::dynamic::Dynamic;
|
||||
use crate::parser::ImmutableString;
|
||||
use crate::plugin::*;
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::utils::ImmutableString;
|
||||
|
||||
def_package!(crate:EvalPackage:"Disable 'eval'.", lib, {
|
||||
combine_with_exported_module!(lib, "eval", eval_override);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use crate::def_package;
|
||||
use crate::dynamic::Variant;
|
||||
use crate::parser::INT;
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::INT;
|
||||
|
||||
use crate::stdlib::{
|
||||
boxed::Box,
|
||||
|
@@ -3,8 +3,9 @@
|
||||
use crate::def_package;
|
||||
use crate::dynamic::Dynamic;
|
||||
use crate::engine::Map;
|
||||
use crate::parser::{ImmutableString, INT};
|
||||
use crate::plugin::*;
|
||||
use crate::utils::ImmutableString;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
use crate::engine::Array;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::def_package;
|
||||
use crate::parser::INT;
|
||||
use crate::plugin::*;
|
||||
use crate::token::Position;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::parser::FLOAT;
|
||||
use crate::FLOAT;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::result::EvalAltResult;
|
||||
@@ -111,7 +111,7 @@ mod int_functions {
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[export_module]
|
||||
mod trig_functions {
|
||||
use crate::parser::FLOAT;
|
||||
use crate::FLOAT;
|
||||
|
||||
pub fn sin(x: FLOAT) -> FLOAT {
|
||||
x.to_radians().sin()
|
||||
@@ -154,7 +154,7 @@ mod trig_functions {
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[export_module]
|
||||
mod float_functions {
|
||||
use crate::parser::FLOAT;
|
||||
use crate::FLOAT;
|
||||
|
||||
pub fn sqrt(x: FLOAT) -> FLOAT {
|
||||
x.sqrt()
|
||||
|
@@ -3,8 +3,9 @@
|
||||
use crate::def_package;
|
||||
use crate::engine::{FN_TO_STRING, KEYWORD_DEBUG, KEYWORD_PRINT};
|
||||
use crate::fn_native::FnPtr;
|
||||
use crate::parser::{ImmutableString, INT};
|
||||
use crate::plugin::*;
|
||||
use crate::utils::ImmutableString;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
use crate::engine::Array;
|
||||
|
@@ -3,9 +3,10 @@
|
||||
use crate::def_package;
|
||||
use crate::dynamic::Dynamic;
|
||||
use crate::fn_native::FnPtr;
|
||||
use crate::parser::{ImmutableString, INT};
|
||||
use crate::plugin::*;
|
||||
use crate::utils::ImmutableString;
|
||||
use crate::StaticVec;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
use crate::{result::EvalAltResult, token::Position};
|
||||
|
@@ -4,12 +4,12 @@ use super::{arithmetic::make_err as make_arithmetic_err, math_basic::MAX_INT};
|
||||
|
||||
use crate::def_package;
|
||||
use crate::dynamic::Dynamic;
|
||||
use crate::parser::INT;
|
||||
use crate::plugin::*;
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::INT;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::parser::FLOAT;
|
||||
use crate::FLOAT;
|
||||
|
||||
use crate::stdlib::boxed::Box;
|
||||
|
||||
|
Reference in New Issue
Block a user