Update the webpage (#1542)

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
Zsolt Borbély 2017-01-26 08:48:27 +01:00 committed by László Langó
parent dd84f11996
commit b89c74fd39
4 changed files with 125 additions and 16 deletions

View File

@ -1409,6 +1409,109 @@ jerry_string_to_utf8_char_buffer (const jerry_value_t value,
- [jerry_create_string_from_utf8](#jerrycreatestringfromutf8)
- [jerry_get_utf8_string_size](#jerrygetutf8stringsize)
## jerry_substring_to_char_buffer
**Summary**
Copy the characters of a cesu-8 encoded substring into a specified buffer.
The '\0' character could occur in character buffer. Returns 0, if the value
parameter is not a string. It will extract the substring between the
specified start position and the end position (or the end of the string,
whichever comes first).
**Prototype**
```c
jerry_size_t
jerry_substring_to_char_buffer (const jerry_value_t value,
jerry_length_t start_pos,
jerry_length_t end_pos,
jerry_char_t *buffer_p,
jerry_size_t buffer_size);
```
- `value` - input string value
- `start_pos` - position of the first character
- `end_pos` - position of the last character
- `buffer_p` - pointer to output buffer
- `buffer_size` - size of the buffer
- return value - number of bytes, actually copied to the buffer
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
jerry_size_t req_sz = jerry_get_string_size (value);
jerry_char_t str_buf_p[req_sz];
jerry_length_t start_pos = 0;
jerry_length_t end_pos = jerry_get_string_length (value);
jerry_substring_to_char_buffer (value, start_pos, end_pos, str_buf_p, req_sz);
jerry_release_value (value);
}
```
**See also**
- [jerry_create_string](#jerrycreatestring)
- [jerry_get_string_size](#jerrygetstringsize)
- [jerry_get_string_length](#jerrygetstringlength)
## jerry_substring_to_utf8_char_buffer
**Summary**
Copy the characters of an utf-8 encoded substring into a specified buffer.
The '\0' character could occur in character buffer. Returns 0, if the value
parameter is not a string. It will extract the substring between the specified
start position and the end position (or the end of the string, whichever
comes first).
**Prototype**
```c
jerry_size_t
jerry_substring_to_utf8_char_buffer (const jerry_value_t value,
jerry_length_t start_pos,
jerry_length_t end_pos,
jerry_char_t *buffer_p,
jerry_size_t buffer_size);
```
- `value` - input string value
- `start_pos` - position of the first character
- `end_pos` - position of the last character
- `buffer_p` - pointer to output buffer
- `buffer_size` - size of the buffer
- return value - number of bytes, actually copied to the buffer
**Example**
```c
{
jerry_value_t value;
... // create or acquire value
jerry_size_t req_sz = jerry_get_utf8_string_size (value);
jerry_char_t str_buf_p[req_sz];
jerry_length_t start_pos = 0;
jerry_length_t end_pos = jerry_get_utf8_string_length (value);
jerry_substring_to_utf8_char_buffer (value, start_pos, end_pos, str_buf_p, req_sz);
jerry_release_value (value);
}
```
**See also**
- [jerry_create_string_from_utf8](#jerrycreatestring)
- [jerry_get_utf8_string_size](#jerrygetutf8stringsize)
- [jerry_get_utf8_string_length](#jerrygetutf8stringlength)
# Functions for array object values
## jerry_get_array_length
@ -2774,8 +2877,9 @@ jerry_free_property_descriptor_fields (const jerry_property_descriptor_t *prop_d
**Summary**
Call function specified by a function value. Error flag
must not be set for any arguments of this function.
Call function specified by a function value. Error flag must
not be set for any arguments of this function. Value of `this`
parameter should be set to `undefined` for non-method calls.
*Note*: Returned value must be freed with [jerry_release_value](#jerryreleasevalue) when it
is no longer needed.
@ -2817,6 +2921,8 @@ jerry_call_function (const jerry_value_t func_obj_val,
jerry_release_value (ret_val);
jerry_release_value (this_val);
}
jerry_release_value (val);
}
```
@ -3241,6 +3347,7 @@ jerry_exec_snapshot (const void *snapshot_p,
size_t global_mode_snapshot_size = jerry_parse_and_save_snapshot (code_to_snapshot_p,
strlen ((const char *) code_to_snapshot_p),
true,
false,
global_mode_snapshot_buffer,
sizeof (global_mode_snapshot_buffer));
jerry_cleanup ();

View File

@ -20,7 +20,7 @@ by `jerry_release_value`.
/* The value stored in the 'global' variable contains a live
* reference to the global object. The system also keeps its
* own live reference to the global object. These two references
* are indepent, and both must be destroyed before the global
* are independent, and both must be destroyed before the global
* object can be freed. */
jerry_release_value (global);
@ -57,16 +57,17 @@ following code is an **INCORRECT WAY** of releasing the 3.14 value.
JerryScript API functions returning with a `jerry_value_t` always
return with a new live reference. Passing a `jerry_value_t` to
an API function never releases its reference. The next example
shows this behaviour through property getting and setting.
an API function never releases its reference (unless explicitly
stated in the documentation). The next example shows this
behaviour through property getting and setting.
```c
jerry_value_t prop_value = jerry_get_property (...);
/* The prop_value must be released later because both the base
* object and the prop_value have an independent reference to
* the same JavaScript value. When the operation is failed
* the prop_value contains a live reference to an error object.
* the same JavaScript value. When the operation fails, the
* prop_value contains a live reference to an error object.
* This reference must be released as well. */
if (jerry_value_has_error_flag (prop_value))
@ -85,20 +86,21 @@ shows this behaviour through property getting and setting.
/* Property setting is the same. */
jerry_value_t new_prop_value = jerry_create_number (2.718);
jerry_value_t result = jerry_set_property (..., new_prop_value);
/* If the property set is successful a new reference is created
/* If the property set is successful, a new reference is created
* for the value referenced by new_prop_value. The new_prop_value
* reference must be released regardless the operation is
* successful. */
* reference must be released regardless of whether the operation
* is successful. */
/* The new_prop_value can be passed to other JerryScript API
* functions before the jerry_release_value () call. */
jerry_release_value (new_prop_value);
/* The reference stored in 'result' variable contains whether
* the operation is successful and must also be freed. */
/* The reference stored in the 'result' variable is live whether
* the operation is successful or not, and must also be freed. */
if (jerry_value_has_error_flag (result))
{
@ -179,5 +181,5 @@ References can be duplicated in C as long as only one of them is freed.
jerry_release_value (c);
/* Both 'b' and 'c' (boolean true) references become dead. */
/* Since all references are released no memory leak is possible. */
/* Since all references are released, no memory leak occurs. */
```

View File

@ -16,7 +16,7 @@
{% else %}
<li><a href="{{ site.github.url }}/">Home</a></li>
{% endif %}
<li><a href="http://github.com/Samsung/jerryscript">View on Github</a></li>
<li><a href="http://github.com/jerryscript-project/jerryscript">View on Github</a></li>
<li><a href="http://www.iotjs.net">Powering <b>IoT.js</b></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">

View File

@ -17,7 +17,7 @@ permalink: /
</p>
</div>
<div class="learn_more">
<p>To learn more, please visit the <a href="http://github.com/Samsung/jerryscript">project on GitHub.</a></p>
<p>To learn more, please visit the <a href="http://github.com/jerryscript-project/jerryscript">project on GitHub.</a></p>
<p>If you want to try JerryScript take a look at our documentation. It includes <a href="{{ site.github.url }}/getting-started/">Getting Started</a> guides and <a href="{{ site.github.url }}/api-reference/">JerryScript APIs reference</a>. </p>
<p>Please, report all bugs and feature requests on JerryScript <a href="https://github.com/Samsung/jerryscript/issues">issue tracker</a>. Feel free to ask questions on <a href="https://github.com/Samsung/jerryscript/labels/question">issue tracker</a>.</p>
<p>Please, report all bugs and feature requests on JerryScript <a href="https://github.com/jerryscript-project/jerryscript/issues">issue tracker</a>. Feel free to ask questions on <a href="https://github.com/jerryscript-project/jerryscript/labels/question">issue tracker</a>.</p>
</div>