Engine::gen_fn_signatures enumerates non-standard external packages.
This commit is contained in:
parent
86fc2f7bf1
commit
d58df1fb34
@ -15,6 +15,7 @@ Bug fixes
|
||||
* Missing `to_hex`, `to_octal` and `to_binary` for `i128` and `u128` are added.
|
||||
* `remove` for arrays and BLOB's now treat negative index correctly.
|
||||
* `parse_int` now works properly for negative numbers.
|
||||
* `Engine::gen_fn_signatures` now generates signatures for external packages registered via `Engine::register_global_module`.
|
||||
|
||||
Enhancements
|
||||
------------
|
||||
|
@ -1027,7 +1027,8 @@ impl Engine {
|
||||
/// Functions from the following sources are included, in order:
|
||||
/// 1) Functions registered into the global namespace
|
||||
/// 2) Functions in registered sub-modules
|
||||
/// 3) Functions in packages (optional)
|
||||
/// 3) Functions in registered packages
|
||||
/// 4) Functions in standard packages (optional)
|
||||
#[cfg(feature = "metadata")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
@ -1040,14 +1041,13 @@ impl Engine {
|
||||
signatures.extend(m.gen_fn_signatures().map(|f| format!("{}::{}", name, f)))
|
||||
});
|
||||
|
||||
if include_packages {
|
||||
signatures.extend(
|
||||
self.global_modules
|
||||
.iter()
|
||||
.skip(1)
|
||||
.filter(|m| !m.internal && (include_packages || !m.standard))
|
||||
.flat_map(|m| m.gen_fn_signatures()),
|
||||
);
|
||||
}
|
||||
|
||||
signatures
|
||||
}
|
||||
|
@ -182,11 +182,6 @@ impl FuncInfo {
|
||||
.collect();
|
||||
sig.push_str(¶ms.join(", "));
|
||||
sig.push(')');
|
||||
|
||||
if !return_type.is_empty() {
|
||||
sig.push_str(" -> ");
|
||||
sig.push_str(&return_type);
|
||||
}
|
||||
} else {
|
||||
for x in 0..self.metadata.params {
|
||||
sig.push('_');
|
||||
@ -194,18 +189,13 @@ impl FuncInfo {
|
||||
sig.push_str(", ");
|
||||
}
|
||||
}
|
||||
|
||||
sig.push(')');
|
||||
}
|
||||
|
||||
if !self.func.is_script() {
|
||||
sig.push(')');
|
||||
|
||||
if !return_type.is_empty() {
|
||||
if !self.func.is_script() && !return_type.is_empty() {
|
||||
sig.push_str(" -> ");
|
||||
sig.push_str(&return_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sig
|
||||
}
|
||||
@ -596,7 +586,7 @@ impl Module {
|
||||
#[cfg(feature = "metadata")]
|
||||
params_info,
|
||||
#[cfg(feature = "metadata")]
|
||||
return_type: "Dynamic".into(),
|
||||
return_type: "".into(),
|
||||
#[cfg(feature = "metadata")]
|
||||
comments: None,
|
||||
},
|
||||
|
@ -196,11 +196,12 @@ impl Engine {
|
||||
/// 1) Functions defined in an [`AST`][crate::AST]
|
||||
/// 2) Functions registered into the global namespace
|
||||
/// 3) Functions in static modules
|
||||
/// 4) Functions in global modules (optional)
|
||||
/// 4) Functions in registered global packages
|
||||
/// 5) Functions in standard packages (optional)
|
||||
pub fn gen_fn_metadata_with_ast_to_json(
|
||||
&self,
|
||||
ast: &AST,
|
||||
include_global: bool,
|
||||
include_packages: bool,
|
||||
) -> serde_json::Result<String> {
|
||||
let _ast = ast;
|
||||
let mut global = ModuleMetadata::new();
|
||||
@ -211,14 +212,20 @@ impl Engine {
|
||||
|
||||
self.global_modules
|
||||
.iter()
|
||||
.take(if include_global { usize::MAX } else { 1 })
|
||||
.filter(|m| include_packages || !m.standard)
|
||||
.flat_map(|m| m.iter_fn())
|
||||
.for_each(|f| global.functions.push(f.into()));
|
||||
.for_each(|f| {
|
||||
let mut meta: FnMetadata = f.into();
|
||||
meta.namespace = FnNamespace::Global;
|
||||
global.functions.push(meta);
|
||||
});
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
_ast.shared_lib()
|
||||
.iter_fn()
|
||||
.for_each(|f| global.functions.push(f.into()));
|
||||
_ast.shared_lib().iter_fn().for_each(|f| {
|
||||
let mut meta: FnMetadata = f.into();
|
||||
meta.namespace = FnNamespace::Global;
|
||||
global.functions.push(meta);
|
||||
});
|
||||
|
||||
global.functions.sort();
|
||||
|
||||
@ -233,7 +240,7 @@ impl Engine {
|
||||
/// 2) Functions in static modules
|
||||
/// 3) Functions in global modules (optional)
|
||||
#[inline(always)]
|
||||
pub fn gen_fn_metadata_to_json(&self, include_global: bool) -> serde_json::Result<String> {
|
||||
self.gen_fn_metadata_with_ast_to_json(&AST::empty(), include_global)
|
||||
pub fn gen_fn_metadata_to_json(&self, include_packages: bool) -> serde_json::Result<String> {
|
||||
self.gen_fn_metadata_with_ast_to_json(&AST::empty(), include_packages)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user