Skip to content

Commit a264560

Browse files
akosthekissLaszloLango
authored andcommitted
Remove character pointer typedefs (#2492)
The `[jerry|ecma]_char_ptr_t` types are some old legacy that are used quite inconsistently. Their `[jerry|ecma]_char_t *` variants are used a lot more often, so it's better to stick to one form throughout the code base. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent df18930 commit a264560

File tree

11 files changed

+30
-52
lines changed

11 files changed

+30
-52
lines changed

docs/02.API-REFERENCE.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ Jerry's char value
143143
typedef uint8_t jerry_char_t;
144144
```
145145

146-
## jerry_char_ptr_t
147-
148-
**Summary**
149-
150-
Pointer to an array of character values
151-
152-
**Prototype**
153-
154-
```c
155-
typedef jerry_char_t *jerry_char_ptr_t;
156-
```
157-
158146
## jerry_size_t
159147

160148
**Summary**
@@ -646,7 +634,7 @@ Registers an external magic string array.
646634

647635
```c
648636
void
649-
jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p,
637+
jerry_register_magic_strings (const jerry_char_t **ex_str_items_p,
650638
uint32_t count,
651639
const jerry_length_t *str_lengths_p);
652640
```
@@ -669,12 +657,12 @@ main (void)
669657

670658
// must be static, because 'jerry_register_magic_strings' does not copy
671659
// the items must be sorted by size at first, then lexicographically
672-
static const jerry_char_ptr_t magic_string_items[] = {
673-
(const jerry_char_ptr_t) "magicstring1",
674-
(const jerry_char_ptr_t) "magicstring2",
675-
(const jerry_char_ptr_t) "magicstring3"
676-
};
677-
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_ptr_t));
660+
static const jerry_char_t *magic_string_items[] = {
661+
(const jerry_char_t *) "magicstring1",
662+
(const jerry_char_t *) "magicstring2",
663+
(const jerry_char_t *) "magicstring3"
664+
};
665+
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_t *));
678666

679667
// must be static, because 'jerry_register_magic_strings' does not copy
680668
static const jerry_length_t magic_string_lengths[] = {

jerry-core/api/jerry-snapshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
17051705
/* Save the array of literals. */
17061706
destination_p = jerry_append_chars_to_buffer (destination_p,
17071707
buffer_end_p,
1708-
";\n\njerry_char_ptr_t literals[",
1708+
";\n\njerry_char_t *literals[",
17091709
0);
17101710

17111711
destination_p = jerry_append_number_to_buffer (destination_p, buffer_end_p, literal_count);

jerry-core/api/jerry.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ jerry_get_context_data (const jerry_context_data_manager_t *manager_p)
257257
* Register external magic string array
258258
*/
259259
void
260-
jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, /**< character arrays, representing
261-
* external magic strings' contents */
260+
jerry_register_magic_strings (const jerry_char_t **ex_str_items_p, /**< character arrays, representing
261+
* external magic strings' contents */
262262
uint32_t count, /**< number of the strings */
263263
const jerry_length_t *str_lengths_p) /**< lengths of all strings */
264264
{

jerry-core/include/jerryscript-core.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ typedef enum
120120
*/
121121
typedef uint8_t jerry_char_t;
122122

123-
/**
124-
* Pointer to an array of character values.
125-
*/
126-
typedef jerry_char_t *jerry_char_ptr_t;
127-
128123
/**
129124
* Size type of JerryScript.
130125
*/
@@ -308,7 +303,7 @@ typedef struct jerry_instance_t jerry_instance_t;
308303
*/
309304
void jerry_init (jerry_init_flag_t flags);
310305
void jerry_cleanup (void);
311-
void jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, uint32_t count,
306+
void jerry_register_magic_strings (const jerry_char_t **ex_str_items_p, uint32_t count,
312307
const jerry_length_t *str_lengths_p);
313308
void jerry_gc (jerry_gc_mode_t mode);
314309
void *jerry_get_context_data (const jerry_context_data_manager_t *manager_p);

jerry-core/lit/lit-char-helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ lit_char_get_utf8_length (ecma_char_t chr) /**< EcmaScript character */
414414
bool
415415
lit_read_code_unit_from_hex (const lit_utf8_byte_t *buf_p, /**< buffer with characters */
416416
lit_utf8_size_t number_of_characters, /**< number of characters to be read */
417-
ecma_char_ptr_t out_code_unit_p) /**< [out] decoded result */
417+
ecma_char_t *out_code_unit_p) /**< [out] decoded result */
418418
{
419419
ecma_char_t code_unit = LIT_CHAR_NULL;
420420

jerry-core/lit/lit-char-helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ size_t lit_char_get_utf8_length (ecma_char_t chr);
220220

221221
/* read a hex encoded code point from a zero terminated buffer */
222222
bool lit_read_code_unit_from_hex (const lit_utf8_byte_t *buf_p, lit_utf8_size_t number_of_characters,
223-
ecma_char_ptr_t out_code_unit_p);
223+
ecma_char_t *out_code_unit_p);
224224

225225
/**
226226
* Null character

jerry-core/lit/lit-globals.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ typedef uint16_t ecma_char_t;
7878
*/
7979
typedef uint32_t ecma_length_t;
8080

81-
/**
82-
* Description of an ecma-character pointer
83-
*/
84-
typedef ecma_char_t *ecma_char_ptr_t;
85-
8681
/**
8782
* Max bytes needed to represent a code unit (utf-16 char) via utf-8 encoding
8883
*/

jerry-main/main-unix-snapshot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static uint8_t input_buffer[JERRY_BUFFER_SIZE];
4343
static uint32_t output_buffer[JERRY_BUFFER_SIZE / 4];
4444
static const char *output_file_name_p = "js.snapshot";
4545
static jerry_length_t magic_string_lengths[JERRY_LITERAL_LENGTH];
46-
static jerry_char_ptr_t magic_string_items[JERRY_LITERAL_LENGTH];
46+
static const jerry_char_t *magic_string_items[JERRY_LITERAL_LENGTH];
4747

4848
/**
4949
* Check whether JerryScript has a requested feature enabled or not. If not,
@@ -337,7 +337,7 @@ process_generate (cli_state_t *cli_state_p, /**< cli state */
337337
jerry_length_t mstr_size = (jerry_length_t) strtol (sp_buffer_p, &sp_buffer_end_p, 10);
338338
if (mstr_size > 0)
339339
{
340-
magic_string_items[num_of_lit] = (jerry_char_ptr_t) (sp_buffer_end_p + 1);
340+
magic_string_items[num_of_lit] = (jerry_char_t *) (sp_buffer_end_p + 1);
341341
magic_string_lengths[num_of_lit] = mstr_size;
342342
num_of_lit++;
343343
}

targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
extern uint32_t jsmbed_js_magic_string_count;
2222
extern uint32_t jsmbed_js_magic_string_values[];
2323

24-
extern const jerry_char_ptr_t jsmbed_js_magic_strings[];
24+
extern const jerry_char_t *jsmbed_js_magic_strings[];
2525
extern const jerry_length_t jsmbed_js_magic_string_lengths[];
2626

2727
void jsmbed_js_load_magic_strings() {

tests/unit-core/test-api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ const jerry_length_t magic_string_lengths[] =
191191
#undef JERRY_MAGIC_STRING_DEF
192192
};
193193

194-
const jerry_char_ptr_t magic_string_items[] =
194+
const jerry_char_t *magic_string_items[] =
195195
{
196196
#define JERRY_MAGIC_STRING_DEF(NAME, STRING) \
197-
(const jerry_char_ptr_t) jerry_magic_string_ex_ ## NAME,
197+
(const jerry_char_t *) jerry_magic_string_ex_ ## NAME,
198198

199199
JERRY_MAGIC_STRING_ITEMS
200200

@@ -1126,7 +1126,7 @@ main (void)
11261126
/* External Magic String */
11271127
jerry_init (JERRY_INIT_SHOW_OPCODES);
11281128

1129-
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_ptr_t));
1129+
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_t *));
11301130
jerry_register_magic_strings (magic_string_items,
11311131
num_magic_string_items,
11321132
magic_string_lengths);

0 commit comments

Comments
 (0)