Skip to content

Commit f8faf57

Browse files
authored
Rename resource_name to source_name (#4846)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent 51da155 commit f8faf57

24 files changed

+171
-170
lines changed

docs/02.API-REFERENCE.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Flags for [jerry_exec_snapshot](#jerry_exec_snapshot) functions:
324324
- JERRY_SNAPSHOT_EXEC_COPY_DATA - copy snapshot data into memory (see below)
325325
- JERRY_SNAPSHOT_EXEC_ALLOW_STATIC - allow executing static snapshots
326326
- JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION - load snapshot as function instead of executing it
327-
- JERRY_SNAPSHOT_EXEC_HAS_RESOURCE - `source_name` field is valid
327+
- JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME - `source_name` field is valid
328328
in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t)
329329
- JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE - `user_value` field is valid
330330
in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t)
@@ -560,7 +560,7 @@ typedef struct
560560
uint32_t options; /**< combination of jerry_parse_option_enable_feature_t values */
561561
jerry_value_t argument_list; /**< function argument list if JERRY_PARSE_HAS_ARGUMENT_LIST is set in options
562562
* Note: must be string value */
563-
jerry_value_t source_name; /**< resource name string (usually a file name)
563+
jerry_value_t source_name; /**< source name string (usually a file name)
564564
* if JERRY_PARSE_HAS_SOURCE_NAME is set in options
565565
* Note: must be string value */
566566
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
626626
```c
627627
typedef struct
628628
{
629-
jerry_value_t source_name; /**< resource name */
629+
jerry_value_t source_name; /**< source name */
630630
jerry_size_t line; /**< line index */
631631
jerry_size_t column; /**< column index */
632632
} jerry_frame_location_t;
@@ -1398,8 +1398,8 @@ Various configuration options for [jerry_exec_snapshot](#jerry_exec_snapshot)
13981398
```c
13991399
typedef struct
14001400
{
1401-
jerry_value_t source_name; /**< resource name string (usually a file name)
1402-
* if JERRY_SNAPSHOT_EXEC_HAS_RESOURCE is set in exec_snapshot_opts
1401+
jerry_value_t source_name; /**< source name string (usually a file name)
1402+
* if JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME is set in exec_snapshot_opts
14031403
* Note: non-string values are ignored */
14041404
jerry_value_t user_value; /**< user value assigned to all functions created by this script including
14051405
* eval calls executed by the script if JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE
@@ -11575,7 +11575,7 @@ main (void)
1157511575

1157611576
**Summary**
1157711577

11578-
Get the resource name (usually a file name) of the currently executed script or the given function object.
11578+
Get the source name (usually a file name) of the currently executed script or the given function object.
1157911579

1158011580
This function is typically called from native callbacks.
1158111581

@@ -11592,17 +11592,17 @@ is no longer needed.
1159211592
jerry_value_t
1159311593
jerry_source_name (jerry_value_t value);
1159411594
```
11595-
- `value` - api value to obtain the resource name from
11595+
- `value` - api value to obtain the source name from
1159611596
- return string value constructed from
11597-
- the currently executed function object's resource name, if the given value is undefined
11598-
- resource name of the function object, if the given value is a function object
11597+
- the currently executed function object's source name, if the given value is undefined
11598+
- source name of the function object, if the given value is a function object
1159911599
- "<anonymous>", otherwise
1160011600

1160111601
*New in version 2.2*.
1160211602

1160311603
**Example**
1160411604

11605-
[doctest]: # (name="02.API-REFERENCE-jsresourcename.c")
11605+
[doctest]: # (name="02.API-REFERENCE-jssourcename.c")
1160611606

1160711607
```c
1160811608
#include <stdio.h>
@@ -11628,10 +11628,10 @@ main (void)
1162811628

1162911629
jerry_value_t global = jerry_current_realm ();
1163011630

11631-
/* Register the "resourceName" method. */
11631+
/* Register the sourceName" method. */
1163211632
{
1163311633
jerry_value_t func = jerry_function_external (source_name_handler);
11634-
jerry_value_t name = jerry_string_sz ("resourceName");
11634+
jerry_value_t name = jerry_string_sz ("sourceName");
1163511635
jerry_value_t result = jerry_object_set (global, name, func);
1163611636
jerry_value_free (result);
1163711637
jerry_value_free (name);
@@ -11640,7 +11640,7 @@ main (void)
1164011640

1164111641
jerry_value_free (global);
1164211642

11643-
const jerry_char_t source[] = "function myFunction() { return resourceName() }; myFunction()";
11643+
const jerry_char_t source[] = "function myFunction() { return sourceName() }; myFunction()";
1164411644

1164511645
jerry_parse_options_t parse_options;
1164611646
parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME;

docs/07.DEBUGGER.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ Currently, `jerryx_debugger_rp_create ()` for raw packet transport layer and
7474
`jerryx_debugger_serial_create (const char* config)` for serial protocol
7575
are also available.)
7676

77-
The resource name provided to `jerry_parse ()` is used by the client
78-
to identify the resource name of the source code. This resource name
77+
The source name provided to `jerry_parse ()` is used by the client
78+
to identify the source name of the source code. This source name
7979
is usually a file name.
8080

8181
## JerryScript debugger C-API interface
@@ -103,8 +103,8 @@ typedef jerry_value_t
103103
size_t source_size, void *user_p);
104104
```
105105

106-
- `source_name_p` - resource (usually a file) name of the source code
107-
- `source_name_size` - size of resource name
106+
- `source_name_p` - source (usually a file) name of the source code
107+
- `source_name_size` - size of source name
108108
- `source_p` - source code character data
109109
- `source_size` - size of source code
110110
- `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
306306
* Runs the source code received by jerry_debugger_wait_for_client_source.
307307
*/
308308
static jerry_value_t
309-
wait_for_source_callback (const jerry_char_t *source_name_p, /**< resource name */
310-
size_t source_name_size, /**< size of resource name */
309+
wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */
310+
size_t source_name_size, /**< size of source name */
311311
const jerry_char_t *source_p, /**< source code */
312312
size_t source_size, /**< source code size */
313313
void *user_p /**< user pointer */)

jerry-core/api/jerry-snapshot.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,10 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
643643
}
644644
#endif /* JERRY_ESNEXT */
645645

646-
#if JERRY_RESOURCE_NAME
647-
/* resource name */
646+
#if JERRY_SOURCE_NAME
647+
/* source name */
648648
extra_bytes += (uint32_t) sizeof (ecma_value_t);
649-
#endif /* JERRY_RESOURCE_NAME */
649+
#endif /* JERRY_SOURCE_NAME */
650650

651651
new_code_size = JERRY_ALIGNUP (new_code_size + extra_bytes, JMEM_ALIGNMENT);
652652

@@ -880,7 +880,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
880880

881881
uint32_t allowed_opts =
882882
(JERRY_SNAPSHOT_EXEC_COPY_DATA | JERRY_SNAPSHOT_EXEC_ALLOW_STATIC | JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION
883-
| JERRY_SNAPSHOT_EXEC_HAS_RESOURCE | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
883+
| JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
884884

885885
if ((exec_snapshot_opts & ~(allowed_opts)) != 0)
886886
{
@@ -955,18 +955,18 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
955955
script_p->realm_p = (ecma_object_t *) JERRY_CONTEXT (global_object_p);
956956
#endif /* JERRY_BUILTIN_REALMS */
957957

958-
#if JERRY_RESOURCE_NAME
959-
ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
958+
#if JERRY_SOURCE_NAME
959+
ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON);
960960

961-
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE) && option_values_p != NULL
961+
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME) && option_values_p != NULL
962962
&& ecma_is_value_string (option_values_p->source_name) > 0)
963963
{
964964
ecma_ref_ecma_string (ecma_get_string_from_value (option_values_p->source_name));
965965
source_name = option_values_p->source_name;
966966
}
967967

968968
script_p->source_name = source_name;
969-
#endif /* JERRY_RESOURCE_NAME */
969+
#endif /* JERRY_SOURCE_NAME */
970970

971971
#if JERRY_FUNCTION_TO_STRING
972972
script_p->source_code = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);

jerry-core/api/jerryscript.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,19 +5364,19 @@ jerry_frame_is_strict (jerry_frame_t *frame_p) /**< frame pointer */
53645364
} /* jerry_frame_is_strict */
53655365

53665366
/**
5367-
* Get the resource name (usually a file name) of the currently executed script or the given function object
5367+
* Get the source name (usually a file name) of the currently executed script or the given function object
53685368
*
53695369
* Note: returned value must be freed with jerry_value_free, when it is no longer needed
53705370
*
53715371
* @return JS string constructed from
5372-
* - the currently executed function object's resource name, if the given value is undefined
5373-
* - resource name of the function object, if the given value is a function object
5372+
* - the currently executed function object's source name, if the given value is undefined
5373+
* - source name of the function object, if the given value is a function object
53745374
* - "<anonymous>", otherwise
53755375
*/
53765376
jerry_value_t
53775377
jerry_source_name (const jerry_value_t value) /**< jerry api value */
53785378
{
5379-
#if JERRY_RESOURCE_NAME
5379+
#if JERRY_SOURCE_NAME
53805380
if (ecma_is_value_undefined (value) && JERRY_CONTEXT (vm_top_context_p) != NULL)
53815381
{
53825382
return ecma_copy_value (ecma_get_source_name (JERRY_CONTEXT (vm_top_context_p)->shared_p->bytecode_header_p));
@@ -5386,16 +5386,16 @@ jerry_source_name (const jerry_value_t value) /**< jerry api value */
53865386

53875387
if (script_value == JMEM_CP_NULL)
53885388
{
5389-
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
5389+
return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON);
53905390
}
53915391

53925392
const cbc_script_t *script_p = ECMA_GET_INTERNAL_VALUE_POINTER (cbc_script_t, script_value);
53935393

53945394
return ecma_copy_value (script_p->source_name);
5395-
#else /* !JERRY_RESOURCE_NAME */
5395+
#else /* !JERRY_SOURCE_NAME */
53965396
JERRY_UNUSED (value);
5397-
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
5398-
#endif /* JERRY_RESOURCE_NAME */
5397+
return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON);
5398+
#endif /* JERRY_SOURCE_NAME */
53995399
} /* jerry_source_name */
54005400

54015401
/**

jerry-core/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,12 @@
716716
#endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */
717717

718718
/**
719-
* Resource name related types into a single guard
719+
* Source name related types into a single guard
720720
*/
721721
#if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM
722-
#define JERRY_RESOURCE_NAME 1
722+
#define JERRY_SOURCE_NAME 1
723723
#else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */
724-
#define JERRY_RESOURCE_NAME 0
724+
#define JERRY_SOURCE_NAME 0
725725
#endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */
726726

727727
#endif /* !JERRYSCRIPT_CONFIG_H */

jerry-core/ecma/base/ecma-helpers.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,9 +1433,9 @@ ecma_script_deref (ecma_value_t script_value) /**< script value */
14331433
}
14341434
}
14351435

1436-
#if JERRY_RESOURCE_NAME
1436+
#if JERRY_SOURCE_NAME
14371437
ecma_deref_ecma_string (ecma_get_string_from_value (script_p->source_name));
1438-
#endif /* JERRY_RESOURCE_NAME */
1438+
#endif /* JERRY_SOURCE_NAME */
14391439

14401440
#if JERRY_MODULE_SYSTEM
14411441
if (type & CBC_SCRIPT_HAS_IMPORT_META)
@@ -1773,27 +1773,27 @@ ecma_compiled_code_get_line_info (const ecma_compiled_code_t *bytecode_header_p)
17731773
#endif /* JERRY_LINE_INFO */
17741774

17751775
/**
1776-
* Get the resource name of a compiled code.
1776+
* Get the source name of a compiled code.
17771777
*
1778-
* @return resource name value
1778+
* @return source name value
17791779
*/
17801780
ecma_value_t
17811781
ecma_get_source_name (const ecma_compiled_code_t *bytecode_p) /**< compiled code */
17821782
{
1783-
#if JERRY_RESOURCE_NAME
1783+
#if JERRY_SOURCE_NAME
17841784
#if JERRY_SNAPSHOT_EXEC
17851785
if (JERRY_UNLIKELY (bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
17861786
{
1787-
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
1787+
return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON);
17881788
}
17891789
#endif /* JERRY_SNAPSHOT_EXEC */
17901790

17911791
ecma_value_t script_value = ((cbc_uint8_arguments_t *) bytecode_p)->script_value;
17921792
return ECMA_GET_INTERNAL_VALUE_POINTER (cbc_script_t, script_value)->source_name;
1793-
#else /* !JERRY_RESOURCE_NAME */
1793+
#else /* !JERRY_SOURCE_NAME */
17941794
JERRY_UNUSED (bytecode_p);
1795-
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
1796-
#endif /* !JERRY_RESOURCE_NAME */
1795+
return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON);
1796+
#endif /* !JERRY_SOURCE_NAME */
17971797
} /* ecma_get_source_name */
17981798

17991799
#if (JERRY_STACK_LIMIT != 0)

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*
4848
* See also: ECMAScript v6, 9.2.1.1
4949
*
50-
* @return resource name as ecma-string
50+
* @return source name as ecma-string
5151
*/
5252
ecma_value_t
5353
ecma_op_function_form_name (ecma_string_t *prop_name_p, /**< property name */

jerry-core/include/jerryscript-debugger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef enum
4343
/**
4444
* Callback for jerry_debugger_wait_and_run_client_source
4545
*
46-
* The callback receives the resource name, source code and a user pointer.
46+
* The callback receives the source name, source code and a user pointer.
4747
*
4848
* @return this value is passed back by jerry_debugger_wait_and_run_client_source
4949
*/

jerry-core/include/jerryscript-snapshot.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ typedef enum
4545
JERRY_SNAPSHOT_EXEC_COPY_DATA = (1u << 0), /**< copy snashot data */
4646
JERRY_SNAPSHOT_EXEC_ALLOW_STATIC = (1u << 1), /**< static snapshots allowed */
4747
JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION = (1u << 2), /**< load snapshot as function instead of executing it */
48-
JERRY_SNAPSHOT_EXEC_HAS_RESOURCE = (1u << 3), /**< source_name field is valid
49-
* in jerry_exec_snapshot_option_values_t */
48+
JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME = (1u << 3), /**< source_name field is valid
49+
* in jerry_exec_snapshot_option_values_t */
5050
JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE = (1u << 4), /**< user_value field is valid
5151
* in jerry_exec_snapshot_option_values_t */
5252
} jerry_exec_snapshot_opts_t;
@@ -56,8 +56,8 @@ typedef enum
5656
*/
5757
typedef struct
5858
{
59-
jerry_value_t source_name; /**< resource name string (usually a file name)
60-
* if JERRY_SNAPSHOT_EXEC_HAS_RESOURCE is set in exec_snapshot_opts
59+
jerry_value_t source_name; /**< source name string (usually a file name)
60+
* if JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME is set in exec_snapshot_opts
6161
* Note: non-string values are ignored */
6262
jerry_value_t user_value; /**< user value assigned to all functions created by this script including
6363
* eval calls executed by the script if JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE

jerry-core/include/jerryscript-types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ typedef enum
441441
*/
442442
typedef struct
443443
{
444-
jerry_value_t source_name; /**< resource name */
444+
jerry_value_t source_name; /**< source name */
445445
jerry_size_t line; /**< line index */
446446
jerry_size_t column; /**< column index */
447447
} jerry_frame_location_t;

0 commit comments

Comments
 (0)