Skip to content

Commit e88d191

Browse files
committed
Style and comment fixes
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent d0b7bdf commit e88d191

File tree

11 files changed

+112
-82
lines changed

11 files changed

+112
-82
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
* See also:
5454
* ECMA-262 v5, B.2.5.1
5555
*
56-
* @return ecma value
56+
* @return undefined - if compiled successfully
57+
* error ecma value - otherwise
58+
*
5759
* Returned value must be freed with ecma_free_value.
5860
*/
5961
static ecma_value_t
@@ -240,8 +242,10 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
240242
* See also:
241243
* ECMA-262 v5, 15.10.6.2
242244
*
243-
* @return ecma value
244-
* Returned value must be freed with ecma_free_value.
245+
* @return array object containing the results - if the matched
246+
* null - otherwise
247+
*
248+
* May raise error, so returned value must be freed with ecma_free_value.
245249
*/
246250
static ecma_value_t
247251
ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */
@@ -314,8 +318,10 @@ ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */
314318
* See also:
315319
* ECMA-262 v5, 15.10.6.3
316320
*
317-
* @return ecma value
318-
* Returned value must be freed with ecma_free_value.
321+
* @return true - if match is not null
322+
* false - otherwise
323+
*
324+
* May raise error, so returned value must be freed with ecma_free_value.
319325
*/
320326
static ecma_value_t
321327
ecma_builtin_regexp_prototype_test (ecma_value_t this_arg, /**< this argument */
@@ -439,4 +445,4 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
439445
* @}
440446
*/
441447

442-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
448+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */

jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* Handle calling [[Call]] of built-in RegExp object
4747
*
4848
* @return ecma value
49+
* Returned value must be freed with ecma_free_value.
4950
*/
5051
ecma_value_t
5152
ecma_builtin_regexp_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
@@ -58,6 +59,7 @@ ecma_builtin_regexp_dispatch_call (const ecma_value_t *arguments_list_p, /**< ar
5859
* Handle calling [[Construct]] of built-in RegExp object
5960
*
6061
* @return ecma value
62+
* Returned value must be freed with ecma_free_value.
6163
*/
6264
ecma_value_t
6365
ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
@@ -152,4 +154,4 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /*
152154
* @}
153155
*/
154156

155-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
157+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */

jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.inc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ROUTINE (LIT_MAGIC_STRING_MATCH, ecma_builtin_string_prototype_object_match, 1,
7373
ROUTINE (LIT_MAGIC_STRING_REPLACE, ecma_builtin_string_prototype_object_replace, 2, 2)
7474
ROUTINE (LIT_MAGIC_STRING_SEARCH, ecma_builtin_string_prototype_object_search, 1, 1)
7575
ROUTINE (LIT_MAGIC_STRING_SPLIT, ecma_builtin_string_prototype_object_split, 2, 2)
76-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
76+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
7777

7878
ROUTINE (LIT_MAGIC_STRING_SUBSTRING, ecma_builtin_string_prototype_object_substring, 2, 2)
7979
ROUTINE (LIT_MAGIC_STRING_TO_LOWER_CASE_UL, ecma_builtin_string_prototype_object_to_lower_case, 0, 0)
@@ -84,7 +84,7 @@ ROUTINE (LIT_MAGIC_STRING_TRIM, ecma_builtin_string_prototype_object_trim, 0, 0)
8484

8585
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ANNEXB_BUILTIN
8686
ROUTINE (LIT_MAGIC_STRING_SUBSTR, ecma_builtin_string_prototype_object_substr, 2, 2)
87-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ANNEXB_BUILTIN */
87+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ANNEXB_BUILTIN */
8888

8989
#undef OBJECT_ID
9090
#undef SIMPLE_VALUE

jerry-core/ecma/operations/ecma-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,13 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
958958
{
959959
return LIT_MAGIC_STRING_DATE_UL;
960960
}
961-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */
961+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */
962962
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
963963
case ECMA_BUILTIN_ID_REGEXP_PROTOTYPE:
964964
{
965965
return LIT_MAGIC_STRING_REGEXP_UL;
966966
}
967-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
967+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
968968
default:
969969
{
970970
JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_GLOBAL));

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@
6565
*
6666
* See also: ECMA-262 v5, 15.10.4.1
6767
*
68-
* @return ecma value
68+
* @return empty ecma value - if parsed successfully
69+
* error ecma value - otherwise
70+
*
6971
* Returned value must be freed with ecma_free_value
7072
*/
7173
ecma_value_t
7274
re_parse_regexp_flags (ecma_string_t *flags_str_p, /**< Input string with flags */
73-
uint16_t *flags_p) /**< Output: parsed flag bits */
75+
uint16_t *flags_p) /**< [out] parsed flag bits */
7476
{
7577
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
7678

@@ -128,7 +130,7 @@ re_parse_regexp_flags (ecma_string_t *flags_str_p, /**< Input string with flags
128130
return ret_value;
129131
} /* re_parse_regexp_flags */
130132

131-
/*
133+
/**
132134
* Initializes the source, global, ignoreCase, multiline, and lastIndex properties of RegExp instance.
133135
*/
134136
void
@@ -228,7 +230,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
228230
*
229231
* See also: ECMA-262 v5, 15.10.4.1
230232
*
231-
* @return ecma value
233+
* @return constructed RegExp object
232234
* Returned value must be freed with ecma_free_value
233235
*/
234236
ecma_value_t
@@ -264,7 +266,9 @@ ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *bytecode_p) /**<
264266
*
265267
* See also: ECMA-262 v5, 15.10.4.1
266268
*
267-
* @return ecma value
269+
* @return constructed RegExp object - if pattern and flags were parsed successfully
270+
* error ecma value - otherwise
271+
*
268272
* Returned value must be freed with ecma_free_value
269273
*/
270274
ecma_value_t
@@ -372,14 +376,16 @@ re_canonicalize (ecma_char_t ch, /**< character */
372376
* See also:
373377
* ECMA-262 v5, 15.10.2.1
374378
*
375-
* @return ecma value
376-
* Returned value must be freed with ecma_free_value
379+
* @return true - if matched
380+
* false - otherwise
381+
*
382+
* May raise error, so returned value must be freed with ecma_free_value
377383
*/
378384
static ecma_value_t
379385
re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
380386
uint8_t *bc_p, /**< pointer to the current RegExp bytecode */
381387
lit_utf8_byte_t *str_p, /**< input string pointer */
382-
lit_utf8_byte_t **out_str_p) /**< Output: matching substring iterator */
388+
lit_utf8_byte_t **out_str_p) /**< [out] matching substring iterator */
383389
{
384390
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
385391
re_opcode_t op;
@@ -703,6 +709,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
703709
uint32_t offset = re_get_value (&bc_p);
704710
lit_utf8_byte_t *sub_str_p = NULL;
705711
ecma_value_t match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
712+
706713
if (ecma_is_value_true (match_value))
707714
{
708715
*out_str_p = sub_str_p;
@@ -712,6 +719,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
712719
{
713720
return match_value;
714721
}
722+
715723
bc_p += offset;
716724
old_bc_p = bc_p;
717725
}
@@ -844,6 +852,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
844852
{
845853
offset = re_get_value (&bc_p);
846854
ecma_value_t match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
855+
847856
if (ecma_is_value_true (match_value))
848857
{
849858
*out_str_p = sub_str_p;
@@ -853,6 +862,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
853862
{
854863
return match_value;
855864
}
865+
856866
bc_p += offset;
857867
old_bc_p = bc_p;
858868
}
@@ -920,6 +930,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
920930

921931
lit_utf8_byte_t *sub_str_p = NULL;
922932
ecma_value_t match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
933+
923934
if (ecma_is_value_true (match_value))
924935
{
925936
*out_str_p = sub_str_p;
@@ -1230,7 +1241,13 @@ re_set_result_array_properties (ecma_object_t *array_obj_p, /**< result array */
12301241
* RegExp helper function to start the recursive matching algorithm
12311242
* and create the result Array object
12321243
*
1233-
* @return ecma value
1244+
* See also:
1245+
* ECMA-262 v5, 15.10.6.2
1246+
*
1247+
* @return array object - if matched
1248+
* null - otherwise
1249+
*
1250+
* May raise error.
12341251
* Returned value must be freed with ecma_free_value
12351252
*/
12361253
ecma_value_t
@@ -1480,4 +1497,4 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
14801497
* @}
14811498
*/
14821499

1483-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
1500+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */

jerry-core/ecma/operations/ecma-regexp-object.h

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,48 +32,39 @@
3232
/**
3333
* RegExp flags
3434
*/
35-
#define RE_FLAG_GLOBAL (1u << 1) /* ECMA-262 v5, 15.10.7.2 */
36-
#define RE_FLAG_IGNORE_CASE (1u << 2) /* ECMA-262 v5, 15.10.7.3 */
37-
#define RE_FLAG_MULTILINE (1u << 3) /* ECMA-262 v5, 15.10.7.4 */
35+
typedef enum
36+
{
37+
RE_FLAG_GLOBAL = (1u << 1), /**< ECMA-262 v5, 15.10.7.2 */
38+
RE_FLAG_IGNORE_CASE = (1u << 2), /**< ECMA-262 v5, 15.10.7.3 */
39+
RE_FLAG_MULTILINE = (1u << 3) /**< ECMA-262 v5, 15.10.7.4 */
40+
} re_flags_t;
3841

3942
/**
4043
* RegExp executor context
4144
*/
4245
typedef struct
4346
{
44-
lit_utf8_byte_t **saved_p; /**< saved result string pointers, ECMA 262 v5, 15.10.2.1, State */
47+
lit_utf8_byte_t **saved_p; /**< saved result string pointers, ECMA 262 v5, 15.10.2.1, State */
4548
const lit_utf8_byte_t *input_start_p; /**< start of input pattern string */
46-
const lit_utf8_byte_t *input_end_p; /**< end of input pattern string */
47-
uint32_t num_of_captures; /**< number of capture groups */
48-
uint32_t num_of_non_captures; /**< number of non-capture groups */
49-
uint32_t *num_of_iterations_p; /**< number of iterations */
50-
uint16_t flags; /**< RegExp flags */
49+
const lit_utf8_byte_t *input_end_p; /**< end of input pattern string */
50+
uint32_t num_of_captures; /**< number of capture groups */
51+
uint32_t num_of_non_captures; /**< number of non-capture groups */
52+
uint32_t *num_of_iterations_p; /**< number of iterations */
53+
uint16_t flags; /**< RegExp flags */
5154
} re_matcher_ctx_t;
5255

53-
extern ecma_value_t
54-
ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *);
55-
56-
extern ecma_value_t
57-
ecma_op_create_regexp_object (ecma_string_t *, ecma_string_t *);
58-
59-
extern ecma_value_t
60-
ecma_regexp_exec_helper (ecma_value_t, ecma_value_t, bool);
61-
62-
extern ecma_char_t
63-
re_canonicalize (ecma_char_t, bool);
64-
extern void
65-
re_set_result_array_properties (ecma_object_t *, ecma_string_t *, uint32_t, int32_t);
66-
67-
extern ecma_value_t
68-
re_parse_regexp_flags (ecma_string_t *, uint16_t *);
69-
70-
extern void
71-
re_initialize_props (ecma_object_t *, ecma_string_t *, uint16_t);
56+
ecma_value_t ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *);
57+
ecma_value_t ecma_op_create_regexp_object (ecma_string_t *, ecma_string_t *);
58+
ecma_value_t ecma_regexp_exec_helper (ecma_value_t, ecma_value_t, bool);
59+
ecma_char_t re_canonicalize (ecma_char_t, bool);
60+
void re_set_result_array_properties (ecma_object_t *, ecma_string_t *, uint32_t, int32_t);
61+
ecma_value_t re_parse_regexp_flags (ecma_string_t *, uint16_t *);
62+
void re_initialize_props (ecma_object_t *, ecma_string_t *, uint16_t);
7263

7364
/**
7465
* @}
7566
* @}
7667
*/
7768

78-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
69+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
7970
#endif /* !ECMA_REGEXP_OBJECT_H */

jerry-core/parser/regexp/re-bytecode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,4 @@ re_dump_bytecode (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytecode context */
444444
* @}
445445
*/
446446

447-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
447+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */

jerry-core/parser/regexp/re-compiler.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler con
8787

8888
/**
8989
* Get the type of a group start
90+
*
91+
* @return RegExp opcode
9092
*/
9193
static re_opcode_t
9294
re_get_start_opcode_type (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
@@ -122,6 +124,8 @@ re_get_start_opcode_type (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler cont
122124

123125
/**
124126
* Get the type of a group end
127+
*
128+
* @return RegExp opcode
125129
*/
126130
static re_opcode_t
127131
re_get_end_opcode_type (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
@@ -202,7 +206,9 @@ re_insert_into_group_with_jump (re_compiler_ctx_t *re_ctx_p, /**< RegExp compile
202206
/**
203207
* Parse alternatives
204208
*
205-
* @return ecma value
209+
* @return empty ecma value - if alternative was successfully parsed
210+
* error ecma value - otherwise
211+
*
206212
* Returned value must be freed with ecma_free_value
207213
*/
208214
static ecma_value_t
@@ -481,7 +487,9 @@ re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
481487
/**
482488
* Compilation of RegExp bytecode
483489
*
484-
* @return ecma value
490+
* @return empty ecma value - if bytecode was compiled successfully
491+
* error ecma value - otherwise
492+
*
485493
* Returned value must be freed with ecma_free_value
486494
*/
487495
ecma_value_t
@@ -594,4 +602,4 @@ re_compile_bytecode (re_compiled_code_t **out_bytecode_p, /**< [out] pointer to
594602
* @}
595603
*/
596604

597-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
605+
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */

jerry-core/parser/regexp/re-parser.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ re_parse_octal (re_parser_ctx_t *parser_ctx_p) /**< RegExp parser context */
105105
/**
106106
* Parse RegExp iterators
107107
*
108-
* @return completion value
108+
* @return empty ecma value - if parsed successfully
109+
* error ecma value - otherwise
110+
*
109111
* Returned value must be freed with ecma_free_value
110112
*/
111113
static ecma_value_t
@@ -298,7 +300,9 @@ re_count_num_of_groups (re_parser_ctx_t *parser_ctx_p) /**< RegExp parser contex
298300
/**
299301
* Read the input pattern and parse the range of character class
300302
*
301-
* @return completion value
303+
* @return empty ecma value - if parsed successfully
304+
* error ecma value - otherwise
305+
*
302306
* Returned value must be freed with ecma_free_value
303307
*/
304308
ecma_value_t
@@ -556,7 +560,9 @@ re_parse_char_class (re_parser_ctx_t *parser_ctx_p, /**< number of classes */
556560
/**
557561
* Read the input pattern and parse the next token for the RegExp compiler
558562
*
559-
* @return completion value
563+
* @return empty ecma value - if parsed successfully
564+
* error ecma value - otherwise
565+
*
560566
* Returned value must be freed with ecma_free_value
561567
*/
562568
ecma_value_t

0 commit comments

Comments
 (0)