From c7a675e18a271259b5fd43e980cc1fec2abec720 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 20 Sep 2020 14:52:38 +0800 Subject: [PATCH] Fix no_object builds. --- RELEASES.md | 4 ++-- doc/src/rust/indexers.md | 2 +- src/api.rs | 17 +++++++++-------- src/module.rs | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 9d8476fb..ccba5394 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -74,7 +74,7 @@ New features * Currying of function pointers is supported via the new `curry` keyword. * Automatic currying of anonymous functions to capture shared variables from the external scope. * Capturing of the calling scope for function call via the `func!(...)` syntax. -* `Module::set_indexer_get_set_fn` is added as a shorthand of both `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn`. +* `Module::set_indexer_get_set_fn` is added as a short-hand of both `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn`. * New `unicode-xid-ident` feature to allow [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) for identifiers. * `Scope::iter_raw` returns an iterator with a reference to the underlying `Dynamic` value (which may be shared). @@ -200,7 +200,7 @@ Breaking changes New features ------------ -* Indexers are now split into getters and setters (which now support updates). The API is split into `Engine::register_indexer_get` and `Engine::register_indexer_set` with `Engine::register_indexer_get_set` being a shorthand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added. +* Indexers are now split into getters and setters (which now support updates). The API is split into `Engine::register_indexer_get` and `Engine::register_indexer_set` with `Engine::register_indexer_get_set` being a short-hand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added. * `Engine:register_fn` and `Engine:register_result_fn` accepts functions that take parameters of type `&str` (immutable string slice), which maps directly to `ImmutableString`. This is to avoid needing wrappers for functions taking string parameters. * Set maximum limit on data sizes: `Engine::set_max_string_size`, `Engine::set_max_array_size` and `Engine::set_max_map_size`. * Supports trailing commas on array literals, object map literals, function definitions and function calls. diff --git a/doc/src/rust/indexers.md b/doc/src/rust/indexers.md index 69f73965..107ed5c9 100644 --- a/doc/src/rust/indexers.md +++ b/doc/src/rust/indexers.md @@ -52,7 +52,7 @@ let mut engine = Engine::new(); engine .register_type::() .register_fn("new_ts", TestStruct::new) - // Shorthand: .register_indexer_get_set(TestStruct::get_field, TestStruct::set_field); + // Short-hand: .register_indexer_get_set(TestStruct::get_field, TestStruct::set_field); .register_indexer_get(TestStruct::get_field) .register_indexer_set(TestStruct::set_field); diff --git a/src/api.rs b/src/api.rs index 85e0aab3..16733f25 100644 --- a/src/api.rs +++ b/src/api.rs @@ -12,17 +12,18 @@ use crate::scope::Scope; use crate::token::{lex, Position}; #[cfg(not(feature = "no_index"))] -#[cfg(not(feature = "no_object"))] use crate::engine::{FN_IDX_GET, FN_IDX_SET}; #[cfg(not(feature = "no_object"))] use crate::{ engine::{make_getter, make_setter, Map}, error::ParseErrorType, - fn_register::{RegisterFn, RegisterResultFn}, token::Token, }; +#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] +use crate::fn_register::{RegisterFn, RegisterResultFn}; + #[cfg(not(feature = "no_function"))] use crate::{ engine::get_script_function_by_signature, fn_args::FuncArgs, fn_call::ensure_no_data_race, @@ -375,7 +376,7 @@ impl Engine { self.register_result_fn(&make_setter(name), callback) } - /// Shorthand for registering both getter and setter functions + /// Short-hand for registering both getter and setter functions /// of a registered type with the `Engine`. /// /// All function signatures must start with `&mut self` and not `&self`. @@ -427,7 +428,7 @@ impl Engine { self.register_get(name, get_fn).register_set(name, set_fn) } - /// Register an index getter for a registered type with the `Engine`. + /// Register an index getter for a custom type with the `Engine`. /// /// The function signature must start with `&mut self` and not `&self`. /// @@ -476,7 +477,7 @@ impl Engine { self.register_fn(FN_IDX_GET, callback) } - /// Register an index getter for a registered type with the `Engine`. + /// Register an index getter for a custom type with the `Engine`. /// Returns `Result>`. /// /// The function signature must start with `&mut self` and not `&self`. @@ -527,7 +528,7 @@ impl Engine { self.register_result_fn(FN_IDX_GET, callback) } - /// Register an index setter for a registered type with the `Engine`. + /// Register an index setter for a custom type with the `Engine`. /// /// # Example /// @@ -575,7 +576,7 @@ impl Engine { self.register_fn(FN_IDX_SET, callback) } - /// Register an index setter for a registered type with the `Engine`. + /// Register an index setter for a custom type with the `Engine`. /// Returns `Result>`. /// /// # Example @@ -627,7 +628,7 @@ impl Engine { self.register_result_fn(FN_IDX_SET, callback) } - /// Shorthand for register both index getter and setter functions for a registered type with the `Engine`. + /// Short-hand for register both index getter and setter functions for a custom type with the `Engine`. /// /// # Example /// diff --git a/src/module.rs b/src/module.rs index 51d5539c..51bfc3bf 100644 --- a/src/module.rs +++ b/src/module.rs @@ -808,7 +808,7 @@ impl Module { } /// Set a pair of Rust index getter and setter functions, returning both hash keys. - /// This is a shorthand for `set_indexer_get_fn` and `set_indexer_set_fn`. + /// This is a short-hand for `set_indexer_get_fn` and `set_indexer_set_fn`. /// /// If there are similar existing Rust functions, they are replaced. ///