• Home
  • Raw
  • Download

Lines Matching +full:before +full:- +full:script

1 …iding the way to run JavaScript in a large range of environments - from desktops to low-memory mic…
7 ## Before trying out the examples: Get and build JerryScript library
9 Before getting started using the JerryScript library it should be cloned and built for a target os/…
18 $ git clone https://github.com/jerryscript-project/jerryscript.git
19 $ jerryscript/tools/build.py --builddir=$(pwd)/example_build --cmake-param="-DCMAKE_INSTALL_PREFIX=…
20 $ make -C $(pwd)/example_build install
25 In this guide we will use `pkg-config` to ease the usage of headers and libraries.
32 Test if the `pkg-config` works for JerryScript:
35 $ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-libm
40 The most basic example to test the engine is to create an `api-example-1.c` file containing the fol…
50 const jerry_char_t script[] = "var str = 'Hello, World!';";
52 bool ret_value = jerry_run_simple (script, sizeof (script) - 1, JERRY_INIT_EMPTY);
61 $ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-def…
67 $ ./api-example-1
71 ## Example 2. Split engine initialization and script execution.
81 Use the following code for the `api-example-2.c` file:
91 const jerry_char_t script[] = "var str = 'Hello, World!';";
92 const jerry_length_t script_size = sizeof (script) - 1;
100 /* Run the demo script with 'eval' */
101 jerry_value_t eval_ret = jerry_eval (script,
121 $ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-def…
127 $ ./api-example-2
131 ## Example 3. Split JavaScript parsing and script execution
135 - script code setup - `jerry_parse`.
136 - script execution - `jerry_run`.
138 The `api-example-3.c` file should contain the following code:
150 const jerry_char_t script[] = "var str = 'Hello, World!';";
156 …jerry_value_t parsed_code = jerry_parse (NULL, 0, script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS…
184 $ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-def…
190 $ ./api-example-3
203 - `jerry_get_global_object`
204 - `jerry_create_string`
205 - `jerry_set_property`
206 - `jerry_create_external_function`
208 The `api-example-4.c` file should contain the following code:
233 const jerry_char_t script[] = "print ();";
234 const jerry_length_t script_size = sizeof (script) - 1;
255 /* Release all jerry_value_t-s */
263 jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
288 $ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-def…
294 $ ./api-example-4
307 - `jerry_value_to_string`
308 - `jerry_string_to_utf8_char_buffer`
310 The `api-example-5.c` file should contain the following code:
337 …size_t copied_bytes = jerry_string_to_utf8_char_buffer (string_value, buffer, sizeof (buffer) - 1);
353 const jerry_char_t script[] = "print ('Hello from JS!');";
354 const jerry_length_t script_size = sizeof (script) - 1;
375 /* Release all jerry_value_t-s */
383 jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
408 $ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-def…
414 $ ./api-example-5
426 - `jerryx_handler_register_global`
427 - `jerryx_handler_print`
433 #include "jerryscript-ext/handler.h"
438 const jerry_char_t script[] = "print ('Hello from JS with ext!');";
439 const jerry_length_t script_size = sizeof (script) - 1;
449 jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
473 (**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `p…
476 $ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libj…
482 $ ./api-example-6
485 ## Example 7. Interaction with JavaScript environment - adding a string property
490 Use the following code as the `api-example-7.c` file:
496 #include "jerryscript-ext/handler.h"
501 const jerry_char_t script[] = "print (my_var);";
532 /* Now starting script that would output value of just initialized field */
533 jerry_value_t eval_ret = jerry_eval (script,
534 sizeof (script) - 1,
549 (**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `p…
552 $ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libj…
555 The sample will output 'Hello from C!'. However, now it is not just a part of the source script, bu…
558 $ ./api-example-7
571 - The error object is a object which was constructed via one of the `Error` objects (available from…
578 - The error value is not an object on its own. This is the exception raised/thrown either via API m…
670 - read command;
671 - if command is 'quit'
672 - exit loop;
673 - else
674 - eval (command);
675 - print result of eval;
676 - loop.
678 See the following `api-example-8-shell.c` file:
687 #include "jerryscript-ext/handler.h"
795 if (!strncmp (cmd, "quit\n", sizeof ("quit\n") - 1))
822 (**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `p…
825 $ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libje…
831 $ ./api-example-8-shell
837 In this example (`api-example-9.c`) an object with a native function is added to the global object.
843 #include "jerryscript-ext/handler.h"
902 const jerry_char_t script[] = " \
907 /* Evaluate script */
908 jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
922 (**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `p…
925 $ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libj…
931 $ ./api-example-9
946 Use the following code for `api-example-10.c`:
952 #include "jerryscript-ext/handler.h"
1014 /* Evaluate script */
1016 sizeof (my_js_object) - 1,
1031 const jerry_char_t script[] = " \
1038 /* Evaluate script */
1039 jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
1053 (**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `p…
1056 $ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext li…
1062 $ ./api-example-10
1080 #include "jerryscript-port.h"
1081 #include "jerryscript-ext/handler.h"
1091 const jerry_char_t script[] = "var a = Math.random (); print(a)";
1100 /* Evaluate the script */
1101 jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
1115 …nce page](https://jerryscript-project.github.io/jerryscript/api-reference/) on [JerryScript home p…