Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 34326) |
| +++ runtime/vm/dart_api_impl.cc (working copy) |
| @@ -1189,6 +1189,26 @@ |
| } |
| +DART_EXPORT Dart_Handle Dart_PortGetId(Dart_Handle port, Dart_Port* port_id) { |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| + Instance& port_instance = Instance::Handle(isolate); |
| + 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.
|
| + if (!DartLibraryCalls::IsSendPort(port_instance) && |
| + !DartLibraryCalls::IsReceivePort(port_instance)) { |
| + return Api::NewError("expected an instance of RawReceivePort or SendPort."); |
| + } |
| + const Object& idObj = Object::Handle( |
| + DartLibraryCalls::PortGetId(port_instance)); |
| + 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.
|
| + Integer& id = Integer::Handle(); |
| + id ^= idObj.raw(); |
| + *port_id = static_cast<Dart_Port>(id.AsInt64Value()); |
| + return Api::Success(); |
| +} |
| + |
| + |
| DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| @@ -1200,7 +1220,7 @@ |
| isolate, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); |
| // TODO(asiva): Symbols should contain private keys. |
| const String& function_name = |
| - String::Handle(isolate_lib.PrivateName(Symbols::_get_or_create())); |
| + String::Handle(isolate_lib.PrivateName(Symbols::_get())); |
| const int kNumArguments = 1; |
| const Function& function = Function::Handle( |
| isolate, |