From 12de1b373affb44771f91f9675c97b860f9be3c7 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 13 May 2021 10:21:54 +0900 Subject: [PATCH] Add a github action to check tidy (#93) * Add a tidy script and a foramt file * This format is based on Google Style * check-tidy came from Samsusng/escargot * How to run: tools/check_tidy.py You can specify clang-format using '--clang-format' The clang-format being used by vscode is usually in ~/.vscode/extensions/ms-vscode.cpptools-{VERSION}-insiders/LLVM/bin/ Signed-off-by: Boram Bae * Add an action to check tidy Signed-off-by: Boram Bae * Update tidy for all packages Signed-off-by: Boram Bae * Use config file strictly Signed-off-by: Boram Bae * Specify target directory to check tidy Signed-off-by: Boram Bae --- .clang-format | 183 +++++ .github/workflows/{dart.yml => format.yml} | 23 +- .../audioplayers/tizen/src/audio_player.cc | 3 +- .../tizen/src/audio_player_error.h | 2 +- .../tizen/src/audio_player_options.h | 2 +- .../tizen/src/audioplayers_tizen_plugin.cc | 7 +- .../tizen/src/flutter_tts_tizen_plugin.cc | 107 +-- .../tizen/src/app_settings_manager.cc | 3 +- .../tizen/src/video_player_error.h | 2 +- .../tizen/src/video_player_options.h | 2 +- .../tizen/inc/lwe/LWEWebView.h | 689 +++++++++--------- .../tizen/inc/lwe/PlatformIntegrationData.h | 496 ++++++------- tools/check_tidy.py | 128 ++++ 13 files changed, 990 insertions(+), 657 deletions(-) create mode 100644 .clang-format rename .github/workflows/{dart.yml => format.yml} (50%) create mode 100755 tools/check_tidy.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..e0e6dfcaf --- /dev/null +++ b/.clang-format @@ -0,0 +1,183 @@ +# This file is generated by the following command +# clang-format(v11.0.1, in vscode v1.55.0) -style=Google -dump-config > .clang-format + +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: "^ IWYU pragma:" +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + - Regex: "^<.*" + Priority: 2 + SortPriority: 0 + - Regex: ".*" + Priority: 3 + SortPriority: 0 +IncludeIsMainRegex: "([-_](test|unittest))?$" +IncludeIsMainSourceRegex: "" +IndentCaseLabels: true +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: "" +MacroBlockEnd: "" +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - "c++" + - "C++" + CanonicalDelimiter: "" + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: "" + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE diff --git a/.github/workflows/dart.yml b/.github/workflows/format.yml similarity index 50% rename from .github/workflows/dart.yml rename to .github/workflows/format.yml index 021d80ff6..7f80d7f86 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/format.yml @@ -1,13 +1,9 @@ -name: Dart +name: Format -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [push, pull_request] jobs: - analysis: + dart: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -22,3 +18,16 @@ jobs: done - name: Verify formatting run: flutter format --set-exit-if-changed packages + clang: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "2.7" + - name: Install clang-format + run: | + sudo apt-get update + sudo apt-get install clang-format-11 + - name: Check tidy + run: tools/check_tidy.py --dir packages diff --git a/packages/audioplayers/tizen/src/audio_player.cc b/packages/audioplayers/tizen/src/audio_player.cc index edaa78216..20685550e 100644 --- a/packages/audioplayers/tizen/src/audio_player.cc +++ b/packages/audioplayers/tizen/src/audio_player.cc @@ -165,7 +165,8 @@ void AudioPlayer::SetDataSource(std::vector &data) { } void AudioPlayer::SetVolume(double volume) { - LOG_INFO("AudioPlayer %s is setting volume %f...", player_id_.c_str(), volume); + LOG_INFO("AudioPlayer %s is setting volume %f...", player_id_.c_str(), + volume); if (volume_ != volume) { volume_ = volume; if (GetPlayerState() != PLAYER_STATE_NONE) { diff --git a/packages/audioplayers/tizen/src/audio_player_error.h b/packages/audioplayers/tizen/src/audio_player_error.h index 09d15328c..2517f622f 100644 --- a/packages/audioplayers/tizen/src/audio_player_error.h +++ b/packages/audioplayers/tizen/src/audio_player_error.h @@ -27,4 +27,4 @@ class AudioPlayerError { std::string message_; }; -#endif // AUDIO_PLAYER_ERROR_H_ \ No newline at end of file +#endif // AUDIO_PLAYER_ERROR_H_ diff --git a/packages/audioplayers/tizen/src/audio_player_options.h b/packages/audioplayers/tizen/src/audio_player_options.h index 9960eec7b..d757d419b 100644 --- a/packages/audioplayers/tizen/src/audio_player_options.h +++ b/packages/audioplayers/tizen/src/audio_player_options.h @@ -3,4 +3,4 @@ enum ReleaseMode { RELEASE, LOOP, STOP }; -#endif // AUDIO_PLAYER_OPTIONS_H_ \ No newline at end of file +#endif // AUDIO_PLAYER_OPTIONS_H_ diff --git a/packages/audioplayers/tizen/src/audioplayers_tizen_plugin.cc b/packages/audioplayers/tizen/src/audioplayers_tizen_plugin.cc index 1ccd670cf..b5492782d 100644 --- a/packages/audioplayers/tizen/src/audioplayers_tizen_plugin.cc +++ b/packages/audioplayers/tizen/src/audioplayers_tizen_plugin.cc @@ -155,7 +155,8 @@ class AudioplayersTizenPlugin : public flutter::Plugin { flutter::EncodableValue &release_mode_value = encodables[flutter::EncodableValue("releaseMode")]; if (std::holds_alternative(release_mode_value)) { - std::string release_mode = std::get(release_mode_value); + std::string release_mode = + std::get(release_mode_value); if (release_mode.compare("ReleaseMode.RELEASE") == 0) { player->SetReleaseMode(RELEASE); } else if (release_mode.compare("ReleaseMode.LOOP") == 0) { @@ -240,8 +241,8 @@ class AudioplayersTizenPlugin : public flutter::Plugin { }; ErrorListener error_listener = [channel = channel_.get()]( - const std::string &player_id, - const std::string &message) { + const std::string &player_id, + const std::string &message) { flutter::EncodableMap wrapped = { {flutter::EncodableValue("playerId"), flutter::EncodableValue(player_id)}, diff --git a/packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc b/packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc index da66a9dea..28137ea4d 100644 --- a/packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc +++ b/packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc @@ -19,7 +19,7 @@ static std::string ErrorToString(int error) { return "TTS - Successful"; case TTS_ERROR_OUT_OF_MEMORY: return "TTS - Out of Memory"; - case TTS_ERROR_IO_ERROR : + case TTS_ERROR_IO_ERROR: return "TTS - I/O error"; case TTS_ERROR_INVALID_PARAMETER: return "TTS - Invalid parameter"; @@ -55,16 +55,20 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { registrar->AddPlugin(std::move(plugin)); } - FlutterTtsTizenPlugin(flutter::PluginRegistrar *registrar) : m_tts(nullptr), - m_voice_type(TTS_VOICE_TYPE_AUTO), m_speed(TTS_SPEED_AUTO), m_speaking(false), - m_await_speak_completion(false) { - m_channel = std::make_unique>( - registrar->messenger(), "flutter_tts", &flutter::StandardMethodCodec::GetInstance()); - m_channel->SetMethodCallHandler( - [this](const auto &call, auto result) { - this->HandleMethodCall(call, std::move(result)); - }); - EnsureTtsHandle(); + FlutterTtsTizenPlugin(flutter::PluginRegistrar *registrar) + : m_tts(nullptr), + m_voice_type(TTS_VOICE_TYPE_AUTO), + m_speed(TTS_SPEED_AUTO), + m_speaking(false), + m_await_speak_completion(false) { + m_channel = + std::make_unique>( + registrar->messenger(), "flutter_tts", + &flutter::StandardMethodCodec::GetInstance()); + m_channel->SetMethodCallHandler([this](const auto &call, auto result) { + this->HandleMethodCall(call, std::move(result)); + }); + EnsureTtsHandle(); } virtual ~FlutterTtsTizenPlugin() { @@ -75,7 +79,6 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { } private: - bool EnsureTtsHandle() { if (m_tts != nullptr) { return true; @@ -90,26 +93,30 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { ret = tts_set_state_changed_cb(m_tts, OnStateChanged, (void *)this); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_set_state_changed_cb failed: %s", ErrorToString(ret).c_str()); + LOG_ERROR("[TTS] tts_set_state_changed_cb failed: %s", + ErrorToString(ret).c_str()); tts_destroy(m_tts); m_tts = nullptr; return false; } - ret = tts_set_utterance_completed_cb(m_tts, OnUtteranceCompleted, (void *)this); + ret = tts_set_utterance_completed_cb(m_tts, OnUtteranceCompleted, + (void *)this); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_set_utterance_completed_cb failed: %s", ErrorToString(ret).c_str()); + LOG_ERROR("[TTS] tts_set_utterance_completed_cb failed: %s", + ErrorToString(ret).c_str()); tts_destroy(m_tts); m_tts = nullptr; return false; } if (m_language.size() == 0) { - char* language; + char *language; ret = tts_get_default_voice(m_tts, &language, &m_voice_type); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_get_default_voice failed: %s", ErrorToString(ret).c_str()); + LOG_ERROR("[TTS] tts_get_default_voice failed: %s", + ErrorToString(ret).c_str()); tts_destroy(m_tts); m_tts = nullptr; return false; @@ -120,12 +127,14 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { ret = tts_foreach_supported_voices(m_tts, OnSupportedVoices, (void *)this); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_foreach_supported_voices failed: %s", ErrorToString(ret).c_str()); + LOG_ERROR("[TTS] tts_foreach_supported_voices failed: %s", + ErrorToString(ret).c_str()); tts_destroy(m_tts); m_tts = nullptr; return false; } - m_languages.erase(unique(m_languages.begin(),m_languages.end()),m_languages.end()); + m_languages.erase(unique(m_languages.begin(), m_languages.end()), + m_languages.end()); ret = tts_prepare(m_tts); if (ret != TTS_ERROR_NONE) { @@ -139,8 +148,8 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { } void HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result) { + const flutter::MethodCall &method_call, + std::unique_ptr> result) { if (!EnsureTtsHandle()) { LOG_ERROR("[TTS] EnsureTtsHandle() failed: %s", "EnsureTtsHandle failed"); result->Error("Invalid Operation", "Invalid Operation"); @@ -148,7 +157,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { } const auto method_name = method_call.method_name(); - const auto& arguments = *method_call.arguments(); + const auto &arguments = *method_call.arguments(); LOG_INFO("method : %s", method_name.c_str()); int ret = TTS_ERROR_NONE; @@ -157,8 +166,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { m_await_speak_completion = std::get(arguments); result->Success(); return; - } - else { + } else { result->Error("Invalid Arguments", "Invalid Arguments"); return; } @@ -171,18 +179,20 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { if (std::holds_alternative(arguments)) { std::string text = std::get(arguments); int utt_id; - ret = tts_add_text(m_tts, text.c_str(), m_language.c_str(), m_voice_type, m_speed, &utt_id); + ret = tts_add_text(m_tts, text.c_str(), m_language.c_str(), + m_voice_type, m_speed, &utt_id); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_add_text failed: %s", ErrorToString(ret).c_str()); + LOG_ERROR("[TTS] tts_add_text failed: %s", + ErrorToString(ret).c_str()); result->Error(std::to_string(ret), "Failed to speak(tts_add_text)."); return; - } + } } else { result->Error("Invalid Arguments", "Invalid Arguments"); return; } ret = tts_play(m_tts); - if (ret != TTS_ERROR_NONE) { + if (ret != TTS_ERROR_NONE) { LOG_ERROR("[TTS] tts_play failed: %s", ErrorToString(ret).c_str()); result->Error(std::to_string(ret), "Failed to speak(tts_play)."); return; @@ -214,22 +224,28 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { return; } else if (method_name.compare("getSpeechRateValidRange") == 0) { int min, normal, max; - ret = tts_get_speed_range (m_tts, &min, &normal, &max); + ret = tts_get_speed_range(m_tts, &min, &normal, &max); if (ret != TTS_ERROR_NONE) { - LOG_ERROR("[TTS] tts_get_speed_range failed: %s", ErrorToString(ret).c_str()); - result->Error(std::to_string(ret), "Failed to getSpeechRateValidRange."); + LOG_ERROR("[TTS] tts_get_speed_range failed: %s", + ErrorToString(ret).c_str()); + result->Error(std::to_string(ret), + "Failed to getSpeechRateValidRange."); return; } flutter::EncodableMap map; - map.insert(std::pair("min", min)); - map.insert(std::pair("normal", normal)); - map.insert(std::pair("max", max)); - map.insert(std::pair("platform", "tizen")); + map.insert(std::pair( + "min", min)); + map.insert(std::pair( + "normal", normal)); + map.insert(std::pair( + "max", max)); + map.insert(std::pair( + "platform", "tizen")); result->Success(flutter::EncodableValue(std::move(map))); return; } else if (method_name.compare("setSpeechRate") == 0) { if (std::holds_alternative(arguments)) { - m_speed = (int) std::get(arguments); + m_speed = (int)std::get(arguments); result->Success(); return; } else { @@ -245,7 +261,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { result->Error("Invalid Arguments", "Invalid Arguments"); return; } - } else if (method_name.compare("getLanguages") == 0) { + } else if (method_name.compare("getLanguages") == 0) { result->Success(flutter::EncodableValue(m_languages)); return; } else { @@ -254,10 +270,12 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { } } - static void OnStateChanged(tts_h tts, tts_state_e previous, tts_state_e current, void *user_data) { + static void OnStateChanged(tts_h tts, tts_state_e previous, + tts_state_e current, void *user_data) { FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data; LOG_INFO("[TTS] State is changed (%d) to (%d)", previous, current); - std::unique_ptr args = std::make_unique(true); + std::unique_ptr args = + std::make_unique(true); if (current == TTS_STATE_PLAYING) { if (previous == TTS_STATE_READY) { plugin->m_channel->InvokeMethod("speak.onStart", std::move(args)); @@ -274,7 +292,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { plugin->m_current_state = current; } - static void OnUtteranceCompleted(tts_h tts, int utt_id, void* user_data) { + static void OnUtteranceCompleted(tts_h tts, int utt_id, void *user_data) { FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data; tts_stop(plugin->m_tts); LOG_INFO("[TTS] Utterance (%d) is completed", true); @@ -282,16 +300,19 @@ class FlutterTtsTizenPlugin : public flutter::Plugin { plugin->m_speaking = false; plugin->m_result->Success(); } - std::unique_ptr args = std::make_unique(true); + std::unique_ptr args = + std::make_unique(true); plugin->m_channel->InvokeMethod("speak.onComplete", std::move(args)); } - static bool OnSupportedVoices(tts_h tts, const char* language, int voice_type, void* user_data) { + static bool OnSupportedVoices(tts_h tts, const char *language, int voice_type, + void *user_data) { if (nullptr != language) { FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data; plugin->m_languages.push_back(flutter::EncodableValue(language)); - LOG_INFO("[TTS] Supported Voices - Language(%s), Type(%d)", language, voice_type); + LOG_INFO("[TTS] Supported Voices - Language(%s), Type(%d)", language, + voice_type); return true; } return false; diff --git a/packages/permission_handler/tizen/src/app_settings_manager.cc b/packages/permission_handler/tizen/src/app_settings_manager.cc index 4b9bb9c0d..c742e1e0a 100644 --- a/packages/permission_handler/tizen/src/app_settings_manager.cc +++ b/packages/permission_handler/tizen/src/app_settings_manager.cc @@ -22,8 +22,7 @@ AppSettingsManager::AppSettingsManager() {} AppSettingsManager::~AppSettingsManager() {} void AppSettingsManager::OpenAppSettings(OnAppSettingsOpened success_callback, - OnAppSettingsError error_callback) -{ + OnAppSettingsError error_callback) { app_control_h service = nullptr; int result = app_control_create(&service); if (result != APP_CONTROL_ERROR_NONE) { diff --git a/packages/video_player/tizen/src/video_player_error.h b/packages/video_player/tizen/src/video_player_error.h index e9332d723..a6fb914be 100644 --- a/packages/video_player/tizen/src/video_player_error.h +++ b/packages/video_player/tizen/src/video_player_error.h @@ -27,4 +27,4 @@ class VideoPlayerError { std::string code_; }; -#endif // VIDEO_PLAYER_ERROR_H_ \ No newline at end of file +#endif // VIDEO_PLAYER_ERROR_H_ diff --git a/packages/video_player/tizen/src/video_player_options.h b/packages/video_player/tizen/src/video_player_options.h index 415341120..88de24d48 100644 --- a/packages/video_player/tizen/src/video_player_options.h +++ b/packages/video_player/tizen/src/video_player_options.h @@ -16,4 +16,4 @@ class VideoPlayerOptions { bool mixWithOthers_; }; -#endif // VIDEO_PLAYER_OPTIONS_H_ \ No newline at end of file +#endif // VIDEO_PLAYER_OPTIONS_H_ diff --git a/packages/webview_flutter/tizen/inc/lwe/LWEWebView.h b/packages/webview_flutter/tizen/inc/lwe/LWEWebView.h index 4457870d5..6e56fa61e 100644 --- a/packages/webview_flutter/tizen/inc/lwe/LWEWebView.h +++ b/packages/webview_flutter/tizen/inc/lwe/LWEWebView.h @@ -28,23 +28,23 @@ #endif #endif -#include "PlatformIntegrationData.h" - +#include #include -#include #include -#include +#include + +#include "PlatformIntegrationData.h" namespace LWE { class LWE_EXPORT LWE { -public: - // You must call Initialize function before using WebContainer or WebView - static void Initialize(const char* localStorageDataFilePath, - const char* cookieStoreDataFilePath, - const char* httpCacheDataDirectorypath); - static bool IsInitialized(); - static void Finalize(); + public: + // You must call Initialize function before using WebContainer or WebView + static void Initialize(const char* localStorageDataFilePath, + const char* cookieStoreDataFilePath, + const char* httpCacheDataDirectorypath); + static bool IsInitialized(); + static void Finalize(); }; #define LWE_DEFAULT_FONT_SIZE 16 @@ -54,360 +54,351 @@ class LWE_EXPORT LWE { enum class WebSecurityMode; class LWE_EXPORT CookieManager { -public: - std::string GetCookie(std::string url); - bool HasCookies(); - void ClearCookies(); + public: + std::string GetCookie(std::string url); + bool HasCookies(); + void ClearCookies(); - static CookieManager* GetInstance(); - static void Destroy(); + static CookieManager* GetInstance(); + static void Destroy(); -private: - CookieManager(); - ~CookieManager(); + private: + CookieManager(); + ~CookieManager(); }; class LWE_EXPORT Settings { -public: - Settings(const std::string& defaultUA, const std::string& ua); - std::string GetDefaultUserAgent() const; - std::string GetUserAgentString() const; - std::string GetProxyURL() const; - int GetCacheMode() const; - TTSMode GetTTSMode() const; - WebSecurityMode GetWebSecurityMode() const; - IdleModeJob GetIdleModeJob() const; - uint32_t GetIdleModeCheckIntervalInMS() const; - void GetBaseBackgroundColor(unsigned char& r, unsigned char& g, - unsigned char& b, unsigned char& a) const; - void GetBaseForegroundColor(unsigned char& r, unsigned char& g, - unsigned char& b, unsigned char& a) const; - bool NeedsDownloadWebFontsEarly() const; - uint32_t NeedsDownScaleImageResourceLargerThan() const; - void SetUserAgentString(const std::string& ua); - void SetCacheMode(int mode); - void SetProxyURL(const std::string& proxyURL); - void setDefaultFontSize(int size); - void SetTTSMode(TTSMode value); - void SetBaseBackgroundColor(unsigned char r, unsigned char g, - unsigned char b, unsigned char a); - void SetBaseForegroundColor(unsigned char r, unsigned char g, - unsigned char b, unsigned char a); - void SetWebSecurityMode(WebSecurityMode value); - void SetIdleModeJob(IdleModeJob j); - void SetIdleModeCheckIntervalInMS(uint32_t intervalInMS); - void SetNeedsDownloadWebFontsEarly(bool b); - void SetNeedsDownScaleImageResourceLargerThan( - uint32_t demention); // Experimental - -private: - std::string m_defaultUserAgent; - std::string m_userAgent; - std::string m_proxyURL; - int m_cacheMode; - uint32_t m_defaultFontSize; - TTSMode m_ttsMode; - unsigned char m_bgR, m_bgG, m_bgB, m_bgA; - unsigned char m_fgR, m_fgG, m_fgB, m_fgA; - WebSecurityMode m_webSecurityMode; - IdleModeJob m_idleModeJob; // default value is IdleModeJob::IdleModeFull - uint32_t m_idleModeCheckIntervalInMS; // default value is 3000(ms) - bool m_needsDownloadWebFontsEarly; - uint32_t m_needsDownScaleImageResourceLargerThan; + public: + Settings(const std::string& defaultUA, const std::string& ua); + std::string GetDefaultUserAgent() const; + std::string GetUserAgentString() const; + std::string GetProxyURL() const; + int GetCacheMode() const; + TTSMode GetTTSMode() const; + WebSecurityMode GetWebSecurityMode() const; + IdleModeJob GetIdleModeJob() const; + uint32_t GetIdleModeCheckIntervalInMS() const; + void GetBaseBackgroundColor(unsigned char& r, unsigned char& g, + unsigned char& b, unsigned char& a) const; + void GetBaseForegroundColor(unsigned char& r, unsigned char& g, + unsigned char& b, unsigned char& a) const; + bool NeedsDownloadWebFontsEarly() const; + uint32_t NeedsDownScaleImageResourceLargerThan() const; + void SetUserAgentString(const std::string& ua); + void SetCacheMode(int mode); + void SetProxyURL(const std::string& proxyURL); + void setDefaultFontSize(int size); + void SetTTSMode(TTSMode value); + void SetBaseBackgroundColor(unsigned char r, unsigned char g, unsigned char b, + unsigned char a); + void SetBaseForegroundColor(unsigned char r, unsigned char g, unsigned char b, + unsigned char a); + void SetWebSecurityMode(WebSecurityMode value); + void SetIdleModeJob(IdleModeJob j); + void SetIdleModeCheckIntervalInMS(uint32_t intervalInMS); + void SetNeedsDownloadWebFontsEarly(bool b); + void SetNeedsDownScaleImageResourceLargerThan( + uint32_t demention); // Experimental + + private: + std::string m_defaultUserAgent; + std::string m_userAgent; + std::string m_proxyURL; + int m_cacheMode; + uint32_t m_defaultFontSize; + TTSMode m_ttsMode; + unsigned char m_bgR, m_bgG, m_bgB, m_bgA; + unsigned char m_fgR, m_fgG, m_fgB, m_fgA; + WebSecurityMode m_webSecurityMode; + IdleModeJob m_idleModeJob; // default value is IdleModeJob::IdleModeFull + uint32_t m_idleModeCheckIntervalInMS; // default value is 3000(ms) + bool m_needsDownloadWebFontsEarly; + uint32_t m_needsDownScaleImageResourceLargerThan; }; class LWE_EXPORT ResourceError { -public: - ResourceError(int code, const std::string& description, - const std::string& url); - int GetErrorCode(); - std::string GetDescription(); - std::string GetUrl(); - -private: - int m_errorCode; - std::string m_description; - std::string m_url; + public: + ResourceError(int code, const std::string& description, + const std::string& url); + int GetErrorCode(); + std::string GetDescription(); + std::string GetUrl(); + + private: + int m_errorCode; + std::string m_description; + std::string m_url; }; class LWE_EXPORT WebContainer { -private: - // use Destroy function instead of using delete operator - ~WebContainer() - { - } - -public: - // Function set for render to buffer - static WebContainer* Create(unsigned width, unsigned height, - float devicePixelRatio, - const char* defaultFontName, const char* locale, - const char* timezoneID); - struct RenderInfo { - void* updatedBufferAddress; - size_t bufferStride; - }; - - struct RenderResult { - size_t updatedX; - size_t updatedY; - size_t updatedWidth; - size_t updatedHeight; - - void* updatedBufferAddress; - size_t bufferImageWidth; - size_t bufferImageHeight; - }; - void RegisterPreRenderingHandler(const std::function& cb); - void RegisterOnRenderedHandler( - const std::function& cb); - // <--- end of function set for render to buffer - - // Function set for render with OpenGL - static WebContainer* CreateGL( - unsigned width, unsigned height, - const std::function& onGLMakeCurrent, - const std::function& - onGLSwapBuffers, - float devicePixelRatio, const char* defaultFontName, const char* locale, - const char* timezoneID); - - struct ExternalImageInfo { - void* imageAddress; - }; - - static WebContainer* CreateGLWithPlatformImage( - unsigned width, unsigned height, - const std::function& onGLMakeCurrent, - const std::function& - onGLSwapBuffers, - const std::function& prepareImageCb, - const std::function& flushCb, - float devicePixelRatio, const char* defaultFontName, const char* locale, - const char* timezoneID); - // <--- end of function set for render with OpenGL - - // Function set for headless - static WebContainer* CreateHeadless(unsigned width, unsigned height, - float devicePixelRatio, - const char* defaultFontName, - const char* locale, - const char* timezoneID); - // <--- end of function set for headless - - void AddIdleCallback(void (*callback)(void*), void* data); - size_t AddTimeout(void (*callback)(void*), void* data, size_t timeoutInMS); - void ClearTimeout(size_t handle); - - void RegisterCanRenderingHandler( - const std::function& cb); - - Settings GetSettings(); - void LoadURL(const std::string& url); - std::string GetURL(); - void LoadData(const std::string& data); - void Reload(); - void StopLoading(); - void GoBack(); - void GoForward(); - bool CanGoBack(); - bool CanGoForward(); - void AddJavaScriptInterface( - const std::string& exposedObjectName, const std::string& jsFunctionName, - std::function cb); - std::string EvaluateJavaScript(const std::string& script); - void EvaluateJavaScript(const std::string& script, - std::function cb); - void ClearHistory(); - void Destroy(); - void Pause(); - void Resume(); - - void ResizeTo(size_t width, size_t height); - - void Focus(); - void Blur(); - - void SetSettings(const Settings& setttings); - void RemoveJavascriptInterface(const std::string& exposedObjectName, - const std::string& jsFunctionName); - void ClearCache(); - - void RegisterOnReceivedErrorHandler( - const std::function& cb); - void RegisterOnPageParsedHandler( - std::function cb); - void RegisterOnPageLoadedHandler( - std::function cb); - void RegisterOnPageStartedHandler( - const std::function& cb); - void RegisterOnLoadResourceHandler( - const std::function& cb); - void RegisterShouldOverrideUrlLoadingHandler( - const std::function& cb); - void RegisterOnProgressChangedHandler( - const std::function& cb); - void RegisterOnDownloadStartHandler( - const std::function& cb); - - void RegisterShowDropdownMenuHandler( - const std::function*, - int)>& cb); - void RegisterShowAlertHandler( - const std::function& cb); - - void RegisterCustomFileResourceRequestHandlers( - std::function resolveFilePathCallback, - std::function fileOpenCallback, - std::function - fileReadCallback, - std::function fileLengthCallback, - std::function fileCloseCallback); - - void CallHandler(const std::string& handler, void* param); - - void SetUserAgentString(const std::string& userAgent); - std::string GetUserAgentString(); - void SetCacheMode(int mode); - int GetCacheMode(); - void SetDefaultFontSize(uint32_t size); - uint32_t GetDefaultFontSize(); - - void DispatchMouseMoveEvent(MouseButtonValue button, - MouseButtonsValue buttons, double x, double y); - void DispatchMouseDownEvent(MouseButtonValue button, - MouseButtonsValue buttons, double x, double y); - void DispatchMouseUpEvent(MouseButtonValue button, + private: + // use Destroy function instead of using delete operator + ~WebContainer() {} + + public: + // Function set for render to buffer + static WebContainer* Create(unsigned width, unsigned height, + float devicePixelRatio, + const char* defaultFontName, const char* locale, + const char* timezoneID); + struct RenderInfo { + void* updatedBufferAddress; + size_t bufferStride; + }; + + struct RenderResult { + size_t updatedX; + size_t updatedY; + size_t updatedWidth; + size_t updatedHeight; + + void* updatedBufferAddress; + size_t bufferImageWidth; + size_t bufferImageHeight; + }; + void RegisterPreRenderingHandler(const std::function& cb); + void RegisterOnRenderedHandler( + const std::function& cb); + // <--- end of function set for render to buffer + + // Function set for render with OpenGL + static WebContainer* CreateGL( + unsigned width, unsigned height, + const std::function& onGLMakeCurrent, + const std::function& + onGLSwapBuffers, + float devicePixelRatio, const char* defaultFontName, const char* locale, + const char* timezoneID); + + struct ExternalImageInfo { + void* imageAddress; + }; + + static WebContainer* CreateGLWithPlatformImage( + unsigned width, unsigned height, + const std::function& onGLMakeCurrent, + const std::function& + onGLSwapBuffers, + const std::function& prepareImageCb, + const std::function& flushCb, + float devicePixelRatio, const char* defaultFontName, const char* locale, + const char* timezoneID); + // <--- end of function set for render with OpenGL + + // Function set for headless + static WebContainer* CreateHeadless(unsigned width, unsigned height, + float devicePixelRatio, + const char* defaultFontName, + const char* locale, + const char* timezoneID); + // <--- end of function set for headless + + void AddIdleCallback(void (*callback)(void*), void* data); + size_t AddTimeout(void (*callback)(void*), void* data, size_t timeoutInMS); + void ClearTimeout(size_t handle); + + void RegisterCanRenderingHandler( + const std::function& cb); + + Settings GetSettings(); + void LoadURL(const std::string& url); + std::string GetURL(); + void LoadData(const std::string& data); + void Reload(); + void StopLoading(); + void GoBack(); + void GoForward(); + bool CanGoBack(); + bool CanGoForward(); + void AddJavaScriptInterface( + const std::string& exposedObjectName, const std::string& jsFunctionName, + std::function cb); + std::string EvaluateJavaScript(const std::string& script); + void EvaluateJavaScript(const std::string& script, + std::function cb); + void ClearHistory(); + void Destroy(); + void Pause(); + void Resume(); + + void ResizeTo(size_t width, size_t height); + + void Focus(); + void Blur(); + + void SetSettings(const Settings& setttings); + void RemoveJavascriptInterface(const std::string& exposedObjectName, + const std::string& jsFunctionName); + void ClearCache(); + + void RegisterOnReceivedErrorHandler( + const std::function& cb); + void RegisterOnPageParsedHandler( + std::function cb); + void RegisterOnPageLoadedHandler( + std::function cb); + void RegisterOnPageStartedHandler( + const std::function& cb); + void RegisterOnLoadResourceHandler( + const std::function& cb); + void RegisterShouldOverrideUrlLoadingHandler( + const std::function& cb); + void RegisterOnProgressChangedHandler( + const std::function& cb); + void RegisterOnDownloadStartHandler( + const std::function& cb); + + void RegisterShowDropdownMenuHandler( + const std::function*, + int)>& cb); + void RegisterShowAlertHandler( + const std::function& cb); + + void RegisterCustomFileResourceRequestHandlers( + std::function resolveFilePathCallback, + std::function fileOpenCallback, + std::function + fileReadCallback, + std::function fileLengthCallback, + std::function fileCloseCallback); + + void CallHandler(const std::string& handler, void* param); + + void SetUserAgentString(const std::string& userAgent); + std::string GetUserAgentString(); + void SetCacheMode(int mode); + int GetCacheMode(); + void SetDefaultFontSize(uint32_t size); + uint32_t GetDefaultFontSize(); + + void DispatchMouseMoveEvent(MouseButtonValue button, + MouseButtonsValue buttons, double x, double y); + void DispatchMouseDownEvent(MouseButtonValue button, MouseButtonsValue buttons, double x, double y); - void DispatchMouseWheelEvent(double x, double y, int delta); - void DispatchKeyDownEvent(KeyValue keyCode); - void DispatchKeyPressEvent(KeyValue keyCode); - void DispatchKeyUpEvent(KeyValue keyCode); - - void DispatchCompositionStartEvent( - const std::string& soFarCompositiedString); - void DispatchCompositionUpdateEvent( - const std::string& soFarCompositiedString); - void DispatchCompositionEndEvent(const std::string& soFarCompositiedString); - void RegisterOnShowSoftwareKeyboardIfPossibleHandler( - const std::function& cb); - void RegisterOnHideSoftwareKeyboardIfPossibleHandler( - const std::function& cb); - - void SetUserData(const std::string& key, void* data); - void* GetUserData(const std::string& key); - - std::string GetTitle(); - void ScrollTo(int x, int y); - void ScrollBy(int x, int y); - int GetScrollX(); - int GetScrollY(); - - size_t Width(); - size_t Height(); - - // You can control rendering flow through this function - // If you got callback, you must call `doRenderingFunction` after - void RegisterSetNeedsRenderingCallback( - const std::function& - doRenderingFunction)>& cb); - -protected: - WebContainer(void* webView); - -private: - void* m_impl; + void DispatchMouseUpEvent(MouseButtonValue button, MouseButtonsValue buttons, + double x, double y); + void DispatchMouseWheelEvent(double x, double y, int delta); + void DispatchKeyDownEvent(KeyValue keyCode); + void DispatchKeyPressEvent(KeyValue keyCode); + void DispatchKeyUpEvent(KeyValue keyCode); + + void DispatchCompositionStartEvent(const std::string& soFarCompositiedString); + void DispatchCompositionUpdateEvent( + const std::string& soFarCompositiedString); + void DispatchCompositionEndEvent(const std::string& soFarCompositiedString); + void RegisterOnShowSoftwareKeyboardIfPossibleHandler( + const std::function& cb); + void RegisterOnHideSoftwareKeyboardIfPossibleHandler( + const std::function& cb); + + void SetUserData(const std::string& key, void* data); + void* GetUserData(const std::string& key); + + std::string GetTitle(); + void ScrollTo(int x, int y); + void ScrollBy(int x, int y); + int GetScrollX(); + int GetScrollY(); + + size_t Width(); + size_t Height(); + + // You can control rendering flow through this function + // If you got callback, you must call `doRenderingFunction` after + void RegisterSetNeedsRenderingCallback( + const std::function& + doRenderingFunction)>& cb); + + protected: + WebContainer(void* webView); + + private: + void* m_impl; }; class LWE_EXPORT WebView { -protected: - // use Destroy function instead of using delete operator - virtual ~WebView() - { - } - -public: - static WebView* Create(void* win, unsigned x, unsigned y, unsigned width, - unsigned height, float devicePixelRatio, - const char* defaultFontName, const char* locale, - const char* timezoneID); - - virtual void Destroy(); - - Settings GetSettings(); - virtual void LoadURL(const std::string& url); - std::string GetURL(); - void LoadData(const std::string& data); - void Reload(); - void StopLoading(); - void GoBack(); - void GoForward(); - bool CanGoBack(); - bool CanGoForward(); - void Pause(); - void Resume(); - void AddJavaScriptInterface( - const std::string& exposedObjectName, const std::string& jsFunctionName, - std::function cb); - std::string EvaluateJavaScript(const std::string& script); - void EvaluateJavaScript(const std::string& script, - std::function cb); - void ClearHistory(); - void SetSettings(const Settings& setttings); - void RemoveJavascriptInterface(const std::string& exposedObjectName, - const std::string& jsFunctionName); - void ClearCache(); - void RegisterOnReceivedErrorHandler( - std::function cb); - void RegisterOnPageParsedHandler( - std::function cb); - void RegisterOnPageLoadedHandler( - std::function cb); - void RegisterOnPageStartedHandler( - std::function cb); - void RegisterOnLoadResourceHandler( - std::function cb); - - void RegisterCustomFileResourceRequestHandlers( - std::function resolveFilePathCallback, - std::function fileOpenCallback, - std::function - fileReadCallback, - std::function fileLengthCallback, - std::function fileCloseCallback); - - void SetUserData(const std::string& key, void* data); - void* GetUserData(const std::string& key); - - std::string GetTitle(); - void ScrollTo(int x, int y); - void ScrollBy(int x, int y); - int GetScrollX(); - int GetScrollY(); - - virtual void* Unwrap() - { - // Some platform returns associated native handle ex) Evas_Object* - return nullptr; - } - virtual void Focus(); - virtual void Blur(); - -protected: - WebView(void* impl) - : m_impl(impl) - { - } - - virtual WebContainer* FetchWebContainer() = 0; - - void* m_impl; + protected: + // use Destroy function instead of using delete operator + virtual ~WebView() {} + + public: + static WebView* Create(void* win, unsigned x, unsigned y, unsigned width, + unsigned height, float devicePixelRatio, + const char* defaultFontName, const char* locale, + const char* timezoneID); + + virtual void Destroy(); + + Settings GetSettings(); + virtual void LoadURL(const std::string& url); + std::string GetURL(); + void LoadData(const std::string& data); + void Reload(); + void StopLoading(); + void GoBack(); + void GoForward(); + bool CanGoBack(); + bool CanGoForward(); + void Pause(); + void Resume(); + void AddJavaScriptInterface( + const std::string& exposedObjectName, const std::string& jsFunctionName, + std::function cb); + std::string EvaluateJavaScript(const std::string& script); + void EvaluateJavaScript(const std::string& script, + std::function cb); + void ClearHistory(); + void SetSettings(const Settings& setttings); + void RemoveJavascriptInterface(const std::string& exposedObjectName, + const std::string& jsFunctionName); + void ClearCache(); + void RegisterOnReceivedErrorHandler( + std::function cb); + void RegisterOnPageParsedHandler( + std::function cb); + void RegisterOnPageLoadedHandler( + std::function cb); + void RegisterOnPageStartedHandler( + std::function cb); + void RegisterOnLoadResourceHandler( + std::function cb); + + void RegisterCustomFileResourceRequestHandlers( + std::function resolveFilePathCallback, + std::function fileOpenCallback, + std::function + fileReadCallback, + std::function fileLengthCallback, + std::function fileCloseCallback); + + void SetUserData(const std::string& key, void* data); + void* GetUserData(const std::string& key); + + std::string GetTitle(); + void ScrollTo(int x, int y); + void ScrollBy(int x, int y); + int GetScrollX(); + int GetScrollY(); + + virtual void* Unwrap() { + // Some platform returns associated native handle ex) Evas_Object* + return nullptr; + } + virtual void Focus(); + virtual void Blur(); + + protected: + WebView(void* impl) : m_impl(impl) {} + + virtual WebContainer* FetchWebContainer() = 0; + + void* m_impl; }; -} // namespace LWE +} // namespace LWE #endif diff --git a/packages/webview_flutter/tizen/inc/lwe/PlatformIntegrationData.h b/packages/webview_flutter/tizen/inc/lwe/PlatformIntegrationData.h index 7d9b10f0e..26716c0a2 100644 --- a/packages/webview_flutter/tizen/inc/lwe/PlatformIntegrationData.h +++ b/packages/webview_flutter/tizen/inc/lwe/PlatformIntegrationData.h @@ -5,271 +5,271 @@ namespace LWE { // This table has same chars with // ASCII printable char(32-126) enum KeyValue { - UnidentifiedKey, - AltLeftKey, - AltRightKey, - ControlLeftKey, - ControlRightKey, - CapsLockKey, - FnKey, - FnLockKey, - HyperKey, - MetaKey, - NumLockKey, - ScrollLockKey, - ShiftLeftKey, - ShiftRightKey, - SuperKey, - SymbolKey, - SymbolLockKey, - EnterKey, - TabKey, - ArrowDownKey, - ArrowUpKey, - ArrowLeftKey, - ArrowRightKey, - EndKey, - HomeKey, - PageDownKey, - PageUpKey, - BackspaceKey, - DeleteKey, - InsertKey, - ContextMenuKey, - EscapeKey, - SpaceKey = 32, - ExclamationMarkKey = 33, - DoubleQuoteMarkKey = 34, - SharpMarkKey = 35, - DollarMarkKey = 36, - PercentMarkKey = 37, - AmpersandMarkKey = 38, - SingleQuoteMarkKey = 39, - LeftParenthesisMarkKey = 40, - RightParenthesisMarkKey = 41, - AsteriskMarkKey = 42, - PlusMarkKey = 43, - CommaMarkKey = 44, - MinusMarkKey = 45, - PeriodKey = 46, - SlashKey = 47, - Digit0Key = 48, - Digit1Key, - Digit2Key, - Digit3Key, - Digit4Key, - Digit5Key, - Digit6Key, - Digit7Key, - Digit8Key, - Digit9Key, - ColonMarkKey = 58, - SemiColonMarkKey = 59, - LessThanMarkKey = 60, - EqualitySignKey = 61, - GreaterThanSignKey = 62, - QuestionMarkKey = 63, - AtMarkKey = 64, - AKey = 65, - BKey, - CKey, - DKey, - EKey, - FKey, - GKey, - HKey, - IKey, - JKey, - KKey, - LKey, - MKey, - NKey, - OKey, - PKey, - QKey, - RKey, - SKey, - TKey, - UKey, - VKey, - WKey, - XKey, - YKey, - ZKey, - LeftSquareBracketKey = 91, - BackslashKey = 92, - RightSquareBracketKey = 93, - CaretMarkKey = 94, - UnderScoreMarkKey = 95, - AccentMarkKey = 96, - LowerAKey = 97, - LowerBKey, - LowerCKey, - LowerDKey, - LowerEKey, - LowerFKey, - LowerGKey, - LowerHKey, - LowerIKey, - LowerJKey, - LowerKKey, - LowerLKey, - LowerMKey, - LowerNKey, - LowerOKey, - LowerPKey, - LowerQKey, - LowerRKey, - LowerSKey, - LowerTKey, - LowerUKey, - LowerVKey, - LowerWKey, - LowerXKey, - LowerYKey, - LowerZKey, - LeftCurlyBracketMarkKey = 123, - VerticalBarMarkKey = 124, - RightCurlyBracketMarkKey = 125, - TildeMarkKey = 126, - F1Key, - F2Key, - F3Key, - F4Key, - F5Key, - F6Key, - F7Key, - F8Key, - F9Key, - F10Key, - F11Key, - F12Key, - F13Key, - F14Key, - F15Key, - F16Key, - F17Key, - F18Key, - F19Key, - F20Key, - TVPreviousChannel, - TVChannelDownKey, - TVChannelUpKey, - TVVolumeUpKey, - TVVolumeDownKey, - TVMuteKey, - TVChannelList, - TVChannelGuide, - TVSimpleMenu, - TVReturnKey, - TVExitKey, - TVInfoKey, - TVRedKey, - TVGreenKey, - TVYellowKey, - TVBlueKey, - TVEManual, - TVExtraApp, - TVSearch, - TVPictureSize, - TVSleep, - TVCaption, - TVMore, - TVBTVoice, - TVColor, - TVPlayBack, - TVMenuKey, - MediaFastForwardKey, - MediaPauseKey, - MediaPlayKey, - MediaPlayPauseKey, - MediaRecordKey, - MediaRewindKey, - MediaStopKey, - MediaTrackNextKey, - MediaTrackPreviousKey, - TVKey, - TV3DModeKey, - TVAntennaCableKey, - TVAudioDescriptionKey, - TVAudioDescriptionMixDownKey, - TVAudioDescriptionMixUpKey, - TVContentsMenuKey, - TVDataServiceKey, - TVInputKey, - TVInputComponent1Key, - TVInputComponent2Key, - TVInputComposite1Key, - TVInputComposite2Key, - TVInputHDMI1Key, - TVInputHDMI2Key, - TVInputHDMI3Key, - TVInputHDMI4Key, - TVInputVGA1Key, - TVMediaContextKey, - TVNetworkKey, - TVNumberEntryKey, - TVPowerKey, - TVRadioServiceKey, - TVSatelliteKey, - TVSatelliteBSKey, - TVSatelliteCSKey, - TVSatelliteToggleKey, - TVTerrestrialAnalogKey, - TVTerrestrialDigitalKey, - TVTimerKey, - TVHomeKey, - MediaAppsKey, - MediaAudioTrackKey, - MediaLastKey, - MediaSkipBackwardKey, - MediaSkipForwardKey, - MediaStepBackwardKey, - MediaStepForwardKey, - MediaTopMenuKey, - BrowserBackKey, - BrowserFavoritesKey, - BrowserForwardKey, - BrowserHomeKey, - BrowserRefreshKey, - BrowserSearchKey, - BrowserStopKey, + UnidentifiedKey, + AltLeftKey, + AltRightKey, + ControlLeftKey, + ControlRightKey, + CapsLockKey, + FnKey, + FnLockKey, + HyperKey, + MetaKey, + NumLockKey, + ScrollLockKey, + ShiftLeftKey, + ShiftRightKey, + SuperKey, + SymbolKey, + SymbolLockKey, + EnterKey, + TabKey, + ArrowDownKey, + ArrowUpKey, + ArrowLeftKey, + ArrowRightKey, + EndKey, + HomeKey, + PageDownKey, + PageUpKey, + BackspaceKey, + DeleteKey, + InsertKey, + ContextMenuKey, + EscapeKey, + SpaceKey = 32, + ExclamationMarkKey = 33, + DoubleQuoteMarkKey = 34, + SharpMarkKey = 35, + DollarMarkKey = 36, + PercentMarkKey = 37, + AmpersandMarkKey = 38, + SingleQuoteMarkKey = 39, + LeftParenthesisMarkKey = 40, + RightParenthesisMarkKey = 41, + AsteriskMarkKey = 42, + PlusMarkKey = 43, + CommaMarkKey = 44, + MinusMarkKey = 45, + PeriodKey = 46, + SlashKey = 47, + Digit0Key = 48, + Digit1Key, + Digit2Key, + Digit3Key, + Digit4Key, + Digit5Key, + Digit6Key, + Digit7Key, + Digit8Key, + Digit9Key, + ColonMarkKey = 58, + SemiColonMarkKey = 59, + LessThanMarkKey = 60, + EqualitySignKey = 61, + GreaterThanSignKey = 62, + QuestionMarkKey = 63, + AtMarkKey = 64, + AKey = 65, + BKey, + CKey, + DKey, + EKey, + FKey, + GKey, + HKey, + IKey, + JKey, + KKey, + LKey, + MKey, + NKey, + OKey, + PKey, + QKey, + RKey, + SKey, + TKey, + UKey, + VKey, + WKey, + XKey, + YKey, + ZKey, + LeftSquareBracketKey = 91, + BackslashKey = 92, + RightSquareBracketKey = 93, + CaretMarkKey = 94, + UnderScoreMarkKey = 95, + AccentMarkKey = 96, + LowerAKey = 97, + LowerBKey, + LowerCKey, + LowerDKey, + LowerEKey, + LowerFKey, + LowerGKey, + LowerHKey, + LowerIKey, + LowerJKey, + LowerKKey, + LowerLKey, + LowerMKey, + LowerNKey, + LowerOKey, + LowerPKey, + LowerQKey, + LowerRKey, + LowerSKey, + LowerTKey, + LowerUKey, + LowerVKey, + LowerWKey, + LowerXKey, + LowerYKey, + LowerZKey, + LeftCurlyBracketMarkKey = 123, + VerticalBarMarkKey = 124, + RightCurlyBracketMarkKey = 125, + TildeMarkKey = 126, + F1Key, + F2Key, + F3Key, + F4Key, + F5Key, + F6Key, + F7Key, + F8Key, + F9Key, + F10Key, + F11Key, + F12Key, + F13Key, + F14Key, + F15Key, + F16Key, + F17Key, + F18Key, + F19Key, + F20Key, + TVPreviousChannel, + TVChannelDownKey, + TVChannelUpKey, + TVVolumeUpKey, + TVVolumeDownKey, + TVMuteKey, + TVChannelList, + TVChannelGuide, + TVSimpleMenu, + TVReturnKey, + TVExitKey, + TVInfoKey, + TVRedKey, + TVGreenKey, + TVYellowKey, + TVBlueKey, + TVEManual, + TVExtraApp, + TVSearch, + TVPictureSize, + TVSleep, + TVCaption, + TVMore, + TVBTVoice, + TVColor, + TVPlayBack, + TVMenuKey, + MediaFastForwardKey, + MediaPauseKey, + MediaPlayKey, + MediaPlayPauseKey, + MediaRecordKey, + MediaRewindKey, + MediaStopKey, + MediaTrackNextKey, + MediaTrackPreviousKey, + TVKey, + TV3DModeKey, + TVAntennaCableKey, + TVAudioDescriptionKey, + TVAudioDescriptionMixDownKey, + TVAudioDescriptionMixUpKey, + TVContentsMenuKey, + TVDataServiceKey, + TVInputKey, + TVInputComponent1Key, + TVInputComponent2Key, + TVInputComposite1Key, + TVInputComposite2Key, + TVInputHDMI1Key, + TVInputHDMI2Key, + TVInputHDMI3Key, + TVInputHDMI4Key, + TVInputVGA1Key, + TVMediaContextKey, + TVNetworkKey, + TVNumberEntryKey, + TVPowerKey, + TVRadioServiceKey, + TVSatelliteKey, + TVSatelliteBSKey, + TVSatelliteCSKey, + TVSatelliteToggleKey, + TVTerrestrialAnalogKey, + TVTerrestrialDigitalKey, + TVTimerKey, + TVHomeKey, + MediaAppsKey, + MediaAudioTrackKey, + MediaLastKey, + MediaSkipBackwardKey, + MediaSkipForwardKey, + MediaStepBackwardKey, + MediaStepForwardKey, + MediaTopMenuKey, + BrowserBackKey, + BrowserFavoritesKey, + BrowserForwardKey, + BrowserHomeKey, + BrowserRefreshKey, + BrowserSearchKey, + BrowserStopKey, }; enum MouseButtonValue { - NoButton = 0, - LeftButton = 0, - MiddleButton = 1, - RightButton = 2 + NoButton = 0, + LeftButton = 0, + MiddleButton = 1, + RightButton = 2 }; enum MouseButtonsValue { - NoButtonDown = 0, - LeftButtonDown = 1, - RightButtonDown = 1 << 1, - MiddleButtonDown = 1 << 2, + NoButtonDown = 0, + LeftButtonDown = 1, + RightButtonDown = 1 << 1, + MiddleButtonDown = 1 << 2, }; enum TTSMode { - Default = 0, - Forced = 1, + Default = 0, + Forced = 1, }; enum class WebSecurityMode { Enable = 0, Disable = 1 }; enum class IdleModeJob { - ClearDrawnBuffers = 1, - ForceGC = 1 << 1, // it also includes calling malloc_trim(0) - DropDecodedImageBuffer = 1 << 2, + ClearDrawnBuffers = 1, + ForceGC = 1 << 1, // it also includes calling malloc_trim(0) + DropDecodedImageBuffer = 1 << 2, - IdleModeFull = ClearDrawnBuffers | ForceGC | DropDecodedImageBuffer, - IdleModeMiddle = ForceGC, - IdleModeNone = 0, + IdleModeFull = ClearDrawnBuffers | ForceGC | DropDecodedImageBuffer, + IdleModeMiddle = ForceGC, + IdleModeNone = 0, - IdleModeDefault = IdleModeFull + IdleModeDefault = IdleModeFull }; -constexpr int IdleModeCheckDefaultIntervalInMS{ 3000 }; -} // namespace LWE +constexpr int IdleModeCheckDefaultIntervalInMS{3000}; +} // namespace LWE #endif diff --git a/tools/check_tidy.py b/tools/check_tidy.py new file mode 100755 index 000000000..e87fc00bc --- /dev/null +++ b/tools/check_tidy.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python + +# Copyright 2015-present Samsung Electronics Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import print_function + +import os +import subprocess +import sys + +from argparse import ArgumentParser +from difflib import unified_diff +from os.path import abspath, dirname, join, relpath, splitext + +DEFAULT_DIR = dirname(dirname(abspath(__file__))) + +TERM_RED = '\033[1;31m' +TERM_GREEN = '\033[1;32m' +TERM_YELLOW = '\033[1;33m' +TERM_PURPLE = '\033[35m' +TERM_EMPTY = '\033[0m' + +clang_format_exts = ['.cc', '.h'] +skip_dirs = ['example', 'lib', '.git'] +skip_files = [] + + +class Stats(object): + def __init__(self): + self.files = 0 + self.lines = 0 + self.empty_lines = 0 + self.errors = 0 + + +def is_checked_by_clang(file): + _, ext = splitext(file) + return ext in clang_format_exts and file not in skip_files + + +def check_tidy(src_dir, update, clang_format, stats): + print('processing directory: %s' % src_dir) + + for dirpath, _, filenames in os.walk(src_dir): + if any(d in relpath(dirpath, src_dir) for d in skip_dirs): + continue + + for file in [join(dirpath, name) for name in filenames if is_checked_by_clang(name)]: + def report_error(msg, line=None): + print('%s%s:%s %s%s' % (TERM_YELLOW, file, '%d:' % line if line else '', msg, TERM_EMPTY)) + stats.errors += 1 + + with open(file, 'r') as f: + original = f.readlines() + formatted = subprocess.check_output([clang_format, '-style=file', file]) + + if update: + with open(file, 'w') as f: + f.write(formatted) + + stats.files += 1 + stats.lines += len(original) + + for lineno, line in enumerate(original): + lineno += 1 + + if '\t' in line: + report_error('TAB character', lineno) + if '\r' in line: + report_error('CR character', lineno) + if line.endswith(' \n') or line.endswith('\t\n'): + report_error('trailing whitespace', lineno) + if not line.endswith('\n'): + report_error('line ends without NEW LINE character', lineno) + + if not line.strip(): + stats.empty_lines += 1 + + diff = list(unified_diff(original, formatted.splitlines(True))) + if diff: + report_error('format error') + for diffline in diff: + print(diffline, end='') + + +def main(): + parser = ArgumentParser(description='Plugins Source Format Checker and Updater') + parser.add_argument('--clang-format', metavar='PATH', default='clang-format-11', + help='path to clang-format (default: %(default)s)') + parser.add_argument('--update', action='store_true', + help='reformat files') + parser.add_argument('--dir', metavar='PATH', default=DEFAULT_DIR, + help='directory to process (default: %(default)s)') + args = parser.parse_args() + + stats = Stats() + + check_tidy(args.dir, args.update, args.clang_format, stats) + + print() + print('* Total number of files: %d' % stats.files) + print('* Total lines of code: %d' % stats.lines) + print('* Total non-empty lines of code: %d' % (stats.lines - stats.empty_lines)) + print('%s* Total number of errors: %d%s' % (TERM_RED if stats.errors else TERM_GREEN, + stats.errors, + TERM_EMPTY)) + + if args.update: + print() + print('All files reformatted, check for changes with `git diff`.'); + + sys.exit(1 if stats.errors else 0) + + +if __name__ == '__main__': + main()