Skip to content

Commit

Permalink
Fix builds
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Dec 31, 2024
1 parent 94fbe24 commit 2b0ed8c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
36 changes: 29 additions & 7 deletions src/api/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ impl Engine {
signatures
}

/// Collect the [`FuncInfo`][crate::FuncInfo] of all functions, native or script-defined,
/// Collect the [`FuncInfo`][crate::module::FuncInfo] of all functions, native or script-defined,
/// mapping them into any type.
/// Exported under the `internals` feature only.
///
Expand All @@ -767,10 +767,32 @@ impl Engine {
/// 5) Functions defined in modules `import`-ed by the current script (if any)
/// 6) Functions in registered sub-modules
#[cfg(feature = "internals")]
#[inline(always)]
pub fn collect_fn_metadata<T>(
&self,
ctx: Option<&NativeCallContext>,
mapper: impl Fn(crate::FuncInfo) -> Option<T> + Copy,
mapper: impl Fn(crate::module::FuncInfo) -> Option<T> + Copy,
include_standard_packages: bool,
) -> Vec<T> {
self.collect_fn_metadata_impl(ctx, mapper, include_standard_packages)
}

/// Collect the [`FuncInfo`][crate::module::FuncInfo] of all functions, native or script-defined,
/// mapping them into any type.
///
/// Return [`None`] from the `mapper` to skip a function.
///
/// Functions from the following sources are included, in order:
/// 1) Functions defined in the current script (if any)
/// 2) Functions registered into the global namespace
/// 3) Functions in registered packages
/// 4) Functions in standard packages (optional)
/// 5) Functions defined in modules `import`-ed by the current script (if any)
/// 6) Functions in registered sub-modules
pub(crate) fn collect_fn_metadata_impl<T>(
&self,
ctx: Option<&NativeCallContext>,
mapper: impl Fn(crate::module::FuncInfo) -> Option<T> + Copy,
include_standard_packages: bool,
) -> Vec<T> {
let mut list = Vec::new();
Expand All @@ -779,7 +801,7 @@ impl Engine {
ctx.iter_namespaces()

Check failure on line 801 in src/api/register.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_function,serde,metadata,internals,debugging, ...

no method named `iter_namespaces` found for reference `&native::NativeCallContext<'_>` in the current scope

Check failure on line 801 in src/api/register.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,no_time,no_function,no_float,no_position,no...

no method named `iter_namespaces` found for reference `&native::NativeCallContext<'_>` in the current scope

Check failure on line 801 in src/api/register.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_time,no_function,no_float,no_position,no_inde...

no method named `iter_namespaces` found for reference `&native::NativeCallContext<'_>` in the current scope
.flat_map(Module::iter_fn)
.filter_map(|(func, f)| {
mapper(crate::FuncInfo {
mapper(crate::module::FuncInfo {
metadata: f,
#[cfg(not(feature = "no_module"))]
namespace: Identifier::new_const(),
Expand All @@ -795,7 +817,7 @@ impl Engine {
.filter(|m| !m.is_internal() && (include_standard_packages || !m.is_standard_lib()))
.flat_map(|m| m.iter_fn())
.filter_map(|(func, f)| {
mapper(crate::FuncInfo {
mapper(crate::module::FuncInfo {
metadata: f,
#[cfg(not(feature = "no_module"))]
namespace: Identifier::new_const(),
Expand All @@ -815,12 +837,12 @@ impl Engine {
list: &mut Vec<T>,
namespace: &str,
module: &Module,
mapper: impl Fn(crate::FuncInfo) -> Option<T> + Copy,
mapper: impl Fn(crate::module::FuncInfo) -> Option<T> + Copy,
) {
module
.iter_fn()
.filter_map(|(func, f)| {

Check warning on line 844 in src/api/register.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_function,serde,metadata,internals,debugging, ...

unused variable: `func`
mapper(crate::FuncInfo {
mapper(crate::module::FuncInfo {
metadata: f,
namespace: namespace.into(),
#[cfg(not(feature = "no_function"))]
Expand Down Expand Up @@ -848,7 +870,7 @@ impl Engine {
.values()
.flat_map(|m| m.iter_fn())
.filter_map(|(func, f)| {
mapper(crate::FuncInfo {
mapper(crate::module::FuncInfo {
metadata: f,
#[cfg(not(feature = "no_module"))]
namespace: Identifier::new_const(),
Expand Down
1 change: 0 additions & 1 deletion src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl FuncMetadata {
/// Information about a function, native or scripted.
///
/// Exported under the `internals` feature only.
#[cfg(feature = "internals")]
pub struct FuncInfo<'a> {
/// Function metadata.
pub metadata: &'a FuncMetadata,
Expand Down
5 changes: 3 additions & 2 deletions src/packages/lang_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ mod core_functions {
#[cfg(not(feature = "no_object"))]
#[export_module]
mod reflection_functions {
use crate::{Array, FuncInfo, Map, ScriptFnMetadata};
use crate::module::FuncInfo;
use crate::{Array, Map, ScriptFnMetadata};

#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_index"))]
Expand All @@ -204,7 +205,7 @@ mod reflection_functions {
) -> Array {
let engine = ctx.engine();

engine.collect_fn_metadata(
engine.collect_fn_metadata_impl(
Some(&ctx),
|FuncInfo {
metadata,
Expand Down

0 comments on commit 2b0ed8c

Please sign in to comment.