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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/native_api_impl.cc
diff --git a/runtime/vm/native_api_impl.cc b/runtime/vm/native_api_impl.cc
index c707c9e9cf776f4b752becc58dedc150cdd3a504..774686cc53e682a159098b44a0d9344c8cf3b35f 100644
--- a/runtime/vm/native_api_impl.cc
+++ b/runtime/vm/native_api_impl.cc
@@ -56,6 +56,30 @@ DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message) {
}
+DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, intptr_t message) {
+ if (!Smi::IsValid(message)) {
+ return false;
+ }
+ Message* msg = new Message(
+ port_id, Smi::New(message), Message::kNormalPriority);
+
+ // Post the message at the given port.
+ return PortMap::PostMessage(msg);
+}
+
+
+DART_EXPORT bool Dart_PostSimpleObject(Dart_Port port_id, Dart_Handle message) {
+ RawObject* raw_obj = Api::UnwrapHandle(message);
+ if (raw_obj->IsHeapObject() && !raw_obj->IsVMHeapObject()) {
+ return false;
+ }
+ Message* msg = new Message(port_id, raw_obj, Message::kNormalPriority);
+
+ // Post the message at the given port.
+ return PortMap::PostMessage(msg);
+}
+
+
DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
Dart_NativeMessageHandler handler,
bool handle_concurrently) {

Powered by Google App Engine
This is Rietveld 408576698