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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 function ToPositiveDataViewOffset(offset) { | 253 function ToPositiveDataViewOffset(offset) { |
254 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); | 254 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); |
255 } | 255 } |
256 | 256 |
257 function DataViewGetInt8(offset, little_endian) { | 257 function DataViewGetInt8(offset, little_endian) { |
258 if (!IS_DATAVIEW(this)) { | 258 if (!IS_DATAVIEW(this)) { |
259 throw MakeTypeError('incompatible_method_reciever', | 259 throw MakeTypeError('incompatible_method_reciever', |
260 ['DataView.getInt8', this]); | 260 ['DataView.getInt8', this]); |
261 } | 261 } |
| 262 if (%_ArgumentsLength() < 1) { |
| 263 throw MakeTypeError('invalid_argument'); |
| 264 } |
262 return %DataViewGetInt8(this, | 265 return %DataViewGetInt8(this, |
263 ToPositiveDataViewOffset(offset), | 266 ToPositiveDataViewOffset(offset), |
264 !!little_endian); | 267 !!little_endian); |
265 } | 268 } |
266 | 269 |
267 function DataViewSetInt8(offset, value, little_endian) { | 270 function DataViewSetInt8(offset, value, little_endian) { |
268 if (!IS_DATAVIEW(this)) { | 271 if (!IS_DATAVIEW(this)) { |
269 throw MakeTypeError('incompatible_method_reciever', | 272 throw MakeTypeError('incompatible_method_reciever', |
270 ['DataView.setInt8', this]); | 273 ['DataView.setInt8', this]); |
271 } | 274 } |
| 275 if (%_ArgumentsLength() < 1) { |
| 276 throw MakeTypeError('invalid_argument'); |
| 277 } |
272 %DataViewSetInt8(this, | 278 %DataViewSetInt8(this, |
273 ToPositiveDataViewOffset(offset), | 279 ToPositiveDataViewOffset(offset), |
274 TO_NUMBER_INLINE(value), | 280 TO_NUMBER_INLINE(value), |
275 !!little_endian); | 281 !!little_endian); |
276 } | 282 } |
277 | 283 |
278 function DataViewGetUint8(offset, little_endian) { | 284 function DataViewGetUint8(offset, little_endian) { |
279 if (!IS_DATAVIEW(this)) { | 285 if (!IS_DATAVIEW(this)) { |
280 throw MakeTypeError('incompatible_method_reciever', | 286 throw MakeTypeError('incompatible_method_reciever', |
281 ['DataView.getUint8', this]); | 287 ['DataView.getUint8', this]); |
282 } | 288 } |
| 289 if (%_ArgumentsLength() < 1) { |
| 290 throw MakeTypeError('invalid_argument'); |
| 291 } |
283 return %DataViewGetUint8(this, | 292 return %DataViewGetUint8(this, |
284 ToPositiveDataViewOffset(offset), | 293 ToPositiveDataViewOffset(offset), |
285 !!little_endian); | 294 !!little_endian); |
286 } | 295 } |
287 | 296 |
288 function DataViewSetUint8(offset, value, little_endian) { | 297 function DataViewSetUint8(offset, value, little_endian) { |
289 if (!IS_DATAVIEW(this)) { | 298 if (!IS_DATAVIEW(this)) { |
290 throw MakeTypeError('incompatible_method_reciever', | 299 throw MakeTypeError('incompatible_method_reciever', |
291 ['DataView.setUint8', this]); | 300 ['DataView.setUint8', this]); |
292 } | 301 } |
| 302 if (%_ArgumentsLength() < 1) { |
| 303 throw MakeTypeError('invalid_argument'); |
| 304 } |
293 %DataViewSetUint8(this, | 305 %DataViewSetUint8(this, |
294 ToPositiveDataViewOffset(offset), | 306 ToPositiveDataViewOffset(offset), |
295 TO_NUMBER_INLINE(value), | 307 TO_NUMBER_INLINE(value), |
296 !!little_endian); | 308 !!little_endian); |
297 } | 309 } |
298 | 310 |
299 function DataViewGetInt16(offset, little_endian) { | 311 function DataViewGetInt16(offset, little_endian) { |
300 if (!IS_DATAVIEW(this)) { | 312 if (!IS_DATAVIEW(this)) { |
301 throw MakeTypeError('incompatible_method_reciever', | 313 throw MakeTypeError('incompatible_method_reciever', |
302 ['DataView.getInt16', this]); | 314 ['DataView.getInt16', this]); |
303 } | 315 } |
| 316 if (%_ArgumentsLength() < 1) { |
| 317 throw MakeTypeError('invalid_argument'); |
| 318 } |
304 return %DataViewGetInt16(this, | 319 return %DataViewGetInt16(this, |
305 ToPositiveDataViewOffset(offset), | 320 ToPositiveDataViewOffset(offset), |
306 !!little_endian); | 321 !!little_endian); |
307 } | 322 } |
308 | 323 |
309 function DataViewSetInt16(offset, value, little_endian) { | 324 function DataViewSetInt16(offset, value, little_endian) { |
310 if (!IS_DATAVIEW(this)) { | 325 if (!IS_DATAVIEW(this)) { |
311 throw MakeTypeError('incompatible_method_reciever', | 326 throw MakeTypeError('incompatible_method_reciever', |
312 ['DataView.setInt16', this]); | 327 ['DataView.setInt16', this]); |
313 } | 328 } |
| 329 if (%_ArgumentsLength() < 1) { |
| 330 throw MakeTypeError('invalid_argument'); |
| 331 } |
314 %DataViewSetInt16(this, | 332 %DataViewSetInt16(this, |
315 ToPositiveDataViewOffset(offset), | 333 ToPositiveDataViewOffset(offset), |
316 TO_NUMBER_INLINE(value), | 334 TO_NUMBER_INLINE(value), |
317 !!little_endian); | 335 !!little_endian); |
318 } | 336 } |
319 | 337 |
320 function DataViewGetUint16(offset, little_endian) { | 338 function DataViewGetUint16(offset, little_endian) { |
321 if (!IS_DATAVIEW(this)) { | 339 if (!IS_DATAVIEW(this)) { |
322 throw MakeTypeError('incompatible_method_reciever', | 340 throw MakeTypeError('incompatible_method_reciever', |
323 ['DataView.getUint16', this]); | 341 ['DataView.getUint16', this]); |
324 } | 342 } |
| 343 if (%_ArgumentsLength() < 1) { |
| 344 throw MakeTypeError('invalid_argument'); |
| 345 } |
325 return %DataViewGetUint16(this, | 346 return %DataViewGetUint16(this, |
326 ToPositiveDataViewOffset(offset), | 347 ToPositiveDataViewOffset(offset), |
327 !!little_endian); | 348 !!little_endian); |
328 } | 349 } |
329 | 350 |
330 function DataViewSetUint16(offset, value, little_endian) { | 351 function DataViewSetUint16(offset, value, little_endian) { |
331 if (!IS_DATAVIEW(this)) { | 352 if (!IS_DATAVIEW(this)) { |
332 throw MakeTypeError('incompatible_method_reciever', | 353 throw MakeTypeError('incompatible_method_reciever', |
333 ['DataView.setUint16', this]); | 354 ['DataView.setUint16', this]); |
334 } | 355 } |
| 356 if (%_ArgumentsLength() < 1) { |
| 357 throw MakeTypeError('invalid_argument'); |
| 358 } |
335 %DataViewSetUint16(this, | 359 %DataViewSetUint16(this, |
336 ToPositiveDataViewOffset(offset), | 360 ToPositiveDataViewOffset(offset), |
337 TO_NUMBER_INLINE(value), | 361 TO_NUMBER_INLINE(value), |
338 !!little_endian); | 362 !!little_endian); |
339 } | 363 } |
340 | 364 |
341 function DataViewGetInt32(offset, little_endian) { | 365 function DataViewGetInt32(offset, little_endian) { |
342 if (!IS_DATAVIEW(this)) { | 366 if (!IS_DATAVIEW(this)) { |
343 throw MakeTypeError('incompatible_method_reciever', | 367 throw MakeTypeError('incompatible_method_reciever', |
344 ['DataView.getInt32', this]); | 368 ['DataView.getInt32', this]); |
345 } | 369 } |
| 370 if (%_ArgumentsLength() < 1) { |
| 371 throw MakeTypeError('invalid_argument'); |
| 372 } |
346 return %DataViewGetInt32(this, | 373 return %DataViewGetInt32(this, |
347 ToPositiveDataViewOffset(offset), | 374 ToPositiveDataViewOffset(offset), |
348 !!little_endian); | 375 !!little_endian); |
349 } | 376 } |
350 | 377 |
351 function DataViewSetInt32(offset, value, little_endian) { | 378 function DataViewSetInt32(offset, value, little_endian) { |
352 if (!IS_DATAVIEW(this)) { | 379 if (!IS_DATAVIEW(this)) { |
353 throw MakeTypeError('incompatible_method_reciever', | 380 throw MakeTypeError('incompatible_method_reciever', |
354 ['DataView.setInt32', this]); | 381 ['DataView.setInt32', this]); |
355 } | 382 } |
| 383 if (%_ArgumentsLength() < 2) { |
| 384 throw MakeTypeError('invalid_argument'); |
| 385 } |
356 %DataViewSetInt32(this, | 386 %DataViewSetInt32(this, |
357 ToPositiveDataViewOffset(offset), | 387 ToPositiveDataViewOffset(offset), |
358 TO_NUMBER_INLINE(value), | 388 TO_NUMBER_INLINE(value), |
359 !!little_endian); | 389 !!little_endian); |
360 } | 390 } |
361 | 391 |
362 function DataViewGetUint32(offset, little_endian) { | 392 function DataViewGetUint32(offset, little_endian) { |
363 if (!IS_DATAVIEW(this)) { | 393 if (!IS_DATAVIEW(this)) { |
364 throw MakeTypeError('incompatible_method_reciever', | 394 throw MakeTypeError('incompatible_method_reciever', |
365 ['DataView.getUint32', this]); | 395 ['DataView.getUint32', this]); |
366 } | 396 } |
| 397 if (%_ArgumentsLength() < 1) { |
| 398 throw MakeTypeError('invalid_argument'); |
| 399 } |
367 return %DataViewGetUint32(this, | 400 return %DataViewGetUint32(this, |
368 ToPositiveDataViewOffset(offset), | 401 ToPositiveDataViewOffset(offset), |
369 !!little_endian); | 402 !!little_endian); |
370 } | 403 } |
371 | 404 |
372 function DataViewSetUint32(offset, value, little_endian) { | 405 function DataViewSetUint32(offset, value, little_endian) { |
373 if (!IS_DATAVIEW(this)) { | 406 if (!IS_DATAVIEW(this)) { |
374 throw MakeTypeError('incompatible_method_reciever', | 407 throw MakeTypeError('incompatible_method_reciever', |
375 ['DataView.setUint32', this]); | 408 ['DataView.setUint32', this]); |
376 } | 409 } |
| 410 if (%_ArgumentsLength() < 1) { |
| 411 throw MakeTypeError('invalid_argument'); |
| 412 } |
377 %DataViewSetUint32(this, | 413 %DataViewSetUint32(this, |
378 ToPositiveDataViewOffset(offset), | 414 ToPositiveDataViewOffset(offset), |
379 TO_NUMBER_INLINE(value), | 415 TO_NUMBER_INLINE(value), |
380 !!little_endian); | 416 !!little_endian); |
381 } | 417 } |
382 | 418 |
383 function DataViewGetFloat32(offset, little_endian) { | 419 function DataViewGetFloat32(offset, little_endian) { |
384 if (!IS_DATAVIEW(this)) { | 420 if (!IS_DATAVIEW(this)) { |
385 throw MakeTypeError('incompatible_method_reciever', | 421 throw MakeTypeError('incompatible_method_reciever', |
386 ['DataView.getFloat32', this]); | 422 ['DataView.getFloat32', this]); |
387 } | 423 } |
| 424 if (%_ArgumentsLength() < 1) { |
| 425 throw MakeTypeError('invalid_argument'); |
| 426 } |
388 return %DataViewGetFloat32(this, | 427 return %DataViewGetFloat32(this, |
389 ToPositiveDataViewOffset(offset), | 428 ToPositiveDataViewOffset(offset), |
390 !!little_endian); | 429 !!little_endian); |
391 } | 430 } |
392 | 431 |
393 function DataViewSetFloat32(offset, value, little_endian) { | 432 function DataViewSetFloat32(offset, value, little_endian) { |
394 if (!IS_DATAVIEW(this)) { | 433 if (!IS_DATAVIEW(this)) { |
395 throw MakeTypeError('incompatible_method_reciever', | 434 throw MakeTypeError('incompatible_method_reciever', |
396 ['DataView.setFloat32', this]); | 435 ['DataView.setFloat32', this]); |
397 } | 436 } |
| 437 if (%_ArgumentsLength() < 1) { |
| 438 throw MakeTypeError('invalid_argument'); |
| 439 } |
398 %DataViewSetFloat32(this, | 440 %DataViewSetFloat32(this, |
399 ToPositiveDataViewOffset(offset), | 441 ToPositiveDataViewOffset(offset), |
400 TO_NUMBER_INLINE(value), | 442 TO_NUMBER_INLINE(value), |
401 !!little_endian); | 443 !!little_endian); |
402 } | 444 } |
403 | 445 |
404 function DataViewGetFloat64(offset, little_endian) { | 446 function DataViewGetFloat64(offset, little_endian) { |
405 if (!IS_DATAVIEW(this)) { | 447 if (!IS_DATAVIEW(this)) { |
406 throw MakeTypeError('incompatible_method_reciever', | 448 throw MakeTypeError('incompatible_method_reciever', |
407 ['DataView.getFloat64', this]); | 449 ['DataView.getFloat64', this]); |
408 } | 450 } |
409 offset = TO_INTEGER(offset); | 451 if (%_ArgumentsLength() < 1) { |
410 if (offset < 0) { | 452 throw MakeTypeError('invalid_argument'); |
411 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
412 } | 453 } |
413 return %DataViewGetFloat64(this, | 454 return %DataViewGetFloat64(this, |
414 ToPositiveDataViewOffset(offset), | 455 ToPositiveDataViewOffset(offset), |
415 !!little_endian); | 456 !!little_endian); |
416 } | 457 } |
417 | 458 |
418 function DataViewSetFloat64(offset, value, little_endian) { | 459 function DataViewSetFloat64(offset, value, little_endian) { |
419 if (!IS_DATAVIEW(this)) { | 460 if (!IS_DATAVIEW(this)) { |
420 throw MakeTypeError('incompatible_method_reciever', | 461 throw MakeTypeError('incompatible_method_reciever', |
421 ['DataView.setFloat64', this]); | 462 ['DataView.setFloat64', this]); |
422 } | 463 } |
423 offset = TO_INTEGER(offset); | 464 if (%_ArgumentsLength() < 1) { |
424 if (offset < 0) { | 465 throw MakeTypeError('invalid_argument'); |
425 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
426 } | 466 } |
427 %DataViewSetFloat64(this, | 467 %DataViewSetFloat64(this, |
428 ToPositiveDataViewOffset(offset), | 468 ToPositiveDataViewOffset(offset), |
429 TO_NUMBER_INLINE(value), | 469 TO_NUMBER_INLINE(value), |
430 !!little_endian); | 470 !!little_endian); |
431 } | 471 } |
432 | 472 |
433 function SetupDataView() { | 473 function SetupDataView() { |
434 %CheckIsBootstrapping(); | 474 %CheckIsBootstrapping(); |
435 | 475 |
(...skipping 29 matching lines...) Expand all Loading... |
465 | 505 |
466 "getFloat32", DataViewGetFloat32, | 506 "getFloat32", DataViewGetFloat32, |
467 "setFloat32", DataViewSetFloat32, | 507 "setFloat32", DataViewSetFloat32, |
468 | 508 |
469 "getFloat64", DataViewGetFloat64, | 509 "getFloat64", DataViewGetFloat64, |
470 "setFloat64", DataViewSetFloat64 | 510 "setFloat64", DataViewSetFloat64 |
471 )); | 511 )); |
472 } | 512 } |
473 | 513 |
474 SetupDataView(); | 514 SetupDataView(); |
OLD | NEW |