Add include_standard_packages to Definitions.

This commit is contained in:
Stephen Chung
2022-07-29 13:39:51 +08:00
parent 52edded841
commit 13a1147dea
8 changed files with 621 additions and 96 deletions

View File

@@ -677,6 +677,8 @@ op **(u64, int) -> u64;
op **(u8, int) -> u8;
op +(Decimal) -> Decimal;
op +(int) -> int;
op +(f32) -> f32;
@@ -793,6 +795,8 @@ op +=(Instant, float) -> ();
/// Add the specified number of `seconds` to the timestamp.
op +=(Instant, int) -> ();
op -(Decimal) -> Decimal;
op -(int) -> int;
op -(f32) -> f32;
@@ -1121,6 +1125,9 @@ op ^(u64, u64) -> u64;
op ^(u8, u8) -> u8;
/// Return the absolute value of the decimal number.
fn abs(x: Decimal) -> Decimal;
/// Return the absolute value of the number.
fn abs(x: int) -> int;
@@ -1293,6 +1300,13 @@ fn atan(x: float, y: float) -> float;
/// Return the arc-hyperbolic-tangent of the floating-point number, in radians.
fn atanh(x: float) -> float;
/// Get an array of object maps containing the function calls stack.
///
/// If there is no debugging interface registered, an empty array is returned.
///
/// An array of strings is returned under `no_object`.
fn back_trace() -> Array;
/// Return an iterator over all the bits in the number.
///
/// # Example
@@ -1406,6 +1420,9 @@ fn blob(len: int, value: int) -> Blob;
/// ```
fn bytes(string: String) -> int;
/// Return the smallest whole number larger than or equals to the decimal number.
fn ceiling(x: Decimal) -> Decimal;
/// Return the smallest whole number larger than or equals to the floating-point number.
fn ceiling(x: float) -> float;
@@ -1547,6 +1564,9 @@ fn clear(string: String) -> ();
/// ```
fn contains(array: Array, value: ?) -> bool;
/// Return the cosine of the decimal number in radians.
fn cos(x: Decimal) -> Decimal;
/// Return the cosine of the floating-point number in radians.
fn cos(x: float) -> float;
@@ -1960,6 +1980,9 @@ fn end(range: InclusiveRange) -> int;
/// ```
fn ends_with(string: String, match_string: String) -> bool;
/// Return the exponential of the decimal number.
fn exp(x: Decimal) -> Decimal;
/// Return the exponential of the floating-point number.
fn exp(x: float) -> float;
@@ -2170,9 +2193,15 @@ fn filter(array: Array, filter: FnPtr) -> Array;
/// ```
fn filter(array: Array, filter_func: String) -> Array;
/// Return the largest whole number less than or equals to the decimal number.
fn floor(x: Decimal) -> Decimal;
/// Return the largest whole number less than or equals to the floating-point number.
fn floor(x: float) -> float;
/// Return the fractional part of the decimal number.
fn fraction(x: Decimal) -> Decimal;
/// Return the fractional part of the floating-point number.
fn fraction(x: float) -> float;
@@ -2274,6 +2303,9 @@ fn get bits(value: int) -> Iterator<bool>;
/// ```
fn get bytes(string: String) -> int;
/// Return the smallest whole number larger than or equals to the decimal number.
fn get ceiling(x: Decimal) -> Decimal;
/// Return the smallest whole number larger than or equals to the floating-point number.
fn get ceiling(x: float) -> float;
@@ -2307,12 +2339,21 @@ fn get end(range: ExclusiveRange) -> int;
/// Return the end of the inclusive range.
fn get end(range: InclusiveRange) -> int;
/// Return the largest whole number less than or equals to the decimal number.
fn get floor(x: Decimal) -> Decimal;
/// Return the largest whole number less than or equals to the floating-point number.
fn get floor(x: float) -> float;
/// Return the fractional part of the decimal number.
fn get fraction(x: Decimal) -> Decimal;
/// Return the fractional part of the floating-point number.
fn get fraction(x: float) -> float;
/// Return the integral part of the decimal number.
fn get int(x: Decimal) -> Decimal;
/// Return the integral part of the floating-point number.
fn get int(x: float) -> float;
@@ -2408,6 +2449,9 @@ fn get is_odd(x: u64) -> bool;
/// Return true if the number is odd.
fn get is_odd(x: u8) -> bool;
/// Return true if the decimal number is zero.
fn get is_zero(x: Decimal) -> bool;
/// Return true if the number is zero.
fn get is_zero(x: int) -> bool;
@@ -2484,6 +2528,10 @@ fn get len(string: String) -> int;
/// ```
fn get name(fn_ptr: FnPtr) -> String;
/// Return the nearest whole number closest to the decimal number.
/// Always round mid-point towards the closest even number.
fn get round(x: Decimal) -> Decimal;
/// Return the nearest whole number closest to the floating-point number.
/// Rounds away from zero.
fn get round(x: float) -> float;
@@ -2848,6 +2896,9 @@ fn insert(array: Array, index: int, item: ?) -> ();
/// ```
fn insert(blob: Blob, index: int, value: int) -> ();
/// Return the integral part of the decimal number.
fn int(x: Decimal) -> Decimal;
/// Return the integral part of the floating-point number.
fn int(x: float) -> float;
@@ -2943,6 +2994,9 @@ fn is_odd(x: u64) -> bool;
/// Return true if the number is odd.
fn is_odd(x: u8) -> bool;
/// Return true if the decimal number is zero.
fn is_zero(x: Decimal) -> bool;
/// Return true if the number is zero.
fn is_zero(x: int) -> bool;
@@ -3020,9 +3074,15 @@ fn len(map: Map) -> int;
/// ```
fn len(string: String) -> int;
/// Return the natural log of the decimal number.
fn ln(x: Decimal) -> Decimal;
/// Return the natural log of the floating-point number.
fn ln(x: float) -> float;
/// Return the log of the decimal number with base 10.
fn log(x: Decimal) -> Decimal;
/// Return the log of the floating-point number with base 10.
fn log(x: float) -> float;
@@ -3323,6 +3383,17 @@ fn parse_be_int(blob: Blob, range: RangeInclusive<int>) -> int;
/// ```
fn parse_be_int(blob: Blob, start: int, len: int) -> int;
/// Parse a string into a decimal number.
///
/// # Example
///
/// ```rhai
/// let x = parse_decimal("123.456");
///
/// print(x); // prints 123.456
/// ```
fn parse_decimal(string: String) -> Decimal;
/// Parse a string into a floating-point number.
///
/// # Example
@@ -3700,6 +3771,27 @@ fn range(from: u64, to: u64) -> Iterator<u64>;
/// ```
fn range(from: u8, to: u8) -> Iterator<u8>;
/// Return an iterator over an exclusive range, each iteration increasing by `step`.
///
/// If `range` is reversed and `step` < 0, iteration goes backwards.
///
/// Otherwise, if `range` is empty, an empty iterator is returned.
///
/// # Example
///
/// ```rhai
/// // prints all values from 8 to 17 in steps of 3
/// for n in range(8..18, 3) {
/// print(n);
/// }
///
/// // prints all values down from 18 to 9 in steps of -3
/// for n in range(18..8, -3) {
/// print(n);
/// }
/// ```
fn range(range: Range<Decimal>, step: Decimal) -> Iterator<Decimal>;
/// Return an iterator over an exclusive range, each iteration increasing by `step`.
///
/// If `range` is reversed and `step` < 0, iteration goes backwards.
@@ -3931,6 +4023,28 @@ fn range(range: Range<u64>, step: u64) -> Iterator<u64>;
/// ```
fn range(range: Range<u8>, step: u8) -> Iterator<u8>;
/// Return an iterator over the exclusive range of `from..to`, each iteration increasing by `step`.
/// The value `to` is never included.
///
/// If `from` > `to` and `step` < 0, iteration goes backwards.
///
/// If `from` > `to` and `step` > 0 or `from` < `to` and `step` < 0, an empty iterator is returned.
///
/// # Example
///
/// ```rhai
/// // prints all values from 8 to 17 in steps of 3
/// for n in range(8, 18, 3) {
/// print(n);
/// }
///
/// // prints all values down from 18 to 9 in steps of -3
/// for n in range(18, 8, -3) {
/// print(n);
/// }
/// ```
fn range(from: Decimal, to: Decimal, step: Decimal) -> Iterator<Decimal>;
/// Return an iterator over the exclusive range of `from..to`, each iteration increasing by `step`.
/// The value `to` is never included.
///
@@ -4764,10 +4878,34 @@ fn reverse(array: Array) -> ();
/// ```
fn reverse(blob: Blob) -> ();
/// Return the nearest whole number closest to the decimal number.
/// Always round mid-point towards the closest even number.
fn round(x: Decimal) -> Decimal;
/// Return the nearest whole number closest to the floating-point number.
/// Rounds away from zero.
fn round(x: float) -> float;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-point towards the closest even number.
fn round(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round towards zero.
fn round_down(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-points towards zero.
fn round_half_down(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-points away from zero.
fn round_half_up(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round away from zero.
fn round_up(x: Decimal, digits: int) -> Decimal;
/// Set the element at the `index` position in the array to a new `value`.
///
/// * If `index` < 0, position counts from the end of the array (`-1` is the last element).
@@ -4993,6 +5131,13 @@ fn shift(array: Array) -> ?;
/// ```
fn shift(blob: Blob) -> int;
/// Return the sign (as an integer) of the decimal number according to the following:
///
/// * `0` if the number is zero
/// * `1` if the number is positive
/// * `-1` if the number is negative
fn sign(x: Decimal) -> int;
/// Return the sign (as an integer) of the number according to the following:
///
/// * `0` if the number is zero
@@ -5042,6 +5187,9 @@ fn sign(x: i32) -> int;
/// * `-1` if the number is negative
fn sign(x: i8) -> int;
/// Return the sine of the decimal number in radians.
fn sin(x: Decimal) -> Decimal;
/// Return the sine of the floating-point number in radians.
fn sin(x: float) -> float;
@@ -5471,6 +5619,9 @@ fn split_rev(string: String, delimiter: String, segments: int) -> Array;
/// ```
fn split_rev(string: String, delimiter: char, segments: int) -> Array;
/// Return the square root of the decimal number.
fn sqrt(x: Decimal) -> Decimal;
/// Return the square root of the floating-point number.
fn sqrt(x: float) -> float;
@@ -5565,6 +5716,9 @@ fn sub_string(string: String, start: int, len: int) -> String;
/// ```
fn tag(value: ?) -> int;
/// Return the tangent of the decimal number in radians.
fn tan(x: Decimal) -> Decimal;
/// Return the tangent of the floating-point number in radians.
fn tan(x: float) -> float;
@@ -5671,9 +5825,34 @@ fn to_debug(unit: ()) -> String;
/// Convert the boolean value into a string in debug format.
fn to_debug(value: bool) -> String;
/// Convert the floating-point number to decimal.
fn to_decimal(x: f32) -> Decimal;
/// Convert the floating-point number to decimal.
fn to_decimal(x: float) -> Decimal;
fn to_decimal(x: i16) -> Decimal;
fn to_decimal(x: i32) -> Decimal;
fn to_decimal(x: int) -> Decimal;
fn to_decimal(x: i8) -> Decimal;
fn to_decimal(x: u16) -> Decimal;
fn to_decimal(x: u32) -> Decimal;
fn to_decimal(x: u64) -> Decimal;
fn to_decimal(x: u8) -> Decimal;
/// Convert radians to degrees.
fn to_degrees(x: float) -> float;
/// Convert the decimal number to floating-point.
fn to_float(x: Decimal) -> float;
/// Convert the 32-bit floating-point number to 64-bit.
fn to_float(x: f32) -> float;
@@ -5725,6 +5904,9 @@ fn to_hex(value: u64) -> String;
/// Convert the `value` into a string in hex format.
fn to_hex(value: u8) -> String;
/// Convert the decimal number into an integer.
fn to_int(x: Decimal) -> int;
fn to_int(x: char) -> int;
/// Convert the floating-point number into an integer.
@@ -6247,10 +6429,10 @@ op |(u32, u32) -> u32;
op |(u64, u64) -> u64;
op |(u8, u8) -> u8;
module general_kenobi {
module general_kenobi {
/// Returns a string where "hello there" is repeated `n` times.
fn hello_there(n: int) -> String;
}
let hello_there;
let hello_there;

View File

@@ -0,0 +1,10 @@
module static;
op minus(int, int) -> int;
module general_kenobi {
/// Returns a string where "hello there" is repeated `n` times.
fn hello_there(n: int) -> String;
}
let hello_there;

View File

@@ -159,6 +159,8 @@ op **(u64, int) -> u64;
op **(u8, int) -> u8;
op +(Decimal) -> Decimal;
op +(int) -> int;
op +(f32) -> f32;
@@ -275,6 +277,8 @@ op +=(Instant, float) -> ();
/// Add the specified number of `seconds` to the timestamp.
op +=(Instant, int) -> ();
op -(Decimal) -> Decimal;
op -(int) -> int;
op -(f32) -> f32;
@@ -603,6 +607,9 @@ op ^(u64, u64) -> u64;
op ^(u8, u8) -> u8;
/// Return the absolute value of the decimal number.
fn abs(x: Decimal) -> Decimal;
/// Return the absolute value of the number.
fn abs(x: int) -> int;
@@ -775,6 +782,13 @@ fn atan(x: float, y: float) -> float;
/// Return the arc-hyperbolic-tangent of the floating-point number, in radians.
fn atanh(x: float) -> float;
/// Get an array of object maps containing the function calls stack.
///
/// If there is no debugging interface registered, an empty array is returned.
///
/// An array of strings is returned under `no_object`.
fn back_trace() -> Array;
/// Return an iterator over all the bits in the number.
///
/// # Example
@@ -888,6 +902,9 @@ fn blob(len: int, value: int) -> Blob;
/// ```
fn bytes(string: String) -> int;
/// Return the smallest whole number larger than or equals to the decimal number.
fn ceiling(x: Decimal) -> Decimal;
/// Return the smallest whole number larger than or equals to the floating-point number.
fn ceiling(x: float) -> float;
@@ -1029,6 +1046,9 @@ fn clear(string: String) -> ();
/// ```
fn contains(array: Array, value: ?) -> bool;
/// Return the cosine of the decimal number in radians.
fn cos(x: Decimal) -> Decimal;
/// Return the cosine of the floating-point number in radians.
fn cos(x: float) -> float;
@@ -1442,6 +1462,9 @@ fn end(range: InclusiveRange) -> int;
/// ```
fn ends_with(string: String, match_string: String) -> bool;
/// Return the exponential of the decimal number.
fn exp(x: Decimal) -> Decimal;
/// Return the exponential of the floating-point number.
fn exp(x: float) -> float;
@@ -1652,9 +1675,15 @@ fn filter(array: Array, filter: FnPtr) -> Array;
/// ```
fn filter(array: Array, filter_func: String) -> Array;
/// Return the largest whole number less than or equals to the decimal number.
fn floor(x: Decimal) -> Decimal;
/// Return the largest whole number less than or equals to the floating-point number.
fn floor(x: float) -> float;
/// Return the fractional part of the decimal number.
fn fraction(x: Decimal) -> Decimal;
/// Return the fractional part of the floating-point number.
fn fraction(x: float) -> float;
@@ -1756,6 +1785,9 @@ fn get bits(value: int) -> Iterator<bool>;
/// ```
fn get bytes(string: String) -> int;
/// Return the smallest whole number larger than or equals to the decimal number.
fn get ceiling(x: Decimal) -> Decimal;
/// Return the smallest whole number larger than or equals to the floating-point number.
fn get ceiling(x: float) -> float;
@@ -1789,12 +1821,21 @@ fn get end(range: ExclusiveRange) -> int;
/// Return the end of the inclusive range.
fn get end(range: InclusiveRange) -> int;
/// Return the largest whole number less than or equals to the decimal number.
fn get floor(x: Decimal) -> Decimal;
/// Return the largest whole number less than or equals to the floating-point number.
fn get floor(x: float) -> float;
/// Return the fractional part of the decimal number.
fn get fraction(x: Decimal) -> Decimal;
/// Return the fractional part of the floating-point number.
fn get fraction(x: float) -> float;
/// Return the integral part of the decimal number.
fn get int(x: Decimal) -> Decimal;
/// Return the integral part of the floating-point number.
fn get int(x: float) -> float;
@@ -1890,6 +1931,9 @@ fn get is_odd(x: u64) -> bool;
/// Return true if the number is odd.
fn get is_odd(x: u8) -> bool;
/// Return true if the decimal number is zero.
fn get is_zero(x: Decimal) -> bool;
/// Return true if the number is zero.
fn get is_zero(x: int) -> bool;
@@ -1966,6 +2010,10 @@ fn get len(string: String) -> int;
/// ```
fn get name(fn_ptr: FnPtr) -> String;
/// Return the nearest whole number closest to the decimal number.
/// Always round mid-point towards the closest even number.
fn get round(x: Decimal) -> Decimal;
/// Return the nearest whole number closest to the floating-point number.
/// Rounds away from zero.
fn get round(x: float) -> float;
@@ -2330,6 +2378,9 @@ fn insert(array: Array, index: int, item: ?) -> ();
/// ```
fn insert(blob: Blob, index: int, value: int) -> ();
/// Return the integral part of the decimal number.
fn int(x: Decimal) -> Decimal;
/// Return the integral part of the floating-point number.
fn int(x: float) -> float;
@@ -2425,6 +2476,9 @@ fn is_odd(x: u64) -> bool;
/// Return true if the number is odd.
fn is_odd(x: u8) -> bool;
/// Return true if the decimal number is zero.
fn is_zero(x: Decimal) -> bool;
/// Return true if the number is zero.
fn is_zero(x: int) -> bool;
@@ -2502,9 +2556,15 @@ fn len(map: Map) -> int;
/// ```
fn len(string: String) -> int;
/// Return the natural log of the decimal number.
fn ln(x: Decimal) -> Decimal;
/// Return the natural log of the floating-point number.
fn ln(x: float) -> float;
/// Return the log of the decimal number with base 10.
fn log(x: Decimal) -> Decimal;
/// Return the log of the floating-point number with base 10.
fn log(x: float) -> float;
@@ -2805,6 +2865,17 @@ fn parse_be_int(blob: Blob, range: RangeInclusive<int>) -> int;
/// ```
fn parse_be_int(blob: Blob, start: int, len: int) -> int;
/// Parse a string into a decimal number.
///
/// # Example
///
/// ```rhai
/// let x = parse_decimal("123.456");
///
/// print(x); // prints 123.456
/// ```
fn parse_decimal(string: String) -> Decimal;
/// Parse a string into a floating-point number.
///
/// # Example
@@ -3182,6 +3253,27 @@ fn range(from: u64, to: u64) -> Iterator<u64>;
/// ```
fn range(from: u8, to: u8) -> Iterator<u8>;
/// Return an iterator over an exclusive range, each iteration increasing by `step`.
///
/// If `range` is reversed and `step` < 0, iteration goes backwards.
///
/// Otherwise, if `range` is empty, an empty iterator is returned.
///
/// # Example
///
/// ```rhai
/// // prints all values from 8 to 17 in steps of 3
/// for n in range(8..18, 3) {
/// print(n);
/// }
///
/// // prints all values down from 18 to 9 in steps of -3
/// for n in range(18..8, -3) {
/// print(n);
/// }
/// ```
fn range(range: Range<Decimal>, step: Decimal) -> Iterator<Decimal>;
/// Return an iterator over an exclusive range, each iteration increasing by `step`.
///
/// If `range` is reversed and `step` < 0, iteration goes backwards.
@@ -3413,6 +3505,28 @@ fn range(range: Range<u64>, step: u64) -> Iterator<u64>;
/// ```
fn range(range: Range<u8>, step: u8) -> Iterator<u8>;
/// Return an iterator over the exclusive range of `from..to`, each iteration increasing by `step`.
/// The value `to` is never included.
///
/// If `from` > `to` and `step` < 0, iteration goes backwards.
///
/// If `from` > `to` and `step` > 0 or `from` < `to` and `step` < 0, an empty iterator is returned.
///
/// # Example
///
/// ```rhai
/// // prints all values from 8 to 17 in steps of 3
/// for n in range(8, 18, 3) {
/// print(n);
/// }
///
/// // prints all values down from 18 to 9 in steps of -3
/// for n in range(18, 8, -3) {
/// print(n);
/// }
/// ```
fn range(from: Decimal, to: Decimal, step: Decimal) -> Iterator<Decimal>;
/// Return an iterator over the exclusive range of `from..to`, each iteration increasing by `step`.
/// The value `to` is never included.
///
@@ -4246,10 +4360,34 @@ fn reverse(array: Array) -> ();
/// ```
fn reverse(blob: Blob) -> ();
/// Return the nearest whole number closest to the decimal number.
/// Always round mid-point towards the closest even number.
fn round(x: Decimal) -> Decimal;
/// Return the nearest whole number closest to the floating-point number.
/// Rounds away from zero.
fn round(x: float) -> float;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-point towards the closest even number.
fn round(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round towards zero.
fn round_down(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-points towards zero.
fn round_half_down(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round mid-points away from zero.
fn round_half_up(x: Decimal, digits: int) -> Decimal;
/// Round the decimal number to the specified number of `digits` after the decimal point and return it.
/// Always round away from zero.
fn round_up(x: Decimal, digits: int) -> Decimal;
/// Set the element at the `index` position in the array to a new `value`.
///
/// * If `index` < 0, position counts from the end of the array (`-1` is the last element).
@@ -4475,6 +4613,13 @@ fn shift(array: Array) -> ?;
/// ```
fn shift(blob: Blob) -> int;
/// Return the sign (as an integer) of the decimal number according to the following:
///
/// * `0` if the number is zero
/// * `1` if the number is positive
/// * `-1` if the number is negative
fn sign(x: Decimal) -> int;
/// Return the sign (as an integer) of the number according to the following:
///
/// * `0` if the number is zero
@@ -4524,6 +4669,9 @@ fn sign(x: i32) -> int;
/// * `-1` if the number is negative
fn sign(x: i8) -> int;
/// Return the sine of the decimal number in radians.
fn sin(x: Decimal) -> Decimal;
/// Return the sine of the floating-point number in radians.
fn sin(x: float) -> float;
@@ -4953,6 +5101,9 @@ fn split_rev(string: String, delimiter: String, segments: int) -> Array;
/// ```
fn split_rev(string: String, delimiter: char, segments: int) -> Array;
/// Return the square root of the decimal number.
fn sqrt(x: Decimal) -> Decimal;
/// Return the square root of the floating-point number.
fn sqrt(x: float) -> float;
@@ -5047,6 +5198,9 @@ fn sub_string(string: String, start: int, len: int) -> String;
/// ```
fn tag(value: ?) -> int;
/// Return the tangent of the decimal number in radians.
fn tan(x: Decimal) -> Decimal;
/// Return the tangent of the floating-point number in radians.
fn tan(x: float) -> float;
@@ -5153,9 +5307,34 @@ fn to_debug(unit: ()) -> String;
/// Convert the boolean value into a string in debug format.
fn to_debug(value: bool) -> String;
/// Convert the floating-point number to decimal.
fn to_decimal(x: f32) -> Decimal;
/// Convert the floating-point number to decimal.
fn to_decimal(x: float) -> Decimal;
fn to_decimal(x: i16) -> Decimal;
fn to_decimal(x: i32) -> Decimal;
fn to_decimal(x: int) -> Decimal;
fn to_decimal(x: i8) -> Decimal;
fn to_decimal(x: u16) -> Decimal;
fn to_decimal(x: u32) -> Decimal;
fn to_decimal(x: u64) -> Decimal;
fn to_decimal(x: u8) -> Decimal;
/// Convert radians to degrees.
fn to_degrees(x: float) -> float;
/// Convert the decimal number to floating-point.
fn to_float(x: Decimal) -> float;
/// Convert the 32-bit floating-point number to 64-bit.
fn to_float(x: f32) -> float;
@@ -5207,6 +5386,9 @@ fn to_hex(value: u64) -> String;
/// Convert the `value` into a string in hex format.
fn to_hex(value: u8) -> String;
/// Convert the decimal number into an integer.
fn to_int(x: Decimal) -> int;
fn to_int(x: char) -> int;
/// Convert the floating-point number into an integer.

View File

@@ -0,0 +1,49 @@
{
"modules": {
"general_kenobi": {
"functions": [
{
"baseHash": 2647973605745432570,
"fullHash": 14052888716942083368,
"namespace": "internal",
"access": "public",
"name": "hello_there",
"type": "native",
"numParams": 1,
"params": [
{
"name": "n",
"type": "i64"
}
],
"returnType": "String",
"signature": "hello_there(n: i64) -> String",
"docComments": [
"/// Returns a string where \"hello there\" is repeated `n` times."
]
}
]
}
},
"functions": [
{
"baseHash": 6399059862174416123,
"fullHash": 15886705420394126404,
"namespace": "global",
"access": "public",
"name": "minus",
"type": "native",
"numParams": 2,
"params": [
{
"type": "i64"
},
{
"type": "i64"
}
],
"returnType": "i64",
"signature": "minus(_: i64, _: i64) -> i64"
}
]
}

View File

@@ -44,5 +44,21 @@ fn main() -> Result<(), Box<EvalAltResult>> {
.write_to_file("examples/definitions/.rhai/all_in_one.d.rhai")
.unwrap();
// Skip standard packages if not needed (e.g. they are provided elsewhere).
engine
.definitions_with_scope(&scope)
.include_standard_packages(false)
.write_to_file("examples/definitions/.rhai/all_in_one_without_standard.d.rhai")
.unwrap();
// Write function definitions as JSON.
let json = engine
.definitions()
.include_standard_packages(false)
.json()
.unwrap();
std::fs::write("examples/definitions/.rhai/defs.json", json).unwrap();
Ok(())
}