32
32
#define ECMA_BUILTINS_INTERNAL
33
33
#include "ecma-builtins-internal.h"
34
34
35
+ /**
36
+ * This object has a custom dispatch function.
37
+ */
38
+ #define BUILTIN_CUSTOM_DISPATCH
39
+
40
+ /**
41
+ * List of built-in routine identifiers.
42
+ */
43
+ enum
44
+ {
45
+ ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_ROUTINE_START = 0 ,
46
+ ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER ,
47
+ ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_OBJECT_SLICE ,
48
+ };
49
+
35
50
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
36
51
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
37
52
#include "ecma-builtin-internal-routines-template.inc.h"
56
71
* Returned value must be freed with ecma_free_value.
57
72
*/
58
73
static ecma_value_t
59
- ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg ) /**< this argument */
74
+ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg , /**< this argument */
75
+ ecma_object_t * object_p ) /**< object value*/
60
76
{
61
- if (ecma_is_value_object (this_arg ))
77
+ JERRY_UNUSED (this_arg );
78
+ if (ecma_arraybuffer_is_detached (object_p ))
62
79
{
63
- ecma_object_t * object_p = ecma_get_object_from_value (this_arg );
64
-
65
- if (ecma_object_class_is (object_p , ECMA_OBJECT_CLASS_ARRAY_BUFFER ))
66
- {
67
- if (ecma_arraybuffer_is_detached (object_p ))
68
- {
69
- return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
70
- }
71
- uint32_t len = ecma_arraybuffer_get_length (object_p );
72
-
73
- return ecma_make_uint32_value (len );
74
- }
80
+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
75
81
}
82
+ uint32_t len = ecma_arraybuffer_get_length (object_p );
83
+
84
+ return ecma_make_uint32_value (len );
76
85
77
- return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a ArrayBuffer object" ));
78
86
} /* ecma_builtin_arraybuffer_prototype_bytelength_getter */
79
87
80
88
/**
@@ -90,6 +98,22 @@ static ecma_value_t
90
98
ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg , /**< this argument */
91
99
const ecma_value_t * argument_list_p , /**< arguments list */
92
100
uint32_t arguments_number ) /**< number of arguments */
101
+ {
102
+ return ecma_builtin_arraybuffer_slice (this_arg , argument_list_p , arguments_number );
103
+ } /* ecma_builtin_arraybuffer_prototype_object_slice */
104
+
105
+ /**
106
+ * Dispatcher of the built-in's routines
107
+ *
108
+ * @return ecma value
109
+ * Returned value must be freed with ecma_free_value.
110
+ */
111
+ ecma_value_t
112
+ ecma_builtin_arraybuffer_prototype_dispatch_routine (uint8_t builtin_routine_id , /**< built-in routine identifier */
113
+ ecma_value_t this_arg , /**< 'this' argument value */
114
+ const ecma_value_t arguments_list_p [], /**< list of arguments
115
+ * passed to routine */
116
+ uint32_t arguments_number ) /**< length of arguments' list */
93
117
{
94
118
if (!ecma_is_value_object (this_arg ))
95
119
{
@@ -104,8 +128,22 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
104
128
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object" ));
105
129
}
106
130
107
- return ecma_builtin_arraybuffer_slice (this_arg , argument_list_p , arguments_number );
108
- } /* ecma_builtin_arraybuffer_prototype_object_slice */
131
+ switch (builtin_routine_id )
132
+ {
133
+ case ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER :
134
+ {
135
+ return ecma_builtin_arraybuffer_prototype_bytelength_getter (this_arg , object_p );
136
+ }
137
+ case ECMA_BUILTIN_ARRAYBUFFER_PROTOTYPE_OBJECT_SLICE :
138
+ {
139
+ return ecma_builtin_arraybuffer_prototype_object_slice (this_arg , arguments_list_p , arguments_number );
140
+ }
141
+ default :
142
+ {
143
+ JERRY_UNREACHABLE ();
144
+ }
145
+ }
146
+ } /* ecma_builtin_arraybuffer_prototype_dispatch_routine */
109
147
110
148
/**
111
149
* @}
0 commit comments