<commit_before>// Copyright (c) 2012 Plenluno All rights reserved.

#ifndef LIBJ_JS_ARRAY_BUFFER_H_
#define LIBJ_JS_ARRAY_BUFFER_H_

#include "libj/constant.h"
#include "libj/mutable.h"
#include "libj/value.h"

namespace libj {

class JsArrayBuffer : LIBJ_MUTABLE(JsArrayBuffer)
 public:
    static Ptr create(Size length = 0);

    virtual Size length() const = 0;
    virtual const void* data() const = 0;

    virtual Value slice(Size begin = 0, Size end = NO_POS) const = 0;

    virtual Boolean getInt8(
        Size byteOffset, Byte* value) const = 0;
    virtual Boolean getUInt8(
        Size byteOffset, UByte* value) const = 0;
    virtual Boolean getInt16(
        Size byteOffset, Short* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getUInt16(
        Size byteOffset, UShort* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getInt32(
        Size byteOffset, Int* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getUInt32(
        Size byteOffset, UInt* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getFloat32(
        Size byteOffset, Float* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getFloat64(
        Size byteOffset, Double* value, Boolean littleEndian = false) const = 0;

    virtual Boolean setInt8(
        Size byteOffset, Byte value) = 0;
    virtual Boolean setUInt8(
        Size byteOffset, UByte value) = 0;
    virtual Boolean setInt16(
        Size byteOffset, Short value, Boolean littleEndian = false) = 0;
    virtual Boolean setUInt16(
        Size byteOffset, UShort value, Boolean littleEndian = false) = 0;
    virtual Boolean setInt32(
        Size byteOffset, Int value, Boolean littleEndian = false) = 0;
    virtual Boolean setUInt32(
        Size byteOffset, UInt value, Boolean littleEndian = false) = 0;
    virtual Boolean setFloat32(
        Size byteOffset, Float value, Boolean littleEndian = false) = 0;
    virtual Boolean setFloat64(
        Size byteOffset, Double value, Boolean littleEndian = false) = 0;
};

#define LIBJ_JS_ARRAY_BUFFER(T) public libj::JsArrayBuffer { \
    LIBJ_MUTABLE_DECLS(T, libj::JsArrayBuffer)

#define LIBJ_JS_ARRAY_BUFFER_IMPL(B) \
public: \
    Size length() const { \
        return B->length(); \
    } \
    const UByte* data() const { \
        return B->data(); \
    } \
    Boolean getInt8( \
        Size byteOffset, Byte* value) const { \
        return B->getInt8(byteOffset, value); \
    } \
    Boolean getUInt8( \
        Size byteOffset, UByte* value) const { \
        return B->getUInt8(byteOffset, value); \
    } \
    Boolean getInt16( \
        Size byteOffset, Short* value, Boolean littleEndian = false) const { \
        return B->getInt16(byteOffset, value, littleEndian); \
    } \
    Boolean getUInt16( \
        Size byteOffset, UShort* value, Boolean littleEndian = false) const { \
        return B->getUInt16(byteOffset, value, littleEndian); \
    } \
    Boolean getInt32( \
        Size byteOffset, Int* value, Boolean littleEndian = false) const { \
        return B->getInt32(byteOffset, value, littleEndian); \
    } \
    Boolean getUInt32( \<commit_msg>change return type of JsArrayBuffer::data<commit_after>// Copyright (c) 2012 Plenluno All rights reserved.

#ifndef LIBJ_JS_ARRAY_BUFFER_H_
#define LIBJ_JS_ARRAY_BUFFER_H_

#include "libj/constant.h"
#include "libj/mutable.h"
#include "libj/value.h"

namespace libj {

class JsArrayBuffer : LIBJ_MUTABLE(JsArrayBuffer)
 public:
    static Ptr create(Size length = 0);

    virtual Size length() const = 0;
    virtual const void* data() const = 0;

    virtual Value slice(Size begin = 0, Size end = NO_POS) const = 0;

    virtual Boolean getInt8(
        Size byteOffset, Byte* value) const = 0;
    virtual Boolean getUInt8(
        Size byteOffset, UByte* value) const = 0;
    virtual Boolean getInt16(
        Size byteOffset, Short* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getUInt16(
        Size byteOffset, UShort* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getInt32(
        Size byteOffset, Int* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getUInt32(
        Size byteOffset, UInt* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getFloat32(
        Size byteOffset, Float* value, Boolean littleEndian = false) const = 0;
    virtual Boolean getFloat64(
        Size byteOffset, Double* value, Boolean littleEndian = false) const = 0;

    virtual Boolean setInt8(
        Size byteOffset, Byte value) = 0;
    virtual Boolean setUInt8(
        Size byteOffset, UByte value) = 0;
    virtual Boolean setInt16(
        Size byteOffset, Short value, Boolean littleEndian = false) = 0;
    virtual Boolean setUInt16(
        Size byteOffset, UShort value, Boolean littleEndian = false) = 0;
    virtual Boolean setInt32(
        Size byteOffset, Int value, Boolean littleEndian = false) = 0;
    virtual Boolean setUInt32(
        Size byteOffset, UInt value, Boolean littleEndian = false) = 0;
    virtual Boolean setFloat32(
        Size byteOffset, Float value, Boolean littleEndian = false) = 0;
    virtual Boolean setFloat64(
        Size byteOffset, Double value, Boolean littleEndian = false) = 0;
};

#define LIBJ_JS_ARRAY_BUFFER(T) public libj::JsArrayBuffer { \
    LIBJ_MUTABLE_DECLS(T, libj::JsArrayBuffer)

#define LIBJ_JS_ARRAY_BUFFER_IMPL(B) \
public: \
    Size length() const { \
        return B->length(); \
    } \
    const void* data() const { \
        return B->data(); \
    } \
    Boolean getInt8( \
        Size byteOffset, Byte* value) const { \
        return B->getInt8(byteOffset, value); \
    } \
    Boolean getUInt8( \
        Size byteOffset, UByte* value) const { \
        return B->getUInt8(byteOffset, value); \
    } \
    Boolean getInt16( \
        Size byteOffset, Short* value, Boolean littleEndian = false) const { \
        return B->getInt16(byteOffset, value, littleEndian); \
    } \
    Boolean getUInt16( \
        Size byteOffset, UShort* value, Boolean littleEndian = false) const { \
        return B->getUInt16(byteOffset, value, littleEndian); \
    } \
    Boolean getInt32( \
        Size byteOffset, Int* value, Boolean littleEndian = false) const { \
        return B->getInt32(byteOffset, value, littleEndian); \
    } \
    Boolean getUInt32( \
{'fraction_non_alphanumeric': 0.09342290267145759, 'fraction_numerical': 0.022184033744727386, 'mean_word_length': 2.9155963302752292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '642441', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1917, 'n_words': 616}