Fix formatting in API and internals

This commit is contained in:
Evgeny Gavrin
2015-06-14 16:39:31 +03:00
parent 841a8dc376
commit e669531811
3 changed files with 216 additions and 141 deletions
+207 -133
View File
@@ -13,9 +13,10 @@ 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,
size_t script_source_size, size_t script_source_size,
jerry_flag_t flags); jerry_flag_t flags);
``` ```
@@ -26,15 +27,17 @@ 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!');";
jerry_run_simple (script, strlen (script), JERRY_FLAG_EMPTY); jerry_run_simple (script, strlen (script), JERRY_FLAG_EMPTY);
} }
@@ -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);
@@ -187,19 +201,18 @@ typedef struct jerry_api_value_t
union union
{ {
jerry_api_string_t *v_string; jerry_api_string_t * v_string;
jerry_api_object_t *v_object; jerry_api_object_t * v_object;
}; };
}; };
} jerry_api_value_t; } 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,13 +221,14 @@ 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,
size_t source_size, size_t source_size,
bool is_direct, bool is_direct,
bool is_strict, bool is_strict,
jerry_api_value_t *retval_p); jerry_api_value_t * retval_p);
``` ```
- `source_p` - source code to evaluate; - `source_p` - source code to evaluate;
@@ -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,26 +262,29 @@ 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);
``` ```
- `v` - value of string to create; - `v` - value of string to create;
- 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,10 +298,11 @@ 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,
char *buffer_p, char * buffer_p,
ssize_t buffer_size); ssize_t buffer_size);
``` ```
@@ -294,13 +314,15 @@ 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 ();
jerry_api_value_t val; jerry_api_value_t val;
bool is_ok = jerry_api_get_object_field_value (obj_p, bool is_ok = jerry_api_get_object_field_value (obj_p,
@@ -315,7 +337,7 @@ jerry_api_string_to_char_buffer (const jerry_api_string_t *string_p,
ssize_t neg_req_sz = jerry_api_string_to_char_buffer (val.string_p, ssize_t neg_req_sz = jerry_api_string_to_char_buffer (val.string_p,
NULL, NULL,
0); 0);
char *str_buf_p = (char*) malloc (-neg_req_sz); char * str_buf_p = (char*) malloc (-neg_req_sz);
// sz would be -neg_req_sz // sz would be -neg_req_sz
size_t sz = jerry_api_string_to_char_buffer (val.string_p, size_t sz = jerry_api_string_to_char_buffer (val.string_p,
@@ -339,26 +361,29 @@ 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);
``` ```
- `string_p` - pointer to the string; - `string_p` - pointer to the string;
- 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");
jerry_api_string_t *str_ptr2_p = jerry_api_acquire_string (str_ptr1_p); jerry_api_string_t * str_ptr2_p = jerry_api_acquire_string (str_ptr1_p);
... // usage of both pointers ... // usage of both pointers
@@ -376,22 +401,25 @@ 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);
``` ```
- `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");
jerry_api_string_t *str_ptr2_p = jerry_api_acquire_string (str_ptr1_p); jerry_api_string_t * str_ptr2_p = jerry_api_acquire_string (str_ptr1_p);
... // usage of both pointers ... // usage of both pointers
@@ -408,12 +436,13 @@ 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);
``` ```
- `v` - value of object to create; - `v` - value of object to create;
@@ -421,19 +450,21 @@ 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,26 +477,29 @@ 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);
``` ```
- `object_p` - pointer to the object; - `object_p` - pointer to the object;
- 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");
jerry_api_object_t *obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p); jerry_api_object_t * obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p);
... // usage of both pointers ... // usage of both pointers
@@ -483,22 +517,25 @@ 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);
``` ```
- `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");
jerry_api_object_t *obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p); jerry_api_object_t * obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p);
... // usage of both pointers ... // usage of both pointers
@@ -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,19 +561,21 @@ 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 ();
jerry_api_value_t val; jerry_api_value_t val;
bool is_ok = jerry_api_get_object_field_value (glob_obj_p, "some_field_name", &val); bool is_ok = jerry_api_get_object_field_value (glob_obj_p, "some_field_name", &val);
@@ -556,11 +596,12 @@ 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,
const char *field_name_p, const char * field_name_p,
const jerry_api_value_t *field_value_p, const jerry_api_value_t * field_value_p,
bool is_writable); bool is_writable);
``` ```
@@ -573,13 +614,15 @@ 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 ();
jerry_api_value_t val; jerry_api_value_t val;
@@ -596,10 +639,11 @@ 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,
const char *field_name_p); const char * field_name_p);
``` ```
- `object_p` - object to delete field at; - `object_p` - object to delete field at;
@@ -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,11 +673,12 @@ 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,
const char *field_name_p, const char * field_name_p,
jerry_api_value_t *field_value_p); jerry_api_value_t * field_value_p);
``` ```
- `object_p` - object; - `object_p` - object;
@@ -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,11 +718,12 @@ 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,
const char *field_name_p, const char * field_name_p,
jerry_api_value_t *field_value_p); jerry_api_value_t * field_value_p);
``` ```
- `object_p` - object; - `object_p` - object;
@@ -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,9 +757,10 @@ 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,
uintptr_t* out_handle_p); uintptr_t* out_handle_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,9 +801,10 @@ 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,
uintptr_t handle, uintptr_t handle,
jerry_object_free_callback_t freecb_p); jerry_object_free_callback_t freecb_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,11 +917,12 @@ 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,
jerry_api_object_t *this_arg_p, jerry_api_object_t * this_arg_p,
jerry_api_value_t *retval_p, jerry_api_value_t * retval_p,
const jerry_api_value_t args_p[], const jerry_api_value_t args_p[],
uint16_t args_count); uint16_t args_count);
``` ```
@@ -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,10 +976,11 @@ 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,
jerry_api_value_t *retval_p, jerry_api_value_t * retval_p,
const jerry_api_value_t args_p[], const jerry_api_value_t args_p[],
uint16_t args_count); uint16_t args_count);
``` ```
@@ -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,16 +1031,18 @@ 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,
jerry_api_value_t *ret_val_p, jerry_api_value_t * ret_val_p,
const jerry_api_value_t args_p[], const jerry_api_value_t args_p[],
const uint16_t args_count); const uint16_t args_count);
``` ```
**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,20 +1059,22 @@ 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,
const jerry_api_value_t *this_p, const jerry_api_value_t * this_p,
jerry_api_value_t *ret_val_p, jerry_api_value_t * ret_val_p,
const jerry_api_value_t args_p[], const jerry_api_value_t args_p[],
const uint16_t args_cnt) const uint16_t args_cnt)
{ {
@@ -1011,8 +1085,8 @@ handler (const jerry_api_object_t *function_obj_p,
} }
{ {
jerry_api_object_t *obj_p = jerry_api_create_external_function (handler); jerry_api_object_t * obj_p = jerry_api_create_external_function (handler);
jerry_api_object_t *glob_obj_p = jerry_api_get_global (); jerry_api_object_t * glob_obj_p = jerry_api_get_global ();
jerry_api_value_t val; jerry_api_value_t val;
val.type = JERRY_API_DATA_TYPE_OBJECT; val.type = JERRY_API_DATA_TYPE_OBJECT;
+4 -6
View File
@@ -5,7 +5,7 @@ permalink: /internals/
--- ---
* toc * toc
{:toc} {TOC}
# High-Level Design # High-Level Design
![High-Level Design]({{ site.baseurl }}/img/engines_high_level_design.jpg) ![High-Level Design]({{ site.baseurl }}/img/engines_high_level_design.jpg)
@@ -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
View File
@@ -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"]