Implement get proxy target (#4367)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-12-18 10:58:48 +01:00
committed by GitHub
parent 1937f820e1
commit 9676500add
4 changed files with 115 additions and 0 deletions
+56
View File
@@ -4494,6 +4494,62 @@ main (void)
- [jerry_get_bigint_size_in_digits](#jerry_get_bigint_size_in_digits)
# Functions for Proxy objects
These APIs all depend on build option (`JERRY_BUILTIN_PROXY`).
## jerry_get_proxy_target
**Summary**
Gets the target object of a Proxy object
*Notes*:
- This API depends on a build option (`JERRY_BUILTIN_PROXY`) and can be checked
in runtime with the `JERRY_FEATURE_PROXY` feature enum value,
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
- The es.next profile enables this by default.
**Prototype**
```c
jerry_value_t
jerry_get_proxy_target (jerry_value_t proxy_value)
```
- `proxy_value` - Proxy object value
- return value
- type error - if proxy_value is not a Proxy object
- target object - otherwise
*New in version [[NEXT_RELEASE]]*.
**Example**
```c
{
jerry_value_t target = jerry_create_object ();
jerry_value_t handler = jerry_create_object ();
jerry_value_t proxy = jerry_create_proxy (target, handler);
jerry_release_value (target);
jerry_release_value (handler);
target = jerry_get_proxy_target (proxy);
// ... usage of the target
jerry_release_value (target);
jerry_release_value (proxy);
}
```
**See also**
- [jerry_create_proxy](#jerry_create_proxy)
# Acquire and release API values
## jerry_acquire_value