@@ -26,30 +26,30 @@ static bool array_valueOf(JSContext *cx, unsigned argc, JS::Value *vp) {
26
26
return false ;
27
27
}
28
28
29
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
29
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
30
30
JS::RootedObject rootedArrayBuffer (cx, arrayBuffer->get ());
31
31
32
32
auto byteLength = JS::GetArrayBufferByteLength (rootedArrayBuffer);
33
33
34
- bool isSharedMemory;
34
+ bool isSharedMemory;
35
35
JS::AutoCheckCannotGC autoNoGC (cx);
36
36
uint8_t *data = JS::GetArrayBufferData (rootedArrayBuffer, &isSharedMemory, autoNoGC);
37
-
37
+
38
38
size_t numberOfDigits = 0 ;
39
39
for (size_t i = 0 ; i < byteLength; i++) {
40
- numberOfDigits += data[i] < 10 ? 1 : data[i] < 100 ? 2 : 3 ;
40
+ numberOfDigits += data[i] < 10 ? 1 : data[i] < 100 ? 2 : 3 ;
41
41
}
42
42
const size_t STRING_LENGTH = byteLength + numberOfDigits;
43
- JS::Latin1Char* buffer = (JS::Latin1Char *)malloc (sizeof (JS::Latin1Char) * STRING_LENGTH);
44
-
43
+ JS::Latin1Char * buffer = (JS::Latin1Char *)malloc (sizeof (JS::Latin1Char) * STRING_LENGTH);
44
+
45
45
size_t charIndex = 0 ;
46
- sprintf ((char *)&buffer[charIndex], " %d" , data[0 ]);
46
+ snprintf ((char *)&buffer[charIndex], 4 , " %d" , data[0 ]);
47
47
charIndex += data[0 ] < 10 ? 1 : data[0 ] < 100 ? 2 : 3 ;
48
48
49
49
for (size_t dataIndex = 1 ; dataIndex < byteLength; dataIndex++) {
50
50
buffer[charIndex] = ' ,' ;
51
51
charIndex++;
52
- sprintf ((char *)&buffer[charIndex], " %d" , data[dataIndex]);
52
+ snprintf ((char *)&buffer[charIndex], 4 , " %d" , data[dataIndex]);
53
53
charIndex += data[dataIndex] < 10 ? 1 : data[dataIndex] < 100 ? 2 : 3 ;
54
54
}
55
55
@@ -84,7 +84,7 @@ static bool iterator_next(JSContext *cx, unsigned argc, JS::Value *vp) {
84
84
JS::RootedObject thisObj (cx);
85
85
if (!args.computeThis (cx, &thisObj)) return false ;
86
86
87
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(thisObj, BytesIteratorSlotIteratedObject);
87
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(thisObj, BytesIteratorSlotIteratedObject);
88
88
JS::RootedObject rootedArrayBuffer (cx, arrayBuffer->get ());
89
89
90
90
JS::RootedValue rootedNextIndex (cx, JS::GetReservedSlot (thisObj, BytesIteratorSlotNextIndex));
@@ -112,7 +112,7 @@ static bool iterator_next(JSContext *cx, unsigned argc, JS::Value *vp) {
112
112
if (!JS_SetProperty (cx, result, " done" , done)) return false ;
113
113
114
114
if (itemKind == ITEM_KIND_VALUE) {
115
- bool isSharedMemory;
115
+ bool isSharedMemory;
116
116
JS::AutoCheckCannotGC autoNoGC (cx);
117
117
uint8_t *data = JS::GetArrayBufferData (rootedArrayBuffer, &isSharedMemory, autoNoGC);
118
118
@@ -125,7 +125,7 @@ static bool iterator_next(JSContext *cx, unsigned argc, JS::Value *vp) {
125
125
JS::RootedValue rootedNextIndex (cx, JS::Int32Value (nextIndex));
126
126
items[0 ].set (rootedNextIndex);
127
127
128
- bool isSharedMemory;
128
+ bool isSharedMemory;
129
129
JS::AutoCheckCannotGC autoNoGC (cx);
130
130
uint8_t *data = JS::GetArrayBufferData (rootedArrayBuffer, &isSharedMemory, autoNoGC);
131
131
@@ -216,8 +216,8 @@ static bool array_iterator_func(JSContext *cx, unsigned argc, JS::Value *vp, int
216
216
if (!JS::Construct (cx, constructor_val, JS::HandleValueArray::empty (), &obj)) return false ;
217
217
if (!obj) return false ;
218
218
219
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
220
-
219
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
220
+
221
221
JS::SetReservedSlot (obj, BytesIteratorSlotIteratedObject, JS::PrivateValue (arrayBuffer));
222
222
JS::SetReservedSlot (obj, BytesIteratorSlotNextIndex, JS::Int32Value (0 ));
223
223
JS::SetReservedSlot (obj, BytesIteratorSlotItemKind, JS::Int32Value (itemKind));
@@ -253,13 +253,13 @@ bool PyBytesProxyHandler::set(JSContext *cx, JS::HandleObject proxy, JS::HandleI
253
253
JS::HandleValue v, JS::HandleValue receiver,
254
254
JS::ObjectOpResult &result) const {
255
255
256
- // block all modifications
257
-
256
+ // block all modifications
257
+
258
258
PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
259
259
260
260
PyErr_Format (PyExc_TypeError,
261
- " '%.100s' object has only read-only attributes" ,
262
- Py_TYPE (self)->tp_name );
261
+ " '%.100s' object has only read-only attributes" ,
262
+ Py_TYPE (self)->tp_name );
263
263
264
264
return result.failReadOnly ();
265
265
}
@@ -298,7 +298,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
298
298
299
299
// "length" and "byteLength" properties have the same value
300
300
if ((JS_StringEqualsLiteral (cx, idString, " length" , &isProperty) && isProperty) || (JS_StringEqualsLiteral (cx, id.toString (), " byteLength" , &isProperty) && isProperty)) {
301
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
301
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
302
302
303
303
JS::RootedObject rootedArrayBuffer (cx, arrayBuffer->get ());
304
304
@@ -314,7 +314,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
314
314
315
315
// "buffer" property
316
316
if (JS_StringEqualsLiteral (cx, idString, " buffer" , &isProperty) && isProperty) {
317
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
317
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
318
318
319
319
desc.set (mozilla::Some (
320
320
JS::PropertyDescriptor::Data (
@@ -392,10 +392,10 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
392
392
// item
393
393
Py_ssize_t index ;
394
394
if (idToIndex (cx, id, &index )) {
395
- JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
395
+ JS::PersistentRootedObject * arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
396
396
JS::RootedObject rootedArrayBuffer (cx, arrayBuffer->get ());
397
397
398
- bool isSharedMemory;
398
+ bool isSharedMemory;
399
399
JS::AutoCheckCannotGC autoNoGC (cx);
400
400
uint8_t *data = JS::GetArrayBufferData (rootedArrayBuffer, &isSharedMemory, autoNoGC);
401
401
@@ -406,7 +406,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
406
406
));
407
407
408
408
return true ;
409
- }
409
+ }
410
410
411
411
PyObject *attrName = idToKey (cx, id);
412
412
PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
0 commit comments