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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 196443009: - First step in refactoring ports with the goal of moving (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_entry.h » ('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) 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 1182
1183 1183
1184 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { 1184 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
1185 Isolate* isolate = Isolate::Current(); 1185 Isolate* isolate = Isolate::Current();
1186 DARTSCOPE(isolate); 1186 DARTSCOPE(isolate);
1187 CHECK_CALLBACK_STATE(isolate); 1187 CHECK_CALLBACK_STATE(isolate);
1188 return Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); 1188 return Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id));
1189 } 1189 }
1190 1190
1191 1191
1192 DART_EXPORT Dart_Handle Dart_PortGetId(Dart_Handle port, Dart_Port* port_id) {
1193 Isolate* isolate = Isolate::Current();
1194 DARTSCOPE(isolate);
1195 CHECK_CALLBACK_STATE(isolate);
1196 const Instance& port_instance = Api::UnwrapInstanceHandle(isolate, port);
1197 if (port_instance.IsNull()) {
1198 RETURN_TYPE_ERROR(isolate, port, Instance);
1199 }
1200 if (!DartLibraryCalls::IsSendPort(port_instance) &&
1201 !DartLibraryCalls::IsReceivePort(port_instance)) {
1202 return Api::NewError("expected an instance of RawReceivePort or SendPort.");
1203 }
1204 const Object& idObj = Object::Handle(
1205 DartLibraryCalls::PortGetId(port_instance));
1206 ASSERT(idObj.IsInteger());
1207 const Integer& id = Integer::Cast(idObj);
1208 *port_id = static_cast<Dart_Port>(id.AsInt64Value());
1209 return Api::Success();
1210 }
1211
1212
1192 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { 1213 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) {
1193 Isolate* isolate = Isolate::Current(); 1214 Isolate* isolate = Isolate::Current();
1194 DARTSCOPE(isolate); 1215 DARTSCOPE(isolate);
1195 CHECK_CALLBACK_STATE(isolate); 1216 CHECK_CALLBACK_STATE(isolate);
1196 1217
1197 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); 1218 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary());
1198 ASSERT(!isolate_lib.IsNull()); 1219 ASSERT(!isolate_lib.IsNull());
1199 const String& class_name = String::Handle( 1220 const String& class_name = String::Handle(
1200 isolate, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); 1221 isolate, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
1201 // TODO(asiva): Symbols should contain private keys. 1222 // TODO(asiva): Symbols should contain private keys.
1202 const String& function_name = 1223 const String& function_name =
1203 String::Handle(isolate_lib.PrivateName(Symbols::_get_or_create())); 1224 String::Handle(isolate_lib.PrivateName(Symbols::_get()));
1204 const int kNumArguments = 1; 1225 const int kNumArguments = 1;
1205 const Function& function = Function::Handle( 1226 const Function& function = Function::Handle(
1206 isolate, 1227 isolate,
1207 Resolver::ResolveStatic(isolate_lib, 1228 Resolver::ResolveStatic(isolate_lib,
1208 class_name, 1229 class_name,
1209 function_name, 1230 function_name,
1210 kNumArguments, 1231 kNumArguments,
1211 Object::empty_array())); 1232 Object::empty_array()));
1212 ASSERT(!function.IsNull()); 1233 ASSERT(!function.IsNull());
1213 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); 1234 const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
(...skipping 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4640 4661
4641 4662
4642 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 4663 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
4643 const char* name, 4664 const char* name,
4644 Dart_ServiceRequestCallback callback, 4665 Dart_ServiceRequestCallback callback,
4645 void* user_data) { 4666 void* user_data) {
4646 Service::RegisterRootEmbedderCallback(name, callback, user_data); 4667 Service::RegisterRootEmbedderCallback(name, callback, user_data);
4647 } 4668 }
4648 4669
4649 } // namespace dart 4670 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698