From a650a43df24eba33217f5e59f3b7a010324aa4bf Mon Sep 17 00:00:00 2001
From: Anthony <anthony.durot@inria.fr>
Date: Mon, 4 Jun 2018 16:22:23 +0200
Subject: [PATCH] pkg/jerryscript: update Javascript example up to date

---
 examples/javascript/main.c | 32 ++++++++++++++++++--------------
 pkg/jerryscript/Makefile   |  2 +-
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/examples/javascript/main.c b/examples/javascript/main.c
index 18d7523c9f..a71d8eb44c 100644
--- a/examples/javascript/main.c
+++ b/examples/javascript/main.c
@@ -31,30 +31,34 @@
 
 int js_run(const jerry_char_t *script, size_t script_size)
 {
-    jerry_value_t ret_value;
 
-    /* Initialize engine */
+    jerry_value_t parsed_code, ret_value;
+    int res = 0;
+
+    /* Initialize engine, no flags, default configuration */
+
     jerry_init(JERRY_INIT_EMPTY);
 
     /* Register the print function in the global object. */
-    jerryx_handler_register_global((const jerry_char_t *) "print", jerryx_handler_print);
 
-    /* Setup Global scope code */
-    ret_value = jerry_parse(script, script_size, false);
+    jerryx_handler_register_global((const jerry_char_t *) "print",
+                                   jerryx_handler_print);
 
-    if (!jerry_value_has_error_flag(ret_value)) {
-        /* Execute the parsed source code in the Global scope */
-        ret_value = jerry_run(ret_value);
-    }
+    /* Setup Global scope code */
 
-    int res = 0;
+    parsed_code = jerry_parse(NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
 
-    if (jerry_value_has_error_flag(ret_value)) {
-        printf("js_run(): Script Error!");
-        res = -1;
+    if (!jerry_value_is_error(parsed_code)) {
+        /* Execute the parsed source code in the Global scope */
+        ret_value = jerry_run(parsed_code);
+        if (jerry_value_is_error(ret_value)) {
+            printf("js_run(): Script Error!");
+            res = -1;
+        }
+        jerry_release_value(ret_value);
     }
 
-    jerry_release_value(ret_value);
+    jerry_release_value(parsed_code);
 
     /* Cleanup engine */
     jerry_cleanup();
diff --git a/pkg/jerryscript/Makefile b/pkg/jerryscript/Makefile
index b9c4095215..eafcaba81e 100644
--- a/pkg/jerryscript/Makefile
+++ b/pkg/jerryscript/Makefile
@@ -1,6 +1,6 @@
 PKG_NAME=jerryscript
 PKG_URL=https://github.com/jerryscript-project/jerryscript.git
-PKG_VERSION=bd574956e3702bc5b0512ad835b1df896cf00626
+PKG_VERSION=e1af56586cf9beeafbc67172b05cad28eca289cb
 PKG_LICENSE=Apache-2.0
 
 .PHONY: all
-- 
GitLab