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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 1762)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -601,7 +601,7 @@
const String& class_name =
String::Handle(String::NewSymbol("ReceivePortImpl"));
const String& function_name =
- String::Handle(String::NewSymbol("handleMessage_"));
+ String::Handle(String::NewSymbol("_handleMessage"));
const int kNumArguments = 3;
const Array& kNoArgumentNames = Array::Handle();
const Function& function = Function::Handle(
@@ -644,6 +644,29 @@
}
+DART_EXPORT bool Dart_IsolateHasActivePorts() {
+ // TODO(turnidge): before submitting turn this into a straight field access
+ // instead of a static method call?
+ Dart_EnterScope();
+ Dart_Handle lib = Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
+ if (Dart_IsError(lib)) {
+ return lib;
+ }
+ Dart_Handle count = Dart_InvokeStatic(lib,
+ Dart_NewString("ReceivePortImpl"),
+ Dart_NewString("_getNumLivePorts"),
+ 0,
+ NULL);
+ DART_CHECK_VALID(count);
+ int64_t count_value = 0;
+ Dart_Handle result = Dart_IntegerValue(count, &count_value);
+ DART_CHECK_VALID(result);
+ Dart_ExitScope();
+
+ return count_value > 0;
+}
+
+
static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
return reinterpret_cast<uint8_t*>(new_ptr);
@@ -674,6 +697,56 @@
}
+DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port) {
+ // TODO(turnidge): before submitting consider grabbing the impl of this from
+ // lib/isolate.cc instead and sharing the code.
+ Dart_Handle lib = Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
+ if (Dart_IsError(lib)) {
+ return lib;
+ }
+ Dart_Handle arg = Dart_NewInteger(port);
+ if (Dart_IsError(arg)) {
+ return arg;
+ }
+ Dart_Handle sp_args[1];
+ sp_args[0] = arg;
+ Dart_Handle send_port = Dart_InvokeStatic(lib,
+ Dart_NewString("SendPortImpl"),
+ Dart_NewString("_create"),
+ 1,
+ sp_args);
+ return send_port;
+}
+
+
+DART_EXPORT Dart_Handle Dart_NewReceivePort(Dart_Port port) {
+ // TODO(turnidge): before submitting consider grabbing the impl of this from
+ // lib/isolate.cc instead and sharing the code.
+ Dart_Handle lib = Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
+ if (Dart_IsError(lib)) {
+ return lib;
+ }
+ Dart_Handle arg = Dart_NewInteger(port);
+ if (Dart_IsError(arg)) {
+ return arg;
+ }
+ Dart_Handle rp_args[1];
+ rp_args[0] = arg;
+ Dart_Handle recv_port = Dart_InvokeStatic(lib,
+ Dart_NewString("ReceivePortImpl"),
+ Dart_NewString("_create"),
+ 1,
+ rp_args);
+ return recv_port;
+}
+
+
+DART_EXPORT Dart_Port Dart_GetMainPort() {
+ Isolate* isolate = Isolate::Current();
+ ASSERT(isolate);
+ return isolate->main_port();
+}
+
// --- Scopes ----
@@ -837,6 +910,7 @@
return Api::Error("Integer too big to fit in int64_t");
}
}
+ OS::Print("%s\n", obj.ToCString());
Anton Muhin 2011/11/23 19:28:14 nit: debugging stuff
turnidge 2011/11/23 21:45:37 Oops, thanks.
return Api::Error("Object is not a Integer");
}

Powered by Google App Engine
This is Rietveld 408576698