Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 namespace dart { | 28 namespace dart { |
| 29 | 29 |
| 30 #define UNWRAP_NONNULL(dart_handle, vm_handle, Type) \ | 30 #define UNWRAP_NONNULL(dart_handle, vm_handle, Type) \ |
| 31 do { \ | 31 do { \ |
| 32 const Object& tmp = Object::Handle(Api::UnwrapHandle((dart_handle))); \ | 32 const Object& tmp = Object::Handle(Api::UnwrapHandle((dart_handle))); \ |
| 33 if (tmp.Is##Type()) { \ | 33 if (tmp.Is##Type()) { \ |
| 34 (vm_handle) ^= tmp.raw(); \ | 34 (vm_handle) ^= tmp.raw(); \ |
| 35 } else if (tmp.IsNull()) { \ | 35 } else if (tmp.IsNull()) { \ |
| 36 return Api::Error("%s expects argument '%s' to be non-null.", \ | 36 return Api::Error("%s expects argument '%s' to be non-null.", \ |
| 37 __func__, #dart_handle); \ | 37 __FUNCTION__, #dart_handle); \ |
|
cshapiro
2011/11/11 01:39:02
Perhaps we should
#define __func__ __FUNCTION_
| |
| 38 } else if (tmp.IsApiFailure()) { \ | 38 } else if (tmp.IsApiFailure()) { \ |
| 39 return dart_handle; \ | 39 return dart_handle; \ |
| 40 } else { \ | 40 } else { \ |
| 41 return Api::Error("%s expects argument '%s' to be of type %s.", \ | 41 return Api::Error("%s expects argument '%s' to be of type %s.", \ |
| 42 __func__, #dart_handle, #Type); \ | 42 __FUNCTION__, #dart_handle, #Type); \ |
| 43 } \ | 43 } \ |
| 44 } while (0) | 44 } while (0) |
| 45 | 45 |
| 46 | 46 |
| 47 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { | 47 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { |
| 48 ASSERT(Isolate::Current() != NULL); | 48 ASSERT(Isolate::Current() != NULL); |
| 49 Zone zone; // Setup a VM zone as we are creating some handles. | 49 Zone zone; // Setup a VM zone as we are creating some handles. |
| 50 HandleScope scope; // Setup a VM handle scope. | 50 HandleScope scope; // Setup a VM handle scope. |
| 51 | 51 |
| 52 // Make sure that the object isn't an ApiFailure. | 52 // Make sure that the object isn't an ApiFailure. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 | 410 |
| 411 | 411 |
| 412 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { | 412 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| 413 Zone zone; // Setup a VM zone as we are creating some handles. | 413 Zone zone; // Setup a VM zone as we are creating some handles. |
| 414 HandleScope scope; // Setup a VM handle scope. | 414 HandleScope scope; // Setup a VM handle scope. |
| 415 String& url_str = String::Handle(); | 415 String& url_str = String::Handle(); |
| 416 UNWRAP_NONNULL(url, url_str, String); | 416 UNWRAP_NONNULL(url, url_str, String); |
| 417 const Library& library = Library::Handle(Library::LookupLibrary(url_str)); | 417 const Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| 418 if (library.IsNull()) { | 418 if (library.IsNull()) { |
| 419 return Api::Error("%s: library '%s' not found.", | 419 return Api::Error("%s: library '%s' not found.", |
| 420 __func__, url_str.ToCString()); | 420 __FUNCTION__, url_str.ToCString()); |
| 421 } else { | 421 } else { |
| 422 return Api::NewLocalHandle(library); | 422 return Api::NewLocalHandle(library); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) { | 427 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) { |
| 428 Zone zone; // Setup a VM zone as we are creating some handles. | 428 Zone zone; // Setup a VM zone as we are creating some handles. |
| 429 HandleScope scope; // Setup a VM handle scope. | 429 HandleScope scope; // Setup a VM handle scope. |
| 430 const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); | 430 const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 ASSERT(isolate != NULL); | 2125 ASSERT(isolate != NULL); |
| 2126 ApiState* state = isolate->api_state(); | 2126 ApiState* state = isolate->api_state(); |
| 2127 ASSERT(state != NULL); | 2127 ASSERT(state != NULL); |
| 2128 ApiLocalScope* scope = state->top_scope(); | 2128 ApiLocalScope* scope = state->top_scope(); |
| 2129 ASSERT(scope != NULL); | 2129 ASSERT(scope != NULL); |
| 2130 return scope->zone().Reallocate(ptr, old_size, new_size); | 2130 return scope->zone().Reallocate(ptr, old_size, new_size); |
| 2131 } | 2131 } |
| 2132 | 2132 |
| 2133 | 2133 |
| 2134 } // namespace dart | 2134 } // namespace dart |
| OLD | NEW |