| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "bin/file.h" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 #include "bin/io_buffer.h" | 9 #include "bin/io_buffer.h" |
| 10 #include "bin/thread.h" | 10 #include "bin/thread.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // The buffer object passed in has to be an Int8List or Uint8List object. | 249 // The buffer object passed in has to be an Int8List or Uint8List object. |
| 250 // Acquire a direct pointer to the data area of the buffer object. | 250 // Acquire a direct pointer to the data area of the buffer object. |
| 251 Dart_TypedData_Type type; | 251 Dart_TypedData_Type type; |
| 252 intptr_t length = end - start; | 252 intptr_t length = end - start; |
| 253 intptr_t buffer_len = 0; | 253 intptr_t buffer_len = 0; |
| 254 void* buffer = NULL; | 254 void* buffer = NULL; |
| 255 Dart_Handle result = | 255 Dart_Handle result = |
| 256 Dart_TypedDataAcquireData(buffer_obj, &type, &buffer, &buffer_len); | 256 Dart_TypedDataAcquireData(buffer_obj, &type, &buffer, &buffer_len); |
| 257 if (Dart_IsError(result)) Dart_PropagateError(result); | 257 if (Dart_IsError(result)) Dart_PropagateError(result); |
| 258 | 258 |
| 259 #ifdef DEBUG | |
| 260 // TODO(ajohnsen): Remove once issue 17602 is fixed. | |
| 261 bool print_debug = true; | |
| 262 for (int i = 0; i < length; i++) { | |
| 263 if (reinterpret_cast<uint8_t*>(buffer)[i] != 0xf3) { | |
| 264 print_debug = false; | |
| 265 break; | |
| 266 } | |
| 267 } | |
| 268 if (print_debug) { | |
| 269 fprintf(stderr, "WARNING: Data is purely 0x3f in File_WriteFrom\n"); | |
| 270 fflush(stderr); | |
| 271 } | |
| 272 #endif | |
| 273 | |
| 274 ASSERT(type == Dart_TypedData_kUint8 || type == Dart_TypedData_kInt8); | 259 ASSERT(type == Dart_TypedData_kUint8 || type == Dart_TypedData_kInt8); |
| 275 ASSERT(end <= buffer_len); | 260 ASSERT(end <= buffer_len); |
| 276 ASSERT(buffer != NULL); | 261 ASSERT(buffer != NULL); |
| 277 | 262 |
| 278 // Write the data out into the file. | 263 // Write the data out into the file. |
| 279 int64_t bytes_written = file->Write(buffer, length); | 264 int64_t bytes_written = file->Write(buffer, length); |
| 280 // Release the direct pointer acquired above. | 265 // Release the direct pointer acquired above. |
| 281 result = Dart_TypedDataReleaseData(buffer_obj); | 266 result = Dart_TypedDataReleaseData(buffer_obj); |
| 282 if (Dart_IsError(result)) Dart_PropagateError(result); | 267 if (Dart_IsError(result)) Dart_PropagateError(result); |
| 283 | 268 |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2)); | 1185 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2)); |
| 1201 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess))); | 1186 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess))); |
| 1202 wrapper->SetAt(1, result); | 1187 wrapper->SetAt(1, result); |
| 1203 return wrapper; | 1188 return wrapper; |
| 1204 } | 1189 } |
| 1205 return CObject::IllegalArgumentError(); | 1190 return CObject::IllegalArgumentError(); |
| 1206 } | 1191 } |
| 1207 | 1192 |
| 1208 } // namespace bin | 1193 } // namespace bin |
| 1209 } // namespace dart | 1194 } // namespace dart |
| OLD | NEW |