| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| 11 | 11 |
| 12 // Implementation of native functions which are used for some | 12 // Implementation of native functions which are used for some |
| 13 // test/debug functionality in standalone dart mode. | 13 // test/debug functionality in standalone dart mode. |
| 14 | 14 |
| 15 void PrintString(FILE* out, Dart_Handle str) { | 15 void PrintString(FILE* out, Dart_Handle str) { |
| 16 const char* cstring = NULL; | 16 const char* cstring = NULL; |
| 17 Dart_Handle result = Dart_StringToCString(str, &cstring); | 17 Dart_Handle result = Dart_StringToCString(str, &cstring); |
| 18 if (!Dart_IsValid(result)) { | 18 if (Dart_IsError(result)) { |
| 19 cstring = Dart_GetError(result); | 19 cstring = Dart_GetError(result); |
| 20 } | 20 } |
| 21 fprintf(out, "%s\n", cstring); | 21 fprintf(out, "%s\n", cstring); |
| 22 fflush(out); | 22 fflush(out); |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { | 26 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { |
| 27 Dart_EnterScope(); | 27 Dart_EnterScope(); |
| 28 PrintString(stdout, Dart_GetNativeArgument(args, 0)); | 28 PrintString(stdout, Dart_GetNativeArgument(args, 0)); |
| 29 Dart_ExitScope(); | 29 Dart_ExitScope(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) { | 32 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) { |
| 33 Dart_EnterScope(); | 33 Dart_EnterScope(); |
| 34 int64_t status = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | 34 int64_t status = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); |
| 35 Dart_ExitScope(); | 35 Dart_ExitScope(); |
| 36 exit(status); | 36 exit(status); |
| 37 } | 37 } |
| OLD | NEW |