| 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 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 namespace bin { | 13 namespace bin { |
| 14 | 14 |
| 15 static const int kWatcherNativeField = 0; | 15 static const int kWatcherNativeField = 0; |
| 16 | 16 |
| 17 | 17 |
| 18 void SetWatcherIdNativeField(Dart_Handle watcher, intptr_t id) { | 18 void SetWatcherIdNativeField(Dart_Handle watcher, intptr_t id) { |
| 19 ThrowIfError(Dart_SetNativeInstanceField(watcher, kWatcherNativeField, id)); | 19 ThrowIfError(Dart_SetNativeInstanceField(watcher, kWatcherNativeField, id)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 void GetWatcherIdNativeField(Dart_Handle watcher, intptr_t* id) { | 23 void GetWatcherIdNativeField(Dart_Handle watcher, intptr_t* id) { |
| 24 ThrowIfError(Dart_GetNativeInstanceField(watcher, kWatcherNativeField, id)); | 24 ThrowIfError(Dart_GetNativeInstanceField(watcher, kWatcherNativeField, id)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) { |
| 28 Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported())); |
| 29 } |
| 27 | 30 |
| 28 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { | 31 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { |
| 29 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); | 32 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); |
| 30 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); | 33 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); |
| 31 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 34 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); |
| 32 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 35 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); |
| 33 intptr_t id = FileSystemWatcher::WatchPath(path, events, recursive); | 36 intptr_t id = FileSystemWatcher::WatchPath(path, events, recursive); |
| 34 if (id == -1) { | 37 if (id == -1) { |
| 35 Dart_PropagateError(DartUtils::NewDartOSError()); | 38 Dart_PropagateError(DartUtils::NewDartOSError()); |
| 36 } else { | 39 } else { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); | 56 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); |
| 54 intptr_t id; | 57 intptr_t id; |
| 55 GetWatcherIdNativeField(watcher, &id); | 58 GetWatcherIdNativeField(watcher, &id); |
| 56 Dart_Handle handle = FileSystemWatcher::ReadEvents(id); | 59 Dart_Handle handle = FileSystemWatcher::ReadEvents(id); |
| 57 ThrowIfError(handle); | 60 ThrowIfError(handle); |
| 58 Dart_SetReturnValue(args, handle); | 61 Dart_SetReturnValue(args, handle); |
| 59 } | 62 } |
| 60 | 63 |
| 61 } // namespace bin | 64 } // namespace bin |
| 62 } // namespace dart | 65 } // namespace dart |
| OLD | NEW |