Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1290)

Side by Side Diff: runtime/bin/process.cc

Issue 9657001: Start using Dart_PropagateError in the runtime/bin directory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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)) {
Søren Gjesse 2012/03/08 21:18:46 Missing delete[] string_args.
turnidge 2012/03/08 22:19:26 Done.
44 Dart_PropagateError(arg);
45 }
42 // The Dart code verifies that the arguments implement the String 46 // The Dart code verifies that the arguments implement the String
43 // interface. However, only builtin Strings are handled by 47 // interface. However, only builtin Strings are handled by
44 // GetStringValue. 48 // GetStringValue.
45 if (!Dart_IsString(arg)) { 49 if (!Dart_IsString(arg)) {
46 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); 50 DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
47 DartUtils::SetStringField( 51 DartUtils::SetStringField(
48 status_handle, "_errorMessage", "Arguments must be builtin strings"); 52 status_handle, "_errorMessage", "Arguments must be builtin strings");
49 delete[] string_args; 53 delete[] string_args;
50 Dart_SetReturnValue(args, Dart_NewBoolean(false)); 54 Dart_SetReturnValue(args, Dart_NewBoolean(false));
51 Dart_ExitScope(); 55 Dart_ExitScope();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 111 }
108 112
109 113
110 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { 114 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) {
111 Dart_EnterScope(); 115 Dart_EnterScope();
112 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); 116 intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
113 bool success = Process::Kill(pid); 117 bool success = Process::Kill(pid);
114 Dart_SetReturnValue(args, Dart_NewBoolean(success)); 118 Dart_SetReturnValue(args, Dart_NewBoolean(success));
115 Dart_ExitScope(); 119 Dart_ExitScope();
116 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698