@ -37,11 +37,17 @@ impl BuiltIn for ArrayBuffer {
fn init ( context : & mut Context ) -> Option < JsValue > {
fn init ( context : & mut Context ) -> Option < JsValue > {
let _timer = Profiler ::global ( ) . start_event ( Self ::NAME , "init" ) ;
let _timer = Profiler ::global ( ) . start_event ( Self ::NAME , "init" ) ;
let flag_attributes = Attribute ::CONFIGURABLE | Attribute ::NON_ENUMERABLE ;
let get_species = FunctionBuilder ::native ( context , Self ::get_species )
let get_species = FunctionBuilder ::native ( context , Self ::get_species )
. name ( "get [Symbol.species]" )
. name ( "get [Symbol.species]" )
. constructor ( false )
. constructor ( false )
. build ( ) ;
. build ( ) ;
let get_byte_length = FunctionBuilder ::native ( context , Self ::get_byte_length )
. name ( "get byteLength" )
. build ( ) ;
ConstructorBuilder ::with_standard_constructor (
ConstructorBuilder ::with_standard_constructor (
context ,
context ,
Self ::constructor ,
Self ::constructor ,
@ -49,6 +55,7 @@ impl BuiltIn for ArrayBuffer {
)
)
. name ( Self ::NAME )
. name ( Self ::NAME )
. length ( Self ::LENGTH )
. length ( Self ::LENGTH )
. accessor ( "byteLength" , Some ( get_byte_length ) , None , flag_attributes )
. static_accessor (
. static_accessor (
WellKnownSymbols ::species ( ) ,
WellKnownSymbols ::species ( ) ,
Some ( get_species ) ,
Some ( get_species ) ,
@ -56,7 +63,6 @@ impl BuiltIn for ArrayBuffer {
Attribute ::CONFIGURABLE ,
Attribute ::CONFIGURABLE ,
)
)
. static_method ( Self ::is_view , "isView" , 1 )
. static_method ( Self ::is_view , "isView" , 1 )
. method ( Self ::byte_length , "byteLength" , 0 )
. method ( Self ::slice , "slice" , 2 )
. method ( Self ::slice , "slice" , 2 )
. property (
. property (
WellKnownSymbols ::to_string_tag ( ) ,
WellKnownSymbols ::to_string_tag ( ) ,
@ -133,7 +139,11 @@ impl ArrayBuffer {
/// - [ECMAScript reference][spec]
/// - [ECMAScript reference][spec]
///
///
/// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength
/// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength
fn byte_length ( this : & JsValue , _args : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
fn get_byte_length (
this : & JsValue ,
_args : & [ JsValue ] ,
context : & mut Context ,
) -> JsResult < JsValue > {
// 1. Let O be the this value.
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
let obj = if let Some ( obj ) = this . as_object ( ) {
let obj = if let Some ( obj ) = this . as_object ( ) {