Skip to content

Commit f4b03fd

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

29 files changed

+135
-171
lines changed

docs/02.API-REFERENCE.md

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

26922692
*Notes*:
2693-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
2693+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
26942694
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
26952695
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
26962696
- The es.next profile enables this by default.
@@ -2709,6 +2709,7 @@ jerry_value_is_promise (const jerry_value_t value)
27092709
- false, otherwise
27102710

27112711
*New in version 2.0*.
2712+
*Changed in version [[NEXT_RELEASE]]*: Build option dependency changed from `JERRY_BUILTIN_PROMISE` to `JERRY_ESNEXT`.
27122713

27132714
**Example**
27142715

@@ -5392,7 +5393,7 @@ The function returns the result of a Promise object.
53925393
*Notes*:
53935394
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
53945395
is no longer needed.
5395-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5396+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
53965397
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
53975398
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
53985399
- The es.next profile enables this by default.
@@ -5413,6 +5414,7 @@ jerry_get_promise_result (const jerry_value_t promise);
54135414
the Promise support was not built into the library.
54145415

54155416
*New in version 2.2*.
5417+
*Changed in version [[NEXT_RELEASE]]*: Build option dependency changed from `JERRY_BUILTIN_PROMISE` to `JERRY_ESNEXT`.
54165418

54175419
**Example**
54185420

@@ -5459,7 +5461,7 @@ example (void)
54595461
*Notes*:
54605462
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
54615463
is no longer needed.
5462-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5464+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
54635465
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
54645466
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
54655467
- The es.next profile enables this by default.
@@ -5479,6 +5481,7 @@ jerry_get_promise_state (const jerry_value_t promise);
54795481
the Promise support was not built into the library.
54805482

54815483
*New in version 2.2*.
5484+
*Changed in version [[NEXT_RELEASE]]*: Build option dependency changed from `JERRY_BUILTIN_PROMISE` to `JERRY_ESNEXT`.
54825485

54835486
**Example**
54845487

@@ -5709,7 +5712,7 @@ Resolve or reject the promise with an argument.
57095712
*Note*:
57105713
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
57115714
is no longer needed.
5712-
- This API depends on a build option (`JERRY_BUILTIN_PROMISE`) and can be checked
5715+
- This API depends on a build option (`JERRY_ESNEXT`) and can be checked
57135716
in runtime with the `JERRY_FEATURE_PROMISE` feature enum value,
57145717
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
57155718
- The es.next profile enables this by default.
@@ -5732,6 +5735,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise,
57325735
- jerry value with error flag - otherwise
57335736

57345737
*New in version 2.0*.
5738+
*Changed in version [[NEXT_RELEASE]]*: Build option dependency changed from `JERRY_BUILTIN_PROMISE` to `JERRY_ESNEXT`.
57355739

57365740
**Example**
57375741

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

@@ -1123,11 +1123,11 @@ jerry_run_all_enqueued_jobs (void)
11231123
{
11241124
jerry_assert_api_available ();
11251125

1126-
#if JERRY_BUILTIN_PROMISE
1126+
#if JERRY_ESNEXT
11271127
return ecma_process_all_enqueued_jobs ();
1128-
#else /* !JERRY_BUILTIN_PROMISE */
1128+
#else /* !JERRY_ESNEXT */
11291129
return ECMA_VALUE_UNDEFINED;
1130-
#endif /* JERRY_BUILTIN_PROMISE */
1130+
#endif /* JERRY_ESNEXT */
11311131
} /* jerry_run_all_enqueued_jobs */
11321132

11331133
/**
@@ -1354,13 +1354,13 @@ bool
13541354
jerry_value_is_promise (const jerry_value_t value) /**< api value */
13551355
{
13561356
jerry_assert_api_available ();
1357-
#if JERRY_BUILTIN_PROMISE
1357+
#if JERRY_ESNEXT
13581358
return (ecma_is_value_object (value)
13591359
&& ecma_is_promise (ecma_get_object_from_value (value)));
1360-
#else /* !JERRY_BUILTIN_PROMISE */
1360+
#else /* !JERRY_ESNEXT */
13611361
JERRY_UNUSED (value);
13621362
return false;
1363-
#endif /* JERRY_BUILTIN_PROMISE */
1363+
#endif /* JERRY_ESNEXT */
13641364
} /* jerry_value_is_promise */
13651365

13661366
/**
@@ -1542,10 +1542,10 @@ static const uint8_t jerry_class_object_type[] =
15421542
#if JERRY_MODULE_SYSTEM
15431543
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
15441544
#endif
1545-
#if JERRY_BUILTIN_PROMISE
1545+
#if JERRY_ESNEXT
15461546
JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */
15471547
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
1548-
#endif /* JERRY_BUILTIN_PROMISE */
1548+
#endif /* JERRY_ESNEXT */
15491549
#if JERRY_BUILTIN_DATAVIEW
15501550
JERRY_OBJECT_TYPE_DATAVIEW, /**< type of ECMA_OBJECT_CLASS_DATAVIEW */
15511551
#endif /* JERRY_BUILTIN_DATAVIEW */
@@ -1803,10 +1803,8 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
18031803
#if JERRY_BUILTIN_JSON
18041804
|| feature == JERRY_FEATURE_JSON
18051805
#endif /* JERRY_BUILTIN_JSON */
1806-
#if JERRY_BUILTIN_PROMISE
1807-
|| feature == JERRY_FEATURE_PROMISE
1808-
#endif /* JERRY_BUILTIN_PROMISE */
18091806
#if JERRY_ESNEXT
1807+
|| feature == JERRY_FEATURE_PROMISE
18101808
|| feature == JERRY_FEATURE_SYMBOL
18111809
#endif /* JERRY_ESNEXT */
18121810
#if JERRY_BUILTIN_TYPEDARRAY
@@ -2560,13 +2558,13 @@ jerry_create_promise (void)
25602558
{
25612559
jerry_assert_api_available ();
25622560

2563-
#if JERRY_BUILTIN_PROMISE
2561+
#if JERRY_ESNEXT
25642562
ecma_value_t promise_value = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
25652563

25662564
return promise_value;
2567-
#else /* !JERRY_BUILTIN_PROMISE */
2565+
#else /* !JERRY_ESNEXT */
25682566
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
2569-
#endif /* JERRY_BUILTIN_PROMISE */
2567+
#endif /* JERRY_ESNEXT */
25702568
} /* jerry_create_promise */
25712569

25722570
/**
@@ -4762,7 +4760,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value *
47624760
{
47634761
jerry_assert_api_available ();
47644762

4765-
#if JERRY_BUILTIN_PROMISE
4763+
#if JERRY_ESNEXT
47664764
if (!ecma_is_value_object (promise) || !ecma_is_promise (ecma_get_object_from_value (promise)))
47674765
{
47684766
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -4779,13 +4777,13 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value *
47794777
}
47804778

47814779
return ecma_reject_promise_with_checks (promise, argument);
4782-
#else /* !JERRY_BUILTIN_PROMISE */
4780+
#else /* !JERRY_ESNEXT */
47834781
JERRY_UNUSED (promise);
47844782
JERRY_UNUSED (argument);
47854783
JERRY_UNUSED (is_resolve);
47864784

47874785
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
4788-
#endif /* JERRY_BUILTIN_PROMISE */
4786+
#endif /* JERRY_ESNEXT */
47894787
} /* jerry_resolve_or_reject_promise */
47904788

47914789
/**
@@ -4799,17 +4797,17 @@ jerry_get_promise_result (const jerry_value_t promise) /**< promise object to ge
47994797
{
48004798
jerry_assert_api_available ();
48014799

4802-
#if JERRY_BUILTIN_PROMISE
4800+
#if JERRY_ESNEXT
48034801
if (!jerry_value_is_promise (promise))
48044802
{
48054803
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
48064804
}
48074805

48084806
return ecma_promise_get_result (ecma_get_object_from_value (promise));
4809-
#else /* !JERRY_BUILTIN_PROMISE */
4807+
#else /* !JERRY_ESNEXT */
48104808
JERRY_UNUSED (promise);
48114809
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p)));
4812-
#endif /* JERRY_BUILTIN_PROMISE */
4810+
#endif /* JERRY_ESNEXT */
48134811
} /* jerry_get_promise_result */
48144812

48154813
/**
@@ -4824,7 +4822,7 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
48244822
{
48254823
jerry_assert_api_available ();
48264824

4827-
#if JERRY_BUILTIN_PROMISE
4825+
#if JERRY_ESNEXT
48284826
if (!jerry_value_is_promise (promise))
48294827
{
48304828
return JERRY_PROMISE_STATE_NONE;
@@ -4834,10 +4832,10 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
48344832
flags &= (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED);
48354833

48364834
return (flags ? flags : JERRY_PROMISE_STATE_REJECTED);
4837-
#else /* !JERRY_BUILTIN_PROMISE */
4835+
#else /* !JERRY_ESNEXT */
48384836
JERRY_UNUSED (promise);
48394837
return JERRY_PROMISE_STATE_NONE;
4840-
#endif /* JERRY_BUILTIN_PROMISE */
4838+
#endif /* JERRY_ESNEXT */
48414839
} /* jerry_get_promise_state */
48424840

48434841
/**
@@ -4852,7 +4850,7 @@ void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< comb
48524850
{
48534851
jerry_assert_api_available ();
48544852

4855-
#if JERRY_BUILTIN_PROMISE && JERRY_PROMISE_CALLBACK
4853+
#if JERRY_ESNEXT && JERRY_PROMISE_CALLBACK
48564854
if (filters == JERRY_PROMISE_EVENT_FILTER_DISABLE || callback == NULL)
48574855
{
48584856
JERRY_CONTEXT (promise_callback_filters) = JERRY_PROMISE_EVENT_FILTER_DISABLE;
@@ -4862,11 +4860,11 @@ void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< comb
48624860
JERRY_CONTEXT (promise_callback_filters) = (uint32_t) filters;
48634861
JERRY_CONTEXT (promise_callback) = callback;
48644862
JERRY_CONTEXT (promise_callback_user_p) = user_p;
4865-
#else /* !JERRY_BUILTIN_PROMISE && !JERRY_PROMISE_CALLBACK */
4863+
#else /* !JERRY_ESNEXT && !JERRY_PROMISE_CALLBACK */
48664864
JERRY_UNUSED (filters);
48674865
JERRY_UNUSED (callback);
48684866
JERRY_UNUSED (user_p);
4869-
#endif /* JERRY_BUILTIN_PROMISE && JERRY_PROMISE_CALLBACK */
4867+
#endif /* JERRY_ESNEXT && JERRY_PROMISE_CALLBACK */
48704868
} /* jerry_promise_set_callback */
48714869

48724870
/**

jerry-core/config.h

Lines changed: 3 additions & 13 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,10 +548,6 @@
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) \
560552
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1))
561553
# error "Invalid value for JERRY_BUILTIN_PROXY macro."
@@ -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)