| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 case kTypedDataFloat32ArrayCid : | 2397 case kTypedDataFloat32ArrayCid : |
| 2398 case kTypedDataFloat32ArrayViewCid : | 2398 case kTypedDataFloat32ArrayViewCid : |
| 2399 case kExternalTypedDataFloat32ArrayCid : | 2399 case kExternalTypedDataFloat32ArrayCid : |
| 2400 type = kFloat32; | 2400 type = kFloat32; |
| 2401 break; | 2401 break; |
| 2402 case kTypedDataFloat64ArrayCid : | 2402 case kTypedDataFloat64ArrayCid : |
| 2403 case kTypedDataFloat64ArrayViewCid : | 2403 case kTypedDataFloat64ArrayViewCid : |
| 2404 case kExternalTypedDataFloat64ArrayCid : | 2404 case kExternalTypedDataFloat64ArrayCid : |
| 2405 type = kFloat64; | 2405 type = kFloat64; |
| 2406 break; | 2406 break; |
| 2407 case kTypedDataFloat32x4ArrayCid : |
| 2408 case kTypedDataFloat32x4ArrayViewCid : |
| 2409 case kExternalTypedDataFloat32x4ArrayCid : |
| 2410 type = kFloat32x4; |
| 2411 break; |
| 2407 default: | 2412 default: |
| 2408 type = kInvalid; | 2413 type = kInvalid; |
| 2409 break; | 2414 break; |
| 2410 } | 2415 } |
| 2411 return type; | 2416 return type; |
| 2412 } | 2417 } |
| 2413 | 2418 |
| 2414 | 2419 |
| 2415 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) { | 2420 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) { |
| 2416 intptr_t class_id = Api::ClassId(object); | 2421 intptr_t class_id = Api::ClassId(object); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 case kUint32 : | 2564 case kUint32 : |
| 2560 return NewTypedData(isolate, kTypedDataUint32ArrayCid, length); | 2565 return NewTypedData(isolate, kTypedDataUint32ArrayCid, length); |
| 2561 case kInt64 : | 2566 case kInt64 : |
| 2562 return NewTypedData(isolate, kTypedDataInt64ArrayCid, length); | 2567 return NewTypedData(isolate, kTypedDataInt64ArrayCid, length); |
| 2563 case kUint64 : | 2568 case kUint64 : |
| 2564 return NewTypedData(isolate, kTypedDataUint64ArrayCid, length); | 2569 return NewTypedData(isolate, kTypedDataUint64ArrayCid, length); |
| 2565 case kFloat32 : | 2570 case kFloat32 : |
| 2566 return NewTypedData(isolate, kTypedDataFloat32ArrayCid, length); | 2571 return NewTypedData(isolate, kTypedDataFloat32ArrayCid, length); |
| 2567 case kFloat64 : | 2572 case kFloat64 : |
| 2568 return NewTypedData(isolate, kTypedDataFloat64ArrayCid, length); | 2573 return NewTypedData(isolate, kTypedDataFloat64ArrayCid, length); |
| 2574 case kFloat32x4: |
| 2575 return NewTypedData(isolate, kTypedDataFloat32x4ArrayCid, length); |
| 2569 default: | 2576 default: |
| 2570 return Api::NewError("%s expects argument 'type' to be of 'TypedData'", | 2577 return Api::NewError("%s expects argument 'type' to be of 'TypedData'", |
| 2571 CURRENT_FUNC); | 2578 CURRENT_FUNC); |
| 2572 } | 2579 } |
| 2573 UNREACHABLE(); | 2580 UNREACHABLE(); |
| 2574 return Api::Null(isolate); | 2581 return Api::Null(isolate); |
| 2575 } | 2582 } |
| 2576 | 2583 |
| 2577 | 2584 |
| 2578 DART_EXPORT Dart_Handle Dart_NewExternalTypedData( | 2585 DART_EXPORT Dart_Handle Dart_NewExternalTypedData( |
| 2579 Dart_TypedData_Type type, | 2586 Dart_TypedData_Type type, |
| 2580 void* data, | 2587 void* data, |
| 2581 intptr_t length, | 2588 intptr_t length, |
| 2582 void* peer, | 2589 void* peer, |
| 2583 Dart_WeakPersistentHandleFinalizer callback) { | 2590 Dart_WeakPersistentHandleFinalizer callback) { |
| 2584 Isolate* isolate = Isolate::Current(); | 2591 Isolate* isolate = Isolate::Current(); |
| 2585 DARTSCOPE(isolate); | 2592 DARTSCOPE(isolate); |
| 2586 if (data == NULL && length != 0) { | 2593 if (data == NULL && length != 0) { |
| 2587 RETURN_NULL_ERROR(data); | 2594 RETURN_NULL_ERROR(data); |
| 2588 } | 2595 } |
| 2589 CHECK_CALLBACK_STATE(isolate); | 2596 CHECK_CALLBACK_STATE(isolate); |
| 2590 switch (type) { | 2597 switch (type) { |
| 2591 case kByteData : | 2598 case kByteData: |
| 2592 return NewExternalByteData(isolate, data, length, peer, callback); | 2599 return NewExternalByteData(isolate, data, length, peer, callback); |
| 2593 case kInt8 : | 2600 case kInt8: |
| 2594 return NewExternalTypedData(kExternalTypedDataInt8ArrayCid, | 2601 return NewExternalTypedData(kExternalTypedDataInt8ArrayCid, |
| 2595 data, | 2602 data, |
| 2596 length, | 2603 length, |
| 2597 peer, | 2604 peer, |
| 2598 callback); | 2605 callback); |
| 2599 case kUint8 : | 2606 case kUint8: |
| 2600 return NewExternalTypedData(kExternalTypedDataUint8ArrayCid, | 2607 return NewExternalTypedData(kExternalTypedDataUint8ArrayCid, |
| 2601 data, | 2608 data, |
| 2602 length, | 2609 length, |
| 2603 peer, | 2610 peer, |
| 2604 callback); | 2611 callback); |
| 2605 case kUint8Clamped : | 2612 case kUint8Clamped: |
| 2606 return NewExternalTypedData(kExternalTypedDataUint8ClampedArrayCid, | 2613 return NewExternalTypedData(kExternalTypedDataUint8ClampedArrayCid, |
| 2607 data, | 2614 data, |
| 2608 length, | 2615 length, |
| 2609 peer, | 2616 peer, |
| 2610 callback); | 2617 callback); |
| 2611 case kInt16 : | 2618 case kInt16: |
| 2612 return NewExternalTypedData(kExternalTypedDataInt16ArrayCid, | 2619 return NewExternalTypedData(kExternalTypedDataInt16ArrayCid, |
| 2613 data, | 2620 data, |
| 2614 length, | 2621 length, |
| 2615 peer, | 2622 peer, |
| 2616 callback); | 2623 callback); |
| 2617 case kUint16 : | 2624 case kUint16: |
| 2618 return NewExternalTypedData(kExternalTypedDataUint16ArrayCid, | 2625 return NewExternalTypedData(kExternalTypedDataUint16ArrayCid, |
| 2619 data, | 2626 data, |
| 2620 length, | 2627 length, |
| 2621 peer, | 2628 peer, |
| 2622 callback); | 2629 callback); |
| 2623 case kInt32 : | 2630 case kInt32: |
| 2624 return NewExternalTypedData(kExternalTypedDataInt32ArrayCid, | 2631 return NewExternalTypedData(kExternalTypedDataInt32ArrayCid, |
| 2625 data, | 2632 data, |
| 2626 length, | 2633 length, |
| 2627 peer, | 2634 peer, |
| 2628 callback); | 2635 callback); |
| 2629 case kUint32 : | 2636 case kUint32: |
| 2630 return NewExternalTypedData(kExternalTypedDataUint32ArrayCid, | 2637 return NewExternalTypedData(kExternalTypedDataUint32ArrayCid, |
| 2631 data, | 2638 data, |
| 2632 length, | 2639 length, |
| 2633 peer, | 2640 peer, |
| 2634 callback); | 2641 callback); |
| 2635 case kInt64 : | 2642 case kInt64: |
| 2636 return NewExternalTypedData(kExternalTypedDataInt64ArrayCid, | 2643 return NewExternalTypedData(kExternalTypedDataInt64ArrayCid, |
| 2637 data, | 2644 data, |
| 2638 length, | 2645 length, |
| 2639 peer, | 2646 peer, |
| 2640 callback); | 2647 callback); |
| 2641 case kUint64 : | 2648 case kUint64: |
| 2642 return NewExternalTypedData(kExternalTypedDataUint64ArrayCid, | 2649 return NewExternalTypedData(kExternalTypedDataUint64ArrayCid, |
| 2643 data, | 2650 data, |
| 2644 length, | 2651 length, |
| 2645 peer, | 2652 peer, |
| 2646 callback); | 2653 callback); |
| 2647 case kFloat32 : | 2654 case kFloat32: |
| 2648 return NewExternalTypedData(kExternalTypedDataFloat32ArrayCid, | 2655 return NewExternalTypedData(kExternalTypedDataFloat32ArrayCid, |
| 2649 data, | 2656 data, |
| 2650 length, | 2657 length, |
| 2651 peer, | 2658 peer, |
| 2652 callback); | 2659 callback); |
| 2653 case kFloat64 : | 2660 case kFloat64: |
| 2654 return NewExternalTypedData(kExternalTypedDataFloat64ArrayCid, | 2661 return NewExternalTypedData(kExternalTypedDataFloat64ArrayCid, |
| 2655 data, | 2662 data, |
| 2656 length, | 2663 length, |
| 2657 peer, | 2664 peer, |
| 2658 callback); | 2665 callback); |
| 2666 case kFloat32x4: |
| 2667 return NewExternalTypedData(kExternalTypedDataFloat32x4ArrayCid, |
| 2668 data, |
| 2669 length, |
| 2670 peer, |
| 2671 callback); |
| 2659 default: | 2672 default: |
| 2660 return Api::NewError("%s expects argument 'type' to be of" | 2673 return Api::NewError("%s expects argument 'type' to be of" |
| 2661 " 'external TypedData'", CURRENT_FUNC); | 2674 " 'external TypedData'", CURRENT_FUNC); |
| 2662 } | 2675 } |
| 2663 UNREACHABLE(); | 2676 UNREACHABLE(); |
| 2664 return Api::Null(isolate); | 2677 return Api::Null(isolate); |
| 2665 } | 2678 } |
| 2666 | 2679 |
| 2667 | 2680 |
| 2668 DART_EXPORT Dart_Handle Dart_ExternalTypedDataGetPeer(Dart_Handle object, | 2681 DART_EXPORT Dart_Handle Dart_ExternalTypedDataGetPeer(Dart_Handle object, |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4820 } | 4833 } |
| 4821 { | 4834 { |
| 4822 NoGCScope no_gc; | 4835 NoGCScope no_gc; |
| 4823 RawObject* raw_obj = obj.raw(); | 4836 RawObject* raw_obj = obj.raw(); |
| 4824 isolate->heap()->SetPeer(raw_obj, peer); | 4837 isolate->heap()->SetPeer(raw_obj, peer); |
| 4825 } | 4838 } |
| 4826 return Api::Success(isolate); | 4839 return Api::Success(isolate); |
| 4827 } | 4840 } |
| 4828 | 4841 |
| 4829 } // namespace dart | 4842 } // namespace dart |
| OLD | NEW |