mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
LibJS: Implement the ArrayBuffer.prototype.detached getter
This commit is contained in:
parent
8157bb601b
commit
bd0ccbe3c8
3 changed files with 17 additions and 0 deletions
|
@ -26,6 +26,7 @@ ThrowCompletionOr<void> ArrayBufferPrototype::initialize(Realm& realm)
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function(realm, vm.names.slice, slice, 2, attr);
|
define_native_function(realm, vm.names.slice, slice, 2, attr);
|
||||||
define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
||||||
|
define_native_accessor(realm, vm.names.detached, detached_getter, {}, Attribute::Configurable);
|
||||||
|
|
||||||
// 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag
|
// 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag
|
||||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
|
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
|
||||||
|
@ -148,4 +149,18 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::byte_length_getter)
|
||||||
return Value(length);
|
return Value(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 25.1.5.4 get ArrayBuffer.prototype.detached, https://tc39.es/proposal-arraybuffer-transfer/#sec-get-arraybuffer.prototype.detached
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::detached_getter)
|
||||||
|
{
|
||||||
|
// 1. Let O be the this value.
|
||||||
|
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||||
|
auto array_buffer_object = TRY(typed_this_value(vm));
|
||||||
|
|
||||||
|
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
|
||||||
|
// FIXME: Check for shared buffer
|
||||||
|
|
||||||
|
// 4. Return IsDetachedBuffer(O).
|
||||||
|
return Value(array_buffer_object->is_detached());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ private:
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(slice);
|
JS_DECLARE_NATIVE_FUNCTION(slice);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(byte_length_getter);
|
JS_DECLARE_NATIVE_FUNCTION(byte_length_getter);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(detached_getter);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ namespace JS {
|
||||||
P(deleteProperty) \
|
P(deleteProperty) \
|
||||||
P(deref) \
|
P(deref) \
|
||||||
P(description) \
|
P(description) \
|
||||||
|
P(detached) \
|
||||||
P(difference) \
|
P(difference) \
|
||||||
P(dir) \
|
P(dir) \
|
||||||
P(direction) \
|
P(direction) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue