OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 throw new MakeRangeError('invalid_data_view_length'); | 230 throw new MakeRangeError('invalid_data_view_length'); |
231 } | 231 } |
232 %DataViewInitialize(this, buffer, offset, length); | 232 %DataViewInitialize(this, buffer, offset, length); |
233 } else { | 233 } else { |
234 throw MakeTypeError('constructor_not_function', ["DataView"]); | 234 throw MakeTypeError('constructor_not_function', ["DataView"]); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 function DataViewGetBuffer() { | 238 function DataViewGetBuffer() { |
239 if (!IS_DATAVIEW(this)) { | 239 if (!IS_DATAVIEW(this)) { |
240 throw MakeTypeError('incompatible_method_reciever', | 240 throw MakeTypeError('incompatible_method_receiver', |
241 ['DataView.buffer', this]); | 241 ['DataView.buffer', this]); |
242 } | 242 } |
243 return %DataViewGetBuffer(this); | 243 return %DataViewGetBuffer(this); |
244 } | 244 } |
245 | 245 |
246 function DataViewGetByteOffset() { | 246 function DataViewGetByteOffset() { |
247 if (!IS_DATAVIEW(this)) { | 247 if (!IS_DATAVIEW(this)) { |
248 throw MakeTypeError('incompatible_method_reciever', | 248 throw MakeTypeError('incompatible_method_receiver', |
249 ['DataView.byteOffset', this]); | 249 ['DataView.byteOffset', this]); |
250 } | 250 } |
251 return %DataViewGetByteOffset(this); | 251 return %DataViewGetByteOffset(this); |
252 } | 252 } |
253 | 253 |
254 function DataViewGetByteLength() { | 254 function DataViewGetByteLength() { |
255 if (!IS_DATAVIEW(this)) { | 255 if (!IS_DATAVIEW(this)) { |
256 throw MakeTypeError('incompatible_method_reciever', | 256 throw MakeTypeError('incompatible_method_receiver', |
257 ['DataView.byteLength', this]); | 257 ['DataView.byteLength', this]); |
258 } | 258 } |
259 return %DataViewGetByteLength(this); | 259 return %DataViewGetByteLength(this); |
260 } | 260 } |
261 | 261 |
262 function ToPositiveDataViewOffset(offset) { | 262 function ToPositiveDataViewOffset(offset) { |
263 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); | 263 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); |
264 } | 264 } |
265 | 265 |
266 function DataViewGetInt8(offset, little_endian) { | 266 function DataViewGetInt8(offset, little_endian) { |
267 if (!IS_DATAVIEW(this)) { | 267 if (!IS_DATAVIEW(this)) { |
268 throw MakeTypeError('incompatible_method_reciever', | 268 throw MakeTypeError('incompatible_method_receiver', |
269 ['DataView.getInt8', this]); | 269 ['DataView.getInt8', this]); |
270 } | 270 } |
271 if (%_ArgumentsLength() < 1) { | 271 if (%_ArgumentsLength() < 1) { |
272 throw MakeTypeError('invalid_argument'); | 272 throw MakeTypeError('invalid_argument'); |
273 } | 273 } |
274 return %DataViewGetInt8(this, | 274 return %DataViewGetInt8(this, |
275 ToPositiveDataViewOffset(offset), | 275 ToPositiveDataViewOffset(offset), |
276 !!little_endian); | 276 !!little_endian); |
277 } | 277 } |
278 | 278 |
279 function DataViewSetInt8(offset, value, little_endian) { | 279 function DataViewSetInt8(offset, value, little_endian) { |
280 if (!IS_DATAVIEW(this)) { | 280 if (!IS_DATAVIEW(this)) { |
281 throw MakeTypeError('incompatible_method_reciever', | 281 throw MakeTypeError('incompatible_method_receiver', |
282 ['DataView.setInt8', this]); | 282 ['DataView.setInt8', this]); |
283 } | 283 } |
284 if (%_ArgumentsLength() < 1) { | 284 if (%_ArgumentsLength() < 2) { |
285 throw MakeTypeError('invalid_argument'); | 285 throw MakeTypeError('invalid_argument'); |
286 } | 286 } |
287 %DataViewSetInt8(this, | 287 %DataViewSetInt8(this, |
288 ToPositiveDataViewOffset(offset), | 288 ToPositiveDataViewOffset(offset), |
289 TO_NUMBER_INLINE(value), | 289 TO_NUMBER_INLINE(value), |
290 !!little_endian); | 290 !!little_endian); |
291 } | 291 } |
292 | 292 |
293 function DataViewGetUint8(offset, little_endian) { | 293 function DataViewGetUint8(offset, little_endian) { |
294 if (!IS_DATAVIEW(this)) { | 294 if (!IS_DATAVIEW(this)) { |
295 throw MakeTypeError('incompatible_method_reciever', | 295 throw MakeTypeError('incompatible_method_receiver', |
296 ['DataView.getUint8', this]); | 296 ['DataView.getUint8', this]); |
297 } | 297 } |
298 if (%_ArgumentsLength() < 1) { | 298 if (%_ArgumentsLength() < 1) { |
299 throw MakeTypeError('invalid_argument'); | 299 throw MakeTypeError('invalid_argument'); |
300 } | 300 } |
301 return %DataViewGetUint8(this, | 301 return %DataViewGetUint8(this, |
302 ToPositiveDataViewOffset(offset), | 302 ToPositiveDataViewOffset(offset), |
303 !!little_endian); | 303 !!little_endian); |
304 } | 304 } |
305 | 305 |
306 function DataViewSetUint8(offset, value, little_endian) { | 306 function DataViewSetUint8(offset, value, little_endian) { |
307 if (!IS_DATAVIEW(this)) { | 307 if (!IS_DATAVIEW(this)) { |
308 throw MakeTypeError('incompatible_method_reciever', | 308 throw MakeTypeError('incompatible_method_receiver', |
309 ['DataView.setUint8', this]); | 309 ['DataView.setUint8', this]); |
310 } | 310 } |
311 if (%_ArgumentsLength() < 1) { | 311 if (%_ArgumentsLength() < 2) { |
312 throw MakeTypeError('invalid_argument'); | 312 throw MakeTypeError('invalid_argument'); |
313 } | 313 } |
314 %DataViewSetUint8(this, | 314 %DataViewSetUint8(this, |
315 ToPositiveDataViewOffset(offset), | 315 ToPositiveDataViewOffset(offset), |
316 TO_NUMBER_INLINE(value), | 316 TO_NUMBER_INLINE(value), |
317 !!little_endian); | 317 !!little_endian); |
318 } | 318 } |
319 | 319 |
320 function DataViewGetInt16(offset, little_endian) { | 320 function DataViewGetInt16(offset, little_endian) { |
321 if (!IS_DATAVIEW(this)) { | 321 if (!IS_DATAVIEW(this)) { |
322 throw MakeTypeError('incompatible_method_reciever', | 322 throw MakeTypeError('incompatible_method_receiver', |
323 ['DataView.getInt16', this]); | 323 ['DataView.getInt16', this]); |
324 } | 324 } |
325 if (%_ArgumentsLength() < 1) { | 325 if (%_ArgumentsLength() < 1) { |
326 throw MakeTypeError('invalid_argument'); | 326 throw MakeTypeError('invalid_argument'); |
327 } | 327 } |
328 return %DataViewGetInt16(this, | 328 return %DataViewGetInt16(this, |
329 ToPositiveDataViewOffset(offset), | 329 ToPositiveDataViewOffset(offset), |
330 !!little_endian); | 330 !!little_endian); |
331 } | 331 } |
332 | 332 |
333 function DataViewSetInt16(offset, value, little_endian) { | 333 function DataViewSetInt16(offset, value, little_endian) { |
334 if (!IS_DATAVIEW(this)) { | 334 if (!IS_DATAVIEW(this)) { |
335 throw MakeTypeError('incompatible_method_reciever', | 335 throw MakeTypeError('incompatible_method_receiver', |
336 ['DataView.setInt16', this]); | 336 ['DataView.setInt16', this]); |
337 } | 337 } |
338 if (%_ArgumentsLength() < 1) { | 338 if (%_ArgumentsLength() < 2) { |
339 throw MakeTypeError('invalid_argument'); | 339 throw MakeTypeError('invalid_argument'); |
340 } | 340 } |
341 %DataViewSetInt16(this, | 341 %DataViewSetInt16(this, |
342 ToPositiveDataViewOffset(offset), | 342 ToPositiveDataViewOffset(offset), |
343 TO_NUMBER_INLINE(value), | 343 TO_NUMBER_INLINE(value), |
344 !!little_endian); | 344 !!little_endian); |
345 } | 345 } |
346 | 346 |
347 function DataViewGetUint16(offset, little_endian) { | 347 function DataViewGetUint16(offset, little_endian) { |
348 if (!IS_DATAVIEW(this)) { | 348 if (!IS_DATAVIEW(this)) { |
349 throw MakeTypeError('incompatible_method_reciever', | 349 throw MakeTypeError('incompatible_method_receiver', |
350 ['DataView.getUint16', this]); | 350 ['DataView.getUint16', this]); |
351 } | 351 } |
352 if (%_ArgumentsLength() < 1) { | 352 if (%_ArgumentsLength() < 1) { |
353 throw MakeTypeError('invalid_argument'); | 353 throw MakeTypeError('invalid_argument'); |
354 } | 354 } |
355 return %DataViewGetUint16(this, | 355 return %DataViewGetUint16(this, |
356 ToPositiveDataViewOffset(offset), | 356 ToPositiveDataViewOffset(offset), |
357 !!little_endian); | 357 !!little_endian); |
358 } | 358 } |
359 | 359 |
360 function DataViewSetUint16(offset, value, little_endian) { | 360 function DataViewSetUint16(offset, value, little_endian) { |
361 if (!IS_DATAVIEW(this)) { | 361 if (!IS_DATAVIEW(this)) { |
362 throw MakeTypeError('incompatible_method_reciever', | 362 throw MakeTypeError('incompatible_method_receiver', |
363 ['DataView.setUint16', this]); | 363 ['DataView.setUint16', this]); |
364 } | 364 } |
365 if (%_ArgumentsLength() < 1) { | 365 if (%_ArgumentsLength() < 2) { |
366 throw MakeTypeError('invalid_argument'); | 366 throw MakeTypeError('invalid_argument'); |
367 } | 367 } |
368 %DataViewSetUint16(this, | 368 %DataViewSetUint16(this, |
369 ToPositiveDataViewOffset(offset), | 369 ToPositiveDataViewOffset(offset), |
370 TO_NUMBER_INLINE(value), | 370 TO_NUMBER_INLINE(value), |
371 !!little_endian); | 371 !!little_endian); |
372 } | 372 } |
373 | 373 |
374 function DataViewGetInt32(offset, little_endian) { | 374 function DataViewGetInt32(offset, little_endian) { |
375 if (!IS_DATAVIEW(this)) { | 375 if (!IS_DATAVIEW(this)) { |
376 throw MakeTypeError('incompatible_method_reciever', | 376 throw MakeTypeError('incompatible_method_receiver', |
377 ['DataView.getInt32', this]); | 377 ['DataView.getInt32', this]); |
378 } | 378 } |
379 if (%_ArgumentsLength() < 1) { | 379 if (%_ArgumentsLength() < 1) { |
380 throw MakeTypeError('invalid_argument'); | 380 throw MakeTypeError('invalid_argument'); |
381 } | 381 } |
382 return %DataViewGetInt32(this, | 382 return %DataViewGetInt32(this, |
383 ToPositiveDataViewOffset(offset), | 383 ToPositiveDataViewOffset(offset), |
384 !!little_endian); | 384 !!little_endian); |
385 } | 385 } |
386 | 386 |
387 function DataViewSetInt32(offset, value, little_endian) { | 387 function DataViewSetInt32(offset, value, little_endian) { |
388 if (!IS_DATAVIEW(this)) { | 388 if (!IS_DATAVIEW(this)) { |
389 throw MakeTypeError('incompatible_method_reciever', | 389 throw MakeTypeError('incompatible_method_receiver', |
390 ['DataView.setInt32', this]); | 390 ['DataView.setInt32', this]); |
391 } | 391 } |
392 if (%_ArgumentsLength() < 2) { | 392 if (%_ArgumentsLength() < 2) { |
393 throw MakeTypeError('invalid_argument'); | 393 throw MakeTypeError('invalid_argument'); |
394 } | 394 } |
395 %DataViewSetInt32(this, | 395 %DataViewSetInt32(this, |
396 ToPositiveDataViewOffset(offset), | 396 ToPositiveDataViewOffset(offset), |
397 TO_NUMBER_INLINE(value), | 397 TO_NUMBER_INLINE(value), |
398 !!little_endian); | 398 !!little_endian); |
399 } | 399 } |
400 | 400 |
401 function DataViewGetUint32(offset, little_endian) { | 401 function DataViewGetUint32(offset, little_endian) { |
402 if (!IS_DATAVIEW(this)) { | 402 if (!IS_DATAVIEW(this)) { |
403 throw MakeTypeError('incompatible_method_reciever', | 403 throw MakeTypeError('incompatible_method_receiver', |
404 ['DataView.getUint32', this]); | 404 ['DataView.getUint32', this]); |
405 } | 405 } |
406 if (%_ArgumentsLength() < 1) { | 406 if (%_ArgumentsLength() < 1) { |
407 throw MakeTypeError('invalid_argument'); | 407 throw MakeTypeError('invalid_argument'); |
408 } | 408 } |
409 return %DataViewGetUint32(this, | 409 return %DataViewGetUint32(this, |
410 ToPositiveDataViewOffset(offset), | 410 ToPositiveDataViewOffset(offset), |
411 !!little_endian); | 411 !!little_endian); |
412 } | 412 } |
413 | 413 |
414 function DataViewSetUint32(offset, value, little_endian) { | 414 function DataViewSetUint32(offset, value, little_endian) { |
415 if (!IS_DATAVIEW(this)) { | 415 if (!IS_DATAVIEW(this)) { |
416 throw MakeTypeError('incompatible_method_reciever', | 416 throw MakeTypeError('incompatible_method_receiver', |
417 ['DataView.setUint32', this]); | 417 ['DataView.setUint32', this]); |
418 } | 418 } |
419 if (%_ArgumentsLength() < 1) { | 419 if (%_ArgumentsLength() < 2) { |
420 throw MakeTypeError('invalid_argument'); | 420 throw MakeTypeError('invalid_argument'); |
421 } | 421 } |
422 %DataViewSetUint32(this, | 422 %DataViewSetUint32(this, |
423 ToPositiveDataViewOffset(offset), | 423 ToPositiveDataViewOffset(offset), |
424 TO_NUMBER_INLINE(value), | 424 TO_NUMBER_INLINE(value), |
425 !!little_endian); | 425 !!little_endian); |
426 } | 426 } |
427 | 427 |
428 function DataViewGetFloat32(offset, little_endian) { | 428 function DataViewGetFloat32(offset, little_endian) { |
429 if (!IS_DATAVIEW(this)) { | 429 if (!IS_DATAVIEW(this)) { |
430 throw MakeTypeError('incompatible_method_reciever', | 430 throw MakeTypeError('incompatible_method_receiver', |
431 ['DataView.getFloat32', this]); | 431 ['DataView.getFloat32', this]); |
432 } | 432 } |
433 if (%_ArgumentsLength() < 1) { | 433 if (%_ArgumentsLength() < 1) { |
434 throw MakeTypeError('invalid_argument'); | 434 throw MakeTypeError('invalid_argument'); |
435 } | 435 } |
436 return %DataViewGetFloat32(this, | 436 return %DataViewGetFloat32(this, |
437 ToPositiveDataViewOffset(offset), | 437 ToPositiveDataViewOffset(offset), |
438 !!little_endian); | 438 !!little_endian); |
439 } | 439 } |
440 | 440 |
441 function DataViewSetFloat32(offset, value, little_endian) { | 441 function DataViewSetFloat32(offset, value, little_endian) { |
442 if (!IS_DATAVIEW(this)) { | 442 if (!IS_DATAVIEW(this)) { |
443 throw MakeTypeError('incompatible_method_reciever', | 443 throw MakeTypeError('incompatible_method_receiver', |
444 ['DataView.setFloat32', this]); | 444 ['DataView.setFloat32', this]); |
445 } | 445 } |
446 if (%_ArgumentsLength() < 1) { | 446 if (%_ArgumentsLength() < 2) { |
447 throw MakeTypeError('invalid_argument'); | 447 throw MakeTypeError('invalid_argument'); |
448 } | 448 } |
449 %DataViewSetFloat32(this, | 449 %DataViewSetFloat32(this, |
450 ToPositiveDataViewOffset(offset), | 450 ToPositiveDataViewOffset(offset), |
451 TO_NUMBER_INLINE(value), | 451 TO_NUMBER_INLINE(value), |
452 !!little_endian); | 452 !!little_endian); |
453 } | 453 } |
454 | 454 |
455 function DataViewGetFloat64(offset, little_endian) { | 455 function DataViewGetFloat64(offset, little_endian) { |
456 if (!IS_DATAVIEW(this)) { | 456 if (!IS_DATAVIEW(this)) { |
457 throw MakeTypeError('incompatible_method_reciever', | 457 throw MakeTypeError('incompatible_method_receiver', |
458 ['DataView.getFloat64', this]); | 458 ['DataView.getFloat64', this]); |
459 } | 459 } |
460 if (%_ArgumentsLength() < 1) { | 460 if (%_ArgumentsLength() < 1) { |
461 throw MakeTypeError('invalid_argument'); | 461 throw MakeTypeError('invalid_argument'); |
462 } | 462 } |
463 return %DataViewGetFloat64(this, | 463 return %DataViewGetFloat64(this, |
464 ToPositiveDataViewOffset(offset), | 464 ToPositiveDataViewOffset(offset), |
465 !!little_endian); | 465 !!little_endian); |
466 } | 466 } |
467 | 467 |
468 function DataViewSetFloat64(offset, value, little_endian) { | 468 function DataViewSetFloat64(offset, value, little_endian) { |
469 if (!IS_DATAVIEW(this)) { | 469 if (!IS_DATAVIEW(this)) { |
470 throw MakeTypeError('incompatible_method_reciever', | 470 throw MakeTypeError('incompatible_method_receiver', |
471 ['DataView.setFloat64', this]); | 471 ['DataView.setFloat64', this]); |
472 } | 472 } |
473 if (%_ArgumentsLength() < 1) { | 473 if (%_ArgumentsLength() < 2) { |
474 throw MakeTypeError('invalid_argument'); | 474 throw MakeTypeError('invalid_argument'); |
475 } | 475 } |
476 %DataViewSetFloat64(this, | 476 %DataViewSetFloat64(this, |
477 ToPositiveDataViewOffset(offset), | 477 ToPositiveDataViewOffset(offset), |
478 TO_NUMBER_INLINE(value), | 478 TO_NUMBER_INLINE(value), |
479 !!little_endian); | 479 !!little_endian); |
480 } | 480 } |
481 | 481 |
482 function SetupDataView() { | 482 function SetupDataView() { |
483 %CheckIsBootstrapping(); | 483 %CheckIsBootstrapping(); |
(...skipping 30 matching lines...) Expand all Loading... |
514 | 514 |
515 "getFloat32", DataViewGetFloat32, | 515 "getFloat32", DataViewGetFloat32, |
516 "setFloat32", DataViewSetFloat32, | 516 "setFloat32", DataViewSetFloat32, |
517 | 517 |
518 "getFloat64", DataViewGetFloat64, | 518 "getFloat64", DataViewGetFloat64, |
519 "setFloat64", DataViewSetFloat64 | 519 "setFloat64", DataViewSetFloat64 |
520 )); | 520 )); |
521 } | 521 } |
522 | 522 |
523 SetupDataView(); | 523 SetupDataView(); |
OLD | NEW |