| 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 #include "bin/socket.h" |
| 7 | 8 |
| 8 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 9 | 10 |
| 11 |
| 10 // Extract an array of C strings from a list of Dart strings. | 12 // Extract an array of C strings from a list of Dart strings. |
| 11 static char** ExtractCStringList(Dart_Handle strings, | 13 static char** ExtractCStringList(Dart_Handle strings, |
| 12 Dart_Handle status_handle, | 14 Dart_Handle status_handle, |
| 13 const char* error_msg, | 15 const char* error_msg, |
| 14 intptr_t* length) { | 16 intptr_t* length) { |
| 15 static const intptr_t kMaxArgumentListLength = 1024 * 1024; | 17 static const intptr_t kMaxArgumentListLength = 1024 * 1024; |
| 16 ASSERT(Dart_IsList(strings)); | 18 ASSERT(Dart_IsList(strings)); |
| 17 intptr_t len = 0; | 19 intptr_t len = 0; |
| 18 Dart_Handle result = Dart_ListLength(strings, &len); | 20 Dart_Handle result = Dart_ListLength(strings, &len); |
| 19 if (Dart_IsError(result)) { | 21 if (Dart_IsError(result)) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 working_directory, | 127 working_directory, |
| 126 string_environment, | 128 string_environment, |
| 127 environment_length, | 129 environment_length, |
| 128 &in, | 130 &in, |
| 129 &out, | 131 &out, |
| 130 &err, | 132 &err, |
| 131 &pid, | 133 &pid, |
| 132 &exit_event, | 134 &exit_event, |
| 133 os_error_message, kMaxChildOsErrorMessageLength); | 135 os_error_message, kMaxChildOsErrorMessageLength); |
| 134 if (error_code == 0) { | 136 if (error_code == 0) { |
| 135 DartUtils::SetIntegerField(in_handle, DartUtils::kIdFieldName, in); | 137 Socket::SetSocketIdNativeField(in_handle, in); |
| 136 DartUtils::SetIntegerField( | 138 Socket::SetSocketIdNativeField(out_handle, out); |
| 137 out_handle, DartUtils::kIdFieldName, out); | 139 Socket::SetSocketIdNativeField(err_handle, err); |
| 138 DartUtils::SetIntegerField( | 140 Socket::SetSocketIdNativeField(exit_handle, exit_event); |
| 139 err_handle, DartUtils::kIdFieldName, err); | |
| 140 DartUtils::SetIntegerField( | |
| 141 exit_handle, DartUtils::kIdFieldName, exit_event); | |
| 142 DartUtils::SetIntegerField(process, "_pid", pid); | 141 DartUtils::SetIntegerField(process, "_pid", pid); |
| 143 } else { | 142 } else { |
| 144 DartUtils::SetIntegerField( | 143 DartUtils::SetIntegerField( |
| 145 status_handle, "_errorCode", error_code); | 144 status_handle, "_errorCode", error_code); |
| 146 DartUtils::SetStringField( | 145 DartUtils::SetStringField( |
| 147 status_handle, "_errorMessage", os_error_message); | 146 status_handle, "_errorMessage", os_error_message); |
| 148 } | 147 } |
| 149 delete[] string_args; | 148 delete[] string_args; |
| 150 delete[] string_environment; | 149 delete[] string_environment; |
| 151 Dart_SetReturnValue(args, Dart_NewBoolean(error_code == 0)); | 150 Dart_SetReturnValue(args, Dart_NewBoolean(error_code == 0)); |
| 152 Dart_ExitScope(); | 151 Dart_ExitScope(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 | 154 |
| 156 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { | 155 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { |
| 157 Dart_EnterScope(); | 156 Dart_EnterScope(); |
| 158 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 157 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 159 int signal = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 158 int signal = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); |
| 160 bool success = Process::Kill(pid, signal); | 159 bool success = Process::Kill(pid, signal); |
| 161 Dart_SetReturnValue(args, Dart_NewBoolean(success)); | 160 Dart_SetReturnValue(args, Dart_NewBoolean(success)); |
| 162 Dart_ExitScope(); | 161 Dart_ExitScope(); |
| 163 } | 162 } |
| OLD | NEW |