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

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

Issue 10902002: Remove inclusion of 'include/dart_api.h' in 'raw_object.h' (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/raw_object.h » ('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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 249
250 void Api::InitOnce() { 250 void Api::InitOnce() {
251 ASSERT(api_native_key_ == Thread::kUnsetThreadLocalKey); 251 ASSERT(api_native_key_ == Thread::kUnsetThreadLocalKey);
252 api_native_key_ = Thread::CreateThreadLocal(); 252 api_native_key_ = Thread::CreateThreadLocal();
253 ASSERT(api_native_key_ != Thread::kUnsetThreadLocalKey); 253 ASSERT(api_native_key_ != Thread::kUnsetThreadLocalKey);
254 } 254 }
255 255
256 256
257 bool Api::ExternalStringGetPeerHelper(Dart_Handle object, void** peer) {
258 NoGCScope no_gc_scope;
259 RawObject* raw_obj = Api::UnwrapHandle(object);
260 switch (Api::ClassId(object)) {
261 case kExternalOneByteStringCid: {
262 RawExternalOneByteString* raw_string =
263 reinterpret_cast<RawExternalOneByteString*>(raw_obj)->ptr();
264 ExternalStringData<uint8_t>* data = raw_string->external_data_;
265 *peer = data->peer();
266 return true;
267 }
268 case kExternalTwoByteStringCid: {
269 RawExternalTwoByteString* raw_string =
270 reinterpret_cast<RawExternalTwoByteString*>(raw_obj)->ptr();
271 ExternalStringData<uint16_t>* data = raw_string->external_data_;
272 *peer = data->peer();
273 return true;
274 }
275 case kExternalFourByteStringCid: {
276 RawExternalFourByteString* raw_string =
277 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr();
278 ExternalStringData<uint32_t>* data = raw_string->external_data_;
279 *peer = data->peer();
280 return true;
281 }
282 }
283 return false;
284 }
285
286
257 // --- Handles --- 287 // --- Handles ---
258 288
259 289
260 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { 290 DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
261 return RawObject::IsErrorClassId(Api::ClassId(handle)); 291 return RawObject::IsErrorClassId(Api::ClassId(handle));
262 } 292 }
263 293
264 294
265 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { 295 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) {
266 return Api::ClassId(object) == kApiErrorCid; 296 return Api::ClassId(object) == kApiErrorCid;
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 CHECK_LENGTH(length, String::kMaxElements); 1549 CHECK_LENGTH(length, String::kMaxElements);
1520 return Api::NewHandle(isolate, String::New(codepoints, length)); 1550 return Api::NewHandle(isolate, String::New(codepoints, length));
1521 } 1551 }
1522 1552
1523 1553
1524 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) { 1554 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
1525 return RawObject::IsExternalStringClassId(Api::ClassId(object)); 1555 return RawObject::IsExternalStringClassId(Api::ClassId(object));
1526 } 1556 }
1527 1557
1528 1558
1529 bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer) {
1530 NoGCScope no_gc_scope;
1531 RawObject* raw_obj = Api::UnwrapHandle(object);
1532 switch (Api::ClassId(object)) {
1533 case kExternalOneByteStringCid: {
1534 RawExternalOneByteString* raw_string =
1535 reinterpret_cast<RawExternalOneByteString*>(raw_obj)->ptr();
1536 ExternalStringData<uint8_t>* data = raw_string->external_data_;
1537 *peer = data->peer();
1538 return true;
1539 }
1540 case kExternalTwoByteStringCid: {
1541 RawExternalTwoByteString* raw_string =
1542 reinterpret_cast<RawExternalTwoByteString*>(raw_obj)->ptr();
1543 ExternalStringData<uint16_t>* data = raw_string->external_data_;
1544 *peer = data->peer();
1545 return true;
1546 }
1547 case kExternalFourByteStringCid: {
1548 RawExternalFourByteString* raw_string =
1549 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr();
1550 ExternalStringData<uint32_t>* data = raw_string->external_data_;
1551 *peer = data->peer();
1552 return true;
1553 }
1554 }
1555 return false;
1556 }
1557
1558
1559 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object, 1559 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
1560 void** peer) { 1560 void** peer) {
1561 if (peer == NULL) { 1561 if (peer == NULL) {
1562 RETURN_NULL_ERROR(peer); 1562 RETURN_NULL_ERROR(peer);
1563 } 1563 }
1564 1564
1565 if (ExternalStringGetPeerHelper(object, peer)) { 1565 if (Api::ExternalStringGetPeerHelper(object, peer)) {
1566 return Api::Success(Isolate::Current()); 1566 return Api::Success(Isolate::Current());
1567 } 1567 }
1568 1568
1569 // It's not an external string, return appropriate error. 1569 // It's not an external string, return appropriate error.
1570 // Note: this is invoked outside of the NoGCScope'd block above, since 1570 // Note: this is invoked outside of the NoGCScope'd block above, since
1571 // error messages allocate new handles. 1571 // error messages allocate new handles.
1572 if (!RawObject::IsStringClassId(Api::ClassId(object))) { 1572 if (!RawObject::IsStringClassId(Api::ClassId(object))) {
1573 RETURN_TYPE_ERROR(Isolate::Current(), object, String); 1573 RETURN_TYPE_ERROR(Isolate::Current(), object, String);
1574 } else { 1574 } else {
1575 return 1575 return
(...skipping 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after
4186 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4186 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4187 Dart::set_perf_events_writer(function); 4187 Dart::set_perf_events_writer(function);
4188 } 4188 }
4189 4189
4190 4190
4191 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4191 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4192 Dart::set_flow_graph_writer(function); 4192 Dart::set_flow_graph_writer(function);
4193 } 4193 }
4194 4194
4195 } // namespace dart 4195 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698