Chromium Code Reviews| 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_mirrors_api.h" | 5 #include "include/dart_mirrors_api.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 DARTSCOPE(isolate); | 316 DARTSCOPE(isolate); |
| 317 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | 317 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
| 318 if (lib.IsNull()) { | 318 if (lib.IsNull()) { |
| 319 RETURN_TYPE_ERROR(isolate, library, Library); | 319 RETURN_TYPE_ERROR(isolate, library, Library); |
| 320 } | 320 } |
| 321 const String& name = String::Handle(isolate, lib.name()); | 321 const String& name = String::Handle(isolate, lib.name()); |
| 322 ASSERT(!name.IsNull()); | 322 ASSERT(!name.IsNull()); |
| 323 return Api::NewHandle(isolate, name.raw()); | 323 return Api::NewHandle(isolate, name.raw()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, | |
| 327 intptr_t* library_id) { | |
| 328 Isolate* isolate = Isolate::Current(); | |
| 329 DARTSCOPE(isolate); | |
| 330 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | |
| 331 if (lib.IsNull()) { | |
| 332 RETURN_TYPE_ERROR(isolate, library, Library); | |
| 333 } | |
|
siva
2013/10/28 02:27:48
Usually we report an error when NULL pointers are
| |
| 334 if (library_id != NULL) { | |
| 335 *library_id = lib.index(); | |
| 336 } | |
|
siva
2013/10/28 02:27:48
Once the NULL check is in place you could remove t
| |
| 337 return Api::Success(); | |
| 338 } | |
| 326 | 339 |
| 327 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library) { | 340 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library) { |
| 328 Isolate* isolate = Isolate::Current(); | 341 Isolate* isolate = Isolate::Current(); |
| 329 DARTSCOPE(isolate); | 342 DARTSCOPE(isolate); |
| 330 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | 343 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
| 331 if (lib.IsNull()) { | 344 if (lib.IsNull()) { |
| 332 RETURN_TYPE_ERROR(isolate, library, Library); | 345 RETURN_TYPE_ERROR(isolate, library, Library); |
| 333 } | 346 } |
| 334 | 347 |
| 335 const GrowableObjectArray& names = | 348 const GrowableObjectArray& names = |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 366 RETURN_TYPE_ERROR(isolate, closure, Instance); | 379 RETURN_TYPE_ERROR(isolate, closure, Instance); |
| 367 } | 380 } |
| 368 | 381 |
| 369 ASSERT(ClassFinalizer::AllClassesFinalized()); | 382 ASSERT(ClassFinalizer::AllClassesFinalized()); |
| 370 | 383 |
| 371 RawFunction* rf = Closure::function(closure_obj); | 384 RawFunction* rf = Closure::function(closure_obj); |
| 372 return Api::NewHandle(isolate, rf); | 385 return Api::NewHandle(isolate, rf); |
| 373 } | 386 } |
| 374 | 387 |
| 375 } // namespace dart | 388 } // namespace dart |
| OLD | NEW |