Stephen Chung
7686ca619a
Use .. for (_).
2022-02-08 09:46:14 +08:00
Stephen Chung
97a8fd3d5b
Improve reify syntax.
2022-02-08 09:25:53 +08:00
Stephen Chung
f8cee0fe4e
Simplify using ..
2022-02-08 09:02:15 +08:00
Stephen Chung
bd9519e96b
Remove reify_dynamic.
2022-02-07 12:02:00 +08:00
Stephen Chung
becbfa8930
Fix errors.
2022-02-06 23:02:59 +08:00
Nathan Kent
86d86a85e4
Remove unsound casting functions
...
The casting functions in `unsafe.rs` were unsound (i.e., they allowed
safe code to cause undefined behavior). While they did appear to be used
in a way that wouldn't cause UB the fact that there exists unsound
functions is unsettling.
This commit removes those functions and replaces it with a macro that
performs the same reification - the difference is that the macro call
will also include the checks which are required to prevent UB. A macro
was chosen instead of a function for two reasons:
1. A macro can keep the same code generation whereas a function would
require going through an `Option` which has negative impacts on code
generation (niche values cause poor DCE).
2. There exist other `unsafe` code blocks in the crate and an attempt to
make Rhai 100% safe is completely out-of-scope for this merge
request, so we may as well use `unsafe` in the macro.
Regarding (2) above, I may come back at a later date with a 100% safe
`reify` function but only once the other `unsafe` blocks are removed.
For posterity, said function would look something like:
```rust
fn reify<A: Any, C>(value: A) -> Option<C> {
let mut v = Some(value);
let v: &mut dyn Any = &mut v;
v.downcast_mut::<Option<C>>().map(Option::take)
}
```
2022-02-05 16:29:05 -08:00
Stephen Chung
3be27746e0
Add allow_shadowing.
2022-02-04 13:20:47 +08:00
Stephen Chung
345a060672
Fix type name display.
2022-02-03 23:54:53 +08:00
Stephen Chung
f1458e79e0
Improve AST debug display.
2022-01-31 13:38:27 +08:00
Stephen Chung
66af69aaff
Refactor and add state to debugger.
2022-01-28 18:59:18 +08:00
Stephen Chung
538af8caee
Scope::clone_visible clones value access mode also.
2022-01-27 16:58:11 +08:00
Stephen Chung
86fc2f7bf1
Refine types display.
2022-01-17 21:51:04 +08:00
Stephen Chung
00b189d0c6
Replace Cow<str> in Scope with SmartString.
2022-01-15 11:26:43 +08:00
Stephen Chung
ae77582028
Minor refactor.
2022-01-14 21:49:38 +08:00
Stephen Chung
37dbc68bf5
Use target_family for wasm.
2022-01-12 08:12:28 +08:00
Stephen Chung
77eb96bd7e
Fix errors.
2022-01-11 11:40:08 +08:00
Stephen Chung
6dedb1ed9f
Fix no_std builds.
2022-01-11 11:33:54 +08:00
Stephen Chung
bc6bf6c6ba
Change expect("exists") to unwrap().
2022-01-06 11:07:52 +08:00
Stephen Chung
b1b4361d08
Fix documentation.
2022-01-06 10:19:25 +08:00
magnus
7bf517b242
Fix documentation
2022-01-06 10:18:02 +08:00
Stephen Chung
123e8b1b48
Improve FnPtr debug display.
2022-01-05 13:48:25 +08:00
Stephen Chung
f35c9c1ac4
Refactor imports.
2022-01-05 12:52:56 +08:00
Stephen Chung
328f6910b6
Refactor wasm feature gates.
2022-01-04 22:16:20 +08:00
Stephen Chung
d99953c101
Fixup AsRef<str> vs &str.
2022-01-04 15:22:48 +08:00
Stephen Chung
d60f14ec27
Streamline hot code.
2022-01-03 23:11:06 +08:00
Stephen Chung
29f1328087
Simplify Dynamic::from for better inlining.
2022-01-02 20:47:03 +08:00
Stephen Chung
d60ed5a502
Reduce size of Variant trait.
2022-01-01 19:54:46 +08:00
Stephen Chung
8329baea29
Fix doc comments.
2021-12-31 23:01:34 +08:00
Stephen Chung
64bf2eef5c
Better error messages.
2021-12-30 12:19:41 +08:00
Stephen Chung
3488dbe74b
Fix merging strings interner.
2021-12-29 14:26:54 +08:00
Stephen Chung
e8b070cbf8
Fix builds.
2021-12-27 22:28:11 +08:00
Stephen Chung
4d226542fa
Split out strings interner.
2021-12-27 21:56:50 +08:00
Stephen Chung
05d4c81e7a
Use type alias for error.
2021-12-27 12:27:31 +08:00
Stephen Chung
e7ca3f41dd
Fix formatting.
2021-12-27 11:43:11 +08:00
Stephen Chung
01c35808cb
Use type alias
2021-12-25 23:49:14 +08:00
Stephen Chung
b4756b4575
Move CallableFunction to own file.
2021-12-20 22:13:00 +08:00
Stephen Chung
e507dcfcb4
Fix no_index build.
2021-12-18 18:44:08 +08:00
Stephen Chung
82d3375fc0
Fix Dynamic::from for BLOB.
2021-12-18 15:36:30 +08:00
Stephen Chung
1c1247ac9a
Tidy up code.
2021-12-18 12:28:56 +08:00
Stephen Chung
fbc2b1f13d
Allow non-custom reserved symbols in custom syntax.
2021-12-16 18:01:49 +08:00
Stephen Chung
f92cbe1f6d
Merge branch 'v1.3-fixes'
2021-12-16 16:10:39 +08:00
Stephen Chung
2adb4ba4a8
Simplify deref_mut to &mut *.
2021-12-15 23:21:05 +08:00
Stephen Chung
ef14079c61
Add ranges.
2021-12-15 12:06:17 +08:00
Stephen Chung
93e3c4c10a
Compact BLOB display.
2021-12-13 09:40:43 +08:00
Stephen Chung
d9d44a9683
Add Engine::register_type_with_name_raw.
2021-12-09 12:49:12 +08:00
Stephen Chung
2a7a648429
Reduce feature gates.
2021-12-06 20:52:47 +08:00
Stephen Chung
b8c4054c20
Add strict variables mode.
2021-12-04 17:57:28 +08:00
Stephen Chung
9a5bd9396a
Fix builds.
2021-12-02 17:46:39 +08:00
Stephen Chung
41dd989866
Support deserialization into byte arrays for BLOB's via serde_bytes.
2021-12-02 14:10:53 +08:00
Stephen Chung
4b4b7a753b
Add low-level warnings.
2021-11-29 13:12:47 +08:00