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

Unified Diff: runtime/bin/main.cc

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_service_patch.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 5e475390a4f13be0a411f8a975dd853aef2a8872..b6e8ee9ef049bddb900a00b4559c829e0b5de546 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -881,16 +881,32 @@ int main(int argc, char** argv) {
}
} else {
// Lookup and invoke the top level main function.
- Dart_Handle main_args[1];
+ // The top-level function may accept up to two arguments:
+ // main(List<String> args, var message).
+ // However most commonly it either accepts one (the args list) or
+ // none.
+ // If the message is optional, main(args, [message]), it is invoked with
+ // one argument only.
+ Dart_Handle main_args[2];
main_args[0] = CreateRuntimeOptions(&dart_options);
+ main_args[1] = Dart_Null();
+ // First try with 1 argument.
result = Dart_Invoke(library, DartUtils::NewString("main"), 1, main_args);
// TODO(iposva): Return a special error type for mismatched argument
// counts from Dart_Invoke to avoid the string comparison.
const char* expected_error = "Dart_Invoke: wrong argument count for "
- "function 'main': 1 passed, 0 expected.";
+ "function 'main': ";
+ intptr_t length = strlen(expected_error);
if (Dart_IsError(result) &&
- strcmp(expected_error, Dart_GetError(result)) == 0) {
- result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL);
+ strncmp(expected_error, Dart_GetError(result), length) == 0) {
+ // Try with two arguments.
+ result =
+ Dart_Invoke(library, DartUtils::NewString("main"), 2, main_args);
+ if (Dart_IsError(result) &&
+ strncmp(expected_error, Dart_GetError(result), length) == 0) {
+ // Finally try with 0 arguments.
+ result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL);
+ }
}
if (Dart_IsError(result)) {
return DartErrorExit(result);
« no previous file with comments | « runtime/bin/io_service_patch.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698