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

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/custom_isolate_test.cc ('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 Instance& port_instance = Instance::Handle(isolate);
1197 port_instance ^= Api::UnwrapHandle(port);
siva 2014/03/25 23:42:51 Maybe you should use: const Instance& port_instan
Ivan Posva 2014/03/26 17:17:31 Done.
1198 if (!DartLibraryCalls::IsSendPort(port_instance) &&
1199 !DartLibraryCalls::IsReceivePort(port_instance)) {
1200 return Api::NewError("expected an instance of RawReceivePort or SendPort.");
1201 }
1202 const Object& idObj = Object::Handle(
1203 DartLibraryCalls::PortGetId(port_instance));
1204 ASSERT(!idObj.IsError());
siva 2014/03/25 23:42:51 ASSERT(idObj.IsInteger()); const Integer id = Inte
Ivan Posva 2014/03/26 17:17:31 Done.
1205 Integer& id = Integer::Handle();
1206 id ^= idObj.raw();
1207 *port_id = static_cast<Dart_Port>(id.AsInt64Value());
1208 return Api::Success();
1209 }
1210
1211
1192 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { 1212 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) {
1193 Isolate* isolate = Isolate::Current(); 1213 Isolate* isolate = Isolate::Current();
1194 DARTSCOPE(isolate); 1214 DARTSCOPE(isolate);
1195 CHECK_CALLBACK_STATE(isolate); 1215 CHECK_CALLBACK_STATE(isolate);
1196 1216
1197 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); 1217 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary());
1198 ASSERT(!isolate_lib.IsNull()); 1218 ASSERT(!isolate_lib.IsNull());
1199 const String& class_name = String::Handle( 1219 const String& class_name = String::Handle(
1200 isolate, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); 1220 isolate, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
1201 // TODO(asiva): Symbols should contain private keys. 1221 // TODO(asiva): Symbols should contain private keys.
1202 const String& function_name = 1222 const String& function_name =
1203 String::Handle(isolate_lib.PrivateName(Symbols::_get_or_create())); 1223 String::Handle(isolate_lib.PrivateName(Symbols::_get()));
1204 const int kNumArguments = 1; 1224 const int kNumArguments = 1;
1205 const Function& function = Function::Handle( 1225 const Function& function = Function::Handle(
1206 isolate, 1226 isolate,
1207 Resolver::ResolveStatic(isolate_lib, 1227 Resolver::ResolveStatic(isolate_lib,
1208 class_name, 1228 class_name,
1209 function_name, 1229 function_name,
1210 kNumArguments, 1230 kNumArguments,
1211 Object::empty_array())); 1231 Object::empty_array()));
1212 ASSERT(!function.IsNull()); 1232 ASSERT(!function.IsNull());
1213 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); 1233 const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
(...skipping 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4640 4660
4641 4661
4642 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 4662 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
4643 const char* name, 4663 const char* name,
4644 Dart_ServiceRequestCallback callback, 4664 Dart_ServiceRequestCallback callback,
4645 void* user_data) { 4665 void* user_data) {
4646 Service::RegisterRootEmbedderCallback(name, callback, user_data); 4666 Service::RegisterRootEmbedderCallback(name, callback, user_data);
4647 } 4667 }
4648 4668
4649 } // namespace dart 4669 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698