Browse Source

Added function to return a runtime platform identifier string.

Lasse Öörni 13 years ago
parent
commit
5bb39d77c4
4 changed files with 22 additions and 3 deletions
  1. 4 3
      Docs/ScriptAPI.dox
  2. 15 0
      Engine/Core/ProcessUtils.cpp
  3. 2 0
      Engine/Core/ProcessUtils.h
  4. 1 0
      Engine/Engine/CoreAPI.cpp

+ 4 - 3
Docs/ScriptAPI.dox

@@ -31,6 +31,7 @@
 - void OpenConsoleWindow()
 - void OpenConsoleWindow()
 - String GetConsoleInput()
 - String GetConsoleInput()
 - String[]@ GetArguments()
 - String[]@ GetArguments()
+- String GetPlatform()
 - uint GetNumPhysicalCPUs()
 - uint GetNumPhysicalCPUs()
 - uint GetNumLogicalCPUs()
 - uint GetNumLogicalCPUs()
 - void SendEvent(const String&, VariantMap&)
 - void SendEvent(const String&, VariantMap&)
@@ -1542,8 +1543,8 @@ Properties:<br>
 - uint useTimer (readonly)
 - uint useTimer (readonly)
 - TextureUsage usage (readonly)
 - TextureUsage usage (readonly)
 - uint format (readonly)
 - uint format (readonly)
-- uint levels (readonly)
 - bool compressed (readonly)
 - bool compressed (readonly)
+- uint levels (readonly)
 - int width (readonly)
 - int width (readonly)
 - int height (readonly)
 - int height (readonly)
 - int[] levelWidth (readonly)
 - int[] levelWidth (readonly)
@@ -1620,8 +1621,8 @@ Properties:<br>
 - uint useTimer (readonly)
 - uint useTimer (readonly)
 - TextureUsage usage (readonly)
 - TextureUsage usage (readonly)
 - uint format (readonly)
 - uint format (readonly)
-- uint levels (readonly)
 - bool compressed (readonly)
 - bool compressed (readonly)
+- uint levels (readonly)
 - int width (readonly)
 - int width (readonly)
 - int height (readonly)
 - int height (readonly)
 - int[] levelWidth (readonly)
 - int[] levelWidth (readonly)
@@ -1652,8 +1653,8 @@ Properties:<br>
 - uint useTimer (readonly)
 - uint useTimer (readonly)
 - TextureUsage usage (readonly)
 - TextureUsage usage (readonly)
 - uint format (readonly)
 - uint format (readonly)
-- uint levels (readonly)
 - bool compressed (readonly)
 - bool compressed (readonly)
+- uint levels (readonly)
 - int width (readonly)
 - int width (readonly)
 - int height (readonly)
 - int height (readonly)
 - int[] levelWidth (readonly)
 - int[] levelWidth (readonly)

+ 15 - 0
Engine/Core/ProcessUtils.cpp

@@ -318,6 +318,21 @@ String GetConsoleInput()
     return ret;
     return ret;
 }
 }
 
 
+String GetPlatform()
+{
+    #if defined(WIN32)
+    return "Windows";
+    #elif defined(__APPLE__)
+    return "Mac OS X";
+    #elif defined(ANDROID)
+    return "Android";
+    #elif defined(__linux__)
+    return "Linux";
+    #else
+    return String();
+    #endif
+}
+
 unsigned GetNumPhysicalCPUs()
 unsigned GetNumPhysicalCPUs()
 {
 {
     #ifndef ANDROID
     #ifndef ANDROID

+ 2 - 0
Engine/Core/ProcessUtils.h

@@ -55,6 +55,8 @@ const Vector<String>& ParseArguments(int argc, char** argv);
 const Vector<String>& GetArguments();
 const Vector<String>& GetArguments();
 /// Read input from the console window. Return empty if no input.
 /// Read input from the console window. Return empty if no input.
 String GetConsoleInput();
 String GetConsoleInput();
+/// Return the runtime platform identifier. Currently either "Windows", "Linux", "Mac OS X" or "Android".
+String GetPlatform();
 /// Return the number of physical CPU cores.
 /// Return the number of physical CPU cores.
 unsigned GetNumPhysicalCPUs();
 unsigned GetNumPhysicalCPUs();
 /// Return the number of logical CPUs (different from physical if hyperthreading is used.)
 /// Return the number of logical CPUs (different from physical if hyperthreading is used.)

+ 1 - 0
Engine/Engine/CoreAPI.cpp

@@ -572,6 +572,7 @@ static void RegisterProcessUtils(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("void OpenConsoleWindow()", asFUNCTION(OpenConsoleWindow), asCALL_CDECL);
     engine->RegisterGlobalFunction("void OpenConsoleWindow()", asFUNCTION(OpenConsoleWindow), asCALL_CDECL);
     engine->RegisterGlobalFunction("String GetConsoleInput()", asFUNCTION(GetConsoleInput), asCALL_CDECL);
     engine->RegisterGlobalFunction("String GetConsoleInput()", asFUNCTION(GetConsoleInput), asCALL_CDECL);
     engine->RegisterGlobalFunction("Array<String>@ GetArguments()", asFUNCTION(GetArgumentsToArray), asCALL_CDECL);
     engine->RegisterGlobalFunction("Array<String>@ GetArguments()", asFUNCTION(GetArgumentsToArray), asCALL_CDECL);
+    engine->RegisterGlobalFunction("String GetPlatform()", asFUNCTION(GetPlatform), asCALL_CDECL);
     engine->RegisterGlobalFunction("uint GetNumPhysicalCPUs()", asFUNCTION(GetNumPhysicalCPUs), asCALL_CDECL);
     engine->RegisterGlobalFunction("uint GetNumPhysicalCPUs()", asFUNCTION(GetNumPhysicalCPUs), asCALL_CDECL);
     engine->RegisterGlobalFunction("uint GetNumLogicalCPUs()", asFUNCTION(GetNumLogicalCPUs), asCALL_CDECL);
     engine->RegisterGlobalFunction("uint GetNumLogicalCPUs()", asFUNCTION(GetNumLogicalCPUs), asCALL_CDECL);
 }
 }