Skip to content

Commit 8bc3be0

Browse files
committed
Added JSFloat32ArrayCustom.cpp - not sure if we need this
1 parent 98721f3 commit 8bc3be0

File tree

3 files changed

+78
-14
lines changed

3 files changed

+78
-14
lines changed

JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@
555555
B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; };
556556
B6D1888B1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; };
557557
B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; };
558+
B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; };
559+
B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; };
558560
B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; };
559561
B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; };
560562
B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1831,6 +1833,7 @@
18311833
B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32Array.cpp; sourceTree = "<group>"; };
18321834
B6D1886F1672DFE700D1037C /* JSFloat32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat32Array.h; sourceTree = "<group>"; };
18331835
B6D188881673751400D1037C /* GlobalDataHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalDataHelper.h; sourceTree = "<group>"; };
1836+
B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32ArrayCustom.cpp; sourceTree = "<group>"; };
18341837
B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; };
18351838
B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; };
18361839
B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = "<group>"; };
@@ -2886,6 +2889,7 @@
28862889
B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */,
28872890
B6D18818166FA73400D1037C /* JSArrayBufferView.h */,
28882891
B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */,
2892+
B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */,
28892893
B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */,
28902894
B6D1886F1672DFE700D1037C /* JSFloat32Array.h */,
28912895
B6D188881673751400D1037C /* GlobalDataHelper.h */,
@@ -4354,6 +4358,7 @@
43544358
B6D18830166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */,
43554359
B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */,
43564360
B6D188701672DFE800D1037C /* JSFloat32Array.cpp in Sources */,
4361+
B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */,
43574362
);
43584363
runOnlyForDeploymentPostprocessing = 0;
43594364
};
@@ -4582,6 +4587,7 @@
45824587
B6D18831166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */,
45834588
B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */,
45844589
B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */,
4590+
B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */,
45854591
);
45864592
runOnlyForDeploymentPostprocessing = 0;
45874593
};

JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@
2727
#ifndef JSArrayBufferViewHelper_h
2828
#define JSArrayBufferViewHelper_h
2929

30-
#include "ExceptionCode.h"
3130
#include "JSArrayBuffer.h"
32-
#include "JSDOMBinding.h"
3331
#include <interpreter/CallFrame.h>
3432
#include <runtime/ArgList.h>
3533
#include <runtime/Error.h>
3634
#include <runtime/JSObject.h>
3735
#include <runtime/JSValue.h>
3836
#include <wtf/ArrayBufferView.h>
3937

40-
namespace JSC {
38+
namespace WebCore {
4139

4240
template <class T>
4341
JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionFunc)(JSC::JSValue))
@@ -52,7 +50,7 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF
5250
if (exec->argumentCount() == 2)
5351
offset = exec->argument(1).toInt32(exec);
5452
if (!impl->set(array, offset))
55-
setDOMException(exec, INDEX_SIZE_ERR);
53+
throwTypeError(exec);
5654

5755
return JSC::jsUndefined();
5856
}
@@ -67,7 +65,7 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF
6765
if (offset > impl->length()
6866
|| offset + length > impl->length()
6967
|| offset + length < offset)
70-
setDOMException(exec, INDEX_SIZE_ERR);
68+
throwTypeError(exec);
7169
else {
7270
for (uint32_t i = 0; i < length; i++) {
7371
JSC::JSValue v = array->get(exec, i);
@@ -105,7 +103,7 @@ PassRefPtr<C> constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* ex
105103
}
106104
RefPtr<C> array = C::create(buffer, offset, length);
107105
if (!array)
108-
setDOMException(exec, INDEX_SIZE_ERR);
106+
throwTypeError(exec);
109107
return array;
110108
}
111109

@@ -142,7 +140,7 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec)
142140
uint32_t length = srcArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec);
143141
RefPtr<C> array = C::create(length);
144142
if (!array) {
145-
setDOMException(exec, INDEX_SIZE_ERR);
143+
throwTypeError(exec);
146144
return array;
147145
}
148146

@@ -163,16 +161,15 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec)
163161
}
164162

165163
template <typename JSType, typename WebCoreType>
166-
static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object)
164+
static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, WebCoreType* object)
167165
{
166+
ASSERT_UNUSED(globalObject, globalObject);
168167
if (!object)
169168
return JSC::jsNull();
170-
171-
if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object))
172-
return wrapper;
173-
174-
exec->heap()->reportExtraMemoryCost(object->byteLength());
175-
return createWrapper<JSType>(exec, globalObject, object);
169+
170+
exec->heap()->reportExtraMemoryCost(object->byteLength());
171+
JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(object);
172+
return jsCell;
176173
}
177174

178175
} // namespace WebCore
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 COMPUTER, 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 COMPUTER, 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+
#include "config.h"
27+
#include "JSFloat32Array.h"
28+
29+
#include "JSArrayBufferViewHelper.h"
30+
#include <wtf/Float32Array.h>
31+
32+
using namespace JSC;
33+
34+
namespace WebCore {
35+
36+
void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
37+
{
38+
impl()->set(index, static_cast<float>(value.toNumber(exec)));
39+
}
40+
41+
JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Float32Array* object)
42+
{
43+
return toJSArrayBufferView<JSFloat32Array>(exec, globalObject, object);
44+
}
45+
46+
JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec)
47+
{
48+
return setWebGLArrayHelper(exec, impl(), toFloat32Array);
49+
}
50+
51+
EncodedJSValue JSC_HOST_CALL JSFloat32ArrayConstructor::constructJSFloat32Array(ExecState* exec)
52+
{
53+
JSFloat32ArrayConstructor* jsConstructor = jsCast<JSFloat32ArrayConstructor*>(exec->callee());
54+
RefPtr<Float32Array> array = constructArrayBufferView<Float32Array, float>(exec);
55+
if (!array.get())
56+
// Exception has already been thrown.
57+
return JSValue::encode(JSValue());
58+
return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
59+
}
60+
61+
} // namespace WebCore

0 commit comments

Comments
 (0)