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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 90 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
91 } | 91 } |
92 } | 92 } |
93 return IONativeLookup(name, argument_count); | 93 return IONativeLookup(name, argument_count); |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 // Implementation of native functions which are used for some | 97 // Implementation of native functions which are used for some |
98 // test/debug functionality in standalone dart mode. | 98 // test/debug functionality in standalone dart mode. |
99 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { | 99 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { |
100 Dart_EnterScope(); | |
101 intptr_t length = 0; | 100 intptr_t length = 0; |
102 uint8_t* chars = NULL; | 101 uint8_t* chars = NULL; |
103 Dart_Handle str = Dart_GetNativeArgument(args, 0); | 102 Dart_Handle str = Dart_GetNativeArgument(args, 0); |
104 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); | 103 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); |
105 if (Dart_IsError(result)) { | 104 if (Dart_IsError(result)) { |
106 // TODO(turnidge): Consider propagating some errors here. What if | 105 // TODO(turnidge): Consider propagating some errors here. What if |
107 // an isolate gets interrupted by the embedder in the middle of | 106 // an isolate gets interrupted by the embedder in the middle of |
108 // Dart_StringToUTF8? We need to make sure not to swallow the | 107 // Dart_StringToUTF8? We need to make sure not to swallow the |
109 // interrupt. | 108 // interrupt. |
110 fputs(Dart_GetError(result), stdout); | 109 fputs(Dart_GetError(result), stdout); |
111 } else { | 110 } else { |
112 fwrite(chars, sizeof(*chars), length, stdout); | 111 fwrite(chars, sizeof(*chars), length, stdout); |
113 } | 112 } |
114 fputc('\n', stdout); | 113 fputc('\n', stdout); |
115 fflush(stdout); | 114 fflush(stdout); |
116 Dart_ExitScope(); | |
117 } | 115 } |
118 | 116 |
119 } // namespace bin | 117 } // namespace bin |
120 } // namespace dart | 118 } // namespace dart |
OLD | NEW |