mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Implement the TypedArray [[ContentType]] internal slot
This commit is contained in:
parent
93bae37dd9
commit
d7750999b3
Notes:
sideshowbarker
2024-07-18 11:26:34 +09:00
|
@ -204,6 +204,10 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
ClassName::ClassName(u32 length, Object& 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() { } \
|
||||
|
|
|
@ -17,9 +17,15 @@ class TypedArrayBase : public Object {
|
|||
JS_OBJECT(TypedArrayBase, Object);
|
||||
|
||||
public:
|
||||
enum class ContentType {
|
||||
BigInt,
|
||||
Number,
|
||||
};
|
||||
|
||||
u32 array_length() const { return m_array_length; }
|
||||
u32 byte_length() const { return m_byte_length; }
|
||||
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; }
|
||||
|
||||
void set_array_length(u32 length) { m_array_length = length; }
|
||||
|
@ -39,6 +45,7 @@ protected:
|
|||
u32 m_array_length { 0 };
|
||||
u32 m_byte_length { 0 };
|
||||
u32 m_byte_offset { 0 };
|
||||
ContentType m_content_type { ContentType::Number };
|
||||
ArrayBuffer* m_viewed_array_buffer { nullptr };
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue