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