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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 3886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3897 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { | 3897 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { |
3898 DARTSCOPE(Thread::Current()); | 3898 DARTSCOPE(Thread::Current()); |
3899 CHECK_CALLBACK_STATE(I); | 3899 CHECK_CALLBACK_STATE(I); |
3900 | 3900 |
3901 const Type& type_obj = Api::UnwrapTypeHandle(I, type); | 3901 const Type& type_obj = Api::UnwrapTypeHandle(I, type); |
3902 // Get the class to instantiate. | 3902 // Get the class to instantiate. |
3903 if (type_obj.IsNull()) { | 3903 if (type_obj.IsNull()) { |
3904 RETURN_TYPE_ERROR(I, type, Type); | 3904 RETURN_TYPE_ERROR(I, type, Type); |
3905 } | 3905 } |
3906 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 3906 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
3907 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(I)); | 3907 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); |
3908 if (!error.IsNull()) { | 3908 if (!error.IsNull()) { |
3909 // An error occurred, return error object. | 3909 // An error occurred, return error object. |
3910 return Api::NewHandle(I, error.raw()); | 3910 return Api::NewHandle(I, error.raw()); |
3911 } | 3911 } |
3912 return Api::NewHandle(I, AllocateObject(I, cls)); | 3912 return Api::NewHandle(I, AllocateObject(I, cls)); |
3913 } | 3913 } |
3914 | 3914 |
3915 | 3915 |
3916 DART_EXPORT Dart_Handle Dart_AllocateWithNativeFields( | 3916 DART_EXPORT Dart_Handle Dart_AllocateWithNativeFields( |
3917 Dart_Handle type, | 3917 Dart_Handle type, |
3918 intptr_t num_native_fields, | 3918 intptr_t num_native_fields, |
3919 const intptr_t* native_fields) { | 3919 const intptr_t* native_fields) { |
3920 DARTSCOPE(Thread::Current()); | 3920 DARTSCOPE(Thread::Current()); |
3921 CHECK_CALLBACK_STATE(I); | 3921 CHECK_CALLBACK_STATE(I); |
3922 | 3922 |
3923 const Type& type_obj = Api::UnwrapTypeHandle(I, type); | 3923 const Type& type_obj = Api::UnwrapTypeHandle(I, type); |
3924 // Get the class to instantiate. | 3924 // Get the class to instantiate. |
3925 if (type_obj.IsNull()) { | 3925 if (type_obj.IsNull()) { |
3926 RETURN_TYPE_ERROR(I, type, Type); | 3926 RETURN_TYPE_ERROR(I, type, Type); |
3927 } | 3927 } |
3928 if (native_fields == NULL) { | 3928 if (native_fields == NULL) { |
3929 RETURN_NULL_ERROR(native_fields); | 3929 RETURN_NULL_ERROR(native_fields); |
3930 } | 3930 } |
3931 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 3931 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
3932 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(I)); | 3932 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); |
3933 if (!error.IsNull()) { | 3933 if (!error.IsNull()) { |
3934 // An error occurred, return error object. | 3934 // An error occurred, return error object. |
3935 return Api::NewHandle(I, error.raw()); | 3935 return Api::NewHandle(I, error.raw()); |
3936 } | 3936 } |
3937 if (num_native_fields != cls.num_native_fields()) { | 3937 if (num_native_fields != cls.num_native_fields()) { |
3938 return Api::NewError( | 3938 return Api::NewError( |
3939 "%s: invalid number of native fields %" Pd " passed in, expected %d", | 3939 "%s: invalid number of native fields %" Pd " passed in, expected %d", |
3940 CURRENT_FUNC, num_native_fields, cls.num_native_fields()); | 3940 CURRENT_FUNC, num_native_fields, cls.num_native_fields()); |
3941 } | 3941 } |
3942 const Instance& instance = Instance::Handle(Z, AllocateObject(I, cls)); | 3942 const Instance& instance = Instance::Handle(Z, AllocateObject(I, cls)); |
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6055 ApiReallocate); | 6055 ApiReallocate); |
6056 writer.WriteFullSnapshot(); | 6056 writer.WriteFullSnapshot(); |
6057 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6057 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
6058 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6058 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
6059 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 6059 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
6060 | 6060 |
6061 return Api::Success(); | 6061 return Api::Success(); |
6062 } | 6062 } |
6063 | 6063 |
6064 } // namespace dart | 6064 } // namespace dart |
OLD | NEW |