summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/DataViewObject.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /js/src/builtin/DataViewObject.h
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/builtin/DataViewObject.h')
-rw-r--r--js/src/builtin/DataViewObject.h43
1 files changed, 15 insertions, 28 deletions
diff --git a/js/src/builtin/DataViewObject.h b/js/src/builtin/DataViewObject.h
index a17b3e1174..db134a5696 100644
--- a/js/src/builtin/DataViewObject.h
+++ b/js/src/builtin/DataViewObject.h
@@ -48,7 +48,7 @@ class DataViewObject : public ArrayBufferViewObject {
const CallArgs& args,
size_t* byteOffsetPtr,
size_t* byteLengthPtr,
- bool* autoLengthPtr);
+ AutoLength* autoLengthPtr);
static bool constructSameCompartment(JSContext* cx, HandleObject bufobj,
const CallArgs& args);
static bool constructWrapped(JSContext* cx, HandleObject bufobj,
@@ -58,16 +58,16 @@ class DataViewObject : public ArrayBufferViewObject {
JSContext* cx, size_t byteOffset, size_t byteLength,
Handle<ArrayBufferObjectMaybeShared*> arrayBuffer, HandleObject proto);
- protected:
- size_t rawByteLength() const {
- return size_t(getFixedSlot(LENGTH_SLOT).toPrivate());
- }
-
public:
static const JSClass protoClass_;
- mozilla::Maybe<size_t> byteLength();
- mozilla::Maybe<size_t> byteOffset();
+ /**
+ * Return the current byteLength, or |Nothing| if the DataView is detached or
+ * out-of-bounds.
+ */
+ mozilla::Maybe<size_t> byteLength() {
+ return ArrayBufferViewObject::length();
+ }
template <typename NativeType>
static bool offsetIsInBounds(uint64_t offset, size_t byteLength) {
@@ -173,19 +173,11 @@ class FixedLengthDataViewObject : public DataViewObject {
public:
static const JSClass class_;
- size_t byteOffset() const { return ArrayBufferViewObject::byteOffset(); }
-
- size_t byteLength() const { return rawByteLength(); }
-
- bool offsetIsInBounds(uint32_t byteSize, uint64_t offset) const {
- return DataViewObject::offsetIsInBounds(byteSize, offset, byteLength());
+ size_t byteOffset() const {
+ return ArrayBufferViewObject::byteOffsetSlotValue();
}
- template <typename NativeType>
- NativeType read(uint64_t offset, bool isLittleEndian) {
- return DataViewObject::read<NativeType>(offset, byteLength(),
- isLittleEndian);
- }
+ size_t byteLength() const { return ArrayBufferViewObject::lengthSlotValue(); }
};
/**
@@ -195,19 +187,14 @@ class ResizableDataViewObject : public DataViewObject {
friend class DataViewObject;
static ResizableDataViewObject* create(
- JSContext* cx, size_t byteOffset, size_t byteLength, bool autoLength,
- Handle<ArrayBufferObjectMaybeShared*> arrayBuffer, HandleObject proto);
+ JSContext* cx, size_t byteOffset, size_t byteLength,
+ AutoLength autoLength, Handle<ArrayBufferObjectMaybeShared*> arrayBuffer,
+ HandleObject proto);
public:
- static const uint8_t AUTO_LENGTH_SLOT = DataViewObject::RESERVED_SLOTS;
-
- static const uint8_t RESERVED_SLOTS = DataViewObject::RESERVED_SLOTS + 1;
+ static const uint8_t RESERVED_SLOTS = RESIZABLE_RESERVED_SLOTS;
static const JSClass class_;
-
- bool isAutoLength() const {
- return getFixedSlot(AUTO_LENGTH_SLOT).toBoolean();
- }
};
// For structured cloning.