OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_BIN_DARTUTILS_H_ | 5 #ifndef RUNTIME_BIN_DARTUTILS_H_ |
6 #define RUNTIME_BIN_DARTUTILS_H_ | 6 #define RUNTIME_BIN_DARTUTILS_H_ |
7 | 7 |
8 #include "bin/isolate_data.h" | 8 #include "bin/isolate_data.h" |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_native_api.h" | 10 #include "include/dart_native_api.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 * functions can also be nested without this error check, since all | 26 * functions can also be nested without this error check, since all |
27 * API functions return any error handles passed in as arguments, unchanged. | 27 * API functions return any error handles passed in as arguments, unchanged. |
28 */ | 28 */ |
29 static inline Dart_Handle ThrowIfError(Dart_Handle handle) { | 29 static inline Dart_Handle ThrowIfError(Dart_Handle handle) { |
30 if (Dart_IsError(handle)) { | 30 if (Dart_IsError(handle)) { |
31 Dart_PropagateError(handle); | 31 Dart_PropagateError(handle); |
32 } | 32 } |
33 return handle; | 33 return handle; |
34 } | 34 } |
35 | 35 |
36 | |
37 class CommandLineOptions { | 36 class CommandLineOptions { |
38 public: | 37 public: |
39 explicit CommandLineOptions(int max_count) | 38 explicit CommandLineOptions(int max_count) |
40 : count_(0), max_count_(max_count), arguments_(NULL) { | 39 : count_(0), max_count_(max_count), arguments_(NULL) { |
41 static const int kWordSize = sizeof(intptr_t); | 40 static const int kWordSize = sizeof(intptr_t); |
42 arguments_ = reinterpret_cast<const char**>(malloc(max_count * kWordSize)); | 41 arguments_ = reinterpret_cast<const char**>(malloc(max_count * kWordSize)); |
43 if (arguments_ == NULL) { | 42 if (arguments_ == NULL) { |
44 max_count_ = 0; | 43 max_count_ = 0; |
45 } | 44 } |
46 } | 45 } |
(...skipping 24 matching lines...) Expand all Loading... |
71 private: | 70 private: |
72 void* operator new(size_t size); | 71 void* operator new(size_t size); |
73 | 72 |
74 int count_; | 73 int count_; |
75 int max_count_; | 74 int max_count_; |
76 const char** arguments_; | 75 const char** arguments_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(CommandLineOptions); | 77 DISALLOW_COPY_AND_ASSIGN(CommandLineOptions); |
79 }; | 78 }; |
80 | 79 |
81 | |
82 class DartUtils { | 80 class DartUtils { |
83 public: | 81 public: |
84 // Returns the integer value of a Dart object. If the object is not | 82 // Returns the integer value of a Dart object. If the object is not |
85 // an integer value an API error is propagated. | 83 // an integer value an API error is propagated. |
86 static int64_t GetIntegerValue(Dart_Handle value_obj); | 84 static int64_t GetIntegerValue(Dart_Handle value_obj); |
87 // Returns the integer value of a Dart object. If the object is not | 85 // Returns the integer value of a Dart object. If the object is not |
88 // an integer value or outside the requested range an API error is | 86 // an integer value or outside the requested range an API error is |
89 // propagated. | 87 // propagated. |
90 static int64_t GetInt64ValueCheckRange(Dart_Handle value_obj, | 88 static int64_t GetInt64ValueCheckRange(Dart_Handle value_obj, |
91 int64_t lower, | 89 int64_t lower, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 bool is_service_isolate); | 252 bool is_service_isolate); |
255 static Dart_Handle PrepareAsyncLibrary(Dart_Handle async_lib, | 253 static Dart_Handle PrepareAsyncLibrary(Dart_Handle async_lib, |
256 Dart_Handle isolate_lib); | 254 Dart_Handle isolate_lib); |
257 static Dart_Handle PrepareIOLibrary(Dart_Handle io_lib); | 255 static Dart_Handle PrepareIOLibrary(Dart_Handle io_lib); |
258 static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib); | 256 static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib); |
259 | 257 |
260 DISALLOW_ALLOCATION(); | 258 DISALLOW_ALLOCATION(); |
261 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); | 259 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); |
262 }; | 260 }; |
263 | 261 |
264 | |
265 class CObject { | 262 class CObject { |
266 public: | 263 public: |
267 // These match the constants in sdk/lib/io/common.dart. | 264 // These match the constants in sdk/lib/io/common.dart. |
268 static const int kSuccess = 0; | 265 static const int kSuccess = 0; |
269 static const int kArgumentError = 1; | 266 static const int kArgumentError = 1; |
270 static const int kOSError = 2; | 267 static const int kOSError = 2; |
271 static const int kFileClosedError = 3; | 268 static const int kFileClosedError = 3; |
272 | 269 |
273 explicit CObject(Dart_CObject* cobject) : cobject_(cobject) {} | 270 explicit CObject(Dart_CObject* cobject) : cobject_(cobject) {} |
274 Dart_CObject_Type type() { return cobject_->type; } | 271 Dart_CObject_Type type() { return cobject_->type; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 static Dart_CObject api_true_; | 348 static Dart_CObject api_true_; |
352 static Dart_CObject api_false_; | 349 static Dart_CObject api_false_; |
353 static CObject null_; | 350 static CObject null_; |
354 static CObject true_; | 351 static CObject true_; |
355 static CObject false_; | 352 static CObject false_; |
356 | 353 |
357 private: | 354 private: |
358 DISALLOW_COPY_AND_ASSIGN(CObject); | 355 DISALLOW_COPY_AND_ASSIGN(CObject); |
359 }; | 356 }; |
360 | 357 |
361 | |
362 #define DECLARE_COBJECT_CONSTRUCTORS(t) \ | 358 #define DECLARE_COBJECT_CONSTRUCTORS(t) \ |
363 explicit CObject##t(Dart_CObject* cobject) : CObject(cobject) { \ | 359 explicit CObject##t(Dart_CObject* cobject) : CObject(cobject) { \ |
364 ASSERT(type() == Dart_CObject_k##t); \ | 360 ASSERT(type() == Dart_CObject_k##t); \ |
365 cobject_ = cobject; \ | 361 cobject_ = cobject; \ |
366 } \ | 362 } \ |
367 explicit CObject##t(CObject* cobject) : CObject() { \ | 363 explicit CObject##t(CObject* cobject) : CObject() { \ |
368 ASSERT(cobject != NULL); \ | 364 ASSERT(cobject != NULL); \ |
369 ASSERT(cobject->type() == Dart_CObject_k##t); \ | 365 ASSERT(cobject->type() == Dart_CObject_k##t); \ |
370 cobject_ = cobject->AsApiCObject(); \ | 366 cobject_ = cobject->AsApiCObject(); \ |
371 } | 367 } |
372 | 368 |
373 | |
374 #define DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(t) \ | 369 #define DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(t) \ |
375 explicit CObject##t##Array(Dart_CObject* cobject) : CObject(cobject) { \ | 370 explicit CObject##t##Array(Dart_CObject* cobject) : CObject(cobject) { \ |
376 ASSERT(type() == Dart_CObject_kTypedData); \ | 371 ASSERT(type() == Dart_CObject_kTypedData); \ |
377 ASSERT(byte_array_type() == Dart_TypedData_k##t); \ | 372 ASSERT(byte_array_type() == Dart_TypedData_k##t); \ |
378 cobject_ = cobject; \ | 373 cobject_ = cobject; \ |
379 } \ | 374 } \ |
380 explicit CObject##t##Array(CObject* cobject) : CObject() { \ | 375 explicit CObject##t##Array(CObject* cobject) : CObject() { \ |
381 ASSERT(cobject != NULL); \ | 376 ASSERT(cobject != NULL); \ |
382 ASSERT(cobject->type() == Dart_CObject_kTypedData); \ | 377 ASSERT(cobject->type() == Dart_CObject_kTypedData); \ |
383 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \ | 378 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \ |
384 cobject_ = cobject->AsApiCObject(); \ | 379 cobject_ = cobject->AsApiCObject(); \ |
385 } | 380 } |
386 | 381 |
387 | |
388 #define DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(t) \ | 382 #define DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(t) \ |
389 explicit CObjectExternal##t##Array(Dart_CObject* cobject) \ | 383 explicit CObjectExternal##t##Array(Dart_CObject* cobject) \ |
390 : CObject(cobject) { \ | 384 : CObject(cobject) { \ |
391 ASSERT(type() == Dart_CObject_kExternalTypedData); \ | 385 ASSERT(type() == Dart_CObject_kExternalTypedData); \ |
392 ASSERT(byte_array_type() == Dart_TypedData_k##t); \ | 386 ASSERT(byte_array_type() == Dart_TypedData_k##t); \ |
393 cobject_ = cobject; \ | 387 cobject_ = cobject; \ |
394 } \ | 388 } \ |
395 explicit CObjectExternal##t##Array(CObject* cobject) : CObject() { \ | 389 explicit CObjectExternal##t##Array(CObject* cobject) : CObject() { \ |
396 ASSERT(cobject != NULL); \ | 390 ASSERT(cobject != NULL); \ |
397 ASSERT(cobject->type() == Dart_CObject_kExternalTypedData); \ | 391 ASSERT(cobject->type() == Dart_CObject_kExternalTypedData); \ |
398 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \ | 392 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \ |
399 cobject_ = cobject->AsApiCObject(); \ | 393 cobject_ = cobject->AsApiCObject(); \ |
400 } | 394 } |
401 | 395 |
402 | |
403 class CObjectBool : public CObject { | 396 class CObjectBool : public CObject { |
404 public: | 397 public: |
405 DECLARE_COBJECT_CONSTRUCTORS(Bool) | 398 DECLARE_COBJECT_CONSTRUCTORS(Bool) |
406 | 399 |
407 bool Value() const { return cobject_->value.as_bool; } | 400 bool Value() const { return cobject_->value.as_bool; } |
408 | 401 |
409 private: | 402 private: |
410 DISALLOW_COPY_AND_ASSIGN(CObjectBool); | 403 DISALLOW_COPY_AND_ASSIGN(CObjectBool); |
411 }; | 404 }; |
412 | 405 |
413 | |
414 class CObjectInt32 : public CObject { | 406 class CObjectInt32 : public CObject { |
415 public: | 407 public: |
416 DECLARE_COBJECT_CONSTRUCTORS(Int32) | 408 DECLARE_COBJECT_CONSTRUCTORS(Int32) |
417 | 409 |
418 int32_t Value() const { return cobject_->value.as_int32; } | 410 int32_t Value() const { return cobject_->value.as_int32; } |
419 | 411 |
420 private: | 412 private: |
421 DISALLOW_COPY_AND_ASSIGN(CObjectInt32); | 413 DISALLOW_COPY_AND_ASSIGN(CObjectInt32); |
422 }; | 414 }; |
423 | 415 |
424 | |
425 class CObjectInt64 : public CObject { | 416 class CObjectInt64 : public CObject { |
426 public: | 417 public: |
427 DECLARE_COBJECT_CONSTRUCTORS(Int64) | 418 DECLARE_COBJECT_CONSTRUCTORS(Int64) |
428 | 419 |
429 int64_t Value() const { return cobject_->value.as_int64; } | 420 int64_t Value() const { return cobject_->value.as_int64; } |
430 | 421 |
431 private: | 422 private: |
432 DISALLOW_COPY_AND_ASSIGN(CObjectInt64); | 423 DISALLOW_COPY_AND_ASSIGN(CObjectInt64); |
433 }; | 424 }; |
434 | 425 |
435 | |
436 class CObjectIntptr : public CObject { | 426 class CObjectIntptr : public CObject { |
437 public: | 427 public: |
438 explicit CObjectIntptr(Dart_CObject* cobject) : CObject(cobject) { | 428 explicit CObjectIntptr(Dart_CObject* cobject) : CObject(cobject) { |
439 ASSERT(type() == Dart_CObject_kInt32 || type() == Dart_CObject_kInt64); | 429 ASSERT(type() == Dart_CObject_kInt32 || type() == Dart_CObject_kInt64); |
440 cobject_ = cobject; | 430 cobject_ = cobject; |
441 } | 431 } |
442 explicit CObjectIntptr(CObject* cobject) : CObject() { | 432 explicit CObjectIntptr(CObject* cobject) : CObject() { |
443 ASSERT(cobject != NULL); | 433 ASSERT(cobject != NULL); |
444 ASSERT(cobject->type() == Dart_CObject_kInt64 || | 434 ASSERT(cobject->type() == Dart_CObject_kInt64 || |
445 cobject->type() == Dart_CObject_kInt32); | 435 cobject->type() == Dart_CObject_kInt32); |
446 cobject_ = cobject->AsApiCObject(); | 436 cobject_ = cobject->AsApiCObject(); |
447 } | 437 } |
448 | 438 |
449 intptr_t Value() { | 439 intptr_t Value() { |
450 intptr_t result; | 440 intptr_t result; |
451 if (type() == Dart_CObject_kInt32) { | 441 if (type() == Dart_CObject_kInt32) { |
452 result = cobject_->value.as_int32; | 442 result = cobject_->value.as_int32; |
453 } else { | 443 } else { |
454 ASSERT(sizeof(result) == 8); | 444 ASSERT(sizeof(result) == 8); |
455 result = static_cast<intptr_t>(cobject_->value.as_int64); | 445 result = static_cast<intptr_t>(cobject_->value.as_int64); |
456 } | 446 } |
457 return result; | 447 return result; |
458 } | 448 } |
459 | 449 |
460 private: | 450 private: |
461 DISALLOW_COPY_AND_ASSIGN(CObjectIntptr); | 451 DISALLOW_COPY_AND_ASSIGN(CObjectIntptr); |
462 }; | 452 }; |
463 | 453 |
464 | |
465 class CObjectBigint : public CObject { | 454 class CObjectBigint : public CObject { |
466 public: | 455 public: |
467 // DECLARE_COBJECT_CONSTRUCTORS(Bigint) would miss hex_value_ initialization. | 456 // DECLARE_COBJECT_CONSTRUCTORS(Bigint) would miss hex_value_ initialization. |
468 explicit CObjectBigint(Dart_CObject* cobject) : CObject(cobject) { | 457 explicit CObjectBigint(Dart_CObject* cobject) : CObject(cobject) { |
469 ASSERT(type() == Dart_CObject_kBigint); | 458 ASSERT(type() == Dart_CObject_kBigint); |
470 cobject_ = cobject; | 459 cobject_ = cobject; |
471 hex_value_ = NULL; | 460 hex_value_ = NULL; |
472 } | 461 } |
473 explicit CObjectBigint(CObject* cobject) : CObject() { | 462 explicit CObjectBigint(CObject* cobject) : CObject() { |
474 ASSERT(cobject != NULL); | 463 ASSERT(cobject != NULL); |
(...skipping 10 matching lines...) Expand all Loading... |
485 return hex_value_; | 474 return hex_value_; |
486 } | 475 } |
487 | 476 |
488 ~CObjectBigint() { free(hex_value_); } | 477 ~CObjectBigint() { free(hex_value_); } |
489 | 478 |
490 private: | 479 private: |
491 char* hex_value_; | 480 char* hex_value_; |
492 DISALLOW_COPY_AND_ASSIGN(CObjectBigint); | 481 DISALLOW_COPY_AND_ASSIGN(CObjectBigint); |
493 }; | 482 }; |
494 | 483 |
495 | |
496 class CObjectDouble : public CObject { | 484 class CObjectDouble : public CObject { |
497 public: | 485 public: |
498 DECLARE_COBJECT_CONSTRUCTORS(Double) | 486 DECLARE_COBJECT_CONSTRUCTORS(Double) |
499 | 487 |
500 double Value() const { return cobject_->value.as_double; } | 488 double Value() const { return cobject_->value.as_double; } |
501 | 489 |
502 private: | 490 private: |
503 DISALLOW_COPY_AND_ASSIGN(CObjectDouble); | 491 DISALLOW_COPY_AND_ASSIGN(CObjectDouble); |
504 }; | 492 }; |
505 | 493 |
506 | |
507 class CObjectString : public CObject { | 494 class CObjectString : public CObject { |
508 public: | 495 public: |
509 DECLARE_COBJECT_CONSTRUCTORS(String) | 496 DECLARE_COBJECT_CONSTRUCTORS(String) |
510 | 497 |
511 intptr_t Length() const { return strlen(cobject_->value.as_string); } | 498 intptr_t Length() const { return strlen(cobject_->value.as_string); } |
512 char* CString() const { return cobject_->value.as_string; } | 499 char* CString() const { return cobject_->value.as_string; } |
513 | 500 |
514 private: | 501 private: |
515 DISALLOW_COPY_AND_ASSIGN(CObjectString); | 502 DISALLOW_COPY_AND_ASSIGN(CObjectString); |
516 }; | 503 }; |
517 | 504 |
518 | |
519 class CObjectArray : public CObject { | 505 class CObjectArray : public CObject { |
520 public: | 506 public: |
521 DECLARE_COBJECT_CONSTRUCTORS(Array) | 507 DECLARE_COBJECT_CONSTRUCTORS(Array) |
522 | 508 |
523 intptr_t Length() const { return cobject_->value.as_array.length; } | 509 intptr_t Length() const { return cobject_->value.as_array.length; } |
524 CObject* operator[](intptr_t index) const { | 510 CObject* operator[](intptr_t index) const { |
525 return new CObject(cobject_->value.as_array.values[index]); | 511 return new CObject(cobject_->value.as_array.values[index]); |
526 } | 512 } |
527 void SetAt(intptr_t index, CObject* value) { | 513 void SetAt(intptr_t index, CObject* value) { |
528 cobject_->value.as_array.values[index] = value->AsApiCObject(); | 514 cobject_->value.as_array.values[index] = value->AsApiCObject(); |
529 } | 515 } |
530 | 516 |
531 private: | 517 private: |
532 DISALLOW_COPY_AND_ASSIGN(CObjectArray); | 518 DISALLOW_COPY_AND_ASSIGN(CObjectArray); |
533 }; | 519 }; |
534 | 520 |
535 | |
536 class CObjectSendPort : public CObject { | 521 class CObjectSendPort : public CObject { |
537 public: | 522 public: |
538 DECLARE_COBJECT_CONSTRUCTORS(SendPort) | 523 DECLARE_COBJECT_CONSTRUCTORS(SendPort) |
539 | 524 |
540 Dart_Port Value() const { return cobject_->value.as_send_port.id; } | 525 Dart_Port Value() const { return cobject_->value.as_send_port.id; } |
541 Dart_Port OriginId() const { return cobject_->value.as_send_port.origin_id; } | 526 Dart_Port OriginId() const { return cobject_->value.as_send_port.origin_id; } |
542 | 527 |
543 private: | 528 private: |
544 DISALLOW_COPY_AND_ASSIGN(CObjectSendPort); | 529 DISALLOW_COPY_AND_ASSIGN(CObjectSendPort); |
545 }; | 530 }; |
546 | 531 |
547 | |
548 class CObjectTypedData : public CObject { | 532 class CObjectTypedData : public CObject { |
549 public: | 533 public: |
550 explicit CObjectTypedData(Dart_CObject* cobject) : CObject(cobject) { | 534 explicit CObjectTypedData(Dart_CObject* cobject) : CObject(cobject) { |
551 ASSERT(type() == Dart_CObject_kTypedData); | 535 ASSERT(type() == Dart_CObject_kTypedData); |
552 cobject_ = cobject; | 536 cobject_ = cobject; |
553 } | 537 } |
554 explicit CObjectTypedData(CObject* cobject) : CObject() { | 538 explicit CObjectTypedData(CObject* cobject) : CObject() { |
555 ASSERT(cobject != NULL); | 539 ASSERT(cobject != NULL); |
556 ASSERT(cobject->type() == Dart_CObject_kTypedData); | 540 ASSERT(cobject->type() == Dart_CObject_kTypedData); |
557 cobject_ = cobject->AsApiCObject(); | 541 cobject_ = cobject->AsApiCObject(); |
558 } | 542 } |
559 | 543 |
560 Dart_TypedData_Type Type() const { | 544 Dart_TypedData_Type Type() const { |
561 return cobject_->value.as_typed_data.type; | 545 return cobject_->value.as_typed_data.type; |
562 } | 546 } |
563 intptr_t Length() const { return cobject_->value.as_typed_data.length; } | 547 intptr_t Length() const { return cobject_->value.as_typed_data.length; } |
564 uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; } | 548 uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; } |
565 | 549 |
566 private: | 550 private: |
567 DISALLOW_COPY_AND_ASSIGN(CObjectTypedData); | 551 DISALLOW_COPY_AND_ASSIGN(CObjectTypedData); |
568 }; | 552 }; |
569 | 553 |
570 | |
571 class CObjectUint8Array : public CObject { | 554 class CObjectUint8Array : public CObject { |
572 public: | 555 public: |
573 DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(Uint8) | 556 DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(Uint8) |
574 | 557 |
575 intptr_t Length() const { return cobject_->value.as_typed_data.length; } | 558 intptr_t Length() const { return cobject_->value.as_typed_data.length; } |
576 uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; } | 559 uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; } |
577 | 560 |
578 private: | 561 private: |
579 DISALLOW_COPY_AND_ASSIGN(CObjectUint8Array); | 562 DISALLOW_COPY_AND_ASSIGN(CObjectUint8Array); |
580 }; | 563 }; |
581 | 564 |
582 | |
583 class CObjectExternalUint8Array : public CObject { | 565 class CObjectExternalUint8Array : public CObject { |
584 public: | 566 public: |
585 DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(Uint8) | 567 DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(Uint8) |
586 | 568 |
587 intptr_t Length() const { | 569 intptr_t Length() const { |
588 return cobject_->value.as_external_typed_data.length; | 570 return cobject_->value.as_external_typed_data.length; |
589 } | 571 } |
590 void SetLength(intptr_t length) { | 572 void SetLength(intptr_t length) { |
591 cobject_->value.as_external_typed_data.length = length; | 573 cobject_->value.as_external_typed_data.length = length; |
592 } | 574 } |
593 uint8_t* Data() const { return cobject_->value.as_external_typed_data.data; } | 575 uint8_t* Data() const { return cobject_->value.as_external_typed_data.data; } |
594 void* Peer() const { return cobject_->value.as_external_typed_data.peer; } | 576 void* Peer() const { return cobject_->value.as_external_typed_data.peer; } |
595 Dart_WeakPersistentHandleFinalizer Callback() const { | 577 Dart_WeakPersistentHandleFinalizer Callback() const { |
596 return cobject_->value.as_external_typed_data.callback; | 578 return cobject_->value.as_external_typed_data.callback; |
597 } | 579 } |
598 | 580 |
599 private: | 581 private: |
600 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); | 582 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); |
601 }; | 583 }; |
602 | 584 |
603 | |
604 class ScopedBlockingCall { | 585 class ScopedBlockingCall { |
605 public: | 586 public: |
606 ScopedBlockingCall() { Dart_ThreadDisableProfiling(); } | 587 ScopedBlockingCall() { Dart_ThreadDisableProfiling(); } |
607 | 588 |
608 ~ScopedBlockingCall() { Dart_ThreadEnableProfiling(); } | 589 ~ScopedBlockingCall() { Dart_ThreadEnableProfiling(); } |
609 | 590 |
610 private: | 591 private: |
611 DISALLOW_ALLOCATION(); | 592 DISALLOW_ALLOCATION(); |
612 DISALLOW_COPY_AND_ASSIGN(ScopedBlockingCall); | 593 DISALLOW_COPY_AND_ASSIGN(ScopedBlockingCall); |
613 }; | 594 }; |
614 | 595 |
615 | |
616 // Where the argument to the constructor is the handle for an object | 596 // Where the argument to the constructor is the handle for an object |
617 // implementing List<int>, this class creates a scope in which the memory | 597 // implementing List<int>, this class creates a scope in which the memory |
618 // backing the list can be accessed. | 598 // backing the list can be accessed. |
619 // | 599 // |
620 // Do not make Dart_ API calls while in a ScopedMemBuffer. | 600 // Do not make Dart_ API calls while in a ScopedMemBuffer. |
621 // Do not call Dart_PropagateError while in a ScopedMemBuffer. | 601 // Do not call Dart_PropagateError while in a ScopedMemBuffer. |
622 class ScopedMemBuffer { | 602 class ScopedMemBuffer { |
623 public: | 603 public: |
624 explicit ScopedMemBuffer(Dart_Handle object) { | 604 explicit ScopedMemBuffer(Dart_Handle object) { |
625 if (!Dart_IsTypedData(object) && !Dart_IsList(object)) { | 605 if (!Dart_IsTypedData(object) && !Dart_IsList(object)) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 bool is_typed_data_; | 645 bool is_typed_data_; |
666 | 646 |
667 DISALLOW_ALLOCATION(); | 647 DISALLOW_ALLOCATION(); |
668 DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer); | 648 DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer); |
669 }; | 649 }; |
670 | 650 |
671 } // namespace bin | 651 } // namespace bin |
672 } // namespace dart | 652 } // namespace dart |
673 | 653 |
674 #endif // RUNTIME_BIN_DARTUTILS_H_ | 654 #endif // RUNTIME_BIN_DARTUTILS_H_ |
OLD | NEW |