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.
**Prototype**
```cpp
jerry_completion_code_t
jerry_run_simple (const char *script_source,
jerry_run_simple (const char * script_source,
size_t script_source_size,
jerry_flag_t flags);
```
@@ -26,15 +27,17 @@ jerry_run_simple (const char *script_source,
**See also**
- [jerry_init](#jerry_init)
- [jerry_cleanup](#jerry_cleanup)
- [jerry_parse](#jerry_parse)
- [jerry_run](#jerry_run)
- [jerry_init](#jerryinit)
- [jerry_cleanup](#jerrycleanup)
- [jerry_parse](#jerryparse)
- [jerry_run](#jerryrun)
**Example**
```cpp
{
const char *script = "print ('Hello, World!');";
const char * script = "print ('Hello, World!');";
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.
**Prototype**
```cpp
void
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.
**See also**
- [jerry_cleanup](#jerry_cleanup)
- [jerry_cleanup](#jerrycleanup)
**Example**
```cpp
{
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.
**Prototype**
```cpp
void
jerry_cleanup (void);
```
**See also**
- [jerry_init](#jerry_init)
- [jerry_init](#jerryinit)
# 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`.
**Prototype**
```cpp
bool
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.
**See also**
- [jerry_run](#jerry_run)
- [jerry_run](#jerryrun)
**Example**
```cpp
{
jerry_init (JERRY_FLAG_ENABLE_LOG);
@@ -131,6 +142,7 @@ Run code of Global scope.
The code should be previously registered through `jerry_parse`.
**Prototype**
```cpp
jerry_completion_code_t
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`).
**See also**
- [jerry_parse](#jerry_parse)
- [jerry_parse](#jerryparse)
**Example**
```cpp
{
jerry_init (JERRY_FLAG_ENABLE_LOG);
@@ -187,19 +201,18 @@ typedef struct jerry_api_value_t
union
{
jerry_api_string_t *v_string;
jerry_api_object_t *v_object;
jerry_api_string_t * v_string;
jerry_api_object_t * v_object;
};
};
} jerry_api_value_t;
```
**See also**
- [jerry_api_string_t](#jerry_api_string_t)
- [jerry_api_object_t](#jerry_api_object_t)
- [jerry_api_eval](#jerry_api_eval)
- [jerry_api_call_function](#jerry_api_call_function)
- [jerry_api_construct_object](#jerry_api_construct_object)
- [jerry_api_eval](#jerryapieval)
- [jerry_api_call_function](#jerryapicallfunction)
- [jerry_api_construct_object](#jerryapiconstructobject)
# jerry_api_eval
@@ -208,13 +221,14 @@ typedef struct jerry_api_value_t
Perform JavaScript `eval`.
**Prototype**
```cpp
jerry_completion_code_t
jerry_api_eval (const char *source_p,
jerry_api_eval (const char * source_p,
size_t source_size,
bool is_direct,
bool is_strict,
jerry_api_value_t *retval_p);
jerry_api_value_t * retval_p);
```
- `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`).
**See also**
- [jerry_api_value_t](#jerry_api_value_t)
- [jerry_api_create_external_function](#jerry_api_create_external_function)
- [jerry_external_handler_t](/#jerry_external_handler_t)
- [jerry_api_value_t](#jerryapivaluet)
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
- [jerry_external_handler_t](#jerryexternalhandlert)
**Example**
```cpp
{
jerry_api_value_t ret_val;
@@ -246,26 +262,29 @@ jerry_api_eval (const char *source_p,
**Summary**
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**
```cpp
jerry_api_string_t*
jerry_api_create_string (const char *v);
jerry_api_create_string (const char * v);
```
- `v` - value of string to create;
- returned value is pointer to created string.
**See also**
- [jerry_api_acquire_string](#jerry_api_acquire_string)
- [jerry_api_release_string](#jerry_api_release_string)
- [jerry_api_string_to_char_buffer](#jerry_api_string_to_char_buffer)
- [jerry_api_acquire_string](#jerryapiacquirestring)
- [jerry_api_release_string](#jerryapireleasestring)
- [jerry_api_string_to_char_buffer](#jerryapistringtocharbuffer)
**Example**
```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.
**Prototype**
```cpp
ssize_t
jerry_api_string_to_char_buffer (const jerry_api_string_t *string_p,
char *buffer_p,
jerry_api_string_to_char_buffer (const jerry_api_string_t * string_p,
char * buffer_p,
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.
**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**
```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;
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,
NULL,
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
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**
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**
```cpp
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;
- returned value - new pointer to the string.
**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**
```cpp
{
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_ptr1_p = jerry_api_create_string ("abc");
jerry_api_string_t * str_ptr2_p = jerry_api_acquire_string (str_ptr1_p);
... // usage of both pointers
@@ -376,22 +401,25 @@ jerry_api_acquire_string (jerry_api_string_t *string_p);
Release specified pointer to the string.
**Prototype**
```cpp
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.
**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**
```cpp
{
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_ptr1_p = jerry_api_create_string ("abc");
jerry_api_string_t * str_ptr2_p = jerry_api_acquire_string (str_ptr1_p);
... // usage of both pointers
@@ -408,12 +436,13 @@ jerry_api_release_string (jerry_api_string_t *string_p);
**Summary**
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**
```cpp
jerry_api_object_t*
jerry_api_create_object (const char *v);
jerry_api_create_object (const char * v);
```
- `v` - value of object to create;
@@ -421,19 +450,21 @@ jerry_api_create_object (const char *v);
**See also**
- [jerry_api_acquire_object](#jerry_api_acquire_object)
- [jerry_api_release_object](#jerry_api_release_object)
- [jerry_api_add_object_field](/#jerry_api_add_object_field)
- [jerry_api_delete_object_field](/#jerry_api_delete_object_field)
- [jerry_api_get_object_field_value](/#jerry_api_get_object_field_value)
- [jerry_api_set_object_field_value](/#jerry_api_set_object_field_value)
- [jerry_api_get_object_native_handle](/#jerry_api_get_object_native_handle)
- [jerry_api_set_object_native_handle](/#jerry_api_set_object_native_handle)
- [jerry_api_acquire_object](#jerryapiacquireobject)
- [jerry_api_release_object](#jerryapireleaseobject)
- [jerry_api_add_object_field](#jerryapiaddobjectfield)
- [jerry_api_delete_object_field](#jerryapideleteobjectfield)
- [jerry_api_get_object_field_value](#jerryapigetobjectfieldvalue)
- [jerry_api_set_object_field_value](#jerryapisetobjectfieldvalue)
- [jerry_api_get_object_native_handle](#jerryapigetobjectnativehandle)
- [jerry_api_set_object_native_handle](#jerryapisetobjectnativehandle)
**Example**
```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**
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**
```cpp
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;
- returned value - new pointer to the object.
**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**
```cpp
{
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_ptr1_p = jerry_api_create_object ("abc");
jerry_api_object_t * obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p);
... // usage of both pointers
@@ -483,22 +517,25 @@ jerry_api_acquire_object (jerry_api_object_t *object_p);
Release specified pointer to the object.
**Prototype**
```cpp
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.
**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**
```cpp
{
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_ptr1_p = jerry_api_create_object ("abc");
jerry_api_object_t * obj_ptr2_p = jerry_api_acquire_object (obj_ptr1_p);
... // usage of both pointers
@@ -516,6 +553,7 @@ jerry_api_release_object (jerry_api_object_t *object_p);
Get the Global object.
**Prototype**
```cpp
jerry_api_object_t*
jerry_api_get_global (void);
@@ -523,19 +561,21 @@ jerry_api_get_global (void);
- 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**
- [jerry_api_release_object](#jerry_api_release_object)
- [jerry_api_add_object_field](/#jerry_api_add_object_field)
- [jerry_api_delete_object_field](/#jerry_api_delete_object_field)
- [jerry_api_get_object_field_value](/#jerry_api_get_object_field_value)
- [jerry_api_set_object_field_value](/#jerry_api_set_object_field_value)
- [jerry_api_release_object](#jerryapireleaseobject)
- [jerry_api_add_object_field](#jerryapiaddobjectfield)
- [jerry_api_delete_object_field](#jerryapideleteobjectfield)
- [jerry_api_get_object_field_value](#jerryapigetobjectfieldvalue)
- [jerry_api_set_object_field_value](#jerryapisetobjectfieldvalue)
**Example**
```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;
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
**Prototype**
```cpp
bool
jerry_api_add_object_field (jerry_api_object_t *object_p,
const char *field_name_p,
const jerry_api_value_t *field_value_p,
jerry_api_add_object_field (jerry_api_object_t * object_p,
const char * field_name_p,
const jerry_api_value_t * field_value_p,
bool is_writable);
```
@@ -573,13 +614,15 @@ jerry_api_add_object_field (jerry_api_object_t *object_p,
- the object is extensible.
**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**
```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;
@@ -596,10 +639,11 @@ jerry_api_add_object_field (jerry_api_object_t *object_p,
Delete field (property) in the specified object
**Prototype**
```cpp
bool
jerry_api_delete_object_field (jerry_api_object_t *object_p,
const char *field_name_p);
jerry_api_delete_object_field (jerry_api_object_t * object_p,
const char * field_name_p);
```
- `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.
**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**
```cpp
{
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.
**Prototype**
```cpp
bool
jerry_api_get_object_field_value (jerry_api_object_t *object_p,
const char *field_name_p,
jerry_api_value_t *field_value_p);
jerry_api_get_object_field_value (jerry_api_object_t * object_p,
const char * field_name_p,
jerry_api_value_t * field_value_p);
```
- `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:
- 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**
- [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**
```cpp
{
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.
**Prototype**
```cpp
bool
jerry_api_set_object_field_value (jerry_api_object_t *object_p,
const char *field_name_p,
jerry_api_value_t *field_value_p);
jerry_api_set_object_field_value (jerry_api_object_t * object_p,
const char * field_name_p,
jerry_api_value_t * field_value_p);
```
- `object_p` - object;
@@ -683,10 +733,12 @@ jerry_api_set_object_field_value (jerry_api_object_t *object_p,
- field value is writable.
**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**
```cpp
{
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.
**Prototype**
```cpp
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);
```
@@ -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.
**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**
```cpp
{
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.
**Prototype**
```cpp
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,
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).
**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**
```cpp
{
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.
**Prototype**
```cpp
bool
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.
**See also**
- [jerry_api_value_t](#jerry_api_value_t)
- [jerry_api_is_constructor](#jerry_api_is_constructor)
- [jerry_api_call_function](#jerry_api_call_function)
- [jerry_api_value_t](#jerryapivaluet)
- [jerry_api_is_constructor](#jerryapiisconstructor)
- [jerry_api_call_function](#jerryapicallfunction)
**Example**
```cpp
{
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.
**Prototype**
```cpp
bool
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.
**See also**
- [jerry_api_value_t](#jerry_api_value_t)
- [jerry_api_is_function](#jerry_api_is_function)
- [jerry_api_construct_object](#jerry_api_construct_object)
- [jerry_api_value_t](#jerryapivaluet)
- [jerry_api_is_function](#jerryapiisfunction)
- [jerry_api_construct_object](#jerryapiconstructobject)
**Example**
```cpp
{
jerry_api_value_t val;
@@ -853,11 +917,12 @@ jerry_api_is_constructor (const jerry_api_object_t* object_p);
Call function object.
**Prototype**
```cpp
bool
jerry_api_call_function (jerry_api_object_t *function_object_p,
jerry_api_object_t *this_arg_p,
jerry_api_value_t *retval_p,
jerry_api_call_function (jerry_api_object_t * function_object_p,
jerry_api_object_t * this_arg_p,
jerry_api_value_t * retval_p,
const jerry_api_value_t args_p[],
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);
- 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**
- [jerry_api_is_function](#jerry_api_is_function)
- [jerry_api_value_t](#jerry_api_value_t)
- [jerry_api_create_external_function](#jerry_api_create_external_function)
- [jerry_api_is_function](#jerryapiisfunction)
- [jerry_api_value_t](#jerryapivaluet)
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
**Example**
```cpp
{
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.
**Prototype**
```cpp
bool
jerry_api_construct_object (jerry_api_object_t *function_object_p,
jerry_api_value_t *retval_p,
jerry_api_construct_object (jerry_api_object_t * function_object_p,
jerry_api_value_t * retval_p,
const jerry_api_value_t args_p[],
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;
- 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**
- [jerry_api_is_constructor](#jerry_api_is_constructor)
- [jerry_api_value_t](#jerry_api_value_t)
- [jerry_api_is_constructor](#jerryapiisconstructor)
- [jerry_api_value_t](#jerryapivaluet)
**Example**
```cpp
{
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.
**Structure**
```cpp
typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj_p,
const jerry_api_value_t *this_p,
jerry_api_value_t *ret_val_p,
typedef bool (* jerry_external_handler_t) (const jerry_api_object_t * function_obj_p,
const jerry_api_value_t * this_p,
jerry_api_value_t * ret_val_p,
const jerry_api_value_t args_p[],
const uint16_t args_count);
```
**See also**
- [jerry_api_create_external_function](#jerry_api_create_external_function)
- [jerry_api_create_external_function](#jerryapicreateexternalfunction)
# 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.
**Prototype**
```cpp
jerry_api_object_t*
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;
- 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**
- [jerry_external_handler_t](/#jerry_external_handler_t)
- [jerry_api_is_function](#jerry_api_is_function)
- [jerry_api_call_function](#jerry_api_call_function)
- [jerry_api_release_object](#jerry_api_release_object)
- [jerry_external_handler_t](#jerryexternalhandlert)
- [jerry_api_is_function](#jerryapiisfunction)
- [jerry_api_call_function](#jerryapicallfunction)
- [jerry_api_release_object](#jerryapireleaseobject)
**Example**
```cpp
static bool
handler (const jerry_api_object_t *function_obj_p,
const jerry_api_value_t *this_p,
jerry_api_value_t *ret_val_p,
handler (const jerry_api_object_t * function_obj_p,
const jerry_api_value_t * this_p,
jerry_api_value_t * ret_val_p,
const jerry_api_value_t args_p[],
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 *glob_obj_p = jerry_api_get_global ();
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_value_t val;
val.type = JERRY_API_DATA_TYPE_OBJECT;
+4 -6
View File
@@ -5,7 +5,7 @@ permalink: /internals/
---
* toc
{:toc}
{TOC}
# High-Level Design
![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
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
{
locus loc;
@@ -71,9 +71,7 @@ typedef struct
token;
```
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.
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 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
# Build settings
#markdown: kramdown
markdown: kramdown
highlighter: pygments
markdown: kramdown
kramdown:
input: GFM
syntax_highlighter: pygments
#markdown: redcarpet
#redcarpet:
# extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"]