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_system_watcher.h" | 5 #include "bin/file_system_watcher.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/file.h" |
9 #include "bin/utils.h" | 10 #include "bin/utils.h" |
10 | 11 |
11 #include "include/dart_api.h" | 12 #include "include/dart_api.h" |
12 | 13 |
13 namespace dart { | 14 namespace dart { |
14 namespace bin { | 15 namespace bin { |
15 | 16 |
16 void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) { | 17 void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) { |
17 Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported())); | 18 Dart_SetBooleanReturnValue(args, FileSystemWatcher::IsSupported()); |
18 } | 19 } |
19 | 20 |
20 void FUNCTION_NAME(FileSystemWatcher_InitWatcher)(Dart_NativeArguments args) { | 21 void FUNCTION_NAME(FileSystemWatcher_InitWatcher)(Dart_NativeArguments args) { |
21 intptr_t id = FileSystemWatcher::Init(); | 22 intptr_t id = FileSystemWatcher::Init(); |
22 if (id >= 0) { | 23 if (id >= 0) { |
23 Dart_SetReturnValue(args, Dart_NewInteger(id)); | 24 Dart_SetReturnValue(args, Dart_NewInteger(id)); |
24 } else { | 25 } else { |
25 OSError os_error; | 26 OSError os_error; |
26 Dart_ThrowException(DartUtils::NewDartOSError(&os_error)); | 27 Dart_ThrowException(DartUtils::NewDartOSError(&os_error)); |
27 } | 28 } |
28 } | 29 } |
29 | 30 |
30 void FUNCTION_NAME(FileSystemWatcher_CloseWatcher)(Dart_NativeArguments args) { | 31 void FUNCTION_NAME(FileSystemWatcher_CloseWatcher)(Dart_NativeArguments args) { |
31 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 32 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
32 FileSystemWatcher::Close(id); | 33 FileSystemWatcher::Close(id); |
33 } | 34 } |
34 | 35 |
35 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { | 36 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { |
36 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 37 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
37 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); | 38 Namespace* namespc = Namespace::GetNamespace(args, 1); |
38 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 39 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 2)); |
39 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 40 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); |
40 intptr_t path_id = FileSystemWatcher::WatchPath(id, path, events, recursive); | 41 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4)); |
| 42 intptr_t path_id = |
| 43 FileSystemWatcher::WatchPath(id, namespc, path, events, recursive); |
41 if (path_id == -1) { | 44 if (path_id == -1) { |
42 Dart_ThrowException(DartUtils::NewDartOSError()); | 45 Dart_ThrowException(DartUtils::NewDartOSError()); |
43 } | 46 } |
44 Dart_SetReturnValue(args, Dart_NewInteger(path_id)); | 47 Dart_SetIntegerReturnValue(args, path_id); |
45 } | 48 } |
46 | 49 |
47 void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) { | 50 void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) { |
48 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 51 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
49 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); | 52 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
50 FileSystemWatcher::UnwatchPath(id, path_id); | 53 FileSystemWatcher::UnwatchPath(id, path_id); |
51 } | 54 } |
52 | 55 |
53 void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) { | 56 void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) { |
54 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 57 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
55 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); | 58 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
56 Dart_Handle handle = FileSystemWatcher::ReadEvents(id, path_id); | 59 Dart_Handle handle = FileSystemWatcher::ReadEvents(id, path_id); |
57 ThrowIfError(handle); | 60 ThrowIfError(handle); |
58 Dart_SetReturnValue(args, handle); | 61 Dart_SetReturnValue(args, handle); |
59 } | 62 } |
60 | 63 |
61 void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) { | 64 void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) { |
62 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 65 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
63 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); | 66 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
64 int socket_id = FileSystemWatcher::GetSocketId(id, path_id); | 67 int socket_id = FileSystemWatcher::GetSocketId(id, path_id); |
65 Dart_SetReturnValue(args, Dart_NewInteger(socket_id)); | 68 Dart_SetIntegerReturnValue(args, socket_id); |
66 } | 69 } |
67 | 70 |
68 } // namespace bin | 71 } // namespace bin |
69 } // namespace dart | 72 } // namespace dart |
OLD | NEW |