OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const char* cstring = NULL; | 99 const char* cstring = NULL; |
100 Dart_Handle result = Dart_StringToCString(str_obj, &cstring); | 100 Dart_Handle result = Dart_StringToCString(str_obj, &cstring); |
101 ASSERT(!Dart_IsError(result)); | 101 ASSERT(!Dart_IsError(result)); |
102 return cstring; | 102 return cstring; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { | 106 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { |
107 bool value = false; | 107 bool value = false; |
108 Dart_Handle result = Dart_BooleanValue(bool_obj, &value); | 108 Dart_Handle result = Dart_BooleanValue(bool_obj, &value); |
109 ASSERT(!Dart_IsError(result)); | 109 if (Dart_IsError(result)) Dart_PropagateError(result); |
110 return value; | 110 return value; |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 void DartUtils::SetIntegerField(Dart_Handle handle, | 114 void DartUtils::SetIntegerField(Dart_Handle handle, |
115 const char* name, | 115 const char* name, |
116 intptr_t val) { | 116 intptr_t val) { |
117 Dart_Handle result = Dart_SetField(handle, | 117 Dart_Handle result = Dart_SetField(handle, |
118 NewString(name), | 118 NewString(name), |
119 Dart_NewInteger(val)); | 119 Dart_NewInteger(val)); |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 new CObjectString(CObject::NewString(os_error->message())); | 1048 new CObjectString(CObject::NewString(os_error->message())); |
1049 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1049 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1050 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1050 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1051 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1051 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1052 result->SetAt(2, error_message); | 1052 result->SetAt(2, error_message); |
1053 return result; | 1053 return result; |
1054 } | 1054 } |
1055 | 1055 |
1056 } // namespace bin | 1056 } // namespace bin |
1057 } // namespace dart | 1057 } // namespace dart |
OLD | NEW |