Skip to content

Commit 52a4507

Browse files
committed
Add costum dispatcher to Arraybuffer & Arraybuffer_prototype
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi [email protected]
1 parent ef35c03 commit 52a4507

4 files changed

+99
-6
lines changed

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

+45
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@
3131
#define ECMA_BUILTINS_INTERNAL
3232
#include "ecma-builtins-internal.h"
3333

34+
/**
35+
* This object has a custom dispatch function.
36+
*/
37+
#define BUILTIN_CUSTOM_DISPATCH
38+
39+
/**
40+
* List of built-in routine identifiers.
41+
*/
42+
enum
43+
{
44+
ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_ROUTINE_START = 0,
45+
ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER,
46+
ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_OBJECT_SLICE,
47+
};
48+
3449
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
3550
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
3651
#include "ecma-builtin-internal-routines-template.inc.h"
@@ -227,6 +242,36 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
227242
return ret_value;
228243
} /* ecma_builtin_arraybuffer_prototype_object_slice */
229244

245+
/**
246+
* Dispatcher of the built-in's routines
247+
*
248+
* @return ecma value
249+
* Returned value must be freed with ecma_free_value.
250+
*/
251+
ecma_value_t
252+
ecma_builtin_arraybuffer_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in routine identifier */
253+
ecma_value_t this_arg, /**< 'this' argument value */
254+
const ecma_value_t arguments_list_p[], /**< list of arguments
255+
* passed to routine */
256+
uint32_t arguments_number) /**< length of arguments' list */
257+
{
258+
switch (builtin_routine_id)
259+
{
260+
case ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER:
261+
{
262+
return ecma_builtin_arraybuffer_prototype_bytelength_getter (this_arg);
263+
}
264+
case ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_OBJECT_SLICE:
265+
{
266+
return ecma_builtin_arraybuffer_prototype_object_slice (this_arg, arguments_list_p, arguments_number);
267+
}
268+
default:
269+
{
270+
JERRY_UNREACHABLE ();
271+
}
272+
}
273+
} /* ecma_builtin_arraybuffer_prototype_dispatch_routine */
274+
230275
/**
231276
* @}
232277
* @}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
3030

3131
/* Readonly accessor properties */
3232
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
33-
ecma_builtin_arraybuffer_prototype_bytelength_getter,
33+
ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER,
3434
ECMA_PROPERTY_FLAG_CONFIGURABLE)
3535

3636
/* ECMA-262 v6, 24.1.4.4 */
@@ -40,7 +40,7 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
4040

4141
/* Routine properties:
4242
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
43-
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, NON_FIXED, 2)
43+
ROUTINE (LIT_MAGIC_STRING_SLICE, ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_OBJECT_SLICE, NON_FIXED, 2)
4444

4545
#endif /* JERRY_BUILTIN_TYPEDARRAY */
4646

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

+50-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@
2828
#define ECMA_BUILTINS_INTERNAL
2929
#include "ecma-builtins-internal.h"
3030

31+
/**
32+
* This object has a custom dispatch function.
33+
*/
34+
#define BUILTIN_CUSTOM_DISPATCH
35+
36+
/**
37+
* List of built-in routine identifiers.
38+
*/
39+
enum
40+
{
41+
ECMA_BUILTIN_ARRAYBUFFER_ROUTINE_START = 0,
42+
ECMA_BUILTIN_ARRAYBUFFER_OBJECT_IS_VIEW,
43+
ECMA_BUILTIN_ARRAYBUFFER_SPECIES_GET,
44+
};
45+
3146
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
3247
#define BUILTIN_UNDERSCORED_ID arraybuffer
3348
#include "ecma-builtin-internal-routines-template.inc.h"
@@ -98,11 +113,44 @@ ecma_builtin_arraybuffer_dispatch_construct (const ecma_value_t *arguments_list_
98113
* @return ecma_value
99114
* returned value must be freed with ecma_free_value
100115
*/
116+
/*
101117
ecma_value_t
102-
ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value */
118+
ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) < This Value
103119
{
104120
return ecma_copy_value (this_value);
105-
} /* ecma_builtin_arraybuffer_species_get */
121+
} *//* ecma_builtin_arraybuffer_species_get */
122+
123+
/**
124+
* Dispatcher of the built-in's routines
125+
*
126+
* @return ecma value
127+
* Returned value must be freed with ecma_free_value.
128+
*/
129+
ecma_value_t
130+
ecma_builtin_arraybuffer_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
131+
ecma_value_t this_arg, /**< 'this' argument value */
132+
const ecma_value_t arguments_list_p[], /**< list of arguments
133+
* passed to routine */
134+
uint32_t arguments_number) /**< length of arguments' list */
135+
{
136+
JERRY_UNUSED (arguments_number);
137+
138+
switch (builtin_routine_id)
139+
{
140+
case ECMA_BUILTIN_ARRAYBUFFER_OBJECT_IS_VIEW:
141+
{
142+
return ecma_builtin_arraybuffer_object_is_view (this_arg, arguments_list_p[0]);
143+
}
144+
case ECMA_BUILTIN_ARRAYBUFFER_SPECIES_GET:
145+
{
146+
return ecma_copy_value (this_arg);
147+
}
148+
default:
149+
{
150+
JERRY_UNREACHABLE ();
151+
}
152+
}
153+
} /* ecma_builtin_arraybuffer_dispatch_routine */
106154

107155
/**
108156
* @}

jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.inc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
4343
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
4444

4545
/* ES2015 24.1.3.1 */
46-
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
46+
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ECMA_BUILTIN_ARRAYBUFFER_OBJECT_IS_VIEW, 1, 1)
4747

4848
/* ES2015 24.1.3.3 */
4949
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
50-
ecma_builtin_arraybuffer_species_get,
50+
ECMA_BUILTIN_ARRAYBUFFER_SPECIES_GET,
5151
ECMA_PROPERTY_FLAG_CONFIGURABLE)
5252

5353
#endif /* JERRY_BUILTIN_TYPEDARRAY */

0 commit comments

Comments
 (0)