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

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

Issue 10896018: Rollback of previous commit -- still under review. (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/benchmark_test.cc ('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 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 } 1518 }
1519 CHECK_LENGTH(length, String::kMaxElements); 1519 CHECK_LENGTH(length, String::kMaxElements);
1520 return Api::NewHandle(isolate, String::New(codepoints, length)); 1520 return Api::NewHandle(isolate, String::New(codepoints, length));
1521 } 1521 }
1522 1522
1523 1523
1524 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) { 1524 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
1525 return RawObject::IsExternalStringClassId(Api::ClassId(object)); 1525 return RawObject::IsExternalStringClassId(Api::ClassId(object));
1526 } 1526 }
1527 1527
1528
1528 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object, 1529 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
1529 void** peer) { 1530 void** peer) {
1531 Isolate* isolate = Isolate::Current();
1532 DARTSCOPE(isolate);
1533 const String& str = Api::UnwrapStringHandle(isolate, object);
1534 if (str.IsNull()) {
1535 RETURN_TYPE_ERROR(isolate, object, String);
1536 }
1537 if (!str.IsExternal()) {
1538 return
1539 Api::NewError("%s expects argument 'object' to be an external String.",
1540 CURRENT_FUNC);
1541 }
1530 if (peer == NULL) { 1542 if (peer == NULL) {
1531 RETURN_NULL_ERROR(peer); 1543 RETURN_NULL_ERROR(peer);
1532 } 1544 }
1533 // NoGCScope no_gc_scope; 1545 *peer = str.GetPeer();
1534 if (Dart_IsExternalString(object)) { 1546 return Api::Success(isolate);
1535 Isolate* isolate = Isolate::Current();
1536 intptr_t class_id = Api::ClassId(object);
1537 void* raw_peer ;
1538 switch (class_id) {
1539 case kExternalOneByteStringCid: {
1540 asm("");
1541 RawExternalOneByteString* raw_string =
1542 (*(reinterpret_cast<RawExternalOneByteString**>(object)))->ptr();
1543 ExternalStringData<uint8_t>* data = raw_string->external_data_;
1544 raw_peer = data != NULL ? data->peer() : NULL;
1545 break;
1546 }
1547 case kExternalTwoByteStringCid: {
1548 RawExternalTwoByteString* raw_string =
1549 (*(reinterpret_cast<RawExternalTwoByteString**>(object)))->ptr();
1550 ExternalStringData<uint16_t>* data = raw_string->external_data_;
1551 raw_peer = data != NULL ? data->peer() : NULL;
1552 break;
1553 }
1554 default: {
1555 RawExternalFourByteString* raw_string =
1556 (*(reinterpret_cast<RawExternalFourByteString**>(object)))->ptr();
1557 ExternalStringData<uint32_t>* data = raw_string->external_data_;
1558 raw_peer = data != NULL ? data->peer() : NULL;
1559 break;
1560 }
1561 }
1562 if (raw_peer != NULL) {
1563 *peer = raw_peer;
1564 return Api::Success(isolate);
1565 } else {
1566 RETURN_TYPE_ERROR(isolate, object, String);
1567 }
1568 }
1569 const char* error_msg = Dart_IsString(object) ?
1570 "%s expects argument 'object' to be an external String." :
1571 "%s expects argument 'object' to be of type String.";
1572 return Api::NewError(error_msg, CURRENT_FUNC);
1573 } 1547 }
1574 1548
1575 1549
1576 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, 1550 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
1577 intptr_t length, 1551 intptr_t length,
1578 void* peer, 1552 void* peer,
1579 Dart_PeerFinalizer callback) { 1553 Dart_PeerFinalizer callback) {
1580 Isolate* isolate = Isolate::Current(); 1554 Isolate* isolate = Isolate::Current();
1581 DARTSCOPE(isolate); 1555 DARTSCOPE(isolate);
1582 if (codepoints == NULL && length != 0) { 1556 if (codepoints == NULL && length != 0) {
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4157 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4131 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4158 Dart::set_perf_events_writer(function); 4132 Dart::set_perf_events_writer(function);
4159 } 4133 }
4160 4134
4161 4135
4162 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4136 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4163 Dart::set_flow_graph_writer(function); 4137 Dart::set_flow_graph_writer(function);
4164 } 4138 }
4165 4139
4166 } // namespace dart 4140 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698