Skip to content

Commit ac4a764

Browse files
committed
Renamed Typed Array functions as suggested in https://bugs.webkit.org/show_bug.cgi?id=120112
1 parent 5570d06 commit ac4a764

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

JavaScriptCore/API/JSTypedArray.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "JSTypedArray.h"
55

6+
#include <wtf/RefPtr.h>
7+
68
#include "JSObjectRef.h"
79
#include "APICast.h"
810
#include "InitializeThreading.h"
@@ -76,23 +78,22 @@ const CreateTypedArrayFuncPtr CreateTypedArrayFunc[] = {
7678

7779

7880

79-
JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value) {
81+
JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object) {
8082
ExecState* exec = toJS(ctx);
8183
APIEntryShim entryShim(exec);
8284

83-
JSValue jsValue = toJS(exec, value);
85+
JSObject* jsObject = toJS(object);
8486
JSTypedArrayType type = kJSTypedArrayTypeNone;
85-
if( jsValue.inherits(JSArrayBufferView::info()) ) {
86-
JSObject* object = jsValue.getObject();
87-
type = TypedArrayTypes[object->classInfo()->typedArrayStorageType];
87+
if( jsObject->inherits(JSArrayBufferView::info()) ) {
88+
type = TypedArrayTypes[jsObject->classInfo()->typedArrayStorageType];
8889
}
89-
else if( jsValue.inherits(JSArrayBuffer::info()) ) {
90+
else if( jsObject->inherits(JSArrayBuffer::info()) ) {
9091
type = kJSTypedArrayTypeArrayBuffer;
9192
}
9293
return type;
9394
}
9495

95-
JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) {
96+
JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) {
9697
ExecState* exec = toJS(ctx);
9798
APIEntryShim entryShim(exec);
9899

@@ -104,18 +105,18 @@ JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_
104105
return toRef(result);
105106
}
106107

107-
void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteLength) {
108+
void* JSObjectGetTypedArrayDataPtr(JSContextRef ctx, JSObjectRef object, size_t* byteLength) {
108109
ExecState* exec = toJS(ctx);
109110
APIEntryShim entryShim(exec);
110111

111-
JSValue jsValue = toJS(exec, value);
112-
if( JSArrayBufferView * view = jsDynamicCast<JSArrayBufferView*>(jsValue) ) {
112+
JSObject* jsObject = toJS(object);
113+
if( JSArrayBufferView * view = jsDynamicCast<JSArrayBufferView*>(jsObject) ) {
113114
if( byteLength ) {
114115
*byteLength = view->impl()->byteLength();
115116
}
116117
return view->impl()->baseAddress();
117118
}
118-
else if( ArrayBuffer * buffer = toArrayBuffer(jsValue) ) {
119+
else if( ArrayBuffer* buffer = toArrayBuffer(jsObject) ) {
119120
if( byteLength ) {
120121
*byteLength = buffer->byteLength();
121122
}
@@ -127,6 +128,3 @@ void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteL
127128
}
128129
return NULL;
129130
}
130-
131-
132-

JavaScriptCore/API/JSTypedArray.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef enum {
4343
@param value The JSValue whose Typed Array type you want to obtain.
4444
@result A value of type JSTypedArrayType that identifies value's Typed Array type.
4545
*/
46-
JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value);
46+
JS_EXPORT JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object);
4747

4848
/*!
4949
@function
@@ -53,17 +53,17 @@ JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef valu
5353
@param numElements The number of elements for the array.
5454
@result A JSObjectRef that is a Typed Array or NULL if there was an error
5555
*/
56-
JS_EXPORT JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements);
56+
JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements);
5757

5858
/*!
5959
@function
6060
@abstract Returns a pointer to a Typed Array's data in memory
6161
@param ctx The execution context to use.
6262
@param value The JSValue whose Typed Array type data pointer you want to obtain.
6363
@param byteLength A pointer to a size_t in which to store the byte length of the Typed Array
64-
@result A pointer to the Typed Array's data or NULL if the JSValue is not a Typed Array
64+
@result A pointer to the Typed Array's data or NULL if the JSValue is not a Typed Array.
6565
*/
66-
JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteLength);
66+
JS_EXPORT void * JSObjectGetTypedArrayDataPtr(JSContextRef ctx, JSObjectRef object, size_t* byteLength);
6767

6868

6969
#ifdef __cplusplus

0 commit comments

Comments
 (0)