Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 18 additions & 168 deletions jerry-core/ecma/builtin-objects/ecma-builtin-map-prototype.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"

/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-map-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID map_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
Expand All @@ -35,179 +39,25 @@
*/

/**
* The Map.prototype object's 'clear' routine
*
* See also:
* ECMA-262 v6, 23.1.3.1
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_clear (ecma_value_t this_arg) /**< this argument */
{
return ecma_op_container_clear (this_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_clear */

/**
* The Map.prototype object's 'delete' routine
*
* See also:
* ECMA-262 v6, 23.1.3.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_delete (ecma_value_t this_arg, /**< this argument */
ecma_value_t key_arg) /**< key argument */
{
return ecma_op_container_delete (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_delete */

/**
* The Map.prototype object's 'forEach' routine
*
* See also:
* ECMA-262 v6, 23.1.3.5
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_foreach (ecma_value_t this_arg, /**< this argument */
ecma_value_t predicate, /**< callback function */
ecma_value_t predicate_this_arg) /**< this argument for
* invoke predicate */
{
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_foreach */

/**
* The Map.prototype object's 'get' routine
*
* See also:
* ECMA-262 v6, 23.1.3.6
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_get (ecma_value_t this_arg, /**< this argument */
ecma_value_t key_arg) /**< key argument */
{
return ecma_op_container_get (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_get */

/**
* The Map.prototype object's 'has' routine
*
* See also:
* ECMA-262 v6, 23.1.3.7
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_has (ecma_value_t this_arg, /**< this argument */
ecma_value_t key_arg) /**< key argument */
{
return ecma_op_container_has (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_has */

/**
* The Map.prototype object's 'set' routine
*
* See also:
* ECMA-262 v6, 23.1.3.9
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_set (ecma_value_t this_arg, /**< this argument */
ecma_value_t key_arg, /**< key argument */
ecma_value_t value_arg) /**< value argument */
{
return ecma_op_container_set (this_arg, key_arg, value_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_set */

/**
* The Map.prototype object's 'size' getter
*
* See also:
* ECMA-262 v6, 23.1.3.10
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_size_getter (ecma_value_t this_arg) /**< this argument */
ecma_value_t
ecma_builtin_map_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
* identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
ecma_length_t arguments_number) /**< length of arguments' list */
{
return ecma_op_container_size (this_arg, LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_object_size_getter */

#if ENABLED (JERRY_ESNEXT)

/**
* The Map.prototype object's 'entries' routine
*
* See also:
* ECMA-262 v6, 23.1.3.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_entries (ecma_value_t this_arg) /**< this argument */
{
return ecma_op_container_create_iterator (this_arg,
ECMA_ITERATOR_KEYS_VALUES,
LIT_MAGIC_STRING_MAP_UL,
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
ECMA_PSEUDO_MAP_ITERATOR);
} /* ecma_builtin_map_prototype_object_entries */

/**
* The Map.prototype object's 'keys' routine
*
* See also:
* ECMA-262 v6, 23.1.3.8
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_keys (ecma_value_t this_arg) /**< this argument */
{
return ecma_op_container_create_iterator (this_arg,
ECMA_ITERATOR_KEYS,
LIT_MAGIC_STRING_MAP_UL,
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
ECMA_PSEUDO_MAP_ITERATOR);
} /* ecma_builtin_map_prototype_object_keys */

/**
* The Map.prototype object's 'values' routine
*
* See also:
* ECMA-262 v6, 23.1.3.11
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_map_prototype_object_values (ecma_value_t this_arg) /**< this argument */
{
return ecma_op_container_create_iterator (this_arg,
ECMA_ITERATOR_VALUES,
LIT_MAGIC_STRING_MAP_UL,
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
ECMA_PSEUDO_MAP_ITERATOR);
} /* ecma_builtin_map_prototype_object_values */

#endif /* ENABLED (JERRY_ESNEXT) */

JERRY_UNUSED (arguments_number);
return ecma_builtin_container_dispatch_routine (builtin_routine_id,
this_arg,
arguments_list_p,
LIT_MAGIC_STRING_MAP_UL);
} /* ecma_builtin_map_prototype_dispatch_routine */
/**
* @}
* @}
Expand Down
22 changes: 11 additions & 11 deletions jerry-core/ecma/builtin-objects/ecma-builtin-map-prototype.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,

/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_CLEAR, ecma_builtin_map_prototype_object_clear, 0, 0)
ROUTINE (LIT_MAGIC_STRING_DELETE, ecma_builtin_map_prototype_object_delete, 1, 1)
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ecma_builtin_map_prototype_object_foreach, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET, ecma_builtin_map_prototype_object_get, 1, 1)
ROUTINE (LIT_MAGIC_STRING_HAS, ecma_builtin_map_prototype_object_has, 1, 1)
ROUTINE (LIT_MAGIC_STRING_SET, ecma_builtin_map_prototype_object_set, 2, 2)
ROUTINE (LIT_MAGIC_STRING_CLEAR, ECMA_CONTAINER_ROUTINE_CLEAR, 0, 0)
ROUTINE (LIT_MAGIC_STRING_DELETE, ECMA_CONTAINER_ROUTINE_DELETE, 1, 1)
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ECMA_CONTAINER_ROUTINE_FOREACH, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET, ECMA_CONTAINER_ROUTINE_GET, 1, 1)
ROUTINE (LIT_MAGIC_STRING_HAS, ECMA_CONTAINER_ROUTINE_HAS, 1, 1)
ROUTINE (LIT_MAGIC_STRING_SET, ECMA_CONTAINER_ROUTINE_SET, 2, 2)
#if ENABLED (JERRY_ESNEXT)
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ecma_builtin_map_prototype_object_entries, 0, 0)
ROUTINE (LIT_MAGIC_STRING_VALUES, ecma_builtin_map_prototype_object_values, 0, 0)
ROUTINE (LIT_MAGIC_STRING_KEYS, ecma_builtin_map_prototype_object_keys, 0, 0)
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ecma_builtin_map_prototype_object_entries, 0, 0)
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_CONTAINER_ROUTINE_ENTRIES, 0, 0)
ROUTINE (LIT_MAGIC_STRING_VALUES, ECMA_CONTAINER_ROUTINE_VALUES, 0, 0)
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_CONTAINER_ROUTINE_KEYS, 0, 0)
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ECMA_CONTAINER_ROUTINE_ENTRIES, 0, 0)
#endif /* ENABLED (JERRY_ESNEXT) */

/* ECMA-262 v6, 23.1.3.10 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
ecma_builtin_map_prototype_object_size_getter,
ECMA_CONTAINER_ROUTINE_SIZE_GETTER,
ECMA_PROPERTY_FLAG_CONFIGURABLE)

#endif /* ENABLED (JERRY_BUILTIN_MAP) */
Expand Down
Loading