Rename resource_name to source_name (#4846)

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
Yonggang Luo
2021-12-07 21:05:04 +08:00
committed by GitHub
parent 51da15516e
commit f8faf574b6
24 changed files with 171 additions and 170 deletions
+13 -13
View File
@@ -324,7 +324,7 @@ Flags for [jerry_exec_snapshot](#jerry_exec_snapshot) functions:
- JERRY_SNAPSHOT_EXEC_COPY_DATA - copy snapshot data into memory (see below)
- JERRY_SNAPSHOT_EXEC_ALLOW_STATIC - allow executing static snapshots
- JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION - load snapshot as function instead of executing it
- JERRY_SNAPSHOT_EXEC_HAS_RESOURCE - `source_name` field is valid
- JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME - `source_name` field is valid
in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t)
- JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE - `user_value` field is valid
in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t)
@@ -560,7 +560,7 @@ typedef struct
uint32_t options; /**< combination of jerry_parse_option_enable_feature_t values */
jerry_value_t argument_list; /**< function argument list if JERRY_PARSE_HAS_ARGUMENT_LIST is set in options
* Note: must be string value */
jerry_value_t source_name; /**< resource name string (usually a file name)
jerry_value_t source_name; /**< source name string (usually a file name)
* if JERRY_PARSE_HAS_SOURCE_NAME is set in options
* Note: must be string value */
uint32_t start_line; /**< start line of the source code if JERRY_PARSE_HAS_START is set in options */
@@ -626,7 +626,7 @@ Source code location data retrieved by
```c
typedef struct
{
jerry_value_t source_name; /**< resource name */
jerry_value_t source_name; /**< source name */
jerry_size_t line; /**< line index */
jerry_size_t column; /**< column index */
} jerry_frame_location_t;
@@ -1398,8 +1398,8 @@ Various configuration options for [jerry_exec_snapshot](#jerry_exec_snapshot)
```c
typedef struct
{
jerry_value_t source_name; /**< resource name string (usually a file name)
* if JERRY_SNAPSHOT_EXEC_HAS_RESOURCE is set in exec_snapshot_opts
jerry_value_t source_name; /**< source name string (usually a file name)
* if JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME is set in exec_snapshot_opts
* Note: non-string values are ignored */
jerry_value_t user_value; /**< user value assigned to all functions created by this script including
* eval calls executed by the script if JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE
@@ -11575,7 +11575,7 @@ main (void)
**Summary**
Get the resource name (usually a file name) of the currently executed script or the given function object.
Get the source name (usually a file name) of the currently executed script or the given function object.
This function is typically called from native callbacks.
@@ -11592,17 +11592,17 @@ is no longer needed.
jerry_value_t
jerry_source_name (jerry_value_t value);
```
- `value` - api value to obtain the resource name from
- `value` - api value to obtain the source name from
- return string value constructed from
- the currently executed function object's resource name, if the given value is undefined
- resource name of the function object, if the given value is a function object
- the currently executed function object's source name, if the given value is undefined
- source name of the function object, if the given value is a function object
- "<anonymous>", otherwise
*New in version 2.2*.
**Example**
[doctest]: # (name="02.API-REFERENCE-jsresourcename.c")
[doctest]: # (name="02.API-REFERENCE-jssourcename.c")
```c
#include <stdio.h>
@@ -11628,10 +11628,10 @@ main (void)
jerry_value_t global = jerry_current_realm ();
/* Register the "resourceName" method. */
/* Register the sourceName" method. */
{
jerry_value_t func = jerry_function_external (source_name_handler);
jerry_value_t name = jerry_string_sz ("resourceName");
jerry_value_t name = jerry_string_sz ("sourceName");
jerry_value_t result = jerry_object_set (global, name, func);
jerry_value_free (result);
jerry_value_free (name);
@@ -11640,7 +11640,7 @@ main (void)
jerry_value_free (global);
const jerry_char_t source[] = "function myFunction() { return resourceName() }; myFunction()";
const jerry_char_t source[] = "function myFunction() { return sourceName() }; myFunction()";
jerry_parse_options_t parse_options;
parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME;
+6 -6
View File
@@ -74,8 +74,8 @@ Currently, `jerryx_debugger_rp_create ()` for raw packet transport layer and
`jerryx_debugger_serial_create (const char* config)` for serial protocol
are also available.)
The resource name provided to `jerry_parse ()` is used by the client
to identify the resource name of the source code. This resource name
The source name provided to `jerry_parse ()` is used by the client
to identify the source name of the source code. This source name
is usually a file name.
## JerryScript debugger C-API interface
@@ -103,8 +103,8 @@ typedef jerry_value_t
size_t source_size, void *user_p);
```
- `source_name_p` - resource (usually a file) name of the source code
- `source_name_size` - size of resource name
- `source_name_p` - source (usually a file) name of the source code
- `source_name_size` - size of source name
- `source_p` - source code character data
- `source_size` - size of source code
- `user_p` - custom pointer passed to [jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source)
@@ -306,8 +306,8 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
* Runs the source code received by jerry_debugger_wait_for_client_source.
*/
static jerry_value_t
wait_for_source_callback (const jerry_char_t *source_name_p, /**< resource name */
size_t source_name_size, /**< size of resource name */
wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */
size_t source_name_size, /**< size of source name */
const jerry_char_t *source_p, /**< source code */
size_t source_size, /**< source code size */
void *user_p /**< user pointer */)