Fix no_object builds.
This commit is contained in:
parent
1ae6af5289
commit
c7a675e18a
@ -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.
|
||||
|
@ -52,7 +52,7 @@ let mut engine = Engine::new();
|
||||
engine
|
||||
.register_type::<TestStruct>()
|
||||
.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);
|
||||
|
||||
|
17
src/api.rs
17
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<Dynamic, Box<EvalAltResult>>`.
|
||||
///
|
||||
/// 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<Dynamic, Box<EvalAltResult>>`.
|
||||
///
|
||||
/// # 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
|
||||
///
|
||||
|
@ -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.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user