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

Side by Side Diff: vm/dart_api_impl.cc

Issue 12209075: Provide implementations for (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 months 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
« no previous file with comments | « no previous file | vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 return Api::Success(isolate); 2331 return Api::Success(isolate);
2332 } 2332 }
2333 2333
2334 2334
2335 DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array, 2335 DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array,
2336 Dart_Scalar_Type* type, 2336 Dart_Scalar_Type* type,
2337 void** data, 2337 void** data,
2338 intptr_t* len) { 2338 intptr_t* len) {
2339 Isolate* isolate = Isolate::Current(); 2339 Isolate* isolate = Isolate::Current();
2340 DARTSCOPE(isolate); 2340 DARTSCOPE(isolate);
2341 if (!RawObject::IsByteArrayClassId(Api::ClassId(array))) { 2341 intptr_t class_id = Api::ClassId(array);
2342 if (!RawObject::IsByteArrayClassId(class_id)) {
2342 RETURN_TYPE_ERROR(isolate, array, 'scalar list'); 2343 RETURN_TYPE_ERROR(isolate, array, 'scalar list');
2343 } 2344 }
2344 if (type == NULL) { 2345 if (type == NULL) {
2345 RETURN_NULL_ERROR(type); 2346 RETURN_NULL_ERROR(type);
2346 } 2347 }
2347 if (data == NULL) { 2348 if (data == NULL) {
2348 RETURN_NULL_ERROR(data); 2349 RETURN_NULL_ERROR(data);
2349 } 2350 }
2350 if (len == NULL) { 2351 if (len == NULL) {
2351 RETURN_NULL_ERROR(len); 2352 RETURN_NULL_ERROR(len);
2352 } 2353 }
2353 isolate->IncrementNoGCScopeDepth(); 2354 // Get the type of typed array.
2354 START_NO_CALLBACK_SCOPE(isolate); 2355 switch (class_id) {
2355 2356 case kByteArrayCid :
2356 UNIMPLEMENTED(); 2357 *type = kByteArray;
2358 break;
2359 case kInt8ArrayCid :
2360 case kExternalInt8ArrayCid :
2361 *type = kInt8;
2362 break;
2363 case kUint8ArrayCid :
2364 case kExternalUint8ArrayCid :
2365 *type = kUint8;
2366 break;
2367 case kUint8ClampedArrayCid :
2368 case kExternalUint8ClampedArrayCid :
2369 *type = kUint8Clamped;
2370 break;
2371 case kInt16ArrayCid :
2372 case kExternalInt16ArrayCid :
2373 *type = kInt16;
2374 break;
2375 case kUint16ArrayCid :
2376 case kExternalUint16ArrayCid :
2377 *type = kUint16;
2378 break;
2379 case kInt32ArrayCid :
2380 case kExternalInt32ArrayCid :
2381 *type = kInt32;
2382 break;
2383 case kUint32ArrayCid :
2384 case kExternalUint32ArrayCid :
2385 *type = kUint32;
2386 break;
2387 case kInt64ArrayCid :
2388 case kExternalInt64ArrayCid :
2389 *type = kInt64;
2390 break;
2391 case kUint64ArrayCid :
2392 case kExternalUint64ArrayCid :
2393 *type = kUint64;
2394 break;
2395 case kFloat32ArrayCid :
2396 case kExternalFloat32ArrayCid :
2397 *type = kFloat32;
2398 break;
2399 case kFloat64ArrayCid :
2400 case kExternalFloat64ArrayCid :
2401 *type = kFloat64;
2402 break;
2403 }
2404 const ByteArray& obj = Api::UnwrapByteArrayHandle(isolate, array);
2405 ASSERT(!obj.IsNull());
2406 *len = obj.Length();
2407 // If it is an external typed array object just return the data field.
2408 if (RawObject::IsExternalByteArrayClassId(class_id)) {
2409 *data = reinterpret_cast<void*>(obj.ByteAddr(0));
2410 } else {
2411 // Regular typed array object, set up some GC and API callback guards.
2412 isolate->IncrementNoGCScopeDepth();
2413 START_NO_CALLBACK_SCOPE(isolate);
2414 *data = reinterpret_cast<void*>(obj.ByteAddr(0));
2415 }
2357 return Api::Success(isolate); 2416 return Api::Success(isolate);
2358 } 2417 }
2359 2418
2360 2419
2361 DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array) { 2420 DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array) {
2362 Isolate* isolate = Isolate::Current(); 2421 Isolate* isolate = Isolate::Current();
2363 DARTSCOPE(isolate); 2422 DARTSCOPE(isolate);
2364 if (!RawObject::IsByteArrayClassId(Api::ClassId(array))) { 2423 intptr_t class_id = Api::ClassId(array);
2424 if (!RawObject::IsByteArrayClassId(class_id)) {
2365 RETURN_TYPE_ERROR(isolate, array, 'scalar list'); 2425 RETURN_TYPE_ERROR(isolate, array, 'scalar list');
2366 } 2426 }
2367 2427 if (!RawObject::IsExternalByteArrayClassId(class_id)) {
2368 UNIMPLEMENTED(); 2428 isolate->DecrementNoGCScopeDepth();
2369 isolate->DecrementNoGCScopeDepth(); 2429 END_NO_CALLBACK_SCOPE(isolate);
2370 END_NO_CALLBACK_SCOPE(isolate); 2430 }
2371 return Api::Success(isolate); 2431 return Api::Success(isolate);
2372 } 2432 }
2373 2433
2374 2434
2375 // --- Closures --- 2435 // --- Closures ---
2376 2436
2377 2437
2378 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) { 2438 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) {
2379 // We can't use a fast class index check here because there are many 2439 // We can't use a fast class index check here because there are many
2380 // different signature classes for closures. 2440 // different signature classes for closures.
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 } 4510 }
4451 { 4511 {
4452 NoGCScope no_gc; 4512 NoGCScope no_gc;
4453 RawObject* raw_obj = obj.raw(); 4513 RawObject* raw_obj = obj.raw();
4454 isolate->heap()->SetPeer(raw_obj, peer); 4514 isolate->heap()->SetPeer(raw_obj, peer);
4455 } 4515 }
4456 return Api::Success(isolate); 4516 return Api::Success(isolate);
4457 } 4517 }
4458 4518
4459 } // namespace dart 4519 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698