Getters/setters and indexers in a plugin module are default global.

This commit is contained in:
Stephen Chung
2020-11-30 00:52:21 +08:00
parent 2e33f35f48
commit 65a4ceb3be
6 changed files with 88 additions and 43 deletions

View File

@@ -166,6 +166,9 @@ as well as all _type iterators_, are automatically exposed to the _global_ names
[iteration]({{rootUrl}}/language/for.md), [getters/setters] and [indexers] for [custom types]
can work as expected.
In fact, the default for all [getters/setters] and [indexers] defined in a plugin module
is `#[rhai_fn(global)]` unless specifically overridden by `#[rhai_fn(internal)]`.
Therefore, in the example above, the `increment` method (defined with `#[rhai_fn(global)]`)
works fine when called in method-call style: