From 06731f66d45ea75d6dd607477758981bb2ec4af7 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Sat, 21 May 2016 12:44:17 -0700 Subject: [PATCH] Add a Platform class. - Rename the "process" module to "os". - Add Platform to it. - Static "name" method. - Static "isPosix" method. - Docs and tests! --- doc/site/modules/index.markdown | 2 +- doc/site/modules/os/index.markdown | 7 ++ doc/site/modules/os/platform.markdown | 26 +++++++ .../modules/{process => os}/process.markdown | 2 +- .../modules/{process => os}/template.html | 10 +-- doc/site/modules/process/index.markdown | 5 -- doc/site/modules/template.html | 4 +- src/cli/main.c | 4 +- src/cli/modules.c | 10 ++- src/module/os.c | 71 +++++++++++++++++++ src/module/{process.h => os.h} | 2 +- src/module/{process.wren => os.wren} | 5 ++ src/module/os.wren.inc | 13 ++++ src/module/process.c | 23 ------ src/module/process.wren.inc | 7 -- test/os/platform/is_posix.wren | 5 ++ test/os/platform/name.wren | 5 ++ test/{ => os}/process/all_arguments.wren | 4 +- test/{ => os}/process/arguments.wren | 2 +- util/xcode/wren.xcodeproj/project.pbxproj | 28 ++++---- 20 files changed, 170 insertions(+), 65 deletions(-) create mode 100644 doc/site/modules/os/index.markdown create mode 100644 doc/site/modules/os/platform.markdown rename doc/site/modules/{process => os}/process.markdown (90%) rename doc/site/modules/{process => os}/template.html (87%) delete mode 100644 doc/site/modules/process/index.markdown create mode 100644 src/module/os.c rename src/module/{process.h => os.h} (68%) rename src/module/{process.wren => os.wren} (70%) create mode 100644 src/module/os.wren.inc delete mode 100644 src/module/process.c delete mode 100644 src/module/process.wren.inc create mode 100644 test/os/platform/is_posix.wren create mode 100644 test/os/platform/name.wren rename test/{ => os}/process/all_arguments.wren (76%) rename test/{ => os}/process/arguments.wren (85%) diff --git a/doc/site/modules/index.markdown b/doc/site/modules/index.markdown index dff56ecc..a84ab5be 100644 --- a/doc/site/modules/index.markdown +++ b/doc/site/modules/index.markdown @@ -44,6 +44,6 @@ applications that want to embed Wren. [libuv]: http://libuv.org * [io](io) -* [process](process) +* [os](os) * [scheduler](scheduler) * [timer](timer) diff --git a/doc/site/modules/os/index.markdown b/doc/site/modules/os/index.markdown new file mode 100644 index 00000000..0ddc56ca --- /dev/null +++ b/doc/site/modules/os/index.markdown @@ -0,0 +1,7 @@ +^title Module "os" + +The os module exposes classes for accessing capabilities provided by the +underlying operating system. + +* [Platform](platform.html) +* [Process](process.html) diff --git a/doc/site/modules/os/platform.markdown b/doc/site/modules/os/platform.markdown new file mode 100644 index 00000000..f4b62b5e --- /dev/null +++ b/doc/site/modules/os/platform.markdown @@ -0,0 +1,26 @@ +^title Platform Class + +The Platform class exposes basic information about the operating system Wren is +running on top of. + +## Static Methods + +### **name** + +The name of the platform. This roughly describes the operating system, and is +usually one of: + +* "iOS" +* "Linux" +* "OS X" +* "POSIX" +* "Unix" +* "Windows" + +If Wren was compiled for an unknown operating system, returns "Unknown". + +### **isPosix** + +Returns `true` if the host operating system is known to support the POSIX +standard. This is true for Linux and other Unices, as well as the various Apple +operating systems. diff --git a/doc/site/modules/process/process.markdown b/doc/site/modules/os/process.markdown similarity index 90% rename from doc/site/modules/process/process.markdown rename to doc/site/modules/os/process.markdown index ff3787ea..8589572b 100644 --- a/doc/site/modules/process/process.markdown +++ b/doc/site/modules/os/process.markdown @@ -1,6 +1,6 @@ ^title Process Class -The Process class lets you work with operating processes, including the +The Process class lets you work with operating system processes, including the currently running one. ## Static Methods diff --git a/doc/site/modules/process/template.html b/doc/site/modules/os/template.html similarity index 87% rename from doc/site/modules/process/template.html rename to doc/site/modules/os/template.html index 5d26689b..b8a2f191 100644 --- a/doc/site/modules/process/template.html +++ b/doc/site/modules/os/template.html @@ -22,11 +22,12 @@