Skip to content

Commit 13d6b25

Browse files
author
Bela Toth
committed
Merge Promise Guard with ESNEXT
JerryScript-DCO-1.0-Signed-off-by: Bela Toth [email protected]
1 parent d69fe41 commit 13d6b25

29 files changed

+132
-172
lines changed

docs/02.API-REFERENCE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ jerry_value_is_object (const jerry_value_t value)
26812681
Returns whether the given `jerry_value_t` is a promise value.
26822682

26832683
*Notes*:
2684-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
2684+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
26852685
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
26862686
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
26872687
- The es.next profile enables this by default.
@@ -5391,7 +5391,7 @@ The function returns the result of a Promise object.
53915391
*Notes*:
53925392
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
53935393
is no longer needed.
5394-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5394+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
53955395
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
53965396
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
53975397
- The es.next profile enables this by default.
@@ -5458,7 +5458,7 @@ example (void)
54585458
*Notes*:
54595459
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
54605460
is no longer needed.
5461-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5461+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
54625462
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
54635463
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
54645464
- The es.next profile enables this by default.
@@ -5708,7 +5708,7 @@ Resolve or reject the promise with an argument.
57085708
*Note*:
57095709
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
57105710
is no longer needed.
5711-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5711+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
57125712
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
57135713
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
57145714
- The es.next profile enables this by default.

jerry-core/api/jerry.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ JERRY_STATIC_ASSERT ((int) RE_FLAG_GLOBAL == (int) JERRY_REGEXP_FLAG_GLOBAL
6666
re_flags_t_must_be_equal_to_jerry_regexp_flags_t);
6767
#endif /* JERRY_BUILTIN_REGEXP */
6868

69-
#if JERRY_BUILTIN_PROMISE
69+
#if JERRY_ESNEXT
7070
/* The internal ECMA_PROMISE_STATE_* values are "one byte away" from the API values */
7171
JERRY_STATIC_ASSERT ((int) ECMA_PROMISE_IS_PENDING == (int) JERRY_PROMISE_STATE_PENDING
7272
&& (int) ECMA_PROMISE_IS_FULFILLED == (int) JERRY_PROMISE_STATE_FULFILLED,
7373
promise_internal_state_matches_external);
74-
#endif /* JERRY_BUILTIN_PROMISE */
74+
#endif /* JERRY_ESNEXT */
7575

7676
/**
7777
* Offset between internal and external arithmetic operator types
@@ -210,9 +210,9 @@ jerry_cleanup (void)
210210
}
211211
}
212212

213-
#if JERRY_BUILTIN_PROMISE
213+
#if JERRY_ESNEXT
214214
ecma_free_all_enqueued_jobs ();
215-
#endif /* JERRY_BUILTIN_PROMISE */
215+
#endif /* JERRY_ESNEXT */
216216
ecma_finalize ();
217217
jerry_make_api_unavailable ();
218218

@@ -1115,11 +1115,11 @@ jerry_run_all_enqueued_jobs (void)
11151115
{
11161116
jerry_assert_api_available ();
11171117

1118-
#if JERRY_BUILTIN_PROMISE
1118+
#if JERRY_ESNEXT
11191119
return ecma_process_all_enqueued_jobs ();
1120-
#else /* !JERRY_BUILTIN_PROMISE */
1120+
#else /* !JERRY_ESNEXT */
11211121
return ECMA_VALUE_UNDEFINED;
1122-
#endif /* JERRY_BUILTIN_PROMISE */
1122+
#endif /* JERRY_ESNEXT */
11231123
} /* jerry_run_all_enqueued_jobs */
11241124

11251125
/**
@@ -1346,13 +1346,13 @@ bool
13461346
jerry_value_is_promise (const jerry_value_t value) /**< api value */
13471347
{
13481348
jerry_assert_api_available ();
1349-
#if JERRY_BUILTIN_PROMISE
1349+
#if JERRY_ESNEXT
13501350
return (ecma_is_value_object (value)
13511351
&& ecma_is_promise (ecma_get_object_from_value (value)));
1352-
#else /* !JERRY_BUILTIN_PROMISE */
1352+
#else /* !JERRY_ESNEXT */
13531353
JERRY_UNUSED (value);
13541354
return false;
1355-
#endif /* JERRY_BUILTIN_PROMISE */
1355+
#endif /* JERRY_ESNEXT */
13561356
} /* jerry_value_is_promise */
13571357

13581358
/**
@@ -1534,10 +1534,10 @@ static const uint8_t jerry_class_object_type[] =
15341534
#if JERRY_MODULE_SYSTEM
15351535
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
15361536
#endif
1537-
#if JERRY_BUILTIN_PROMISE
1537+
#if JERRY_ESNEXT
15381538
JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */
15391539
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
1540-
#endif /* JERRY_BUILTIN_PROMISE */
1540+
#endif /* JERRY_ESNEXT */
15411541
#if JERRY_BUILTIN_DATAVIEW
15421542
JERRY_OBJECT_TYPE_DATAVIEW, /**< type of ECMA_OBJECT_CLASS_DATAVIEW */
15431543
#endif /* JERRY_BUILTIN_DATAVIEW */
@@ -1795,10 +1795,8 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
17951795
#if JERRY_BUILTIN_JSON
17961796
|| feature == JERRY_FEATURE_JSON
17971797
#endif /* JERRY_BUILTIN_JSON */
1798-
#if JERRY_BUILTIN_PROMISE
1799-
|| feature == JERRY_FEATURE_PROMISE
1800-
#endif /* JERRY_BUILTIN_PROMISE */
18011798
#if JERRY_ESNEXT
1799+
|| feature == JERRY_FEATURE_PROMISE
18021800
|| feature == JERRY_FEATURE_SYMBOL
18031801
#endif /* JERRY_ESNEXT */
18041802
#if JERRY_BUILTIN_TYPEDARRAY
@@ -2552,13 +2550,13 @@ jerry_create_promise (void)
25522550
{
25532551
jerry_assert_api_available ();
25542552

2555-
#if JERRY_BUILTIN_PROMISE
2553+
#if JERRY_ESNEXT
25562554
ecma_value_t promise_value = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
25572555

25582556
return promise_value;
2559-
#else /* !JERRY_BUILTIN_PROMISE */
2557+
#else /* !JERRY_ESNEXT */
25602558
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
2561-
#endif /* JERRY_BUILTIN_PROMISE */
2559+
#endif /* JERRY_ESNEXT */
25622560
} /* jerry_create_promise */
25632561

25642562
/**
@@ -4754,7 +4752,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value *
47544752
{
47554753
jerry_assert_api_available ();
47564754

4757-
#if JERRY_BUILTIN_PROMISE
4755+
#if JERRY_ESNEXT
47584756
if (!ecma_is_value_object (promise) || !ecma_is_promise (ecma_get_object_from_value (promise)))
47594757
{
47604758
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -4771,13 +4769,13 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value *
47714769
}
47724770

47734771
return ecma_reject_promise_with_checks (promise, argument);
4774-
#else /* !JERRY_BUILTIN_PROMISE */
4772+
#else /* !JERRY_ESNEXT */
47754773
JERRY_UNUSED (promise);
47764774
JERRY_UNUSED (argument);
47774775
JERRY_UNUSED (is_resolve);
47784776

47794777
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
4780-
#endif /* JERRY_BUILTIN_PROMISE */
4778+
#endif /* JERRY_ESNEXT */
47814779
} /* jerry_resolve_or_reject_promise */
47824780

47834781
/**
@@ -4791,17 +4789,17 @@ jerry_get_promise_result (const jerry_value_t promise) /**< promise object to ge
47914789
{
47924790
jerry_assert_api_available ();
47934791

4794-
#if JERRY_BUILTIN_PROMISE
4792+
#if JERRY_ESNEXT
47954793
if (!jerry_value_is_promise (promise))
47964794
{
47974795
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
47984796
}
47994797

48004798
return ecma_promise_get_result (ecma_get_object_from_value (promise));
4801-
#else /* !JERRY_BUILTIN_PROMISE */
4799+
#else /* !JERRY_ESNEXT */
48024800
JERRY_UNUSED (promise);
48034801
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
4804-
#endif /* JERRY_BUILTIN_PROMISE */
4802+
#endif /* JERRY_ESNEXT */
48054803
} /* jerry_get_promise_result */
48064804

48074805
/**
@@ -4816,7 +4814,7 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
48164814
{
48174815
jerry_assert_api_available ();
48184816

4819-
#if JERRY_BUILTIN_PROMISE
4817+
#if JERRY_ESNEXT
48204818
if (!jerry_value_is_promise (promise))
48214819
{
48224820
return JERRY_PROMISE_STATE_NONE;
@@ -4826,10 +4824,10 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
48264824
flags &= (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED);
48274825

48284826
return (flags ? flags : JERRY_PROMISE_STATE_REJECTED);
4829-
#else /* !JERRY_BUILTIN_PROMISE */
4827+
#else /* !JERRY_ESNEXT */
48304828
JERRY_UNUSED (promise);
48314829
return JERRY_PROMISE_STATE_NONE;
4832-
#endif /* JERRY_BUILTIN_PROMISE */
4830+
#endif /* JERRY_ESNEXT */
48334831
} /* jerry_get_promise_state */
48344832

48354833
/**
@@ -4844,7 +4842,7 @@ void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< comb
48444842
{
48454843
jerry_assert_api_available ();
48464844

4847-
#if JERRY_BUILTIN_PROMISE && JERRY_PROMISE_CALLBACK
4845+
#if JERRY_ESNEXT && JERRY_PROMISE_CALLBACK
48484846
if (filters == JERRY_PROMISE_EVENT_FILTER_DISABLE || callback == NULL)
48494847
{
48504848
JERRY_CONTEXT (promise_callback_filters) = JERRY_PROMISE_EVENT_FILTER_DISABLE;
@@ -4854,11 +4852,11 @@ void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< comb
48544852
JERRY_CONTEXT (promise_callback_filters) = (uint32_t) filters;
48554853
JERRY_CONTEXT (promise_callback) = callback;
48564854
JERRY_CONTEXT (promise_callback_user_p) = user_p;
4857-
#else /* !JERRY_BUILTIN_PROMISE && !JERRY_PROMISE_CALLBACK */
4855+
#else /* !JERRY_ESNEXT && !JERRY_PROMISE_CALLBACK */
48584856
JERRY_UNUSED (filters);
48594857
JERRY_UNUSED (callback);
48604858
JERRY_UNUSED (user_p);
4861-
#endif /* JERRY_BUILTIN_PROMISE && JERRY_PROMISE_CALLBACK */
4859+
#endif /* JERRY_ESNEXT && JERRY_PROMISE_CALLBACK */
48624860
} /* jerry_promise_set_callback */
48634861

48644862
/**

jerry-core/config.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@
9595
# define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT
9696
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
9797

98-
#ifndef JERRY_BUILTIN_PROMISE
99-
# define JERRY_BUILTIN_PROMISE JERRY_ESNEXT
100-
#endif /* !defined (JERRY_BUILTIN_PROMISE) */
101-
10298
#ifndef JERRY_BUILTIN_PROXY
10399
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT
104100
#endif /* !defined (JERRY_BUILTIN_PROXY) */
@@ -552,12 +548,8 @@
552548
|| ((JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1))
553549
# error "Invalid value for JERRY_BUILTIN_WEAKREF macro."
554550
#endif
555-
#if !defined (JERRY_BUILTIN_PROMISE) \
556-
|| ((JERRY_BUILTIN_PROMISE != 0) && (JERRY_BUILTIN_PROMISE != 1))
557-
# error "Invalid value for JERRY_BUILTIN_PROMISE macro."
558-
#endif
559551
#if !defined (JERRY_BUILTIN_PROXY) \
560-
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1))
552+
|| ((JERRY_ESNEXT != 0) && (JERRY_BUILTIN_PROXY != 1))
561553
# error "Invalid value for JERRY_BUILTIN_PROXY macro."
562554
#endif
563555
#if !defined (JERRY_BUILTIN_TYPEDARRAY) \
@@ -575,10 +567,8 @@
575567
#if (JERRY_ESNEXT == 0) \
576568
&& ((JERRY_BUILTIN_DATAVIEW == 1) \
577569
|| (JERRY_BUILTIN_CONTAINER == 1) \
578-
|| (JERRY_BUILTIN_PROMISE == 1) \
579570
|| (JERRY_BUILTIN_PROXY == 1) \
580571
|| (JERRY_BUILTIN_REFLECT == 1) \
581-
|| (JERRY_BUILTIN_PROMISE == 1) \
582572
|| (JERRY_BUILTIN_TYPEDARRAY == 1) \
583573
|| (JERRY_BUILTIN_WEAKREF == 1))
584574
# error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_xxxxx macro."
@@ -705,9 +695,9 @@
705695
/**
706696
* Promise support must be enabled if Promise callback support is enabled.
707697
*/
708-
#if JERRY_PROMISE_CALLBACK && !JERRY_BUILTIN_PROMISE
709-
# error "Promise callback support depends on Promise support"
710-
#endif /* JERRY_PROMISE_CALLBACK && !JERRY_BUILTIN_PROMISE */
698+
#if JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT
699+
# error "Promise callback support depends on ESNext support"
700+
#endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */
711701

712702
/**
713703
* Resource name related types into a single guard

jerry-core/debugger/debugger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,13 +1457,13 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
14571457
string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL;
14581458
break;
14591459
}
1460-
#if JERRY_BUILTIN_PROMISE
1460+
#if JERRY_ESNEXT
14611461
case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE:
14621462
{
14631463
string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL;
14641464
break;
14651465
}
1466-
#endif /* JERRY_BUILTIN_PROMISE */
1466+
#endif /* JERRY_ESNEXT */
14671467
case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE:
14681468
{
14691469
string_id = LIT_MAGIC_STRING_URI_ERROR_UL;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,11 @@ const char * const ecma_error_json_not_supported_p = "JSON support is disabled";
4646
* Error message, if Symbol support is disabled
4747
*/
4848
const char * const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
49-
#endif /* !JERRY_ESNEXT */
50-
51-
#if !JERRY_BUILTIN_PROMISE
5249
/**
5350
* Error message, if Promise support is disabled
5451
*/
5552
const char * const ecma_error_promise_not_supported_p = "Promise support is disabled";
56-
#endif /* !JERRY_BUILTIN_PROMISE */
53+
#endif /* !JERRY_ESNEXT */
5754

5855
#if !JERRY_BUILTIN_TYPEDARRAY
5956
/**

jerry-core/ecma/base/ecma-errors.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ extern const char * const ecma_error_json_not_supported_p;
3333

3434
#if !JERRY_ESNEXT
3535
extern const char * const ecma_error_symbol_not_supported_p;
36-
#endif /* !JERRY_ESNEXT */
3736

38-
#if !JERRY_BUILTIN_PROMISE
3937
extern const char * const ecma_error_promise_not_supported_p;
40-
#endif /* !JERRY_BUILTIN_PROMISE */
38+
#endif /* !JERRY_ESNEXT */
4139

4240
#if !JERRY_BUILTIN_TYPEDARRAY
4341
extern const char * const ecma_error_typed_array_not_supported_p;

0 commit comments

Comments
 (0)