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
+4 -1
View File
@@ -3,9 +3,11 @@
#include "modules.h"
#include "io.wren.inc"
#include "scheduler.wren.inc"
#include "timer.wren.inc"
#include "io.h"
#include "scheduler.h"
#include "timer.h"
@@ -30,8 +32,9 @@ typedef struct
// The array of built-in modules.
static BuiltInModule modules[] =
{
{"io", &ioModuleSource, ioBindForeign, NULL},
{"scheduler", &schedulerModuleSource, schedulerBindForeign, NULL},
{"timer", &timerModuleSource, timerBindForeign, NULL},
{"timer", &timerModuleSource, timerBindForeign, NULL},
// Sentinel marking the end of the list.
{NULL, NULL, NULL, NULL}
+1 -1
View File
@@ -2,8 +2,8 @@
#include <string.h>
#include "modules.h"
#include "vm.h"
#include "scheduler.h"
#include "vm.h"
#define MAX_LINE_LENGTH 1024 // TODO: Something less arbitrary.