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 "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
12 | 12 |
13 #include "bin/extensions.h" | 13 #include "bin/extensions.h" |
14 #include "bin/crypto.h" | |
14 #include "bin/directory.h" | 15 #include "bin/directory.h" |
siva
2013/11/05 23:37:46
extensions.h should come here in the order.
Ivan Posva
2013/11/05 23:44:56
Done.
| |
15 #include "bin/file.h" | 16 #include "bin/file.h" |
16 #include "bin/io_buffer.h" | 17 #include "bin/io_buffer.h" |
17 #include "bin/utils.h" | 18 #include "bin/utils.h" |
18 #include "bin/socket.h" | 19 #include "bin/socket.h" |
siva
2013/11/05 23:37:46
socket.h should go before.
Ivan Posva
2013/11/05 23:44:56
Done.
| |
19 | 20 |
20 namespace dart { | 21 namespace dart { |
21 namespace bin { | 22 namespace bin { |
22 | 23 |
23 const char* DartUtils::original_working_directory = NULL; | 24 const char* DartUtils::original_working_directory = NULL; |
24 const char* DartUtils::kDartScheme = "dart:"; | 25 const char* DartUtils::kDartScheme = "dart:"; |
25 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; | 26 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; |
26 const char* DartUtils::kAsyncLibURL = "dart:async"; | 27 const char* DartUtils::kAsyncLibURL = "dart:async"; |
27 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 28 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
28 const char* DartUtils::kCoreLibURL = "dart:core"; | 29 const char* DartUtils::kCoreLibURL = "dart:core"; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 bool bytes_written = file_stream->WriteFully(buffer, num_bytes); | 237 bool bytes_written = file_stream->WriteFully(buffer, num_bytes); |
237 ASSERT(bytes_written); | 238 ASSERT(bytes_written); |
238 } | 239 } |
239 | 240 |
240 | 241 |
241 void DartUtils::CloseFile(void* stream) { | 242 void DartUtils::CloseFile(void* stream) { |
242 delete reinterpret_cast<File*>(stream); | 243 delete reinterpret_cast<File*>(stream); |
243 } | 244 } |
244 | 245 |
245 | 246 |
247 bool DartUtils::EntropySource(uint8_t* buffer, size_t length) { | |
248 return Crypto::GetRandomBytes(length, buffer); | |
249 } | |
250 | |
251 | |
246 static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib, const char* method, | 252 static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib, const char* method, |
247 Dart_Handle arg) { | 253 Dart_Handle arg) { |
248 const int kNumArgs = 1; | 254 const int kNumArgs = 1; |
249 Dart_Handle dart_args[kNumArgs]; | 255 Dart_Handle dart_args[kNumArgs]; |
250 dart_args[0] = arg; | 256 dart_args[0] = arg; |
251 return Dart_Invoke(lib, DartUtils::NewString(method), kNumArgs, dart_args); | 257 return Dart_Invoke(lib, DartUtils::NewString(method), kNumArgs, dart_args); |
252 } | 258 } |
253 | 259 |
254 | 260 |
255 // TODO(iposva): Allocate from the zone instead of leaking error string | 261 // TODO(iposva): Allocate from the zone instead of leaking error string |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1042 new CObjectString(CObject::NewString(os_error->message())); | 1048 new CObjectString(CObject::NewString(os_error->message())); |
1043 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1049 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1044 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1050 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1045 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1051 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1046 result->SetAt(2, error_message); | 1052 result->SetAt(2, error_message); |
1047 return result; | 1053 return result; |
1048 } | 1054 } |
1049 | 1055 |
1050 } // namespace bin | 1056 } // namespace bin |
1051 } // namespace dart | 1057 } // namespace dart |
OLD | NEW |