| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/tonic/dart_wrappable.h" | 6 #include "sky/engine/tonic/dart_wrappable.h" |
| 7 | 7 |
| 8 #include "sky/engine/tonic/dart_class_library.h" | 8 #include "sky/engine/tonic/dart_class_library.h" |
| 9 #include "sky/engine/tonic/dart_error.h" | 9 #include "sky/engine/tonic/dart_error.h" |
| 10 #include "sky/engine/tonic/dart_exception_factory.h" | 10 #include "sky/engine/tonic/dart_exception_factory.h" |
| 11 #include "sky/engine/tonic/dart_state.h" | 11 #include "sky/engine/tonic/dart_state.h" |
| 12 #include "sky/engine/tonic/dart_wrapper_info.h" | 12 #include "sky/engine/tonic/dart_wrapper_info.h" |
| 13 #include "sky/engine/wtf/text/StringBuilder.h" | |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 | 15 |
| 17 DartWrappable::~DartWrappable() { | 16 DartWrappable::~DartWrappable() { |
| 18 CHECK(!dart_wrapper_); | 17 CHECK(!dart_wrapper_); |
| 19 } | 18 } |
| 20 | 19 |
| 21 void DartWrappable::AcceptDartGCVisitor(DartGCVisitor& visitor) const { | 20 void DartWrappable::AcceptDartGCVisitor(DartGCVisitor& visitor) const { |
| 22 } | 21 } |
| 23 | 22 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 71 } |
| 73 return reinterpret_cast<DartWrappable*>( | 72 return reinterpret_cast<DartWrappable*>( |
| 74 native_fields[DartWrappable::kPeerIndex]); | 73 native_fields[DartWrappable::kPeerIndex]); |
| 75 } | 74 } |
| 76 | 75 |
| 77 DartWrappable* DartConverterWrappable::FromArgumentsWithNullCheck( | 76 DartWrappable* DartConverterWrappable::FromArgumentsWithNullCheck( |
| 78 Dart_NativeArguments args, int index, Dart_Handle& exception) { | 77 Dart_NativeArguments args, int index, Dart_Handle& exception) { |
| 79 Dart_Handle handle = Dart_GetNativeArgument(args, index); | 78 Dart_Handle handle = Dart_GetNativeArgument(args, index); |
| 80 if (Dart_IsNull(handle)) { | 79 if (Dart_IsNull(handle)) { |
| 81 DartState* state = DartState::Current(); | 80 DartState* state = DartState::Current(); |
| 82 StringBuilder message; | 81 exception = state->exception_factory().CreateNullArgumentException(index); |
| 83 message.appendLiteral("Argument "); | |
| 84 message.appendNumber(index); | |
| 85 message.appendLiteral(" cannot be null."); | |
| 86 exception = state->exception_factory().CreateException("ArgumentError", | |
| 87 message.toString()); | |
| 88 return nullptr; | 82 return nullptr; |
| 89 } | 83 } |
| 90 intptr_t native_fields[DartWrappable::kNumberOfNativeFields]; | 84 intptr_t native_fields[DartWrappable::kNumberOfNativeFields]; |
| 91 Dart_Handle result = Dart_GetNativeFieldsOfArgument( | 85 Dart_Handle result = Dart_GetNativeFieldsOfArgument( |
| 92 args, index, DartWrappable::kNumberOfNativeFields, native_fields); | 86 args, index, DartWrappable::kNumberOfNativeFields, native_fields); |
| 93 if (Dart_IsError(result)) { | 87 if (Dart_IsError(result)) { |
| 94 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); | 88 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); |
| 95 return nullptr; | 89 return nullptr; |
| 96 } | 90 } |
| 97 return reinterpret_cast<DartWrappable*>( | 91 return reinterpret_cast<DartWrappable*>( |
| 98 native_fields[DartWrappable::kPeerIndex]); | 92 native_fields[DartWrappable::kPeerIndex]); |
| 99 } | 93 } |
| 100 | 94 |
| 101 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |