Update the webpage (#2334)

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2018-05-17 07:40:49 +02:00
committed by yichoi
parent dc12458382
commit f97f82f7be
9 changed files with 152 additions and 108 deletions
+2
View File
@@ -61,6 +61,8 @@ python tools/build.py --cmake-param=CMAKE_PARAM
python tools/build.py --profile=es5.1|es2015-subset|minimal python tools/build.py --profile=es5.1|es2015-subset|minimal
``` ```
See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
**Use (jerry, compiler-default, external) libc** **Use (jerry, compiler-default, external) libc**
The default libc is jerry-libc, but you can use compiler-default libc or an external libc: The default libc is jerry-libc, but you can use compiler-default libc or an external libc:
+86 -89
View File
@@ -957,7 +957,7 @@ main (void)
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (parsed_code)) if (!jerry_value_is_error (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
@@ -1099,6 +1099,45 @@ jerry_get_global_object (void);
Functions to check the type of an API value ([jerry_value_t](#jerry_value_t)). Functions to check the type of an API value ([jerry_value_t](#jerry_value_t)).
## jerry_value_is_abort
**Summary**
Returns whether the given `jerry_value_t` has the error and abort value set.
**Prototype**
```c
bool
jerry_value_is_abort (const jerry_value_t value);
```
- `value` - api value
- return value
- true, if the given `jerry_value_t` has the error and abort value set
- false, otherwise
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
if (jerry_value_is_abort (value))
{
...
}
jerry_release_value (value);
}
```
**See also**
- [jerry_value_t](#jerry_value_t)
- [jerry_value_is_error](#jerry_value_is_error)
## jerry_value_is_array ## jerry_value_is_array
**Summary** **Summary**
@@ -1254,6 +1293,44 @@ jerry_value_is_constructor (const jerry_value_t value)
- [jerry_release_value](#jerry_release_value) - [jerry_release_value](#jerry_release_value)
## jerry_value_is_error
**Summary**
Returns whether the given `jerry_value_t` is error value.
**Prototype**
```c
bool
jerry_value_is_error (const jerry_value_t value);
```
- `value` - api value
- return value
- true, if the given `jerry_value_t` is error value.
- false, otherwise
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
if (jerry_value_is_error (value))
{
...
}
jerry_release_value (value);
}
```
**See also**
- [jerry_value_t](#jerry_value_t)
- [jerry_value_is_abort](#jerry_value_is_abort)
## jerry_value_is_function ## jerry_value_is_function
@@ -1651,7 +1728,7 @@ If a non-error object is used as the input for the function the method
will return `JERRY_ERROR_NONE` indicating that the value was not will return `JERRY_ERROR_NONE` indicating that the value was not
an Error object. However it is still possible that the value contains an Error object. However it is still possible that the value contains
error semantics. To correctly detect if a value have error use the error semantics. To correctly detect if a value have error use the
[jerry_value_has_error_flag](#jerry_value_has_error_flag) method. [jerry_value_is_error](#jerry_value_is_error) method.
**Prototype** **Prototype**
@@ -1682,87 +1759,7 @@ jerry_get_error_type (const jerry_value_t value);
**See also** **See also**
- [jerry_create_error](#jerry_create_error) - [jerry_create_error](#jerry_create_error)
- [jerry_value_has_error_flag](#jerry_value_has_error_flag) - [jerry_value_is_error](#jerry_value_is_error)
## jerry_value_has_error_flag
**Summary**
Returns whether the given `jerry_value_t` has the error flag set.
**Prototype**
```c
bool
jerry_value_has_error_flag (const jerry_value_t value);
```
- `value` - api value
- return value
- true, if the given `jerry_value_t` has the error flag set
- false, otherwise
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
if (jerry_value_has_error_flag (value))
{
...
}
jerry_release_value (value);
}
```
**See also**
- [jerry_value_t](#jerry_value_t)
- [jerry_value_has_abort_flag](#jerry_value_has_abort_flag)
## jerry_value_has_abort_flag
**Summary**
Returns whether the given `jerry_value_t` has the error and abort flags set.
**Prototype**
```c
bool
jerry_value_has_abort_flag (const jerry_value_t value);
```
- `value` - api value
- return value
- true, if the given `jerry_value_t` has the error and abort flags set
- false, otherwise
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
if (jerry_value_has_abort_flag (value))
{
...
}
jerry_release_value (value);
}
```
**See also**
- [jerry_value_t](#jerry_value_t)
- [jerry_value_has_error_flag](#jerry_value_has_error_flag)
## jerry_value_clear_error_flag ## jerry_value_clear_error_flag
@@ -2657,7 +2654,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise,
argument, argument,
is_resolve); is_resolve);
if (jerry_value_has_error_flag (is_ok)) if (jerry_value_is_error (is_ok))
{ {
// handle the error. // handle the error.
} }
@@ -2671,7 +2668,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise,
**See also** **See also**
- [jerry_release_value](#jerry_release_value) - [jerry_release_value](#jerry_release_value)
- [jerry_value_has_error_flag](#jerry_value_has_error_flag) - [jerry_value_is_error](#jerry_value_is_error)
# Acquire and release API values # Acquire and release API values
@@ -2945,7 +2942,7 @@ jerry_create_error (jerry_error_t error_type,
**See also** **See also**
- [jerry_value_has_error_flag](#jerry_value_has_error_flag) - [jerry_value_is_error](#jerry_value_is_error)
- [jerry_value_clear_error_flag](#jerry_value_clear_error_flag) - [jerry_value_clear_error_flag](#jerry_value_clear_error_flag)
- [jerry_value_set_error_flag](#jerry_value_set_error_flag) - [jerry_value_set_error_flag](#jerry_value_set_error_flag)
@@ -4184,7 +4181,7 @@ jerry_call_function (const jerry_value_t func_obj_val,
jerry_value_t this_val = jerry_create_undefined (); jerry_value_t this_val = jerry_create_undefined ();
jerry_value_t ret_val = jerry_call_function (val, this_val, NULL, 0); jerry_value_t ret_val = jerry_call_function (val, this_val, NULL, 0);
if (!jerry_value_has_error_flag (ret_val)) if (!jerry_value_is_error (ret_val))
{ {
... // handle return value ... // handle return value
} }
@@ -4239,7 +4236,7 @@ jerry_construct_object (const jerry_value_t func_obj_val,
{ {
jerry_value_t ret_val = jerry_construct_object (val, NULL, 0); jerry_value_t ret_val = jerry_construct_object (val, NULL, 0);
if (!jerry_value_has_error_flag (ret_val)) if (!jerry_value_is_error (ret_val))
{ {
... // handle return value ... // handle return value
} }
@@ -4710,7 +4707,7 @@ find_my_object(const jerry_value_t candidate,
{ {
find_my_object_info_t *info_p = (find_my_object_info_t *) user_data_p; find_my_object_info_t *info_p = (find_my_object_info_t *) user_data_p;
jerry_value_t has_property = jerry_object_has_property (candidate, info_p->property_name); jerry_value_t has_property = jerry_object_has_property (candidate, info_p->property_name);
bool keep_searching = (jerry_value_has_error_flag (has_property) || !jerry_get_boolean_value ()); bool keep_searching = (jerry_value_is_error (has_property) || !jerry_get_boolean_value ());
if (!keep_searching) if (!keep_searching)
{ {
/* We found it, so we acquire the value and record it. */ /* We found it, so we acquire the value and record it. */
+3 -3
View File
@@ -67,7 +67,7 @@ main (void)
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (parsed_code)) if (!jerry_value_is_error (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
@@ -335,7 +335,7 @@ main (void)
false); false);
/* If command evaluated successfully, print value, returned by eval */ /* If command evaluated successfully, print value, returned by eval */
if (jerry_value_has_error_flag (ret_val)) if (jerry_value_is_error (ret_val))
{ {
/* Evaluated JS code thrown an exception /* Evaluated JS code thrown an exception
* and didn't handle it with try-catch-finally */ * and didn't handle it with try-catch-finally */
@@ -472,7 +472,7 @@ add_handler (const jerry_value_t func_value, /**< function object */
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "x"); jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "x");
jerry_value_t x_val = jerry_get_property (this_val, prop_name); jerry_value_t x_val = jerry_get_property (this_val, prop_name);
if (!jerry_value_has_error_flag (x_val)) if (!jerry_value_is_error (x_val))
{ {
/* Convert Jerry API values to double */ /* Convert Jerry API values to double */
double x = jerry_get_number_value (x_val); double x = jerry_get_number_value (x_val);
+28 -8
View File
@@ -21,7 +21,8 @@ It is questionable whether a library should be able to terminate an application.
* *
* @param code gives the cause of the error. * @param code gives the cause of the error.
* *
* Note: jerry expects the function not to return. * Note:
* Jerry expects the function not to return.
* *
* Example: a libc-based port may implement this with exit() or abort(), or both. * Example: a libc-based port may implement this with exit() or abort(), or both.
*/ */
@@ -91,14 +92,26 @@ typedef struct
/** /**
* Get timezone and daylight saving data * Get timezone and daylight saving data
* *
* Note:
* This port function is called by jerry-core when
* CONFIG_DISABLE_DATE_BUILTIN is _not_ defined. Otherwise this function is
* not used.
*
* @param[out] tz_p time zone structure to fill.
* @return true - if success * @return true - if success
* false - otherwise * false - otherwise
*/ */
bool jerry_port_get_time_zone (jerry_time_zone_t *); bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
/** /**
* Get system time * Get system time
* *
* Note:
* This port function is called by jerry-core when
* CONFIG_DISABLE_DATE_BUILTIN is _not_ defined. It is also common practice
* in application code to use this function for the initialization of the
* random number generator.
*
* @return milliseconds since Unix epoch * @return milliseconds since Unix epoch
*/ */
double jerry_port_get_current_time (void); double jerry_port_get_current_time (void);
@@ -110,12 +123,13 @@ Allow user to provide external buffer for jerry instance (which includes an isol
```c ```c
/** /**
* Get the current instance, which contains the current context, heap and other infomation. * Get the current instance which contains the current context, heap and other
* Each port should provide its own implementation of this interface. * structures. Each port should provide its own implementation of this interface.
* *
*Note: * Note:
* This port function will be called automatically by jerry-core * This port function is called by jerry-core when
* when JERRY_ENABLE_EXTERNAL_CONTEXT is defined. If not, this function will never be called. * JERRY_ENABLE_EXTERNAL_CONTEXT is defined. Otherwise this function is not
* used.
* *
* @return the pointer to the jerry instance. * @return the pointer to the jerry instance.
*/ */
@@ -127,6 +141,12 @@ struct jerry_instance_t *jerry_port_get_current_instance (void);
```c ```c
/** /**
* Makes the process sleep for a given time. * Makes the process sleep for a given time.
*
* Note:
* This port function is called by jerry-core when JERRY_DEBUGGER is
* defined. Otherwise this function is not used.
*
* @param sleep_time milliseconds to sleep.
*/ */
void jerry_port_sleep (uint32_t sleep_time); void jerry_port_sleep (uint32_t sleep_time);
``` ```
@@ -269,7 +289,7 @@ void jerry_port_sleep (uint32_t sleep_time)
#ifdef HAVE_TIME_H #ifdef HAVE_TIME_H
nanosleep (&(const struct timespec) nanosleep (&(const struct timespec)
{ {
sleep_time / 1000, (sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */ (time_t) sleep_time / 1000, ((long int) sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
} }
, NULL); , NULL);
#elif defined (HAVE_UNISTD_H) #elif defined (HAVE_UNISTD_H)
+2 -2
View File
@@ -71,7 +71,7 @@ behaviour through property getting and setting.
* prop_value contains a live reference to an error object. * prop_value contains a live reference to an error object.
* This reference must be released as well. */ * This reference must be released as well. */
if (jerry_value_has_error_flag (prop_value)) if (jerry_value_is_error (prop_value))
{ {
/* Errors can be handled here. */ /* Errors can be handled here. */
} }
@@ -103,7 +103,7 @@ behaviour through property getting and setting.
/* The reference stored in the 'result' variable is live whether /* The reference stored in the 'result' variable is live whether
* the operation is successful or not, and must also be freed. */ * the operation is successful or not, and must also be freed. */
if (jerry_value_has_error_flag (result)) if (jerry_value_is_error (result))
{ {
/* Errors can be handled here. */ /* Errors can be handled here. */
} }
+1 -1
View File
@@ -315,7 +315,7 @@ wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource nam
source_size, source_size,
JERRY_PARSE_NO_OPTS); JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_val)) if (!jerry_value_is_error (ret_val))
{ {
jerry_value_t func_val = ret_val; jerry_value_t func_val = ret_val;
ret_val = jerry_run (func_val); ret_val = jerry_run (func_val);
+3 -3
View File
@@ -254,7 +254,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
4); 4);
if (jerry_value_has_error_flag (rv)) if (jerry_value_is_error (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
@@ -650,7 +650,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
1); 1);
if (jerry_value_has_error_flag (rv)) if (jerry_value_is_error (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
@@ -741,7 +741,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
1); 1);
if (jerry_value_has_error_flag (rv)) if (jerry_value_is_error (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
+1 -1
View File
@@ -146,7 +146,7 @@ register_common_functions (void)
{ {
jerry_value_t ret = jerry_create_undefined (); jerry_value_t ret = jerry_create_undefined ();
for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_has_error_flag (ret); i++) for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_error (ret); i++)
{ {
ret = jerryx_handler_register_global ((const jerry_char_t *) common_functions[i].name_p, ret = jerryx_handler_register_global ((const jerry_char_t *) common_functions[i].name_p,
common_functions[i].handler_p); common_functions[i].handler_p);
+26 -1
View File
@@ -37,6 +37,11 @@ The purpose of having resolvers is to be able to account for the fact that diffe
differently and thus, for each type of module a module resolver must be supplied at the point where an instance of that differently and thus, for each type of module a module resolver must be supplied at the point where an instance of that
type of module is requested. type of module is requested.
Individual modules may be removed from the cache by calling `jerryx_module_clear_cache`. This function behaves
identically to `jerryx_module_resolve` in that it first checks the cache for the requested module, except that it
removes the module if found. Additionally, it clears the entire cache of all modules if called using a JavaScript value
of `undefined` as its first parameter.
Additionally, this extension provides a means of easily defining so-called "native" JerryScript modules which can be Additionally, this extension provides a means of easily defining so-called "native" JerryScript modules which can be
resolved using the native JerryScript module resolver `jerryx_module_native_resolver`, which can be passed to resolved using the native JerryScript module resolver `jerryx_module_native_resolver`, which can be passed to
`jerryx_module_resolve()`. Native modules are registered during application startup and by calling `dlopen()` by means `jerryx_module_resolve()`. Native modules are registered during application startup and by calling `dlopen()` by means
@@ -66,7 +71,7 @@ to `jerryx_module_resolve` with a module name whose canonical name matches an al
```c ```c
jerry_value_t jerry_value_t
jerryx_module_resolve (const jerry_char_t *name, jerryx_module_resolve (const jerry_value_t name,
const jerryx_module_resolver_t *resolvers_p, const jerryx_module_resolver_t *resolvers_p,
size_t resolver_count); size_t resolver_count);
``` ```
@@ -77,6 +82,26 @@ jerryx_module_resolve (const jerry_char_t *name,
- return value - `jerry_value_t` representing the module that was loaded, or the error that occurred in the process. - return value - `jerry_value_t` representing the module that was loaded, or the error that occurred in the process.
## jerryx_module_clear_cache
**Summary**
Remove a module from the current context's cache, or clear the cache entirely.
**Prototype**
```c
void
jerryx_module_clear_cache (const jerry_value_t name,
const jerryx_module_resolver_t *resolvers_p,
size_t resolver_count);
```
- `name` - the name of the module to remove from cache or a JavaScript `undefined` to clear the entire cache
- `resolvers_p` - the list of resolvers to call in sequence
- `resolver_count` - the number of resolvers in `resolvers_p`
## jerryx_module_native_resolver ## jerryx_module_native_resolver
**Summary** **Summary**