| 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 #include "bin/process.h" | 6 #include "bin/process.h" |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) { | 10 void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 Dart_ExitScope(); | 27 Dart_ExitScope(); |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 const char* path = DartUtils::GetStringValue(path_handle); | 30 const char* path = DartUtils::GetStringValue(path_handle); |
| 31 Dart_Handle arguments = Dart_GetNativeArgument(args, 2); | 31 Dart_Handle arguments = Dart_GetNativeArgument(args, 2); |
| 32 // The arguments are copied into a non-extensible array in the | 32 // The arguments are copied into a non-extensible array in the |
| 33 // dart code so this should not fail. | 33 // dart code so this should not fail. |
| 34 ASSERT(Dart_IsList(arguments)); | 34 ASSERT(Dart_IsList(arguments)); |
| 35 intptr_t length = 0; | 35 intptr_t length = 0; |
| 36 Dart_Handle result = Dart_ListLength(arguments, &length); | 36 Dart_Handle result = Dart_ListLength(arguments, &length); |
| 37 ASSERT(Dart_IsValid(result)); | 37 ASSERT(!Dart_IsError(result)); |
| 38 char** string_args = new char*[length]; | 38 char** string_args = new char*[length]; |
| 39 for (int i = 0; i < length; i++) { | 39 for (int i = 0; i < length; i++) { |
| 40 Dart_Handle arg = Dart_ListGetAt(arguments, i); | 40 Dart_Handle arg = Dart_ListGetAt(arguments, i); |
| 41 ASSERT(Dart_IsValid(arg)); | 41 ASSERT(!Dart_IsError(arg)); |
| 42 // The Dart code verifies that the arguments implement the String | 42 // The Dart code verifies that the arguments implement the String |
| 43 // interface. However, only builtin Strings are handled by | 43 // interface. However, only builtin Strings are handled by |
| 44 // GetStringValue. | 44 // GetStringValue. |
| 45 if (!Dart_IsString(arg)) { | 45 if (!Dart_IsString(arg)) { |
| 46 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); | 46 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); |
| 47 DartUtils::SetStringInstanceField( | 47 DartUtils::SetStringInstanceField( |
| 48 status_handle, "_errorMessage", "Arguments must be builtin strings"); | 48 status_handle, "_errorMessage", "Arguments must be builtin strings"); |
| 49 delete[] string_args; | 49 delete[] string_args; |
| 50 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 50 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 51 Dart_ExitScope(); | 51 Dart_ExitScope(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Dart_ExitScope(); | 94 Dart_ExitScope(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 | 97 |
| 98 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) { | 98 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) { |
| 99 Dart_EnterScope(); | 99 Dart_EnterScope(); |
| 100 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 100 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 101 Process::Exit(pid); | 101 Process::Exit(pid); |
| 102 Dart_ExitScope(); | 102 Dart_ExitScope(); |
| 103 } | 103 } |
| OLD | NEW |