Allow changing the 'this' binding of a realm (#4357)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -9171,6 +9171,54 @@ jerry_set_realm (jerry_value_t realm_value);
|
||||
|
||||
- [jerry_create_realm](#jerry_create_realm)
|
||||
|
||||
## jerry_realm_set_this
|
||||
|
||||
**Summary**
|
||||
|
||||
Sets the 'this' binding of a realm. This function must be called before executing
|
||||
any script on the realm. Otherwise the operation is undefined.
|
||||
|
||||
*Notes*:
|
||||
- This feature depends on build option (`JERRY_BUILTIN_REALMS`) and can be checked
|
||||
in runtime with the `JERRY_FEATURE_REALM` feature enum value,
|
||||
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerry_realm_set_this (jerry_value_t realm_value, jerry_value_t this_value)
|
||||
```
|
||||
- `realm_value` - realm value
|
||||
- `this_value` - new this value
|
||||
- return
|
||||
- exception - if any error is happened
|
||||
- true - otherwise
|
||||
|
||||
*New in version [[NEXT_RELEASE]]*.
|
||||
|
||||
**Example**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t realm_value = jerry_create_realm ();
|
||||
|
||||
jerry_value_t old_realm = jerry_set_realm (realm_value);
|
||||
/* The prototype of the object comes from the new realm. */
|
||||
jerry_value_t this_value = jerry_create_object ();
|
||||
jerry_set_realm (old_realm);
|
||||
|
||||
jerry_value_t result = jerry_realm_set_this (realm_value, this_value);
|
||||
|
||||
... // usage of the realm
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_create_realm](#jerry_create_realm)
|
||||
- [jerry_set_realm](#jerry_set_realm)
|
||||
|
||||
# ArrayBuffer and TypedArray functions
|
||||
|
||||
These APIs all depend on the es.next profile.
|
||||
|
||||
Reference in New Issue
Block a user