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 4330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4341 if (!ret_obj.IsNull() && !ret_obj.IsInstance()) { | 4341 if (!ret_obj.IsNull() && !ret_obj.IsInstance()) { |
4342 FATAL1("Return value check failed: saw '%s' expected a dart Instance.", | 4342 FATAL1("Return value check failed: saw '%s' expected a dart Instance.", |
4343 ret_obj.ToCString()); | 4343 ret_obj.ToCString()); |
4344 } | 4344 } |
4345 NoGCScope no_gc_scope; | 4345 NoGCScope no_gc_scope; |
4346 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 4346 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
4347 arguments->SetReturn(ret_obj); | 4347 arguments->SetReturn(ret_obj); |
4348 } | 4348 } |
4349 | 4349 |
4350 | 4350 |
4351 // --- Metadata ---- | |
4352 | |
4353 DART_EXPORT Dart_Handle Dart_GetMetadata(Dart_Handle object) { | |
4354 Isolate* isolate = Isolate::Current(); | |
4355 CHECK_ISOLATE(isolate); | |
4356 DARTSCOPE(isolate); | |
4357 Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | |
4358 Class& cls = Class::Handle(isolate); | |
4359 if (obj.IsClass()) { | |
4360 cls ^= obj.raw(); | |
4361 } else if (obj.IsFunction()) { | |
4362 cls = Function::Cast(obj).origin(); | |
4363 } else if (obj.IsField()) { | |
4364 cls = Field::Cast(obj).origin(); | |
4365 } else { | |
4366 return Api::NewHandle(isolate, Array::New(0)); | |
siva
2013/06/12 00:16:52
return Api::NewHandle(isolate, Object::empty_array
hausner
2013/06/12 01:10:05
Done.
| |
4367 } | |
4368 const Library& lib = Library::Handle(cls.library()); | |
4369 obj = lib.GetMetadata(obj); | |
4370 return Api::NewHandle(isolate, obj.raw()); | |
siva
2013/06/12 00:16:52
why not:
return Api::NewHandle(isolate, lib.GetMe
hausner
2013/06/12 01:10:05
Done.
| |
4371 } | |
4372 | |
4373 | |
4351 // --- Scripts and Libraries --- | 4374 // --- Scripts and Libraries --- |
4352 | 4375 |
4353 | 4376 |
4354 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( | 4377 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( |
4355 Dart_LibraryTagHandler handler) { | 4378 Dart_LibraryTagHandler handler) { |
4356 Isolate* isolate = Isolate::Current(); | 4379 Isolate* isolate = Isolate::Current(); |
4357 CHECK_ISOLATE(isolate); | 4380 CHECK_ISOLATE(isolate); |
4358 isolate->set_library_tag_handler(handler); | 4381 isolate->set_library_tag_handler(handler); |
4359 return Api::Success(); | 4382 return Api::Success(); |
4360 } | 4383 } |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4837 } | 4860 } |
4838 { | 4861 { |
4839 NoGCScope no_gc; | 4862 NoGCScope no_gc; |
4840 RawObject* raw_obj = obj.raw(); | 4863 RawObject* raw_obj = obj.raw(); |
4841 isolate->heap()->SetPeer(raw_obj, peer); | 4864 isolate->heap()->SetPeer(raw_obj, peer); |
4842 } | 4865 } |
4843 return Api::Success(); | 4866 return Api::Success(); |
4844 } | 4867 } |
4845 | 4868 |
4846 } // namespace dart | 4869 } // namespace dart |
OLD | NEW |