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

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

Issue 897193002: Finish moving service protocol to json rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 10 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
« no previous file with comments | « no previous file | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 848
849 class DartScope { 849 class DartScope {
850 public: 850 public:
851 DartScope() { Dart_EnterScope(); } 851 DartScope() { Dart_EnterScope(); }
852 ~DartScope() { Dart_ExitScope(); } 852 ~DartScope() { Dart_ExitScope(); }
853 }; 853 };
854 854
855 855
856 static const char* ServiceRequestHandler( 856 static const char* ServiceRequestHandler(
857 const char* name, 857 const char* name,
858 const char** arguments, 858 const char** param_keys,
859 intptr_t num_arguments, 859 const char** param_values,
860 const char** option_keys, 860 intptr_t num_params,
861 const char** option_values,
862 intptr_t num_options,
863 void* user_data) { 861 void* user_data) {
864 DartScope scope; 862 DartScope scope;
865 ASSERT(num_arguments > 0);
866 ASSERT(strncmp(arguments[0], "io", 2) == 0);
867 // TODO(ajohnsen): Store the library/function in isolate data or user_data. 863 // TODO(ajohnsen): Store the library/function in isolate data or user_data.
868 Dart_Handle dart_io_str = Dart_NewStringFromCString("dart:io"); 864 Dart_Handle dart_io_str = Dart_NewStringFromCString("dart:io");
869 if (Dart_IsError(dart_io_str)) return ServiceRequestError(dart_io_str); 865 if (Dart_IsError(dart_io_str)) return ServiceRequestError(dart_io_str);
870 Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str); 866 Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str);
871 if (Dart_IsError(io_lib)) return ServiceRequestError(io_lib); 867 if (Dart_IsError(io_lib)) return ServiceRequestError(io_lib);
872 Dart_Handle handler_function_name = 868 Dart_Handle handler_function_name =
873 Dart_NewStringFromCString("_serviceObjectHandler"); 869 Dart_NewStringFromCString("_serviceObjectHandler");
874 if (Dart_IsError(handler_function_name)) { 870 if (Dart_IsError(handler_function_name)) {
875 return ServiceRequestError(handler_function_name); 871 return ServiceRequestError(handler_function_name);
876 } 872 }
877 Dart_Handle paths = Dart_NewList(num_arguments - 1); 873 // TODO(johnmccutchan): paths is no longer used. Update the io
878 for (int i = 0; i < num_arguments - 1; i++) { 874 // _serviceObjectHandler function to use json rpc.
879 Dart_ListSetAt(paths, i, Dart_NewStringFromCString(arguments[i + 1])); 875 Dart_Handle paths = Dart_NewList(0);
880 } 876 Dart_Handle keys = Dart_NewList(num_params);
881 Dart_Handle keys = Dart_NewList(num_options); 877 Dart_Handle values = Dart_NewList(num_params);
882 Dart_Handle values = Dart_NewList(num_options); 878 for (int i = 0; i < num_params; i++) {
883 for (int i = 0; i < num_options; i++) { 879 Dart_ListSetAt(keys, i, Dart_NewStringFromCString(param_keys[i]));
884 Dart_ListSetAt(keys, i, Dart_NewStringFromCString(option_keys[i])); 880 Dart_ListSetAt(values, i, Dart_NewStringFromCString(param_values[i]));
885 Dart_ListSetAt(values, i, Dart_NewStringFromCString(option_values[i]));
886 } 881 }
887 Dart_Handle args[] = {paths, keys, values}; 882 Dart_Handle args[] = {paths, keys, values};
888 Dart_Handle result = Dart_Invoke(io_lib, handler_function_name, 3, args); 883 Dart_Handle result = Dart_Invoke(io_lib, handler_function_name, 3, args);
889 if (Dart_IsError(result)) return ServiceRequestError(result); 884 if (Dart_IsError(result)) return ServiceRequestError(result);
890 const char *json; 885 const char *json;
891 result = Dart_StringToCString(result, &json); 886 result = Dart_StringToCString(result, &json);
892 if (Dart_IsError(result)) return ServiceRequestError(result); 887 if (Dart_IsError(result)) return ServiceRequestError(result);
893 return strdup(json); 888 return strdup(json);
894 } 889 }
895 890
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 exit(Process::GlobalExitCode()); 1112 exit(Process::GlobalExitCode());
1118 } 1113 }
1119 1114
1120 } // namespace bin 1115 } // namespace bin
1121 } // namespace dart 1116 } // namespace dart
1122 1117
1123 int main(int argc, char** argv) { 1118 int main(int argc, char** argv) {
1124 dart::bin::main(argc, argv); 1119 dart::bin::main(argc, argv);
1125 UNREACHABLE(); 1120 UNREACHABLE();
1126 } 1121 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698