feat: add io module with File.size async stat and scheduler resume helpers

Introduce a new built-in "io" module exposing a File class with a static size(path) method that performs asynchronous filesystem stat via libuv. The method uses a foreign function startSize_ to initiate the stat request and resumes the calling fiber through the scheduler upon completion. Extend the scheduler with schedulerResumeDouble and schedulerResumeString to support resuming fibers with numeric or string results. Include the generated io.wren.inc source, update the Xcode project to compile io.c and io.wren.inc, register the module in modules.c, and add a test file verifying synchronous-style async size calls and error handling.
This commit is contained in:
Bob Nystrom
2015-09-16 14:34:49 +00:00
parent e0984a5012
commit e4cac681a5
10 changed files with 143 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
import "io" for File
import "scheduler" for Scheduler
System.print(File.size("test/io/file/size.wren")) // expect: 401
// Runs asynchronously.
Scheduler.add {
System.print("async")
}
System.print(File.size("test/io/file/size.wren"))
// expect: async
// expect: 401
var error = Fiber.new {
System.print(File.size("nonexistent"))
}.try()
System.print(error) // expect: no such file or directory