Verified Commit 144e1a9e authored by RobLoach's avatar RobLoach
Browse files

Update love.system.getOS()

parent e6917034
......@@ -4,6 +4,10 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.16.2 - Unreleased
### Added
- `love.system.getOS()` now returns actual operating system name
## 0.16.1 - 2018-03-12
### Added
- `List()` for linked list
......
......@@ -6,8 +6,38 @@
namespace love {
std::string system::getOS() {
// TODO(RobLoach): Resolve the actual current OS.
return "libretro";
// TODO(RobLoach): Replace Macros with something more complex?
#if (defined __HAIKU__)
return "Linux";
#elif((defined __BEOS__) ||(defined __beos__))
return "Linux";
#elif(defined _WIN32_WCE) || (defined _WIN64_WCE)
return "Windows";
#elif((defined WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP)
return "Windows";
#elif(((defined _WIN32) || (defined _WIN64)) && (!defined __CYGWIN__))
return "Windows";
#elif(defined OS2)
return "OS X";
#elif((defined __MACH__) && (defined __APPLE__))
return "OS X";
#elif defined(macintosh)
return "OS X";
#elif defined(ANDROID)
return "Android";
#elif defined(__linux)
return "Linux";
#elif defined(__sun) || defined(sun)
return "Linux";
#elif defined(__FreeBSD__) || defined(__DragonFly__)
return "Linux";
#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
return "Linux";
#elif defined(unix) || defined(__unix__)
return "Linux";
#else
return "Other";
#endif
}
std::vector<int> system::getVersion() {
......
......@@ -12,6 +12,8 @@ class system {
public:
/**
* @brief Gets the current operating system.
*
* @return The current operating system. "OS X", "Windows", "Linux", "Android" or "iOS".
*/
std::string getOS();
......
var os = love.system.getOS()
assert_equal(os, "libretro", "love.system.getOS()")
assert_not_equal(os, "", "love.system.getOS()")
var version = love.system.getVersionString()
assert_equal(version[1], '.', "love.system.getVersionString()")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment