diff --git a/.clang-format b/.clang-format index cf595948c3..fd035f5eea 100644 --- a/.clang-format +++ b/.clang-format @@ -66,3 +66,5 @@ IndentPPDirectives: AfterHash IncludeBlocks: Preserve UseTab: Never BreakConstructorInitializers: BeforeComma + +AlignConsecutiveMacros: AcrossEmptyLines diff --git a/core/platform/ApplicationProtocol.h b/core/platform/ApplicationProtocol.h index a7c12f5d44..ff1ce7c1a3 100644 --- a/core/platform/ApplicationProtocol.h +++ b/core/platform/ApplicationProtocol.h @@ -46,21 +46,19 @@ public: */ enum class Platform { - Windows, /**< Windows */ - UWP, - UWP_Phone, + Unknown, + Win32, /**< Win32 Apps */ + WinUWP, /**< WinUWP */ Linux, /**< Linux */ - macOS, /**< macOS */ + OSX, /**< macOS */ Android, /**< Android */ - Emscripten, /**< Emscripten */ - iOS, /**< Apple iOS */ - }; - - enum class SubPlatform { - Null, - Win32, - WinRT, - tvOS, + iOS, /**< Apple iOS */ + tvOS, /**< Apple tvOS */ + Wasm, /**< aka WebAssembly/Emscripten */ + /* alias */ + Windows = Win32, + macOS = OSX, + Emscripten = Wasm }; /** diff --git a/core/platform/PlatformConfig.h b/core/platform/PlatformConfig.h index e663fbf95f..9f40b8bfa4 100644 --- a/core/platform/PlatformConfig.h +++ b/core/platform/PlatformConfig.h @@ -45,14 +45,19 @@ THE SOFTWARE. // define supported target platform macro which CC uses. #define AX_PLATFORM_UNKNOWN 0 -#define AX_PLATFORM_IOS 1 -#define AX_PLATFORM_ANDROID 2 -#define AX_PLATFORM_WIN32 3 -#define AX_PLATFORM_LINUX 5 -#define AX_PLATFORM_MAC 8 -#define AX_PLATFORM_WASM 10 +#define AX_PLATFORM_WIN32 1 +#define AX_PLATFORM_WINUWP 2 +#define AX_PLATFORM_LINUX 3 +#define AX_PLATFORM_OSX 4 +#define AX_PLATFORM_ANDROID 5 +#define AX_PLATFORM_IOS 6 +#define AX_PLATFORM_TVOS 7 +#define AX_PLATFORM_WASM 8 + +// alias platform macros +#define AX_PLATFORM_WINRT AX_PLATFORM_WINUWP +#define AX_PLATFORM_MAC AX_PLATFORM_OSX #define AX_PLATFORM_EMSCRIPTEN AX_PLATFORM_WASM -#define AX_PLATFORM_WINRT 13 // Determine target platform by compile environment macro. #define AX_TARGET_PLATFORM AX_PLATFORM_UNKNOWN diff --git a/core/platform/ios/Application-ios.mm b/core/platform/ios/Application-ios.mm index b5ea90e41f..bfbb69d01e 100644 --- a/core/platform/ios/Application-ios.mm +++ b/core/platform/ios/Application-ios.mm @@ -102,7 +102,11 @@ LanguageType Application::getCurrentLanguage() Application::Platform Application::getTargetPlatform() { +#if TARGET_OS_IOS return Platform::iOS; +#else /*elif TARGET_OS_TV*/ + return Platform::tvOS; +#endif } std::string Application::getVersion() diff --git a/core/platform/mac/Application-mac.mm b/core/platform/mac/Application-mac.mm index 9a8b7b6edb..a666bafe84 100644 --- a/core/platform/mac/Application-mac.mm +++ b/core/platform/mac/Application-mac.mm @@ -108,7 +108,7 @@ void Application::setAnimationInterval(float interval) Application::Platform Application::getTargetPlatform() { - return Platform::macOS; + return Platform::OSX; } std::string Application::getVersion() diff --git a/core/platform/wasm/Application-wasm.cpp b/core/platform/wasm/Application-wasm.cpp index 65291b8e54..89c920df4f 100644 --- a/core/platform/wasm/Application-wasm.cpp +++ b/core/platform/wasm/Application-wasm.cpp @@ -130,7 +130,7 @@ const std::string& Application::getResourceRootPath() Application::Platform Application::getTargetPlatform() { - return Platform::Emscripten; + return Platform::Wasm; } std::string Application::getVersion() diff --git a/core/platform/win32/Application-win32.cpp b/core/platform/win32/Application-win32.cpp index adc34c7d7f..f627043608 100644 --- a/core/platform/win32/Application-win32.cpp +++ b/core/platform/win32/Application-win32.cpp @@ -245,7 +245,7 @@ const char* Application::getCurrentLanguageCode() Application::Platform Application::getTargetPlatform() { - return Platform::Windows; + return Platform::Win32; } std::string Application::getVersion() diff --git a/core/platform/winrt/Application-winrt.cpp b/core/platform/winrt/Application-winrt.cpp index c0524c496d..31ce534d51 100644 --- a/core/platform/winrt/Application-winrt.cpp +++ b/core/platform/winrt/Application-winrt.cpp @@ -147,14 +147,7 @@ LanguageType Application::getCurrentLanguage() Application::Platform Application::getTargetPlatform() { - if (isWindowsPhone()) - { - return Platform::UWP; - } - else - { - return Platform::UWP_Phone; - } + return Platform::WinUWP; } std::string Application::getVersion() diff --git a/extensions/scripting/lua-bindings/script/core/Constants.lua b/extensions/scripting/lua-bindings/script/core/Constants.lua index 28badd5ae2..a7400f1ea2 100644 --- a/extensions/scripting/lua-bindings/script/core/Constants.lua +++ b/extensions/scripting/lua-bindings/script/core/Constants.lua @@ -190,15 +190,23 @@ cc.UNIFORM_SAMPLER_S = 'AX_Texture0' cc.UNIFORM_SIN_TIME_S = 'AX_SinTime' cc.UNIFORM_TIME_S = 'AX_Time' -cc.PLATFORM_WINDOWS = 0 -cc.PLATFORM_UWP = 1 -cc.PLATFORM_UWP_PHONE = 2 +-- refer to: ApplicationProtocol.h: enum class Platform +cc.PLATFORM_UNKNOWN = 0 +cc.PLATFORM_WIN32 = 1 +cc.PLATFORM_WINUWP = 2 cc.PLATFORM_LINUX = 3 -cc.PLATFORM_MACOS = 4 +cc.PLATFORM_OSX = 4 cc.PLATFORM_ANDROID = 5 cc.PLATFORM_IOS = 6 +cc.PLATFORM_TVOS = 7 +cc.PLATFORM_WASM = 8 -- iPAD device of iOS, TODO: provide API: isIPad() +-- platform alias +cc.PLATFORM_WINDOWS = cc.PLATFORM_WIN32 +cc.PLATFORM_MACOS = cc.PLATFORM_OSX +cc.PLATFORM_EMSCRIPTEN = cc.PLATFORM_WASM + cc.LANGUAGE_ENGLISH = 0 cc.LANGUAGE_CHINESE = 1 cc.LANGUAGE_FRENCH = 2