Add isAnonymous to JSON metadata.

This commit is contained in:
Stephen Chung 2023-03-17 06:28:00 +08:00
parent c62162b3c5
commit 091e16124c
2 changed files with 5 additions and 1 deletions

View File

@ -10,7 +10,7 @@ Bug fixes
* Complex indexing/dotting chains now parse correctly, for example: `a[b][c[d]].e` * Complex indexing/dotting chains now parse correctly, for example: `a[b][c[d]].e`
* `map` and `filter` for arrays are marked `pure`. Warnings are added to the documentation of pure array methods that take `this` closures. * `map` and `filter` for arrays are marked `pure`. Warnings are added to the documentation of pure array methods that take `this` closures.
* Syntax such as `foo.bar::baz` no longer panics, but returns a proper parse error. * Syntax such as `foo.bar::baz` no longer panics, but returns a proper parse error.
* `x += y` where `x` and `y` are `char` now works correctly. * Some op-assignment statements, such as `x += y` where `x` and `y` are `char`, now work correctly instead of failing silently.
* Expressions such as `!inside` now parses correctly instead of as `!in` followed by `side`. * Expressions such as `!inside` now parses correctly instead of as `!in` followed by `side`.
* Custom syntax starting with symbols now works correctly and no longer raises a parse error. * Custom syntax starting with symbols now works correctly and no longer raises a parse error.
* Comparing different custom types now works correctly when the appropriate comparison operators are registered. * Comparing different custom types now works correctly when the appropriate comparison operators are registered.
@ -32,6 +32,7 @@ Enhancements
* Loading a module via `import` now gives the module access to the current scope, including variables and constants defined inside. * Loading a module via `import` now gives the module access to the current scope, including variables and constants defined inside.
* Some very simple operator calls (e.g. integer add) are short-circuited to avoid the overhead of a function call, resulting in a small speed improvement. * Some very simple operator calls (e.g. integer add) are short-circuited to avoid the overhead of a function call, resulting in a small speed improvement.
* The tokenizer now uses table-driven keyword recognizers generated by GNU gperf. At least _theoretically_ it should be faster... * The tokenizer now uses table-driven keyword recognizers generated by GNU gperf. At least _theoretically_ it should be faster...
* The field `isAnonymous` is added to JSON functions metadata.
Version 1.12.0 Version 1.12.0

View File

@ -3,6 +3,7 @@
use crate::api::formatting::format_type; use crate::api::formatting::format_type;
use crate::module::{calc_native_fn_hash, FuncInfo, ModuleFlags}; use crate::module::{calc_native_fn_hash, FuncInfo, ModuleFlags};
use crate::parser::is_anonymous_fn;
use crate::{calc_fn_hash, Engine, FnAccess, SmartString, StaticVec, AST}; use crate::{calc_fn_hash, Engine, FnAccess, SmartString, StaticVec, AST};
use serde::Serialize; use serde::Serialize;
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
@ -34,6 +35,7 @@ struct FnMetadata<'a> {
pub namespace: crate::FnNamespace, pub namespace: crate::FnNamespace,
pub access: FnAccess, pub access: FnAccess,
pub name: &'a str, pub name: &'a str,
pub is_anonymous: bool,
#[serde(rename = "type")] #[serde(rename = "type")]
pub typ: FnType, pub typ: FnType,
pub num_params: usize, pub num_params: usize,
@ -83,6 +85,7 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
namespace: info.metadata.namespace, namespace: info.metadata.namespace,
access: info.metadata.access, access: info.metadata.access,
name: &info.metadata.name, name: &info.metadata.name,
is_anonymous: is_anonymous_fn(&info.metadata.name),
typ, typ,
num_params: info.metadata.num_params, num_params: info.metadata.num_params,
params: info params: info