Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 1375) |
| +++ runtime/vm/dart_api_impl.cc (working copy) |
| @@ -27,6 +27,23 @@ |
| namespace dart { |
| +#define UNWRAP_NONNULL(dart_handle, vm_handle, Type) \ |
|
Ivan Posva
2011/11/10 00:12:55
How about adding a line like this here:
Type& vm_
turnidge
2011/11/10 17:48:57
I tried this and it was a bit too magical for me.
|
| + do { \ |
| + const Object& tmp = Object::Handle(Api::UnwrapHandle((dart_handle))); \ |
| + if (tmp.Is##Type()) { \ |
| + (vm_handle) ^= tmp.raw(); \ |
| + } else if (tmp.IsNull()) { \ |
| + return Api::Error("%s expects argument '%s' to be non-null.", \ |
| + __func__, #dart_handle); \ |
| + } else if (tmp.IsApiFailure()) { \ |
| + return dart_handle; \ |
| + } else { \ |
| + return Api::Error("%s expects argument '%s' to be of type %s.", \ |
| + __func__, #dart_handle, #Type); \ |
| + } \ |
|
Ivan Posva
2011/11/10 00:12:55
\ at column 80.
turnidge
2011/11/10 17:48:57
Done.
|
| + } while (0) |
| + |
| + |
| DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { |
| ASSERT(Isolate::Current() != NULL); |
| Zone zone; // Setup a VM zone as we are creating some handles. |
| @@ -381,10 +398,12 @@ |
| DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| Zone zone; // Setup a VM zone as we are creating some handles. |
| HandleScope scope; // Setup a VM handle scope. |
| - const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); |
| + String& url_str = String::Handle(); |
| + UNWRAP_NONNULL(url, url_str, String); |
| const Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| if (library.IsNull()) { |
| - return Api::Error("Unknown library"); |
| + return Api::Error("%s: library '%s' not found.", |
| + __func__, url_str.ToCString()); |
| } else { |
| return Api::NewLocalHandle(library); |
| } |