| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include "base/logging.h" |
| 8 #include "mojo/dart/embedder/common.h" | 9 #include "mojo/dart/embedder/common.h" |
| 9 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| 10 | 11 |
| 11 namespace mojo { | 12 namespace mojo { |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 15 Dart_Handle DartEmbedder::GetDartType(const char* library_url, |
| 16 const char* class_name) { |
| 17 return Dart_GetType(Dart_LookupLibrary(NewCString(library_url)), |
| 18 NewCString(class_name), 0, NULL); |
| 19 } |
| 20 |
| 21 Dart_Handle DartEmbedder::NewDartExceptionWithMessage( |
| 22 const char* library_url, |
| 23 const char* error_type, |
| 24 const char* message) { |
| 25 // Create a Dart Exception object with a message. |
| 26 Dart_Handle type = GetDartType(library_url, error_type); |
| 27 DCHECK(!Dart_IsError(type)); |
| 28 if (message != NULL) { |
| 29 Dart_Handle args[1]; |
| 30 args[0] = NewCString(message); |
| 31 return Dart_New(type, Dart_Null(), 1, args); |
| 32 } else { |
| 33 return Dart_New(type, Dart_Null(), 0, NULL); |
| 34 } |
| 35 } |
| 36 |
| 37 Dart_Handle DartEmbedder::NewInternalError(const char* message) { |
| 38 return NewDartExceptionWithMessage("dart:core", "_InternalError", message); |
| 39 } |
| 40 |
| 14 int64_t DartEmbedder::GetIntegerValue(Dart_Handle value_obj) { | 41 int64_t DartEmbedder::GetIntegerValue(Dart_Handle value_obj) { |
| 15 int64_t value = 0; | 42 int64_t value = 0; |
| 16 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value); | 43 Dart_Handle result = Dart_IntegerToInt64(value_obj, &value); |
| 17 if (Dart_IsError(result)) { | 44 if (Dart_IsError(result)) { |
| 18 Dart_PropagateError(result); | 45 Dart_PropagateError(result); |
| 19 } | 46 } |
| 20 return value; | 47 return value; |
| 21 } | 48 } |
| 22 | 49 |
| 23 int64_t DartEmbedder::GetInt64ValueCheckRange( | 50 int64_t DartEmbedder::GetInt64ValueCheckRange( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 181 } |
| 155 Dart_Handle err = Dart_ListSetAsBytes(result, 0, bytes, length); | 182 Dart_Handle err = Dart_ListSetAsBytes(result, 0, bytes, length); |
| 156 if (Dart_IsError(err)) { | 183 if (Dart_IsError(err)) { |
| 157 Dart_PropagateError(err); | 184 Dart_PropagateError(err); |
| 158 } | 185 } |
| 159 return result; | 186 return result; |
| 160 } | 187 } |
| 161 | 188 |
| 162 } // namespace dart | 189 } // namespace dart |
| 163 } // namespace mojo | 190 } // namespace mojo |
| OLD | NEW |