| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/vmservice_impl.h" | 5 #include "bin/vmservice_impl.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 Dart_ShutdownIsolate(); | 123 Dart_ShutdownIsolate(); |
| 124 error_msg_ = "Invalid isolate state - Unable to make it runnable."; | 124 error_msg_ = "Invalid isolate state - Unable to make it runnable."; |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 Dart_EnterIsolate(isolate); | 128 Dart_EnterIsolate(isolate); |
| 129 Dart_EnterScope(); | 129 Dart_EnterScope(); |
| 130 library = Dart_RootLibrary(); | 130 library = Dart_RootLibrary(); |
| 131 // Set requested TCP port. | 131 // Set requested TCP port. |
| 132 DartUtils::SetStringField(library, "_ip", server_ip); | 132 DartUtils::SetStringField(library, "_ip", server_ip); |
| 133 // If we have a port specified, start the server immediately. |
| 134 bool auto_start = server_port >= 0; |
| 135 if (server_port < 0) { |
| 136 // Adjust server_port to port 0 which will result in the first available |
| 137 // port when the HTTP server is started. |
| 138 server_port = 0; |
| 139 } |
| 140 // Set initial state. |
| 133 DartUtils::SetIntegerField(library, "_port", server_port); | 141 DartUtils::SetIntegerField(library, "_port", server_port); |
| 142 Dart_SetField(library, |
| 143 DartUtils::NewString("_autoStart"), |
| 144 Dart_NewBoolean(auto_start)); |
| 145 // Invoke main. |
| 134 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL); | 146 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL); |
| 135 SHUTDOWN_ON_ERROR(result); | 147 SHUTDOWN_ON_ERROR(result); |
| 136 // Load resources. | 148 // Load resources. |
| 137 result = LoadResources(library); | 149 result = LoadResources(library); |
| 138 SHUTDOWN_ON_ERROR(result); | 150 SHUTDOWN_ON_ERROR(result); |
| 139 | 151 |
| 140 Dart_ExitScope(); | 152 Dart_ExitScope(); |
| 141 Dart_ExitIsolate(); | 153 Dart_ExitIsolate(); |
| 142 | 154 |
| 143 return true; | 155 return true; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 printf("Service exited with an error:\n%s\n", Dart_GetError(result)); | 289 printf("Service exited with an error:\n%s\n", Dart_GetError(result)); |
| 278 } | 290 } |
| 279 Dart_ExitScope(); | 291 Dart_ExitScope(); |
| 280 Dart_ExitIsolate(); | 292 Dart_ExitIsolate(); |
| 281 } | 293 } |
| 282 | 294 |
| 283 | 295 |
| 284 | 296 |
| 285 } // namespace bin | 297 } // namespace bin |
| 286 } // namespace dart | 298 } // namespace dart |
| OLD | NEW |