From 62dc782e5c01d87a72064c1e806cb64255aa6ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=A1l?= Date: Fri, 29 Jan 2021 13:15:37 +0100 Subject: [PATCH] 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 --- docs/02.API-REFERENCE.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md index 551592720..6e0ab6780 100644 --- a/docs/02.API-REFERENCE.md +++ b/docs/02.API-REFERENCE.md @@ -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; } ```