| 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 564 |
| 565 | 565 |
| 566 void FUNCTION_NAME(File_Stat)(Dart_NativeArguments args) { | 566 void FUNCTION_NAME(File_Stat)(Dart_NativeArguments args) { |
| 567 Dart_EnterScope(); | 567 Dart_EnterScope(); |
| 568 if (Dart_IsString(Dart_GetNativeArgument(args, 0))) { | 568 if (Dart_IsString(Dart_GetNativeArgument(args, 0))) { |
| 569 const char* path = | 569 const char* path = |
| 570 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 570 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 571 | 571 |
| 572 int64_t stat_data[File::kStatSize]; | 572 int64_t stat_data[File::kStatSize]; |
| 573 File::Stat(path, stat_data); | 573 File::Stat(path, stat_data); |
| 574 Dart_Handle returned_data = Dart_NewTypedData(kInt64, File::kStatSize); | 574 Dart_Handle returned_data = Dart_NewTypedData(Dart_TypedData_kInt64, |
| 575 File::kStatSize); |
| 575 if (Dart_IsError(returned_data)) Dart_PropagateError(returned_data); | 576 if (Dart_IsError(returned_data)) Dart_PropagateError(returned_data); |
| 576 Dart_TypedData_Type data_type_unused; | 577 Dart_TypedData_Type data_type_unused; |
| 577 void* data_location; | 578 void* data_location; |
| 578 intptr_t data_length_unused; | 579 intptr_t data_length_unused; |
| 579 Dart_Handle status = Dart_TypedDataAcquireData(returned_data, | 580 Dart_Handle status = Dart_TypedDataAcquireData(returned_data, |
| 580 &data_type_unused, | 581 &data_type_unused, |
| 581 &data_location, | 582 &data_location, |
| 582 &data_length_unused); | 583 &data_length_unused); |
| 583 if (Dart_IsError(status)) Dart_PropagateError(status); | 584 if (Dart_IsError(status)) Dart_PropagateError(status); |
| 584 memmove(data_location, stat_data, File::kStatSize * sizeof(int64_t)); | 585 memmove(data_location, stat_data, File::kStatSize * sizeof(int64_t)); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 return CObject::NewOSError(); | 956 return CObject::NewOSError(); |
| 956 } | 957 } |
| 957 } else { | 958 } else { |
| 958 return CObject::FileClosedError(); | 959 return CObject::FileClosedError(); |
| 959 } | 960 } |
| 960 } | 961 } |
| 961 return CObject::IllegalArgumentError(); | 962 return CObject::IllegalArgumentError(); |
| 962 } | 963 } |
| 963 | 964 |
| 964 | 965 |
| 965 static int SizeInBytes(Dart_CObject::TypedDataType type) { | 966 static int SizeInBytes(Dart_TypedData_Type type) { |
| 966 switch (type) { | 967 switch (type) { |
| 967 case Dart_CObject::kInt8Array: | 968 case Dart_TypedData_kInt8: |
| 968 case Dart_CObject::kUint8Array: | 969 case Dart_TypedData_kUint8: |
| 969 case Dart_CObject::kUint8ClampedArray: | 970 case Dart_TypedData_kUint8Clamped: |
| 970 return 1; | 971 return 1; |
| 971 case Dart_CObject::kInt16Array: | 972 case Dart_TypedData_kInt16: |
| 972 case Dart_CObject::kUint16Array: | 973 case Dart_TypedData_kUint16: |
| 973 return 2; | 974 return 2; |
| 974 case Dart_CObject::kInt32Array: | 975 case Dart_TypedData_kInt32: |
| 975 case Dart_CObject::kUint32Array: | 976 case Dart_TypedData_kUint32: |
| 976 case Dart_CObject::kFloat32Array: | 977 case Dart_TypedData_kFloat32: |
| 977 return 4; | 978 return 4; |
| 978 case Dart_CObject::kInt64Array: | 979 case Dart_TypedData_kInt64: |
| 979 case Dart_CObject::kUint64Array: | 980 case Dart_TypedData_kUint64: |
| 980 case Dart_CObject::kFloat64Array: | 981 case Dart_TypedData_kFloat64: |
| 981 return 8; | 982 return 8; |
| 982 default: | 983 default: |
| 983 break; | 984 break; |
| 984 } | 985 } |
| 985 UNREACHABLE(); | 986 UNREACHABLE(); |
| 986 return -1; | 987 return -1; |
| 987 } | 988 } |
| 988 | 989 |
| 989 | 990 |
| 990 static CObject* FileWriteFromRequest(const CObjectArray& request) { | 991 static CObject* FileWriteFromRequest(const CObjectArray& request) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 } | 1136 } |
| 1136 return CObject::IllegalArgumentError(); | 1137 return CObject::IllegalArgumentError(); |
| 1137 } | 1138 } |
| 1138 | 1139 |
| 1139 | 1140 |
| 1140 static void FileService(Dart_Port dest_port_id, | 1141 static void FileService(Dart_Port dest_port_id, |
| 1141 Dart_Port reply_port_id, | 1142 Dart_Port reply_port_id, |
| 1142 Dart_CObject* message) { | 1143 Dart_CObject* message) { |
| 1143 CObject* response = CObject::IllegalArgumentError(); | 1144 CObject* response = CObject::IllegalArgumentError(); |
| 1144 CObjectArray request(message); | 1145 CObjectArray request(message); |
| 1145 if (message->type == Dart_CObject::kArray) { | 1146 if (message->type == Dart_CObject_kArray) { |
| 1146 if (request.Length() > 1 && request[0]->IsInt32()) { | 1147 if (request.Length() > 1 && request[0]->IsInt32()) { |
| 1147 CObjectInt32 requestType(request[0]); | 1148 CObjectInt32 requestType(request[0]); |
| 1148 switch (requestType.Value()) { | 1149 switch (requestType.Value()) { |
| 1149 case File::kExistsRequest: | 1150 case File::kExistsRequest: |
| 1150 response = FileExistsRequest(request); | 1151 response = FileExistsRequest(request); |
| 1151 break; | 1152 break; |
| 1152 case File::kCreateRequest: | 1153 case File::kCreateRequest: |
| 1153 response = FileCreateRequest(request); | 1154 response = FileCreateRequest(request); |
| 1154 break; | 1155 break; |
| 1155 case File::kOpenRequest: | 1156 case File::kOpenRequest: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 if (service_port != ILLEGAL_PORT) { | 1241 if (service_port != ILLEGAL_PORT) { |
| 1241 // Return a send port for the service port. | 1242 // Return a send port for the service port. |
| 1242 Dart_Handle send_port = Dart_NewSendPort(service_port); | 1243 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 1243 Dart_SetReturnValue(args, send_port); | 1244 Dart_SetReturnValue(args, send_port); |
| 1244 } | 1245 } |
| 1245 Dart_ExitScope(); | 1246 Dart_ExitScope(); |
| 1246 } | 1247 } |
| 1247 | 1248 |
| 1248 } // namespace bin | 1249 } // namespace bin |
| 1249 } // namespace dart | 1250 } // namespace dart |
| OLD | NEW |