| OLD | NEW |
| 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 "vm/dart_api_message.h" | 5 #include "vm/dart_api_message.h" |
| 6 #include "vm/object.h" | 6 #include "vm/object.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 p[len] = '\0'; | 270 p[len] = '\0'; |
| 271 return object; | 271 return object; |
| 272 } | 272 } |
| 273 case ObjectStore::kTwoByteStringClass: | 273 case ObjectStore::kTwoByteStringClass: |
| 274 // Two byte strings not supported. | 274 // Two byte strings not supported. |
| 275 return NULL; | 275 return NULL; |
| 276 case ObjectStore::kFourByteStringClass: | 276 case ObjectStore::kFourByteStringClass: |
| 277 // Four byte strings not supported. | 277 // Four byte strings not supported. |
| 278 return NULL; | 278 return NULL; |
| 279 case ObjectStore::kInternalByteArrayClass: { | 279 case ObjectStore::kUint8ArrayClass: { |
| 280 intptr_t len = ReadSmiValue(); | 280 intptr_t len = ReadSmiValue(); |
| 281 Dart_CObject* object = AllocateDartCObjectByteArray(len); | 281 Dart_CObject* object = AllocateDartCObjectByteArray(len); |
| 282 AddBackwardReference(object_id, object); | 282 AddBackwardReference(object_id, object); |
| 283 if (len > 0) { | 283 if (len > 0) { |
| 284 uint8_t* p = object->value.as_byte_array.values; | 284 uint8_t* p = object->value.as_byte_array.values; |
| 285 for (intptr_t i = 0; i < len; i++) { | 285 for (intptr_t i = 0; i < len; i++) { |
| 286 p[i] = Read<uint8_t>(); | 286 p[i] = Read<uint8_t>(); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 return object; | 289 return object; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 // Write out array elements. | 536 // Write out array elements. |
| 537 for (int i = 0; i < object->value.as_array.length; i++) { | 537 for (int i = 0; i < object->value.as_array.length; i++) { |
| 538 WriteCObject(object->value.as_array.values[i]); | 538 WriteCObject(object->value.as_array.values[i]); |
| 539 } | 539 } |
| 540 break; | 540 break; |
| 541 } | 541 } |
| 542 case Dart_CObject::kByteArray: { | 542 case Dart_CObject::kByteArray: { |
| 543 // Write out the serialization header value for this object. | 543 // Write out the serialization header value for this object. |
| 544 WriteInlinedHeader(object); | 544 WriteInlinedHeader(object); |
| 545 // Write out the class and tags information. | 545 // Write out the class and tags information. |
| 546 WriteObjectHeader(ObjectStore::kInternalByteArrayClass, 0); | 546 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0); |
| 547 uint8_t* bytes = object->value.as_byte_array.values; | 547 uint8_t* bytes = object->value.as_byte_array.values; |
| 548 intptr_t len = object->value.as_byte_array.length; | 548 intptr_t len = object->value.as_byte_array.length; |
| 549 WriteSmi(len); | 549 WriteSmi(len); |
| 550 for (intptr_t i = 0; i < len; i++) { | 550 for (intptr_t i = 0; i < len; i++) { |
| 551 Write<uint8_t>(bytes[i]); | 551 Write<uint8_t>(bytes[i]); |
| 552 } | 552 } |
| 553 break; | 553 break; |
| 554 } | 554 } |
| 555 default: | 555 default: |
| 556 UNREACHABLE(); | 556 UNREACHABLE(); |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) { | 561 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) { |
| 562 WriteCObject(object); | 562 WriteCObject(object); |
| 563 UnmarkAllCObjects(object); | 563 UnmarkAllCObjects(object); |
| 564 FinalizeBuffer(); | 564 FinalizeBuffer(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace dart | 567 } // namespace dart |
| OLD | NEW |