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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // Make a copy of the error message as the original message string 268 // Make a copy of the error message as the original message string
269 // may get deallocated when we return back from the Dart API call. 269 // may get deallocated when we return back from the Dart API call.
270 const String& error = String::Handle( 270 const String& error = String::Handle(
271 Isolate::Current()->object_store()->sticky_error()); 271 Isolate::Current()->object_store()->sticky_error());
272 const Object& obj = Object::Handle(ApiError::New(error)); 272 const Object& obj = Object::Handle(ApiError::New(error));
273 *handle = Api::NewLocalHandle(obj); 273 *handle = Api::NewLocalHandle(obj);
274 } 274 }
275 275
276 276
277 DART_EXPORT void Dart_SetMessageCallbacks( 277 DART_EXPORT void Dart_SetMessageCallbacks(
278 Dart_CreatePortCallback create_port_callback,
278 Dart_PostMessageCallback post_message_callback, 279 Dart_PostMessageCallback post_message_callback,
279 Dart_ClosePortCallback close_port_callback) { 280 Dart_ClosePortCallback close_port_callback) {
280 Isolate* isolate = Isolate::Current(); 281 Isolate* isolate = Isolate::Current();
281 ASSERT(isolate != NULL); 282 ASSERT(isolate != NULL);
283 ASSERT(create_port_callback != NULL);
282 ASSERT(post_message_callback != NULL); 284 ASSERT(post_message_callback != NULL);
283 ASSERT(close_port_callback != NULL); 285 ASSERT(close_port_callback != NULL);
286 isolate->set_create_port_callback(create_port_callback);
284 isolate->set_post_message_callback(post_message_callback); 287 isolate->set_post_message_callback(post_message_callback);
285 isolate->set_close_port_callback(close_port_callback); 288 isolate->set_close_port_callback(close_port_callback);
286 } 289 }
287 290
288 291
289 static RawInstance* DeserializeMessage(void* data) { 292 static RawInstance* DeserializeMessage(void* data) {
290 // Create a snapshot object using the buffer. 293 // Create a snapshot object using the buffer.
291 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data); 294 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
292 ASSERT(snapshot->IsPartialSnapshot()); 295 ASSERT(snapshot->IsPartialSnapshot());
293 296
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 } 1928 }
1926 // Since this is only a snapshot the root library should not be set. 1929 // Since this is only a snapshot the root library should not be set.
1927 isolate->object_store()->set_root_library(Library::Handle()); 1930 isolate->object_store()->set_root_library(Library::Handle());
1928 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator); 1931 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator);
1929 writer.WriteFullSnapshot(); 1932 writer.WriteFullSnapshot();
1930 *snapshot_size = writer.Size(); 1933 *snapshot_size = writer.Size();
1931 return Api::Success(); 1934 return Api::Success();
1932 } 1935 }
1933 1936
1934 1937
1938 DART_EXPORT Dart_Port Dart_CreatePort() {
1939 return PortMap::CreatePort();
1940 }
1941
1942
1943 DART_EXPORT bool Dart_IsolateHasActivePorts() {
1944 Isolate* isolate = Isolate::Current();
1945 ASSERT(isolate);
1946 return isolate->active_ports() > 0;
1947 }
1948
1949
1935 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 1950 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
1936 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 1951 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
1937 return reinterpret_cast<uint8_t*>(new_ptr); 1952 return reinterpret_cast<uint8_t*>(new_ptr);
1938 } 1953 }
1939 1954
1940 1955
1941 DART_EXPORT bool Dart_PostIntArray(Dart_Port port, 1956 DART_EXPORT bool Dart_PostIntArray(Dart_Port port,
1942 intptr_t len, 1957 intptr_t len,
1943 intptr_t* data) { 1958 intptr_t* data) {
1944 uint8_t* buffer = NULL; 1959 uint8_t* buffer = NULL;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 ASSERT(isolate != NULL); 2148 ASSERT(isolate != NULL);
2134 ApiState* state = isolate->api_state(); 2149 ApiState* state = isolate->api_state();
2135 ASSERT(state != NULL); 2150 ASSERT(state != NULL);
2136 ApiLocalScope* scope = state->top_scope(); 2151 ApiLocalScope* scope = state->top_scope();
2137 ASSERT(scope != NULL); 2152 ASSERT(scope != NULL);
2138 return scope->zone().Reallocate(ptr, old_size, new_size); 2153 return scope->zone().Reallocate(ptr, old_size, new_size);
2139 } 2154 }
2140 2155
2141 2156
2142 } // namespace dart 2157 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698