mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
LibJS: Implement the TypedArray [[ContentType]] internal slot
This commit is contained in:
parent
93bae37dd9
commit
d7750999b3
2 changed files with 11 additions and 0 deletions
|
@ -204,6 +204,10 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
||||||
ClassName::ClassName(u32 length, Object& prototype) \
|
ClassName::ClassName(u32 length, Object& prototype) \
|
||||||
: TypedArray(length, prototype) \
|
: TypedArray(length, prototype) \
|
||||||
{ \
|
{ \
|
||||||
|
if constexpr (StringView { #ClassName }.is_one_of("BigInt64Array", "BigUint64Array")) \
|
||||||
|
m_content_type = ContentType::BigInt; \
|
||||||
|
else \
|
||||||
|
m_content_type = ContentType::Number; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
ClassName::~ClassName() { } \
|
ClassName::~ClassName() { } \
|
||||||
|
|
|
@ -17,9 +17,15 @@ class TypedArrayBase : public Object {
|
||||||
JS_OBJECT(TypedArrayBase, Object);
|
JS_OBJECT(TypedArrayBase, Object);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class ContentType {
|
||||||
|
BigInt,
|
||||||
|
Number,
|
||||||
|
};
|
||||||
|
|
||||||
u32 array_length() const { return m_array_length; }
|
u32 array_length() const { return m_array_length; }
|
||||||
u32 byte_length() const { return m_byte_length; }
|
u32 byte_length() const { return m_byte_length; }
|
||||||
u32 byte_offset() const { return m_byte_offset; }
|
u32 byte_offset() const { return m_byte_offset; }
|
||||||
|
ContentType content_type() const { return m_content_type; }
|
||||||
ArrayBuffer* viewed_array_buffer() const { return m_viewed_array_buffer; }
|
ArrayBuffer* viewed_array_buffer() const { return m_viewed_array_buffer; }
|
||||||
|
|
||||||
void set_array_length(u32 length) { m_array_length = length; }
|
void set_array_length(u32 length) { m_array_length = length; }
|
||||||
|
@ -39,6 +45,7 @@ protected:
|
||||||
u32 m_array_length { 0 };
|
u32 m_array_length { 0 };
|
||||||
u32 m_byte_length { 0 };
|
u32 m_byte_length { 0 };
|
||||||
u32 m_byte_offset { 0 };
|
u32 m_byte_offset { 0 };
|
||||||
|
ContentType m_content_type { ContentType::Number };
|
||||||
ArrayBuffer* m_viewed_array_buffer { nullptr };
|
ArrayBuffer* m_viewed_array_buffer { nullptr };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue