aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorZoltan Herczeg <zherczeg.u-szeged@partner.samsung.com>2017-09-21 11:03:23 +0200
committerDániel Bátyai <dbatyai@inf.u-szeged.hu>2017-09-21 11:03:23 +0200
commit8d916a44f1d0578c0ad3fee8eb5613c2f0ef8f70 (patch)
treeff98cf2320b08ddd5fc96eca4268d61cfb2b1747 /docs
parent7713d307028e67b056e221a6bd400134c947e423 (diff)
Parse functions directly (#2015)
This patch adds direct function source code parsing, which is useful to avoid source code duplications. The patch also improves the Function constructor. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Diffstat (limited to 'docs')
-rw-r--r--docs/02.API-REFERENCE.md59
1 files changed, 48 insertions, 11 deletions
diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md
index 1cfb909c..9113a02a 100644
--- a/docs/02.API-REFERENCE.md
+++ b/docs/02.API-REFERENCE.md
@@ -667,7 +667,7 @@ jerry_parse (const jerry_char_t *source_p,
bool is_strict);
```
-- `source_p` - string, containing source code to parse. It must be a valid utf8 string.
+- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
- `source_size` - size of the string, in bytes.
- `is_strict` - defines strict mode.
- return value
@@ -706,8 +706,8 @@ main (void)
**Summary**
Parse script and construct an ECMAScript function. The lexical
-environment is set to the global lexical environment. The name
-(usually a file name) is also passed to this function which is
+environment is set to the global lexical environment. The resource
+name (usually a file name) is also passed to this function which is
used by the debugger to find the source code.
*Note*: The returned value must be freed with [jerry_release_value](#jerry_release_value) when it
@@ -717,25 +717,62 @@ is no longer needed.
```c
jerry_value_t
-jerry_parse_named_resource (const jerry_char_t *name_p, /**< name (usually a file name) */
- size_t name_length, /**< length of name */
+jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
+ size_t resource_name_length, /**< length of resource name */
const jerry_char_t *source_p, /**< script source */
size_t source_size, /**< script source size */
bool is_strict) /**< strict mode */
-{
```
-- `name_p` - name, usually a file name
-- `name_length` - size of the file name, in bytes
-- `source_p` - string, containing source code to parse. It must be a valid UTF8 string
-- `source_size` - size of the string, in bytes
-- `is_strict` - defines strict mode
+- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string).
+- `resource_name_length` - size of the resource name, in bytes.
+- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
+- `source_size` - size of the string, in bytes.
+- `is_strict` - defines strict mode.
- return value
- function object value, if script was parsed successfully,
- thrown error, otherwise
This function is identical to [jerry_parse](#jerry_parse), except that an additional filename parameter has been added.
+## jerry_parse_function
+
+**Summary**
+
+Parse function source code and construct an ECMAScript
+function. The function arguments and function body are
+passed as separated arguments. The lexical environment
+is set to the global lexical environment. The resource
+name (usually a file name) is also passed to this function
+which is used by the debugger to find the source code.
+
+*Note*: The returned value must be freed with [jerry_release_value](#jerry_release_value) when it
+is no longer needed.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
+ size_t resource_name_length, /**< length of resource name */
+ const jerry_char_t *arg_list_p, /**< script source */
+ size_t arg_list_size, /**< script source size */
+ const jerry_char_t *source_p, /**< script source */
+ size_t source_size, /**< script source size */
+ bool is_strict) /**< strict mode */
+```
+
+- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string).
+- `resource_name_length` - size of the resource name, in bytes.
+- `arg_list_p` - argument list of the function (must be a valid UTF8 string).
+- `arg_list_size` - size of the argument list, in bytes.
+- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
+- `source_size` - size of the string, in bytes.
+- `is_strict` - defines strict mode.
+- return value
+ - function object value, if script was parsed successfully,
+ - thrown error, otherwise
+
## jerry_run
**Summary**