| 1 | /* |
| 2 | * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef JSByteArray_h |
| 27 | #define JSByteArray_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSByteArray.h:27:9`! |
| 28 | |
| 29 | #include "JSObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.h`/ |
| 30 | |
| 31 | #include <wtf/ByteArray.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ByteArray.h`/ |
| 32 | |
| 33 | namespace JSCcxx . . $ `<built-in>:463:9`! { |
| 34 | |
| 35 | class JSByteArraycxx . . $ QTJSC/JSByteArray# : public JSObjectcxx . . $ QTJSC/JSObject# { |
| 36 | friend class JSGlobalDatacxx . . $ QTJSC/JSGlobalData#; |
| 37 | public: |
| 38 | bool canAccessIndexcxx . . $ QTJSC/JSByteArray#canAccessIndex(dfa6e707f7696010).(unsigned i) { return i < m_storage->length(); } |
| 39 | JSValuecxx . . $ QTJSC/JSValue# getIndexcxx . . $ QTJSC/JSByteArray#getIndex(bf7e02f8c8245e31).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i) |
| 40 | { |
| 41 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(canAccessIndex(i)); |
| 42 | return jsNumbercxx . . $ QTJSC/jsNumber(bdb4a03c934d5200).(exec, m_storage->data()[i]); |
| 43 | } |
| 44 | |
| 45 | void setIndexcxx . . $ QTJSC/JSByteArray#setIndex(3d89109e85ced1be).(unsigned i, int value) |
| 46 | { |
| 47 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(canAccessIndex(i)); |
| 48 | if (value & ~0xFF) { |
| 49 | if (value < 0) |
| 50 | value = 0; |
| 51 | else |
| 52 | value = 255; |
| 53 | } |
| 54 | m_storage->data()[i] = static_cast<unsigned char>(value); |
| 55 | } |
| 56 | |
| 57 | void setIndexcxx . . $ QTJSC/JSByteArray#setIndex(ff807c9ed962492e).(unsigned i, double value) |
| 58 | { |
| 59 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(canAccessIndex(i)); |
| 60 | if (!(value > 0)) // Clamp NaN to 0 |
| 61 | value = 0; |
| 62 | else if (value > 255) |
| 63 | value = 255; |
| 64 | m_storage->data()[i] = static_cast<unsigned char>(value + 0.5); |
| 65 | } |
| 66 | |
| 67 | void setIndexcxx . . $ QTJSC/JSByteArray#setIndex(b1b60585cf3bb95).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i, JSValuecxx . . $ QTJSC/JSValue# value) |
| 68 | { |
| 69 | double byteValue = value.toNumbercxx . . $ QTJSC/JSValue#toNumber(1fd034e372fd1279).(exec); |
| 70 | if (exec->hadExceptioncxx . . $ QTJSC/ExecState#hadException(50ce9a9e25b4a850).()) |
| 71 | return; |
| 72 | if (canAccessIndexcxx . . $ QTJSC/JSByteArray#canAccessIndex(dfa6e707f7696010).(i)) |
| 73 | setIndexcxx . . $ QTJSC/JSByteArray#setIndex(ff807c9ed962492e).(i, byteValue); |
| 74 | } |
| 75 | |
| 76 | JSByteArraycxx . . $ QTJSC/JSByteArray#JSByteArray(7360081306676c36).(ExecStatecxx . . $ QTJSC/ExecState#* exec, NonNullPassRefPtrcxx . . $ NonNullPassRefPtr#<Structurecxx . . $ QTJSC/Structure#>, WTFcxx . . $ `<built-in>:467:9`!::ByteArraycxx . . $ QTWTF/ByteArray#* storage, const JSCcxx . . $ QTJSC/::ClassInfocxx . . $ QTJSC/ClassInfo#* = &s_defaultInfocxx . . $ QTJSC/JSByteArray#s_defaultInfo.); |
| 77 | static PassRefPtrcxx . . $ PassRefPtr#<Structurecxx . . $ QTJSC/Structure#> createStructurecxx . . $ QTJSC/JSByteArray#createStructure(da75fbe5e97e240f).(JSValuecxx . . $ QTJSC/JSValue# prototype); |
| 78 | |
| 79 | virtual bool getOwnPropertySlotcxx . . $ QTJSC/JSByteArray#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(JSCcxx . . $ QTJSC/::ExecStatecxx . . $ QTJSC/ExecState#*, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSCcxx . . $ `<built-in>:463:9`!::PropertySlotcxx . . $ QTJSC/PropertySlot#&); |
| 80 | virtual bool getOwnPropertySlotcxx . . $ QTJSC/JSByteArray#getOwnPropertySlot(d57d1c8d4b24d235).(JSCcxx . . $ QTJSC/::ExecStatecxx . . $ QTJSC/ExecState#*, unsigned propertyName, JSCcxx . . $ QTJSC/::PropertySlotcxx . . $ QTJSC/PropertySlot#&); |
| 81 | virtual bool getOwnPropertyDescriptorcxx . . $ QTJSC/JSByteArray#getOwnPropertyDescriptor(dce4ef7012294c32).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#&, PropertyDescriptorcxx . . $ QTJSC/PropertyDescriptor#&); |
| 82 | virtual void putcxx . . $ QTJSC/JSByteArray#put(dfb3133dafbe9ff4).(JSCcxx . . $ QTJSC/::ExecStatecxx . . $ QTJSC/ExecState#*, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue#, JSCcxx . . $ `<built-in>:463:9`!::PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#&); |
| 83 | virtual void putcxx . . $ QTJSC/JSByteArray#put(b1b60585cf3bb95).(JSCcxx . . $ QTJSC/::ExecStatecxx . . $ QTJSC/ExecState#*, unsigned propertyName, JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue#); |
| 84 | |
| 85 | virtual void getOwnPropertyNamescxx . . $ QTJSC/JSByteArray#getOwnPropertyNames(2f9e3f18de200b4e).(JSCcxx . . $ QTJSC/::ExecStatecxx . . $ QTJSC/ExecState#*, JSCcxx . . $ `<built-in>:463:9`!::PropertyNameArraycxx . . $ QTJSC/PropertyNameArray#&, EnumerationModecxx . . $ QTJSC/EnumerationMode# mode = ExcludeDontEnumPropertiescxx . . $ QTJSC/ExcludeDontEnumProperties.); |
| 86 | |
| 87 | virtual const ClassInfocxx . . $ QTJSC/ClassInfo#* classInfocxx . . $ QTJSC/JSByteArray#classInfo(f90fb4cda7a7c2e2).() const { return m_classInfocxx . . $ QTJSC/JSByteArray#m_classInfo.; } |
| 88 | static const ClassInfocxx . . $ QTJSC/ClassInfo# s_defaultInfocxx . . $ QTJSC/JSByteArray#s_defaultInfo.; |
| 89 | |
| 90 | size_t lengthcxx . . $ QTJSC/JSByteArray#length(fe4d2d262d4164a8).() const { return m_storage->length(); } |
| 91 | |
| 92 | WTFcxx . . $ QTWTF/::ByteArraycxx . . $ QTWTF/ByteArray#* storagecxx . . $ QTJSC/JSByteArray#storage(b6b3afe283036bd3).() const { return m_storage.get(); } |
| 93 | |
| 94 | #if !ASSERT_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:71:9`! |
| 95 | virtual ~JSByteArray(); |
| 96 | #endif |
| 97 | |
| 98 | protected: |
| 99 | static const unsigned StructureFlagscxx . . $ QTJSC/JSByteArray#StructureFlags. = OverridesGetOwnPropertySlotcxx . . $ QTJSC/OverridesGetOwnPropertySlot. | OverridesGetPropertyNamescxx . . $ QTJSC/OverridesGetPropertyNames. | JSObjectcxx . . $ QTJSC/JSObject#::StructureFlagscxx . . $ QTJSC/JSObject#StructureFlags.; |
| 100 | |
| 101 | private: |
| 102 | enum VPtrStealingHackTypecxx . . $ QTJSC/JSByteArray#VPtrStealingHackType# { VPtrStealingHackcxx . . $ QTJSC/JSByteArray#VPtrStealingHack. }; |
| 103 | JSByteArraycxx . . $ QTJSC/JSByteArray#JSByteArray(f5945a2a2cab03f).(VPtrStealingHackTypecxx . . $ QTJSC/JSByteArray#VPtrStealingHackType#) |
| 104 | : JSObjectcxx . . $ QTJSC/JSObject#(createStructurecxx . . $ QTJSC/JSByteArray#createStructure(da75fbe5e97e240f).(jsNullcxx . . $ QTJSC/jsNull(ad9afe69d7bf6378).())) |
| 105 | , m_classInfocxx . . $ QTJSC/JSByteArray#m_classInfo.(0) |
| 106 | { |
| 107 | } |
| 108 | |
| 109 | RefPtrcxx . . $ RefPtr#<WTFcxx . . $ `<built-in>:467:9`!::ByteArraycxx . . $ QTWTF/ByteArray#> m_storagecxx . . $ QTJSC/JSByteArray#m_storage.; |
| 110 | const ClassInfocxx . . $ QTJSC/ClassInfo#* m_classInfocxx . . $ QTJSC/JSByteArray#m_classInfo.; |
| 111 | }; |
| 112 | |
| 113 | JSByteArraycxx . . $ QTJSC/JSByteArray#* asByteArraycxx . . $ QTJSC/asByteArray(2ee06460bf5cb4a6).(JSValuecxx . . $ QTJSC/JSValue# value); |
| 114 | inline JSByteArraycxx . . $ QTJSC/JSByteArray#* asByteArraycxx . . $ QTJSC/asByteArray(2ee06460bf5cb4a6).(JSValuecxx . . $ QTJSC/JSValue# value) |
| 115 | { |
| 116 | return static_cast<JSByteArray*>(asCell(value)); |
| 117 | } |
| 118 | |
| 119 | inline bool isJSByteArraycxx . . $ QTJSC/isJSByteArray(b468e0305807c4ec).(JSGlobalDatacxx . . $ QTJSC/JSGlobalData#* globalData, JSValuecxx . . $ QTJSC/JSValue# v) { return v.isCellcxx . . $ QTJSC/JSValue#isCell(50ce9a9e25b4a850).() && v.asCellcxx . . $ QTJSC/JSValue#asCell(60510463d9a84528).()->vptrcxx . . $ QTJSC/JSCell#vptr(50c7df7de5344ebb).() == globalData->jsByteArrayVPtrcxx . . $ QTJSC/JSGlobalData#jsByteArrayVPtr.; } |
| 120 | |
| 121 | } // namespace JSC |
| 122 | |
| 123 | #endif // JSByteArray_h |