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

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

Issue 1499853004: Adds a special case for sending an int over a port with the native API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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_native_api.h" 5 #include "include/dart_native_api.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_message.h" 9 #include "vm/dart_api_message.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 bool success = writer.WriteCMessage(message); 49 bool success = writer.WriteCMessage(message);
50 50
51 if (!success) return success; 51 if (!success) return success;
52 52
53 // Post the message at the given port. 53 // Post the message at the given port.
54 return PortMap::PostMessage(new Message( 54 return PortMap::PostMessage(new Message(
55 port_id, buffer, writer.BytesWritten(), Message::kNormalPriority)); 55 port_id, buffer, writer.BytesWritten(), Message::kNormalPriority));
56 } 56 }
57 57
58 58
59 DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, intptr_t message) {
60 if (!Smi::IsValid(message)) {
61 return false;
62 }
63 Message* msg = new Message(port_id, message, Message::kNormalPriority);
64
65 // Post the message at the given port.
66 return PortMap::PostMessage(msg);
67 }
68
69
59 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, 70 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
60 Dart_NativeMessageHandler handler, 71 Dart_NativeMessageHandler handler,
61 bool handle_concurrently) { 72 bool handle_concurrently) {
62 if (name == NULL) { 73 if (name == NULL) {
63 name = "<UnnamedNativePort>"; 74 name = "<UnnamedNativePort>";
64 } 75 }
65 if (handler == NULL) { 76 if (handler == NULL) {
66 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", 77 OS::PrintErr("%s expects argument 'handler' to be non-null.\n",
67 CURRENT_FUNC); 78 CURRENT_FUNC);
68 return ILLEGAL_PORT; 79 return ILLEGAL_PORT;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); 115 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T);
105 if (::Dart_IsError(result)) { 116 if (::Dart_IsError(result)) {
106 return result; 117 return result;
107 } 118 }
108 CHECK_CALLBACK_STATE(T); 119 CHECK_CALLBACK_STATE(T);
109 CompileAll(T, &result); 120 CompileAll(T, &result);
110 return result; 121 return result;
111 } 122 }
112 123
113 } // namespace dart 124 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698