Chromium Code Reviews| 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 | 11 |
| 11 // Implementation of native functions which are used for some | 12 // Implementation of native functions which are used for some |
| 12 // test/debug functionality in standalone dart mode. | 13 // test/debug functionality in standalone dart mode. |
| 13 | 14 |
| 14 void PrintString(FILE* out, Dart_Handle str) { | 15 void PrintString(FILE* out, Dart_Handle str) { |
| 15 Dart_Result result = Dart_StringToCString(str); | 16 Dart_Result result = Dart_StringToCString(str); |
| 16 const char* cstring = Dart_IsValidResult(result) ? | 17 const char* cstring = Dart_IsValidResult(result) ? |
| 17 Dart_GetResultAsCString(result) : Dart_GetErrorCString(result); | 18 Dart_GetResultAsCString(result) : Dart_GetErrorCString(result); |
| 18 fprintf(out, "%s\n", cstring); | 19 fprintf(out, "%s\n", cstring); |
| 19 fflush(out); | 20 fflush(out); |
| 20 } | 21 } |
| 21 | 22 |
| 22 | 23 |
| 23 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { | 24 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { |
| 24 Dart_EnterScope(); | 25 Dart_EnterScope(); |
| 25 PrintString(stdout, Dart_GetNativeArgument(args, 0)); | 26 PrintString(stdout, Dart_GetNativeArgument(args, 0)); |
| 26 Dart_ExitScope(); | 27 Dart_ExitScope(); |
| 27 } | 28 } |
| 29 | |
| 30 void FUNCTION_NAME(Runtime_Exit)(Dart_NativeArguments args) { | |
| 31 Dart_EnterScope(); | |
| 32 int64_t status = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | |
| 33 exit(status); | |
| 34 Dart_ExitScope(); | |
|
Ivan Posva
2011/10/21 23:05:22
Needs to move above exit to really make any sense.
rchandia
2011/10/25 14:37:50
Done.
| |
| 35 } | |
| OLD | NEW |