mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Update pages
This commit is contained in:
parent
40d0d1b969
commit
faefc3e5e3
48
03.api.md
48
03.api.md
@ -35,7 +35,7 @@ jerry_run_simple (const char * script_source,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
const char * script = "print ('Hello, World!');";
|
||||
|
||||
@ -69,7 +69,7 @@ jerry_init (jerry_flag_t flags);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||
|
||||
@ -121,7 +121,7 @@ jerry_parse (const char* source_p, size_t source_size);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||
|
||||
@ -156,7 +156,7 @@ jerry_run (void);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_init (JERRY_FLAG_ENABLE_LOG);
|
||||
|
||||
@ -246,7 +246,7 @@ jerry_api_eval (const char * source_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_value_t ret_val;
|
||||
|
||||
@ -282,7 +282,7 @@ jerry_api_create_string (const char * v);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_string_t * string_p = jerry_api_create_string ("abc");
|
||||
|
||||
@ -320,7 +320,7 @@ jerry_api_string_to_char_buffer (const jerry_api_string_t * string_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t * obj_p = jerry_api_get_global ();
|
||||
jerry_api_value_t val;
|
||||
@ -380,7 +380,7 @@ jerry_api_acquire_string (jerry_api_string_t * string_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight 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);
|
||||
@ -416,7 +416,7 @@ jerry_api_release_string (jerry_api_string_t * string_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight 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);
|
||||
@ -462,7 +462,7 @@ jerry_api_create_object (const char * v);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t * object_p = jerry_api_create_object ("abc");
|
||||
|
||||
@ -496,7 +496,7 @@ jerry_api_acquire_object (jerry_api_object_t * object_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight 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);
|
||||
@ -532,7 +532,7 @@ jerry_api_release_object (jerry_api_object_t * object_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight 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);
|
||||
@ -573,7 +573,7 @@ Received pointer should be released with [jerry_api_release_object](#jerryapirel
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t * glob_obj_p = jerry_api_get_global ();
|
||||
|
||||
@ -620,7 +620,7 @@ jerry_api_add_object_field (jerry_api_object_t * object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t * obj_p = jerry_api_create_object ();
|
||||
|
||||
@ -658,7 +658,7 @@ jerry_api_delete_object_field (jerry_api_object_t * object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t* obj_p;
|
||||
... // receive or construct obj_p
|
||||
@ -696,7 +696,7 @@ If value was retrieved successfully, it should be freed with [jerry_api_release_
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t* obj_p;
|
||||
... // receive or construct obj_p
|
||||
@ -739,7 +739,7 @@ jerry_api_set_object_field_value (jerry_api_object_t * object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t* obj_p;
|
||||
jerry_api_value_t val;
|
||||
@ -775,7 +775,7 @@ jerry_api_get_object_native_handle (jerry_api_object_t * object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t* obj_p;
|
||||
uintptr_t handle_set;
|
||||
@ -820,7 +820,7 @@ jerry_api_set_object_native_handle (jerry_api_object_t * object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_object_t* obj_p;
|
||||
uintptr_t handle_set;
|
||||
@ -860,7 +860,7 @@ jerry_api_is_function (const jerry_api_object_t* object_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_value_t val;
|
||||
|
||||
@ -897,7 +897,7 @@ jerry_api_is_constructor (const jerry_api_object_t* object_p);
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_value_t val;
|
||||
|
||||
@ -945,7 +945,7 @@ jerry_api_call_function (jerry_api_object_t * function_object_p,
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_value_t val;
|
||||
|
||||
@ -1001,7 +1001,7 @@ If call was performed successfully, returned value should be freed with [jerry_a
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
{
|
||||
jerry_api_value_t val;
|
||||
|
||||
@ -1071,7 +1071,7 @@ Received pointer should be released with [jerry_api_release_object](#jerryapirel
|
||||
|
||||
**Example**
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
static bool
|
||||
handler (const jerry_api_object_t * function_obj_p,
|
||||
const jerry_api_value_t * this_p,
|
||||
|
||||
@ -61,7 +61,7 @@ Due to some limitations of the parser, some parsing functions take `this_arg` an
|
||||
|
||||
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:
|
||||
|
||||
```cpp
|
||||
{% highlight cpp %}
|
||||
typedef struct
|
||||
{
|
||||
locus loc;
|
||||
@ -69,7 +69,7 @@ typedef struct
|
||||
literal_index_t uid;
|
||||
}
|
||||
token;
|
||||
```
|
||||
{% endhighlight %}
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ This guide is intended to introduce you to JerryScript embedding API through cre
|
||||
|
||||
## Step 1. Execute JavaScript from your application
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
#include <string.h>
|
||||
#include "jerry.h"
|
||||
|
||||
@ -40,7 +40,7 @@ Here we perform the same actions, as `jerry_run_simple`, while splitting into se
|
||||
- engine cleanup
|
||||
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
#include <string.h>
|
||||
#include "jerry.h"
|
||||
|
||||
@ -66,7 +66,7 @@ While code became a bit more complex, the change introduced possibilities to int
|
||||
|
||||
## Step 3. Execution in 'eval'-mode
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
#include <string.h>
|
||||
#include "jerry.h"
|
||||
|
||||
@ -101,7 +101,7 @@ This way, we execute two independent script parts in one execution environment.
|
||||
|
||||
## Step 4. Interaction with JavaScript environment
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
#include <string.h>
|
||||
#include "jerry.h"
|
||||
|
||||
@ -170,7 +170,7 @@ Pointers to strings / objects and values should be released just when become unn
|
||||
|
||||
The following example function would output a JavaScript value:
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
static void
|
||||
print_value (const jerry_api_value_t * value_p)
|
||||
{
|
||||
@ -240,7 +240,7 @@ Shell operation can be described with following loop:
|
||||
- print result of eval;
|
||||
- loop.
|
||||
|
||||
{% highlight cpp linenos=table %}
|
||||
{% highlight cpp %}
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user