Introduce new Promise API methods (#3186)

The new API methods make it possible to get a Promise object's
result and it's state.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Péter Gál
2019-10-28 14:07:37 +01:00
committed by Dániel Bátyai
parent 351b88184c
commit eebbed143d
6 changed files with 440 additions and 3 deletions
@@ -53,7 +53,7 @@ ecma_is_promise (ecma_object_t *obj_p) /**< points to object */
* @return ecma value of the promise result.
* Returned value must be freed with ecma_free_value
*/
static inline ecma_value_t
ecma_value_t
ecma_promise_get_result (ecma_object_t *obj_p) /**< points to promise object */
{
JERRY_ASSERT (ecma_is_promise (obj_p));
@@ -84,7 +84,7 @@ ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */
*
* @return the state's enum value
*/
static inline uint8_t JERRY_ATTR_ALWAYS_INLINE
uint8_t
ecma_promise_get_state (ecma_object_t *obj_p) /**< points to promise object */
{
JERRY_ASSERT (ecma_is_promise (obj_p));
@@ -71,6 +71,8 @@ typedef struct
bool ecma_is_promise (ecma_object_t *obj_p);
ecma_value_t
ecma_op_create_promise_object (ecma_value_t executor, ecma_promise_executor_type_t type);
uint8_t ecma_promise_get_state (ecma_object_t *promise_p);
ecma_value_t ecma_promise_get_result (ecma_object_t *promise_p);
ecma_value_t ecma_promise_new_capability (void);
ecma_value_t
ecma_promise_then (ecma_value_t promise,