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_state.h" | 11 #include "sky/engine/tonic/dart_state.h" |
11 #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" |
12 | 14 |
13 namespace blink { | 15 namespace blink { |
14 | 16 |
15 DartWrappable::~DartWrappable() { | 17 DartWrappable::~DartWrappable() { |
16 CHECK(!dart_wrapper_); | 18 CHECK(!dart_wrapper_); |
17 } | 19 } |
18 | 20 |
19 void DartWrappable::AcceptDartGCVisitor(DartGCVisitor& visitor) const { | 21 void DartWrappable::AcceptDartGCVisitor(DartGCVisitor& visitor) const { |
20 } | 22 } |
21 | 23 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (Dart_IsError(result)) { | 69 if (Dart_IsError(result)) { |
68 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); | 70 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); |
69 return nullptr; | 71 return nullptr; |
70 } | 72 } |
71 return reinterpret_cast<DartWrappable*>( | 73 return reinterpret_cast<DartWrappable*>( |
72 native_fields[DartWrappable::kPeerIndex]); | 74 native_fields[DartWrappable::kPeerIndex]); |
73 } | 75 } |
74 | 76 |
75 DartWrappable* DartConverterWrappable::FromArgumentsWithNullCheck( | 77 DartWrappable* DartConverterWrappable::FromArgumentsWithNullCheck( |
76 Dart_NativeArguments args, int index, Dart_Handle& exception) { | 78 Dart_NativeArguments args, int index, Dart_Handle& exception) { |
77 Dart_Handle handle = Dart_GetNativeArgument(args, index); | 79 Dart_Handle handle = Dart_GetNativeArgument(args, index); |
78 if (Dart_IsNull(handle)) | 80 if (Dart_IsNull(handle)) { |
| 81 DartState* state = DartState::Current(); |
| 82 StringBuilder message; |
| 83 message.appendLiteral("Argument "); |
| 84 message.appendNumber(index); |
| 85 message.appendLiteral(" cannot be null."); |
| 86 exception = state->exception_factory().CreateException("ArgumentError", |
| 87 message.toString()); |
79 return nullptr; | 88 return nullptr; |
| 89 } |
80 intptr_t native_fields[DartWrappable::kNumberOfNativeFields]; | 90 intptr_t native_fields[DartWrappable::kNumberOfNativeFields]; |
81 Dart_Handle result = Dart_GetNativeFieldsOfArgument( | 91 Dart_Handle result = Dart_GetNativeFieldsOfArgument( |
82 args, index, DartWrappable::kNumberOfNativeFields, native_fields); | 92 args, index, DartWrappable::kNumberOfNativeFields, native_fields); |
83 if (Dart_IsError(result)) { | 93 if (Dart_IsError(result)) { |
84 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); | 94 exception = Dart_NewStringFromCString(DartError::kInvalidArgument); |
85 return nullptr; | 95 return nullptr; |
86 } | 96 } |
87 return reinterpret_cast<DartWrappable*>( | 97 return reinterpret_cast<DartWrappable*>( |
88 native_fields[DartWrappable::kPeerIndex]); | 98 native_fields[DartWrappable::kPeerIndex]); |
89 } | 99 } |
90 | 100 |
91 } // namespace blink | 101 } // namespace blink |
OLD | NEW |