| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 const char* DartUtils::kBuiltinLibURL = "./dart:builtin-lib"; | 7 const char* DartUtils::kBuiltinLibURL = "./dart:builtin-lib"; |
| 8 const char* DartUtils::kBuiltinLibSpec = "library { }"; | 8 const char* DartUtils::kBuiltinLibSpec = "library { }"; |
| 9 const char* DartUtils::kIdFieldName = "_id"; | 9 const char* DartUtils::kIdFieldName = "_id"; |
| 10 | 10 |
| 11 | 11 |
| 12 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) { | 12 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) { |
| 13 assert(Dart_IsInteger(value_obj)); | 13 ASSERT(Dart_IsInteger(value_obj)); |
| 14 Dart_Result result = Dart_IntegerValue(value_obj); | 14 Dart_Result result = Dart_IntegerValue(value_obj); |
| 15 ASSERT(Dart_IsValidResult(result)); | 15 ASSERT(Dart_IsValidResult(result)); |
| 16 return Dart_GetResultAsCInt64(result); | 16 return Dart_GetResultAsCInt64(result); |
| 17 } | 17 } |
| 18 | 18 |
| 19 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { | 19 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { |
| 20 Dart_Result result = Dart_StringToCString(str_obj); | 20 Dart_Result result = Dart_StringToCString(str_obj); |
| 21 ASSERT(Dart_IsValidResult(result)); | 21 ASSERT(Dart_IsValidResult(result)); |
| 22 return Dart_GetResultAsCString(result); | 22 return Dart_GetResultAsCString(result); |
| 23 } | 23 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 Dart_Result result = Dart_SetInstanceField(handle, | 35 Dart_Result result = Dart_SetInstanceField(handle, |
| 36 Dart_NewString(name), | 36 Dart_NewString(name), |
| 37 Dart_NewInteger(val)); | 37 Dart_NewInteger(val)); |
| 38 ASSERT(Dart_IsValidResult(result)); | 38 ASSERT(Dart_IsValidResult(result)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 intptr_t DartUtils::GetIntegerInstanceField(Dart_Handle handle, | 41 intptr_t DartUtils::GetIntegerInstanceField(Dart_Handle handle, |
| 42 const char* name) { | 42 const char* name) { |
| 43 Dart_Result result = | 43 Dart_Result result = |
| 44 Dart_GetInstanceField(handle, Dart_NewString(name)); | 44 Dart_GetInstanceField(handle, Dart_NewString(name)); |
| 45 assert(Dart_IsValidResult(result)); | 45 ASSERT(Dart_IsValidResult(result)); |
| 46 intptr_t value = DartUtils::GetIntegerValue(Dart_GetResult(result)); | 46 intptr_t value = DartUtils::GetIntegerValue(Dart_GetResult(result)); |
| 47 return value; | 47 return value; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void DartUtils::SetStringInstanceField(Dart_Handle handle, | 50 void DartUtils::SetStringInstanceField(Dart_Handle handle, |
| 51 const char* name, | 51 const char* name, |
| 52 const char* val) { | 52 const char* val) { |
| 53 Dart_Result result = Dart_SetInstanceField(handle, | 53 Dart_Result result = Dart_SetInstanceField(handle, |
| 54 Dart_NewString(name), | 54 Dart_NewString(name), |
| 55 Dart_NewString(val)); | 55 Dart_NewString(val)); |
| 56 ASSERT(Dart_IsValidResult(result)); | 56 ASSERT(Dart_IsValidResult(result)); |
| 57 } | 57 } |
| OLD | NEW |