Extend jerry_create_realm API docs a bit (#4549)
Add additional information for jerry_create_realm method and rework the example to be a compilable/runnable doctest. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
@@ -6131,6 +6131,14 @@ jerry_create_undefined (void);
|
||||
|
||||
Creates a `jerry_value_t` representing a new global object.
|
||||
|
||||
*Notes*:
|
||||
- Returned value must be freed with [jerry_release_value](#jerry_release_value)
|
||||
when it is no longer needed.
|
||||
- This API depends on a 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).
|
||||
- The es.next profile enables this by default.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
@@ -6144,13 +6152,24 @@ jerry_create_realm (void);
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
jerry_value_t realm_value = jerry_create_realm ();
|
||||
|
||||
... // usage of the value
|
||||
// usage of the value
|
||||
|
||||
jerry_release_value (realm_value);
|
||||
jerry_cleanup ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user