| 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 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } else { | 539 } else { |
| 540 CHECK_CALLBACK_STATE(isolate); | 540 CHECK_CALLBACK_STATE(isolate); |
| 541 // This is a VM internal object. Call the C++ method of printing. | 541 // This is a VM internal object. Call the C++ method of printing. |
| 542 return Api::NewHandle(isolate, String::New(obj.ToCString())); | 542 return Api::NewHandle(isolate, String::New(obj.ToCString())); |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 | 545 |
| 546 | 546 |
| 547 DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2) { | 547 DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2) { |
| 548 Isolate* isolate = Isolate::Current(); | 548 Isolate* isolate = Isolate::Current(); |
| 549 CHECK_ISOLATE(isolate); | 549 DARTSCOPE(isolate); |
| 550 { | 550 { |
| 551 NoGCScope ngc; | 551 NoGCScope ngc; |
| 552 if (Api::UnwrapHandle(obj1) == Api::UnwrapHandle(obj2)) { | 552 if (Api::UnwrapHandle(obj1) == Api::UnwrapHandle(obj2)) { |
| 553 return true; | 553 return true; |
| 554 } | 554 } |
| 555 } | 555 } |
| 556 const Object& object1 = Object::Handle(isolate, Api::UnwrapHandle(obj1)); | 556 const Object& object1 = Object::Handle(isolate, Api::UnwrapHandle(obj1)); |
| 557 const Object& object2 = Object::Handle(isolate, Api::UnwrapHandle(obj2)); | 557 const Object& object2 = Object::Handle(isolate, Api::UnwrapHandle(obj2)); |
| 558 if (object1.IsInstance() && object2.IsInstance()) { | 558 if (object1.IsInstance() && object2.IsInstance()) { |
| 559 return Instance::Cast(object1).IsIdenticalTo(Instance::Cast(object2)); | 559 return Instance::Cast(object1).IsIdenticalTo(Instance::Cast(object2)); |
| (...skipping 3221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3781 | 3781 |
| 3782 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, | 3782 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, |
| 3783 int* count) { | 3783 int* count) { |
| 3784 Isolate* isolate = Isolate::Current(); | 3784 Isolate* isolate = Isolate::Current(); |
| 3785 CHECK_ISOLATE(isolate); | 3785 CHECK_ISOLATE(isolate); |
| 3786 ReusableObjectHandleScope reused_obj_handle(isolate); | 3786 ReusableObjectHandleScope reused_obj_handle(isolate); |
| 3787 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); | 3787 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); |
| 3788 if (instance.IsNull()) { | 3788 if (instance.IsNull()) { |
| 3789 RETURN_TYPE_ERROR(isolate, obj, Instance); | 3789 RETURN_TYPE_ERROR(isolate, obj, Instance); |
| 3790 } | 3790 } |
| 3791 const Class& cls = Class::Handle(isolate, instance.clazz()); | 3791 *count = instance.NumNativeFields(); |
| 3792 *count = cls.num_native_fields(); | |
| 3793 return Api::Success(); | 3792 return Api::Success(); |
| 3794 } | 3793 } |
| 3795 | 3794 |
| 3796 | 3795 |
| 3797 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, | 3796 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, |
| 3798 int index, | 3797 int index, |
| 3799 intptr_t* value) { | 3798 intptr_t* value) { |
| 3800 Isolate* isolate = Isolate::Current(); | 3799 Isolate* isolate = Isolate::Current(); |
| 3801 CHECK_ISOLATE(isolate); | 3800 DARTSCOPE(isolate); |
| 3802 ReusableObjectHandleScope reused_obj_handle(isolate); | 3801 ReusableObjectHandleScope reused_obj_handle(isolate); |
| 3803 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); | 3802 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); |
| 3804 if (instance.IsNull()) { | 3803 if (instance.IsNull()) { |
| 3805 RETURN_TYPE_ERROR(isolate, obj, Instance); | 3804 RETURN_TYPE_ERROR(isolate, obj, Instance); |
| 3806 } | 3805 } |
| 3807 if (!instance.IsValidNativeIndex(index)) { | 3806 if (!instance.IsValidNativeIndex(index)) { |
| 3808 return Api::NewError( | 3807 return Api::NewError( |
| 3809 "%s: invalid index %d passed in to access native instance field", | 3808 "%s: invalid index %d passed in to access native instance field", |
| 3810 CURRENT_FUNC, index); | 3809 CURRENT_FUNC, index); |
| 3811 } | 3810 } |
| 3812 *value = instance.GetNativeField(index); | 3811 *value = instance.GetNativeField(index); |
| 3813 return Api::Success(); | 3812 return Api::Success(); |
| 3814 } | 3813 } |
| 3815 | 3814 |
| 3816 | 3815 |
| 3817 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, | 3816 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, |
| 3818 int index, | 3817 int index, |
| 3819 intptr_t value) { | 3818 intptr_t value) { |
| 3820 Isolate* isolate = Isolate::Current(); | 3819 Isolate* isolate = Isolate::Current(); |
| 3821 CHECK_ISOLATE(isolate); | 3820 DARTSCOPE(isolate); |
| 3822 ReusableObjectHandleScope reused_obj_handle(isolate); | 3821 ReusableObjectHandleScope reused_obj_handle(isolate); |
| 3823 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); | 3822 const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj); |
| 3824 if (instance.IsNull()) { | 3823 if (instance.IsNull()) { |
| 3825 RETURN_TYPE_ERROR(isolate, obj, Instance); | 3824 RETURN_TYPE_ERROR(isolate, obj, Instance); |
| 3826 } | 3825 } |
| 3827 if (!instance.IsValidNativeIndex(index)) { | 3826 if (!instance.IsValidNativeIndex(index)) { |
| 3828 return Api::NewError( | 3827 return Api::NewError( |
| 3829 "%s: invalid index %d passed in to set native instance field", | 3828 "%s: invalid index %d passed in to set native instance field", |
| 3830 CURRENT_FUNC, index); | 3829 CURRENT_FUNC, index); |
| 3831 } | 3830 } |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4608 | 4607 |
| 4609 | 4608 |
| 4610 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4609 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 4611 const char* name, | 4610 const char* name, |
| 4612 Dart_ServiceRequestCallback callback, | 4611 Dart_ServiceRequestCallback callback, |
| 4613 void* user_data) { | 4612 void* user_data) { |
| 4614 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4613 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 4615 } | 4614 } |
| 4616 | 4615 |
| 4617 } // namespace dart | 4616 } // namespace dart |
| OLD | NEW |