Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 16968006: Add Dart_Allocate to the C++ API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/include/dart_api.h ('K') | « runtime/include/dart_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 if (constructor.IsConstructor()) { 2811 if (constructor.IsConstructor()) {
2812 ASSERT(result.IsNull()); 2812 ASSERT(result.IsNull());
2813 } else { 2813 } else {
2814 ASSERT(result.IsNull() || result.IsInstance()); 2814 ASSERT(result.IsNull() || result.IsInstance());
2815 new_object ^= result.raw(); 2815 new_object ^= result.raw();
2816 } 2816 }
2817 return Api::NewHandle(isolate, new_object.raw()); 2817 return Api::NewHandle(isolate, new_object.raw());
2818 } 2818 }
2819 2819
2820 2820
2821 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle clazz) {
2822 Isolate* isolate = Isolate::Current();
2823 DARTSCOPE(isolate);
2824 CHECK_CALLBACK_STATE(isolate);
2825 Object& result = Object::Handle(isolate);
siva 2013/06/18 00:52:14 result doesn't seem to be used at all.
2826
2827 // Get the class to instantiate.
2828 Class& cls =
2829 Class::Handle(isolate, Api::UnwrapClassHandle(isolate, clazz).raw());
siva 2013/06/18 00:52:14 const Class& cls = Api::UnwrapClassHandle(isolate,
2830 if (cls.IsNull()) {
2831 RETURN_TYPE_ERROR(isolate, clazz, Class);
2832 }
2833
2834 return Api::NewHandle(isolate, Instance::New(cls));
2835 }
siva 2013/06/18 00:52:14 We would also need a test for this in dart_api_imp
vsm 2013/06/19 14:55:12 I rewrote this code to also accept Types, and I ad
2836
2837
2821 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, 2838 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
2822 Dart_Handle name, 2839 Dart_Handle name,
2823 int number_of_arguments, 2840 int number_of_arguments,
2824 Dart_Handle* arguments) { 2841 Dart_Handle* arguments) {
2825 Isolate* isolate = Isolate::Current(); 2842 Isolate* isolate = Isolate::Current();
2826 DARTSCOPE(isolate); 2843 DARTSCOPE(isolate);
2827 CHECK_CALLBACK_STATE(isolate); 2844 CHECK_CALLBACK_STATE(isolate);
2828 2845
2829 const String& function_name = Api::UnwrapStringHandle(isolate, name); 2846 const String& function_name = Api::UnwrapStringHandle(isolate, name);
2830 if (function_name.IsNull()) { 2847 if (function_name.IsNull()) {
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 } 3860 }
3844 { 3861 {
3845 NoGCScope no_gc; 3862 NoGCScope no_gc;
3846 RawObject* raw_obj = obj.raw(); 3863 RawObject* raw_obj = obj.raw();
3847 isolate->heap()->SetPeer(raw_obj, peer); 3864 isolate->heap()->SetPeer(raw_obj, peer);
3848 } 3865 }
3849 return Api::Success(); 3866 return Api::Success();
3850 } 3867 }
3851 3868
3852 } // namespace dart 3869 } // namespace dart
OLDNEW
« runtime/include/dart_api.h ('K') | « runtime/include/dart_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698