Fix formatting in API and internals
This commit is contained in:
@@ -13,6 +13,7 @@ permalink: /API/
|
|||||||
The simplest way to run JavaScript.
|
The simplest way to run JavaScript.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_completion_code_t
|
jerry_completion_code_t
|
||||||
jerry_run_simple (const char * script_source,
|
jerry_run_simple (const char * script_source,
|
||||||
@@ -26,12 +27,14 @@ jerry_run_simple (const char *script_source,
|
|||||||
|
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_init](#jerry_init)
|
|
||||||
- [jerry_cleanup](#jerry_cleanup)
|
- [jerry_init](#jerryinit)
|
||||||
- [jerry_parse](#jerry_parse)
|
- [jerry_cleanup](#jerrycleanup)
|
||||||
- [jerry_run](#jerry_run)
|
- [jerry_parse](#jerryparse)
|
||||||
|
- [jerry_run](#jerryrun)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
const char * script = "print ('Hello, World!');";
|
const char * script = "print ('Hello, World!');";
|
||||||
@@ -47,6 +50,7 @@ jerry_run_simple (const char *script_source,
|
|||||||
Initializes JerryScript engine, making possible to run JavaScript code and perform operations on JavaScript values.
|
Initializes JerryScript engine, making possible to run JavaScript code and perform operations on JavaScript values.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void
|
void
|
||||||
jerry_init (jerry_flag_t flags);
|
jerry_init (jerry_flag_t flags);
|
||||||
@@ -60,9 +64,11 @@ jerry_init (jerry_flag_t flags);
|
|||||||
- `JERRY_FLAG_EMPTY` - no flags, just initialize in default configuration.
|
- `JERRY_FLAG_EMPTY` - no flags, just initialize in default configuration.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_cleanup](#jerry_cleanup)
|
|
||||||
|
- [jerry_cleanup](#jerrycleanup)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||||
@@ -82,13 +88,15 @@ Finish JavaScript engine execution, freeing memory and JavaScript values.
|
|||||||
JavaScript values, received from engine, are inaccessible after the cleanup.
|
JavaScript values, received from engine, are inaccessible after the cleanup.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void
|
void
|
||||||
jerry_cleanup (void);
|
jerry_cleanup (void);
|
||||||
```
|
```
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_init](#jerry_init)
|
|
||||||
|
- [jerry_init](#jerryinit)
|
||||||
|
|
||||||
# jerry_parse
|
# jerry_parse
|
||||||
|
|
||||||
@@ -99,6 +107,7 @@ Current API doesn't permit replacement or modification of Global scope's code wi
|
|||||||
so `jerry_parse` could be invoked only once between `jerry_init` and `jerry_cleanup`.
|
so `jerry_parse` could be invoked only once between `jerry_init` and `jerry_cleanup`.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_parse (const char* source_p, size_t source_size);
|
jerry_parse (const char* source_p, size_t source_size);
|
||||||
@@ -107,9 +116,11 @@ jerry_parse (const char* source_p, size_t source_size);
|
|||||||
- `source_size` - size of the string, in bytes.
|
- `source_size` - size of the string, in bytes.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_run](#jerry_run)
|
|
||||||
|
- [jerry_run](#jerryrun)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||||
@@ -131,6 +142,7 @@ Run code of Global scope.
|
|||||||
The code should be previously registered through `jerry_parse`.
|
The code should be previously registered through `jerry_parse`.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_completion_code_t
|
jerry_completion_code_t
|
||||||
jerry_run (void);
|
jerry_run (void);
|
||||||
@@ -139,9 +151,11 @@ jerry_run (void);
|
|||||||
- returned value - completion code that indicates whether run performed successfully (`JERRY_COMPLETION_CODE_OK`), or an unhandled JavaScript exception occurred (`JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION`).
|
- returned value - completion code that indicates whether run performed successfully (`JERRY_COMPLETION_CODE_OK`), or an unhandled JavaScript exception occurred (`JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION`).
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_parse](#jerry_parse)
|
|
||||||
|
- [jerry_parse](#jerryparse)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||||
@@ -195,11 +209,10 @@ typedef struct jerry_api_value_t
|
|||||||
```
|
```
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_string_t](#jerry_api_string_t)
|
|
||||||
- [jerry_api_object_t](#jerry_api_object_t)
|
- [jerry_api_eval](#jerryapieval)
|
||||||
- [jerry_api_eval](#jerry_api_eval)
|
- [jerry_api_call_function](#jerryapicallfunction)
|
||||||
- [jerry_api_call_function](#jerry_api_call_function)
|
- [jerry_api_construct_object](#jerryapiconstructobject)
|
||||||
- [jerry_api_construct_object](#jerry_api_construct_object)
|
|
||||||
|
|
||||||
|
|
||||||
# jerry_api_eval
|
# jerry_api_eval
|
||||||
@@ -208,6 +221,7 @@ typedef struct jerry_api_value_t
|
|||||||
Perform JavaScript `eval`.
|
Perform JavaScript `eval`.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_completion_code_t
|
jerry_completion_code_t
|
||||||
jerry_api_eval (const char * source_p,
|
jerry_api_eval (const char * source_p,
|
||||||
@@ -225,11 +239,13 @@ jerry_api_eval (const char *source_p,
|
|||||||
- returned value - completion code that indicates whether run performed successfully (`JERRY_COMPLETION_CODE_OK`), or an unhandled JavaScript exception occurred (`JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION`).
|
- returned value - completion code that indicates whether run performed successfully (`JERRY_COMPLETION_CODE_OK`), or an unhandled JavaScript exception occurred (`JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION`).
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_create_external_function](#jerry_api_create_external_function)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
- [jerry_external_handler_t](/#jerry_external_handler_t)
|
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
|
||||||
|
- [jerry_external_handler_t](#jerryexternalhandlert)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_value_t ret_val;
|
jerry_api_value_t ret_val;
|
||||||
@@ -246,9 +262,10 @@ jerry_api_eval (const char *source_p,
|
|||||||
**Summary**
|
**Summary**
|
||||||
Create new JavaScript string.
|
Create new JavaScript string.
|
||||||
|
|
||||||
Upon the JavaScript string becomes unused, all pointers to it should be released using [jerry_api_release_string](#jerry_api_release_string).
|
Upon the JavaScript string becomes unused, all pointers to it should be released using [jerry_api_release_string](#jerryapireleasestring).
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_string_t*
|
jerry_api_string_t*
|
||||||
jerry_api_create_string (const char * v);
|
jerry_api_create_string (const char * v);
|
||||||
@@ -258,11 +275,13 @@ jerry_api_create_string (const char *v);
|
|||||||
- returned value is pointer to created string.
|
- returned value is pointer to created string.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_acquire_string](#jerry_api_acquire_string)
|
|
||||||
- [jerry_api_release_string](#jerry_api_release_string)
|
- [jerry_api_acquire_string](#jerryapiacquirestring)
|
||||||
- [jerry_api_string_to_char_buffer](#jerry_api_string_to_char_buffer)
|
- [jerry_api_release_string](#jerryapireleasestring)
|
||||||
|
- [jerry_api_string_to_char_buffer](#jerryapistringtocharbuffer)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_string_t * string_p = jerry_api_create_string ("abc");
|
jerry_api_string_t * string_p = jerry_api_create_string ("abc");
|
||||||
@@ -279,6 +298,7 @@ jerry_api_create_string (const char *v);
|
|||||||
Copy string characters to specified buffer, append zero character at end of the buffer.
|
Copy string characters to specified buffer, append zero character at end of the buffer.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
ssize_t
|
ssize_t
|
||||||
jerry_api_string_to_char_buffer (const jerry_api_string_t * string_p,
|
jerry_api_string_to_char_buffer (const jerry_api_string_t * string_p,
|
||||||
@@ -294,10 +314,12 @@ jerry_api_string_to_char_buffer (const jerry_api_string_t *string_p,
|
|||||||
- otherwise (in case size of buffer is insuficcient) - negative number, which is calculated as negation of buffer size, that is required to hold characters.
|
- otherwise (in case size of buffer is insuficcient) - negative number, which is calculated as negation of buffer size, that is required to hold characters.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_create_string](#jerry_api_create_string)
|
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
- [jerry_api_create_string](#jerryapicreatestring)
|
||||||
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * obj_p = jerry_api_get_global ();
|
jerry_api_object_t * obj_p = jerry_api_get_global ();
|
||||||
@@ -339,9 +361,10 @@ jerry_api_string_to_char_buffer (const jerry_api_string_t *string_p,
|
|||||||
**Summary**
|
**Summary**
|
||||||
Acquire new pointer to the string for usage outside of the engine.
|
Acquire new pointer to the string for usage outside of the engine.
|
||||||
|
|
||||||
The acquired pointer should be released with [jerry_api_release_string](#jerry_api_release_string).
|
The acquired pointer should be released with [jerry_api_release_string](#jerryapireleasestring).
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_string_t*
|
jerry_api_string_t*
|
||||||
jerry_api_acquire_string (jerry_api_string_t * string_p);
|
jerry_api_acquire_string (jerry_api_string_t * string_p);
|
||||||
@@ -351,10 +374,12 @@ jerry_api_acquire_string (jerry_api_string_t *string_p);
|
|||||||
- returned value - new pointer to the string.
|
- returned value - new pointer to the string.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_release_string](#jerry_api_release_string)
|
|
||||||
- [jerry_api_create_string](#jerry_api_create_string)
|
- [jerry_api_release_string](#jerryapireleasestring)
|
||||||
|
- [jerry_api_create_string](#jerryapicreatestring)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_string_t * str_ptr1_p = jerry_api_create_string ("abc");
|
jerry_api_string_t * str_ptr1_p = jerry_api_create_string ("abc");
|
||||||
@@ -376,6 +401,7 @@ jerry_api_acquire_string (jerry_api_string_t *string_p);
|
|||||||
Release specified pointer to the string.
|
Release specified pointer to the string.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void
|
void
|
||||||
jerry_api_release_string (jerry_api_string_t * string_p);
|
jerry_api_release_string (jerry_api_string_t * string_p);
|
||||||
@@ -384,10 +410,12 @@ jerry_api_release_string (jerry_api_string_t *string_p);
|
|||||||
- `string_p` - pointer to the string.
|
- `string_p` - pointer to the string.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_acquire_string](#jerry_api_acquire_string)
|
|
||||||
- [jerry_api_create_string](#jerry_api_create_string)
|
- [jerry_api_acquire_string](#jerryapiacquirestring)
|
||||||
|
- [jerry_api_create_string](#jerryapicreatestring)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_string_t * str_ptr1_p = jerry_api_create_string ("abc");
|
jerry_api_string_t * str_ptr1_p = jerry_api_create_string ("abc");
|
||||||
@@ -408,9 +436,10 @@ jerry_api_release_string (jerry_api_string_t *string_p);
|
|||||||
**Summary**
|
**Summary**
|
||||||
Create new JavaScript object, like with `new Object()`.
|
Create new JavaScript object, like with `new Object()`.
|
||||||
|
|
||||||
Upon the JavaScript object becomes unused, all pointers to it should be released using [jerry_api_release_object](#jerry_api_release_object).
|
Upon the JavaScript object becomes unused, all pointers to it should be released using [jerry_api_release_object](#jerryapireleaseobject).
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_object_t*
|
jerry_api_object_t*
|
||||||
jerry_api_create_object (const char * v);
|
jerry_api_create_object (const char * v);
|
||||||
@@ -421,16 +450,18 @@ jerry_api_create_object (const char *v);
|
|||||||
|
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_acquire_object](#jerry_api_acquire_object)
|
|
||||||
- [jerry_api_release_object](#jerry_api_release_object)
|
- [jerry_api_acquire_object](#jerryapiacquireobject)
|
||||||
- [jerry_api_add_object_field](/#jerry_api_add_object_field)
|
- [jerry_api_release_object](#jerryapireleaseobject)
|
||||||
- [jerry_api_delete_object_field](/#jerry_api_delete_object_field)
|
- [jerry_api_add_object_field](#jerryapiaddobjectfield)
|
||||||
- [jerry_api_get_object_field_value](/#jerry_api_get_object_field_value)
|
- [jerry_api_delete_object_field](#jerryapideleteobjectfield)
|
||||||
- [jerry_api_set_object_field_value](/#jerry_api_set_object_field_value)
|
- [jerry_api_get_object_field_value](#jerryapigetobjectfieldvalue)
|
||||||
- [jerry_api_get_object_native_handle](/#jerry_api_get_object_native_handle)
|
- [jerry_api_set_object_field_value](#jerryapisetobjectfieldvalue)
|
||||||
- [jerry_api_set_object_native_handle](/#jerry_api_set_object_native_handle)
|
- [jerry_api_get_object_native_handle](#jerryapigetobjectnativehandle)
|
||||||
|
- [jerry_api_set_object_native_handle](#jerryapisetobjectnativehandle)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * object_p = jerry_api_create_object ("abc");
|
jerry_api_object_t * object_p = jerry_api_create_object ("abc");
|
||||||
@@ -446,9 +477,10 @@ jerry_api_create_object (const char *v);
|
|||||||
**Summary**
|
**Summary**
|
||||||
Acquire new pointer to the object for usage outside of the engine.
|
Acquire new pointer to the object for usage outside of the engine.
|
||||||
|
|
||||||
The acquired pointer should be released with [jerry_api_release_object](#jerry_api_release_object).
|
The acquired pointer should be released with [jerry_api_release_object](#jerryapireleaseobject).
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_object_t*
|
jerry_api_object_t*
|
||||||
jerry_api_acquire_object (jerry_api_object_t * object_p);
|
jerry_api_acquire_object (jerry_api_object_t * object_p);
|
||||||
@@ -458,10 +490,12 @@ jerry_api_acquire_object (jerry_api_object_t *object_p);
|
|||||||
- returned value - new pointer to the object.
|
- returned value - new pointer to the object.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_release_object](#jerry_api_release_object)
|
|
||||||
- [jerry_api_create_object](#jerry_api_create_object)
|
- [jerry_api_release_object](#jerryapireleaseobject)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * obj_ptr1_p = jerry_api_create_object ("abc");
|
jerry_api_object_t * obj_ptr1_p = jerry_api_create_object ("abc");
|
||||||
@@ -483,6 +517,7 @@ jerry_api_acquire_object (jerry_api_object_t *object_p);
|
|||||||
Release specified pointer to the object.
|
Release specified pointer to the object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void
|
void
|
||||||
jerry_api_release_object (jerry_api_object_t * object_p);
|
jerry_api_release_object (jerry_api_object_t * object_p);
|
||||||
@@ -491,10 +526,12 @@ jerry_api_release_object (jerry_api_object_t *object_p);
|
|||||||
- `object_p` - pointer to the object.
|
- `object_p` - pointer to the object.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_acquire_object](#jerry_api_acquire_object)
|
|
||||||
- [jerry_api_create_object](#jerry_api_create_object)
|
- [jerry_api_acquire_object](#jerryapiacquireobject)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * obj_ptr1_p = jerry_api_create_object ("abc");
|
jerry_api_object_t * obj_ptr1_p = jerry_api_create_object ("abc");
|
||||||
@@ -516,6 +553,7 @@ jerry_api_release_object (jerry_api_object_t *object_p);
|
|||||||
Get the Global object.
|
Get the Global object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_object_t*
|
jerry_api_object_t*
|
||||||
jerry_api_get_global (void);
|
jerry_api_get_global (void);
|
||||||
@@ -523,16 +561,18 @@ jerry_api_get_global (void);
|
|||||||
|
|
||||||
- returned value - pointer to the Global object.
|
- returned value - pointer to the Global object.
|
||||||
|
|
||||||
Received pointer should be released with [jerry_api_release_object](#jerry_api_release_object), just when the value becomes unnecessary.
|
Received pointer should be released with [jerry_api_release_object](#jerryapireleaseobject), just when the value becomes unnecessary.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_release_object](#jerry_api_release_object)
|
|
||||||
- [jerry_api_add_object_field](/#jerry_api_add_object_field)
|
- [jerry_api_release_object](#jerryapireleaseobject)
|
||||||
- [jerry_api_delete_object_field](/#jerry_api_delete_object_field)
|
- [jerry_api_add_object_field](#jerryapiaddobjectfield)
|
||||||
- [jerry_api_get_object_field_value](/#jerry_api_get_object_field_value)
|
- [jerry_api_delete_object_field](#jerryapideleteobjectfield)
|
||||||
- [jerry_api_set_object_field_value](/#jerry_api_set_object_field_value)
|
- [jerry_api_get_object_field_value](#jerryapigetobjectfieldvalue)
|
||||||
|
- [jerry_api_set_object_field_value](#jerryapisetobjectfieldvalue)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * glob_obj_p = jerry_api_get_global ();
|
jerry_api_object_t * glob_obj_p = jerry_api_get_global ();
|
||||||
@@ -556,6 +596,7 @@ Received pointer should be released with [jerry_api_release_object](#jerry_api_r
|
|||||||
Create field (named data property) in an object
|
Create field (named data property) in an object
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_add_object_field (jerry_api_object_t * object_p,
|
jerry_api_add_object_field (jerry_api_object_t * object_p,
|
||||||
@@ -573,10 +614,12 @@ jerry_api_add_object_field (jerry_api_object_t *object_p,
|
|||||||
- the object is extensible.
|
- the object is extensible.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t * obj_p = jerry_api_create_object ();
|
jerry_api_object_t * obj_p = jerry_api_create_object ();
|
||||||
@@ -596,6 +639,7 @@ jerry_api_add_object_field (jerry_api_object_t *object_p,
|
|||||||
Delete field (property) in the specified object
|
Delete field (property) in the specified object
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_delete_object_field (jerry_api_object_t * object_p,
|
jerry_api_delete_object_field (jerry_api_object_t * object_p,
|
||||||
@@ -608,10 +652,12 @@ jerry_api_delete_object_field (jerry_api_object_t *object_p,
|
|||||||
- there is field with specified name in the object.
|
- there is field with specified name in the object.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t* obj_p;
|
jerry_api_object_t* obj_p;
|
||||||
@@ -627,6 +673,7 @@ jerry_api_delete_object_field (jerry_api_object_t *object_p,
|
|||||||
Get value of field (property) in the specified object, i.e. perform [[Get]] operation.
|
Get value of field (property) in the specified object, i.e. perform [[Get]] operation.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_get_object_field_value (jerry_api_object_t * object_p,
|
jerry_api_get_object_field_value (jerry_api_object_t * object_p,
|
||||||
@@ -640,13 +687,15 @@ jerry_api_get_object_field_value (jerry_api_object_t *object_p,
|
|||||||
- returned value - true, if field value was retrieved successfully, i.e. upon the call:
|
- returned value - true, if field value was retrieved successfully, i.e. upon the call:
|
||||||
- there is field with specified name in the object.
|
- there is field with specified name in the object.
|
||||||
|
|
||||||
If value was retrieved successfully, it should be freed with jerry_api_release_value just when it becomes unnecessary.
|
If value was retrieved successfully, it should be freed with [jerry_api_release_object](#jerryapireleaseobject) just when it becomes unnecessary.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t* obj_p;
|
jerry_api_object_t* obj_p;
|
||||||
@@ -669,6 +718,7 @@ If value was retrieved successfully, it should be freed with jerry_api_release_v
|
|||||||
Set value of a field (property) in the specified object, i.e. perform [[Put]] operation.
|
Set value of a field (property) in the specified object, i.e. perform [[Put]] operation.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_set_object_field_value (jerry_api_object_t * object_p,
|
jerry_api_set_object_field_value (jerry_api_object_t * object_p,
|
||||||
@@ -683,10 +733,12 @@ jerry_api_set_object_field_value (jerry_api_object_t *object_p,
|
|||||||
- field value is writable.
|
- field value is writable.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t* obj_p;
|
jerry_api_object_t* obj_p;
|
||||||
@@ -705,6 +757,7 @@ jerry_api_set_object_field_value (jerry_api_object_t *object_p,
|
|||||||
Get native handle, previously associated with specified object.
|
Get native handle, previously associated with specified object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_get_object_native_handle (jerry_api_object_t * object_p,
|
jerry_api_get_object_native_handle (jerry_api_object_t * object_p,
|
||||||
@@ -716,10 +769,12 @@ jerry_api_get_object_native_handle (jerry_api_object_t *object_p,
|
|||||||
- returned value - true, if there is handle associated with the object.
|
- returned value - true, if there is handle associated with the object.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
|
||||||
- [jerry_api_set_object_native_handle](/#jerry_api_set_object_native_handle)
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
- [jerry_api_set_object_native_handle](#jerryapisetobjectnativehandle)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t* obj_p;
|
jerry_api_object_t* obj_p;
|
||||||
@@ -746,6 +801,7 @@ Set native handle and, optionally, "free" callback for the specified object.
|
|||||||
If native handle or "free" callback were already set for the object, corresponding value is updated.
|
If native handle or "free" callback were already set for the object, corresponding value is updated.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_set_object_native_handle (jerry_api_object_t * object_p,
|
jerry_api_set_object_native_handle (jerry_api_object_t * object_p,
|
||||||
@@ -758,10 +814,12 @@ jerry_api_set_object_native_handle (jerry_api_object_t *object_p,
|
|||||||
- `freecb_p` - pointer to "free" callback or NULL (if not NULL the callback would be called upon GC of the object).
|
- `freecb_p` - pointer to "free" callback or NULL (if not NULL the callback would be called upon GC of the object).
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_create_object](/#jerry_api_create_object)
|
|
||||||
- [jerry_api_get_object_native_handle](/#jerry_api_get_object_native_handle)
|
- [jerry_api_create_object](#jerryapicreateobject)
|
||||||
|
- [jerry_api_get_object_native_handle](#jerryapigetobjectnativehandle)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_object_t* obj_p;
|
jerry_api_object_t* obj_p;
|
||||||
@@ -785,6 +843,7 @@ jerry_api_set_object_native_handle (jerry_api_object_t *object_p,
|
|||||||
Check whether the specified object is a function object.
|
Check whether the specified object is a function object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_is_function (const jerry_api_object_t* object_p);
|
jerry_api_is_function (const jerry_api_object_t* object_p);
|
||||||
@@ -794,11 +853,13 @@ jerry_api_is_function (const jerry_api_object_t* object_p);
|
|||||||
- returned value - just boolean, indicating whether the specified object can be called as function.
|
- returned value - just boolean, indicating whether the specified object can be called as function.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_is_constructor](#jerry_api_is_constructor)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
- [jerry_api_call_function](#jerry_api_call_function)
|
- [jerry_api_is_constructor](#jerryapiisconstructor)
|
||||||
|
- [jerry_api_call_function](#jerryapicallfunction)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_value_t val;
|
jerry_api_value_t val;
|
||||||
@@ -819,6 +880,7 @@ jerry_api_is_function (const jerry_api_object_t* object_p);
|
|||||||
Check whether the specified object is a constructor function object.
|
Check whether the specified object is a constructor function object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_is_constructor (const jerry_api_object_t* object_p);
|
jerry_api_is_constructor (const jerry_api_object_t* object_p);
|
||||||
@@ -828,11 +890,13 @@ jerry_api_is_constructor (const jerry_api_object_t* object_p);
|
|||||||
- returned value - just boolean, indicating whether the specified object can be called as constructor.
|
- returned value - just boolean, indicating whether the specified object can be called as constructor.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
|
||||||
- [jerry_api_is_function](#jerry_api_is_function)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
- [jerry_api_construct_object](#jerry_api_construct_object)
|
- [jerry_api_is_function](#jerryapiisfunction)
|
||||||
|
- [jerry_api_construct_object](#jerryapiconstructobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_value_t val;
|
jerry_api_value_t val;
|
||||||
@@ -853,6 +917,7 @@ jerry_api_is_constructor (const jerry_api_object_t* object_p);
|
|||||||
Call function object.
|
Call function object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_call_function (jerry_api_object_t * function_object_p,
|
jerry_api_call_function (jerry_api_object_t * function_object_p,
|
||||||
@@ -870,14 +935,16 @@ jerry_api_call_function (jerry_api_object_t *function_object_p,
|
|||||||
- specified object is a function object (see also jerry_api_is_function);
|
- specified object is a function object (see also jerry_api_is_function);
|
||||||
- no unhandled exceptions were thrown in connection with the call.
|
- no unhandled exceptions were thrown in connection with the call.
|
||||||
|
|
||||||
If call was performed successfully, returned value should be freed with [jerry_api_release_value](#jerry_api_release_value) just when it becomes unnecessary.
|
If call was performed successfully, returned value should be freed with [jerry_api_release_object](#jerryapireleaseobject) just when it becomes unnecessary.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_is_function](#jerry_api_is_function)
|
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
- [jerry_api_is_function](#jerryapiisfunction)
|
||||||
- [jerry_api_create_external_function](#jerry_api_create_external_function)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_value_t val;
|
jerry_api_value_t val;
|
||||||
@@ -909,6 +976,7 @@ jerry_api_call_function (jerry_api_object_t *function_object_p,
|
|||||||
Construct object invoking specified function object as constructor.
|
Construct object invoking specified function object as constructor.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool
|
bool
|
||||||
jerry_api_construct_object (jerry_api_object_t * function_object_p,
|
jerry_api_construct_object (jerry_api_object_t * function_object_p,
|
||||||
@@ -924,13 +992,14 @@ jerry_api_construct_object (jerry_api_object_t *function_object_p,
|
|||||||
- specified object is a constructor function object;
|
- specified object is a constructor function object;
|
||||||
- no unhandled exceptions were thrown in connection with the call.
|
- no unhandled exceptions were thrown in connection with the call.
|
||||||
|
|
||||||
If call was performed successfully, returned value should be freed with [[jerry_api_release_value|API#jerry_api_release_value]] just when it becomes unnecessary.
|
If call was performed successfully, returned value should be freed with [jerry_api_release_object](#jerryapireleaseobject) just when it becomes unnecessary.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_is_constructor](#jerry_api_is_constructor)
|
- [jerry_api_is_constructor](#jerryapiisconstructor)
|
||||||
- [jerry_api_value_t](#jerry_api_value_t)
|
- [jerry_api_value_t](#jerryapivaluet)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
{
|
{
|
||||||
jerry_api_value_t val;
|
jerry_api_value_t val;
|
||||||
@@ -962,6 +1031,7 @@ If call was performed successfully, returned value should be freed with [[jerry_
|
|||||||
The data type represents pointer to call handler of a native function object.
|
The data type represents pointer to call handler of a native function object.
|
||||||
|
|
||||||
**Structure**
|
**Structure**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
typedef bool (* jerry_external_handler_t) (const jerry_api_object_t * function_obj_p,
|
typedef bool (* jerry_external_handler_t) (const jerry_api_object_t * function_obj_p,
|
||||||
const jerry_api_value_t * this_p,
|
const jerry_api_value_t * this_p,
|
||||||
@@ -971,7 +1041,8 @@ typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj
|
|||||||
```
|
```
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_api_create_external_function](#jerry_api_create_external_function)
|
|
||||||
|
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
|
||||||
|
|
||||||
# jerry_api_create_external_function
|
# jerry_api_create_external_function
|
||||||
|
|
||||||
@@ -979,6 +1050,7 @@ typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj
|
|||||||
Create an external function object.
|
Create an external function object.
|
||||||
|
|
||||||
**Prototype**
|
**Prototype**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
jerry_api_object_t*
|
jerry_api_object_t*
|
||||||
jerry_api_create_external_function (jerry_external_handler_t handler_p);
|
jerry_api_create_external_function (jerry_external_handler_t handler_p);
|
||||||
@@ -987,15 +1059,17 @@ jerry_api_create_external_function (jerry_external_handler_t handler_p);
|
|||||||
- `handler_p` - pointer to native handler of the function object;
|
- `handler_p` - pointer to native handler of the function object;
|
||||||
- returned value - pointer to constructed external function object.
|
- returned value - pointer to constructed external function object.
|
||||||
|
|
||||||
Received pointer should be released with [jerry_api_release_object](#jerry_api_release_object), just when the value becomes unnecessary.
|
Received pointer should be released with [jerry_api_release_object](#jerryapireleaseobject), just when the value becomes unnecessary.
|
||||||
|
|
||||||
**See also**
|
**See also**
|
||||||
- [jerry_external_handler_t](/#jerry_external_handler_t)
|
|
||||||
- [jerry_api_is_function](#jerry_api_is_function)
|
- [jerry_external_handler_t](#jerryexternalhandlert)
|
||||||
- [jerry_api_call_function](#jerry_api_call_function)
|
- [jerry_api_is_function](#jerryapiisfunction)
|
||||||
- [jerry_api_release_object](#jerry_api_release_object)
|
- [jerry_api_call_function](#jerryapicallfunction)
|
||||||
|
- [jerry_api_release_object](#jerryapireleaseobject)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
static bool
|
static bool
|
||||||
handler (const jerry_api_object_t * function_obj_p,
|
handler (const jerry_api_object_t * function_obj_p,
|
||||||
|
|||||||
+4
-6
@@ -5,7 +5,7 @@ permalink: /internals/
|
|||||||
---
|
---
|
||||||
|
|
||||||
* toc
|
* toc
|
||||||
{:toc}
|
{TOC}
|
||||||
|
|
||||||
# High-Level Design
|
# High-Level Design
|
||||||

|

|
||||||
@@ -59,9 +59,9 @@ Due to some limitations of the parser, some parsing functions take `this_arg` an
|
|||||||
|
|
||||||
### Lexer
|
### Lexer
|
||||||
|
|
||||||
The lexer splits input string on set of tokens. The token structure (jerry-core/parser/js/lexer.h) consists of three elements: token type, location of the token and optional data:
|
The lexer splits input string on set of tokens. The token structure (`./jerry-core/parser/js/lexer.h`) consists of three elements: token type, location of the token and optional data:
|
||||||
|
|
||||||
``` c
|
```cpp
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
locus loc;
|
locus loc;
|
||||||
@@ -71,9 +71,7 @@ typedef struct
|
|||||||
token;
|
token;
|
||||||
```
|
```
|
||||||
|
|
||||||
Location of token (`locus`). It is just an index of first token's character at a string that represents the program.
|
Location of token (`locus`). It is just an index of first token's character at a string that represents the program. Token types are are listed in lexer.h header file (`token_type` enum). Depending on token type, token specific data (`uid` field) has the different meaning.
|
||||||
|
|
||||||
Token types are are listed in lexer.h header file (`token_type` enum). Depending on token type, token specific data (`uid` field) has the different meaning.
|
|
||||||
|
|
||||||
Token type | `uid` meaning
|
Token type | `uid` meaning
|
||||||
------------|--------------
|
------------|--------------
|
||||||
|
|||||||
+5
-2
@@ -9,10 +9,13 @@ url: "http://samsung.github.io" # the base hostname & protocol for your site
|
|||||||
#github_username: samsung
|
#github_username: samsung
|
||||||
|
|
||||||
# Build settings
|
# Build settings
|
||||||
#markdown: kramdown
|
|
||||||
markdown: kramdown
|
|
||||||
highlighter: pygments
|
highlighter: pygments
|
||||||
|
|
||||||
|
markdown: kramdown
|
||||||
kramdown:
|
kramdown:
|
||||||
input: GFM
|
input: GFM
|
||||||
syntax_highlighter: pygments
|
syntax_highlighter: pygments
|
||||||
|
|
||||||
|
#markdown: redcarpet
|
||||||
|
#redcarpet:
|
||||||
|
# extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"]
|
||||||
|
|||||||
Reference in New Issue
Block a user