| 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 "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_IsError(result)); | 37 if (Dart_IsError(result)) { |
| 38 Dart_PropagateError(result); |
| 39 } |
| 38 char** string_args = new char*[length]; | 40 char** string_args = new char*[length]; |
| 39 for (int i = 0; i < length; i++) { | 41 for (int i = 0; i < length; i++) { |
| 40 Dart_Handle arg = Dart_ListGetAt(arguments, i); | 42 Dart_Handle arg = Dart_ListGetAt(arguments, i); |
| 41 ASSERT(!Dart_IsError(arg)); | 43 if (Dart_IsError(arg)) { |
| 44 delete[] string_args; |
| 45 Dart_PropagateError(arg); |
| 46 } |
| 42 // The Dart code verifies that the arguments implement the String | 47 // The Dart code verifies that the arguments implement the String |
| 43 // interface. However, only builtin Strings are handled by | 48 // interface. However, only builtin Strings are handled by |
| 44 // GetStringValue. | 49 // GetStringValue. |
| 45 if (!Dart_IsString(arg)) { | 50 if (!Dart_IsString(arg)) { |
| 46 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); | 51 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); |
| 47 DartUtils::SetStringField( | 52 DartUtils::SetStringField( |
| 48 status_handle, "_errorMessage", "Arguments must be builtin strings"); | 53 status_handle, "_errorMessage", "Arguments must be builtin strings"); |
| 49 delete[] string_args; | 54 delete[] string_args; |
| 50 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 55 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 51 Dart_ExitScope(); | 56 Dart_ExitScope(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 112 } |
| 108 | 113 |
| 109 | 114 |
| 110 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { | 115 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { |
| 111 Dart_EnterScope(); | 116 Dart_EnterScope(); |
| 112 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 117 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 113 bool success = Process::Kill(pid); | 118 bool success = Process::Kill(pid); |
| 114 Dart_SetReturnValue(args, Dart_NewBoolean(success)); | 119 Dart_SetReturnValue(args, Dart_NewBoolean(success)); |
| 115 Dart_ExitScope(); | 120 Dart_ExitScope(); |
| 116 } | 121 } |
| OLD | NEW |