Skip to content

Commit 3b799ea

Browse files
committed
Formatting
1 parent 896dea1 commit 3b799ea

File tree

2 files changed

+50
-54
lines changed

2 files changed

+50
-54
lines changed

JavaScriptCore/API/JSTypedArray.cpp

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015 Dominic Szablewski. All rights reserved.
2+
* Copyright (C) 2015 Dominic Szablewski ([email protected])
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -25,18 +25,16 @@
2525

2626

2727
#include "config.h"
28-
2928
#include "JSTypedArray.h"
3029

31-
#include <wtf/RefPtr.h>
32-
3330
#include "JSObjectRef.h"
3431
#include "APICast.h"
3532
#include "InitializeThreading.h"
3633
#include "JSCallbackObject.h"
3734
#include "JSClassRef.h"
3835
#include "JSGlobalObject.h"
3936

37+
#include "TypedArrayInlines.h"
4038
#include "JSArrayBuffer.h"
4139
#include "JSFloat32Array.h"
4240
#include "JSFloat64Array.h"
@@ -48,7 +46,8 @@
4846
#include "JSUint16Array.h"
4947
#include "JSUint32Array.h"
5048

51-
#include "TypedArrayInlines.h"
49+
#include <wtf/RefPtr.h>
50+
5251

5352
using namespace JSC;
5453

@@ -71,9 +70,7 @@ struct OpaqueJSData : public ThreadSafeRefCounted<OpaqueJSData> {
7170
friend class WTF::ThreadSafeRefCounted<OpaqueJSData>;
7271

7372
OpaqueJSData(
74-
PassRefPtr<ArrayBuffer> buffer,
75-
void* baseAddress,
76-
size_t byteLength)
73+
PassRefPtr<ArrayBuffer> buffer, void* baseAddress, size_t byteLength)
7774
: m_byteLength(byteLength)
7875
, m_baseAddress(baseAddress)
7976
, m_buffer(buffer)
@@ -106,12 +103,11 @@ JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object)
106103

107104
JSObject* jsObject = toJS(object);
108105
JSTypedArrayType type = kJSTypedArrayTypeNone;
109-
if( jsObject->inherits(JSArrayBufferView::info()) ) {
106+
if (jsObject->inherits(JSArrayBufferView::info()))
110107
type = TypedArrayTypes[jsObject->classInfo()->typedArrayStorageType];
111-
}
112-
else if( jsObject->inherits(JSArrayBuffer::info()) ) {
108+
else if (jsObject->inherits(JSArrayBuffer::info()))
113109
type = kJSTypedArrayTypeArrayBuffer;
114-
}
110+
115111
return type;
116112
}
117113

@@ -122,41 +118,42 @@ JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType,
122118

123119
JSObject* result;
124120
JSGlobalObject* jsGlobal = exec->lexicalGlobalObject();
125-
switch( arrayType ) {
126-
case kJSTypedArrayTypeInt8Array:
127-
result = Int8Array::create(numElements)->wrap(exec, jsGlobal);
128-
break;
129-
case kJSTypedArrayTypeInt16Array:
130-
result = Int16Array::create(numElements)->wrap(exec, jsGlobal);
131-
break;
132-
case kJSTypedArrayTypeInt32Array:
133-
result = Int8Array::create(numElements)->wrap(exec, jsGlobal);
134-
break;
135-
case kJSTypedArrayTypeUint8Array:
136-
result = Int32Array::create(numElements)->wrap(exec, jsGlobal);
137-
break;
138-
case kJSTypedArrayTypeUint8ClampedArray:
139-
result = Uint8ClampedArray::create(numElements)->wrap(exec, jsGlobal);
140-
break;
141-
case kJSTypedArrayTypeUint16Array:
142-
result = Uint16Array::create(numElements)->wrap(exec, jsGlobal);
143-
break;
144-
case kJSTypedArrayTypeUint32Array:
145-
result = Uint32Array::create(numElements)->wrap(exec, jsGlobal);
146-
break;
147-
case kJSTypedArrayTypeFloat32Array:
148-
result = Float32Array::create(numElements)->wrap(exec, jsGlobal);
149-
break;
150-
case kJSTypedArrayTypeFloat64Array:
151-
result = Float64Array::create(numElements)->wrap(exec, jsGlobal);
152-
break;
153-
case kJSTypedArrayTypeArrayBuffer:
154-
result = JSArrayBuffer::create(
155-
exec->vm(), jsGlobal->arrayBufferStructure(), ArrayBuffer::create(numElements, 1));
156-
break;
157-
default:
158-
result = NULL;
159-
break;
121+
122+
switch (arrayType) {
123+
case kJSTypedArrayTypeInt8Array:
124+
result = Int8Array::create(numElements)->wrap(exec, jsGlobal);
125+
break;
126+
case kJSTypedArrayTypeInt16Array:
127+
result = Int16Array::create(numElements)->wrap(exec, jsGlobal);
128+
break;
129+
case kJSTypedArrayTypeInt32Array:
130+
result = Int8Array::create(numElements)->wrap(exec, jsGlobal);
131+
break;
132+
case kJSTypedArrayTypeUint8Array:
133+
result = Int32Array::create(numElements)->wrap(exec, jsGlobal);
134+
break;
135+
case kJSTypedArrayTypeUint8ClampedArray:
136+
result = Uint8ClampedArray::create(numElements)->wrap(exec, jsGlobal);
137+
break;
138+
case kJSTypedArrayTypeUint16Array:
139+
result = Uint16Array::create(numElements)->wrap(exec, jsGlobal);
140+
break;
141+
case kJSTypedArrayTypeUint32Array:
142+
result = Uint32Array::create(numElements)->wrap(exec, jsGlobal);
143+
break;
144+
case kJSTypedArrayTypeFloat32Array:
145+
result = Float32Array::create(numElements)->wrap(exec, jsGlobal);
146+
break;
147+
case kJSTypedArrayTypeFloat64Array:
148+
result = Float64Array::create(numElements)->wrap(exec, jsGlobal);
149+
break;
150+
case kJSTypedArrayTypeArrayBuffer:
151+
result = JSArrayBuffer::create(
152+
exec->vm(), jsGlobal->arrayBufferStructure(), ArrayBuffer::create(numElements, 1));
153+
break;
154+
default:
155+
result = nullptr;
156+
break;
160157
}
161158

162159
return toRef(result);
@@ -168,26 +165,25 @@ JSDataRef JSObjectGetRetainedTypedArrayData(JSContextRef ctx, JSObjectRef object
168165
APIEntryShim entryShim(exec);
169166

170167
JSObject* jsObject = toJS(object);
171-
if( JSArrayBufferView * view = jsDynamicCast<JSArrayBufferView*>(jsObject) ) {
168+
if (JSArrayBufferView * view = jsDynamicCast<JSArrayBufferView*>(jsObject))
172169
return OpaqueJSData::create(view->buffer(), view->impl()->baseAddress(), view->impl()->byteLength()).leakRef();
173-
}
174-
else if( ArrayBuffer* buffer = toArrayBuffer(jsObject) ) {
170+
171+
if (ArrayBuffer* buffer = toArrayBuffer(jsObject))
175172
return OpaqueJSData::create(buffer, buffer->data(), buffer->byteLength()).leakRef();
176-
}
177173

178174
return NULL;
179175
}
180176

181177
JSDataRef JSDataRetain(JSDataRef data)
182178
{
183-
if(data != nullptr)
179+
if (data)
184180
data->ref();
185181
return data;
186182
}
187183

188184
void JSDataRelease(JSDataRef data)
189185
{
190-
if(data != nullptr)
186+
if (data)
191187
data->deref();
192188
}
193189

JavaScriptCore/API/JSTypedArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015 Dominic Szablewski. All rights reserved.
2+
* Copyright (C) 2015 Dominic Szablewski ([email protected])
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions

0 commit comments

Comments
 (0)