Skip to content

Commit

Permalink
Minimize use of autos (#275)
Browse files Browse the repository at this point in the history
* Remove unnecessary namespace identifiers

* Minimize use of autos
  • Loading branch information
swift-kim authored Apr 21, 2022
1 parent dea5aae commit fc30c34
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 94 deletions.
5 changes: 3 additions & 2 deletions shell/platform/tizen/accessibility_bridge_delegate_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ AccessibilityBridgeDelegateTizen::AccessibilityBridgeDelegateTizen(

void AccessibilityBridgeDelegateTizen::OnAccessibilityEvent(
ui::AXEventGenerator::TargetedEvent targeted_event) {
auto bridge = engine_->accessibility_bridge().lock();
std::shared_ptr<AccessibilityBridge> bridge =
engine_->accessibility_bridge().lock();
if (!bridge) {
FT_LOG(Error) << "Accessibility bridge is deallocated";
return;
}

auto platform_node_delegate =
std::shared_ptr<FlutterPlatformNodeDelegate> platform_node_delegate =
bridge->GetFlutterPlatformNodeDelegateFromID(targeted_event.node->id())
.lock();
if (!platform_node_delegate) {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/accessibility_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger)
}
}
}
reply(flutter::EncodableValue());
reply(EncodableValue());
});
}

Expand Down
8 changes: 4 additions & 4 deletions shell/platform/tizen/channels/app_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ AppControlResult AppControl::AddExtraData(std::string key,
}

AppControlResult AppControl::SetExtraData(const EncodableMap& map) {
for (const auto& v : map) {
if (!std::holds_alternative<std::string>(v.first)) {
for (const auto& element : map) {
if (!std::holds_alternative<std::string>(element.first)) {
FT_LOG(Error) << "Invalid key. Omitting.";
continue;
}
const auto& key = std::get<std::string>(v.first);
AppControlResult ret = AddExtraData(key, v.second);
const auto& key = std::get<std::string>(element.first);
AppControlResult ret = AddExtraData(key, element.second);
if (!ret) {
FT_LOG(Error)
<< "The value for the key " << key
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/app_control_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void AppControlChannel::NotifyAppControl(void* handle) {
void AppControlChannel::HandleMethodCall(
const MethodCall<EncodableValue>& method_call,
std::unique_ptr<MethodResult<EncodableValue>> result) {
const auto& method_name = method_call.method_name();
const std::string& method_name = method_call.method_name();

const auto* arguments = std::get_if<EncodableMap>(method_call.arguments());
if (!arguments) {
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const std::map<int, int> kEcoreModifierToGtkModifier = {

uint32_t Utf8ToUtf32CodePoint(const char* utf8) {
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
for (auto wchar : converter.from_bytes(utf8)) {
for (wchar_t wchar : converter.from_bytes(utf8)) {
return wchar;
}
return 0;
Expand Down Expand Up @@ -282,7 +282,7 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
}

rapidjson::Document event(rapidjson::kObjectType);
auto& allocator = event.GetAllocator();
rapidjson::MemoryPoolAllocator<>& allocator = event.GetAllocator();
event.AddMember(kKeyMapKey, kLinuxKeyMap, allocator);
event.AddMember(kToolkitKey, kGtkToolkit, allocator);
event.AddMember(kUnicodeScalarValuesKey, unicode_scalar_values, allocator);
Expand All @@ -297,7 +297,7 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
channel_->Send(event, [callback = std::move(callback)](const uint8_t* reply,
size_t reply_size) {
if (reply != nullptr) {
auto decoded =
std::unique_ptr<rapidjson::Document> decoded =
JsonMessageCodec::GetInstance().DecodeMessage(reply, reply_size);
bool handled = (*decoded)[kHandledKey].GetBool();
callback(handled);
Expand Down
8 changes: 4 additions & 4 deletions shell/platform/tizen/channels/platform_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ PlatformChannel::~PlatformChannel() {}
void PlatformChannel::HandleMethodCall(
const MethodCall<rapidjson::Document>& method_call,
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
const auto& method = method_call.method_name();
const auto* arguments = method_call.arguments();
const std::string& method = method_call.method_name();
const rapidjson::Document* arguments = method_call.arguments();

if (method == kSystemNavigatorPopMethod) {
SystemNavigatorPop();
Expand Down Expand Up @@ -125,7 +125,7 @@ void PlatformChannel::HandleMethodCall(
RestoreSystemUiOverlays();
result->Success();
} else if (method == kSetEnabledSystemUiOverlaysMethod) {
const auto& list = arguments[0];
const rapidjson::Document& list = arguments[0];
std::vector<std::string> overlays;
for (auto iter = list.Begin(); iter != list.End(); ++iter) {
overlays.push_back(iter->GetString());
Expand All @@ -134,7 +134,7 @@ void PlatformChannel::HandleMethodCall(
result->Success();
#endif
} else if (method == kSetPreferredOrientationsMethod) {
const auto& list = arguments[0];
const rapidjson::Document& list = arguments[0];
std::vector<std::string> orientations;
for (auto iter = list.Begin(); iter != list.End(); ++iter) {
orientations.push_back(iter->GetString());
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void PlatformViewChannel::Dispose() {
}

PlatformView* PlatformViewChannel::FindViewById(int view_id) {
auto it = views_.find(view_id);
if (it != views_.end()) {
return it->second;
auto iter = views_.find(view_id);
if (iter != views_.end()) {
return iter->second;
}
return nullptr;
}
Expand Down Expand Up @@ -139,14 +139,14 @@ void PlatformViewChannel::OnCreate(
if (params) {
byte_message = *params;
}
auto it = view_factories_.find(*view_type);
if (it != view_factories_.end()) {
auto iter = view_factories_.find(*view_type);
if (iter != view_factories_.end()) {
PlatformView* focused_view = FindFocusedView();
if (focused_view) {
focused_view->SetFocus(false);
}
PlatformView* view =
it->second->Create(*view_id, *width, *height, byte_message);
iter->second->Create(*view_id, *width, *height, byte_message);
if (view) {
views_[*view_id] = view;
result->Success(EncodableValue(view->GetTextureId()));
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/settings_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SettingsChannel::~SettingsChannel() {

void SettingsChannel::SendSettingsEvent() {
rapidjson::Document event(rapidjson::kObjectType);
auto& allocator = event.GetAllocator();
rapidjson::MemoryPoolAllocator<>& allocator = event.GetAllocator();
event.AddMember(kTextScaleFactorKey, GetTextScaleFactor(), allocator);
event.AddMember(kAlwaysUse24HourFormatKey, Prefer24HourTime(), allocator);
event.AddMember(kPlatformBrightnessKey, "light", allocator);
Expand Down
26 changes: 13 additions & 13 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,21 @@ void TextInputChannel::HandleMethodCall(
"Selection base/extent values invalid.");
return;
}
auto selection_base_value = selection_base->value.GetInt();
auto selection_extent_value = selection_extent->value.GetInt();
int selection_base_value = selection_base->value.GetInt();
int selection_extent_value = selection_extent->value.GetInt();

active_model_->SetText(text->value.GetString());
active_model_->SetSelection(
TextRange(selection_base_value, selection_extent_value));

auto composing_base = args.FindMember(kComposingBaseKey);
auto composing_extent = args.FindMember(kComposingBaseKey);
auto composing_base_value = composing_base != args.MemberEnd()
? composing_base->value.GetInt()
: -1;
auto composing_extent_value = composing_extent != args.MemberEnd()
? composing_extent->value.GetInt()
: -1;
int composing_base_value = composing_base != args.MemberEnd()
? composing_base->value.GetInt()
: -1;
int composing_extent_value = composing_extent != args.MemberEnd()
? composing_extent->value.GetInt()
: -1;

if (composing_base_value == -1 && composing_extent_value == -1) {
active_model_->EndComposing();
Expand All @@ -272,8 +272,8 @@ void TextInputChannel::HandleMethodCall(
size_t cursor_offset = selection_base_value - composing_start;

active_model_->SetComposingRange(
flutter::TextRange(static_cast<size_t>(composing_base_value),
static_cast<size_t>(composing_extent_value)),
TextRange(static_cast<size_t>(composing_base_value),
static_cast<size_t>(composing_extent_value)),
cursor_offset);
}
SendStateUpdate(*active_model_);
Expand All @@ -288,7 +288,7 @@ void TextInputChannel::HandleMethodCall(

void TextInputChannel::SendStateUpdate(const TextInputModel& model) {
auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
auto& allocator = args->GetAllocator();
rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator();
args->PushBack(client_id_, allocator);

TextRange selection = model.selection();
Expand Down Expand Up @@ -326,7 +326,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event, bool is_down) {
FT_LOG(Debug) << "Entering select mode.";
}
#else
auto device_name = ecore_device_name_get(event->dev);
const char* device_name = ecore_device_name_get(event->dev);
bool is_ime = device_name ? strcmp(device_name, "ime") == 0 : true;
#endif

Expand Down Expand Up @@ -422,7 +422,7 @@ void TextInputChannel::EnterPressed(TextInputModel* model, bool select) {
SendStateUpdate(*model);
}
auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
auto& allocator = args->GetAllocator();
rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator();
args->PushBack(client_id_, allocator);
args->PushBack(rapidjson::Value(input_action_, allocator).Move(), allocator);

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/window_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ WindowChannel::~WindowChannel() {}
void WindowChannel::HandleMethodCall(
const MethodCall<EncodableValue>& method_call,
std::unique_ptr<MethodResult<EncodableValue>> result) {
const auto& method_name = method_call.method_name();
const std::string& method_name = method_call.method_name();

if (method_name == "getWindowGeometry") {
TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry();
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/flutter_project_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {
// Returns the path of the directory containing the app binary, or an empty
// string if the directory cannot be found.
std::filesystem::path GetBinDirectory() {
auto* res_path = app_get_resource_path();
char* res_path = app_get_resource_path();
if (!res_path) {
return GetExecutableDirectory();
}
Expand Down Expand Up @@ -109,7 +109,7 @@ UniqueAotDataPtr FlutterProjectBundle::LoadAotData(
source.type = kFlutterEngineAOTDataSourceTypeElfPath;
source.elf_path = path_string.c_str();
FlutterEngineAOTData data = nullptr;
auto result = engine_procs.CreateAOTData(&source, &data);
FlutterEngineResult result = engine_procs.CreateAOTData(&source, &data);
if (result != kSuccess) {
FT_LOG(Error) << "Failed to load AOT data from: " << path_string;
return UniqueAotDataPtr(nullptr, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine(
void FlutterDesktopShutdownEngine(FlutterDesktopEngineRef engine_ref) {
flutter::Logger::Stop();

auto* engine = EngineFromHandle(engine_ref);
flutter::FlutterTizenEngine* engine = EngineFromHandle(engine_ref);
engine->StopEngine();
delete engine;
}
Expand Down
28 changes: 15 additions & 13 deletions shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) {
<< engine_message->struct_size;
return;
}
auto engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
auto message = engine->ConvertToDesktopMessage(*engine_message);
auto* engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
FlutterDesktopMessage message =
engine->ConvertToDesktopMessage(*engine_message);
engine->message_dispatcher_->HandleMessage(message);
};
args.custom_task_runners = &custom_task_runners;
Expand All @@ -239,8 +240,8 @@ bool FlutterTizenEngine::RunEngine(const char* entrypoint) {

FlutterRendererConfig renderer_config = GetRendererConfig();

auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
&args, this, &engine_);
FlutterEngineResult result = embedder_api_.Run(
FLUTTER_ENGINE_VERSION, &renderer_config, &args, this, &engine_);
if (result != kSuccess || engine_ == nullptr) {
FT_LOG(Error) << "Failed to start the Flutter engine with error: "
<< result;
Expand Down Expand Up @@ -393,7 +394,7 @@ void FlutterTizenEngine::SetWindowOrientation(int32_t degree) {
renderer_->SetRotate(degree);
// Compute renderer transformation based on the angle of rotation.
double rad = (360 - degree) * M_PI / 180;
auto geometry = renderer_->GetWindowGeometry();
TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry();
double width = geometry.w;
double height = geometry.h;

Expand Down Expand Up @@ -451,7 +452,7 @@ void FlutterTizenEngine::SetupLocales() {
std::vector<LanguageInfo> languages = GetPreferredLanguageInfo();
std::vector<FlutterLocale> flutter_locales;
flutter_locales.reserve(languages.size());
for (const auto& info : languages) {
for (const LanguageInfo& info : languages) {
flutter_locales.push_back(CovertToFlutterLocale(info));
}
// Convert the locale list to the locale pointer list that must be provided.
Expand Down Expand Up @@ -542,7 +543,7 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() {
config.open_gl.gl_external_texture_frame_callback =
[](void* user_data, int64_t texture_id, size_t width, size_t height,
FlutterOpenGLTexture* texture) -> bool {
auto engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
auto* engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
if (!engine->texture_registrar()) {
return false;
}
Expand Down Expand Up @@ -592,7 +593,7 @@ void FlutterTizenEngine::OnUpdateSemanticsNode(const FlutterSemanticsNode* node,
FT_LOG(Debug) << "Update semantics node [id=" << node->id
<< ", label=" << node->label << ", hint=" << node->hint
<< ", value=" << node->value << "]";
auto engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
auto* engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
if (engine->accessibility_bridge_) {
engine->accessibility_bridge_->AddFlutterSemanticsNodeUpdate(node);
} else {
Expand All @@ -603,18 +604,19 @@ void FlutterTizenEngine::OnUpdateSemanticsNode(const FlutterSemanticsNode* node,
void FlutterTizenEngine::OnUpdateSemanticsCustomActions(
const FlutterSemanticsCustomAction* action,
void* user_data) {
auto engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
auto bridge = engine->accessibility_bridge_;
auto* engine = reinterpret_cast<FlutterTizenEngine*>(user_data);
std::shared_ptr<AccessibilityBridge> bridge = engine->accessibility_bridge_;
if (bridge) {
if (action->id == kFlutterSemanticsCustomActionIdBatchEnd) {
// Custom action with id = kFlutterSemanticsCustomActionIdBatchEnd
// indicates this is the end of the update batch.
bridge->CommitUpdates();
// Attaches the accessibility root to the window delegate.
auto root = bridge->GetFlutterPlatformNodeDelegateFromID(0);
auto window =
std::weak_ptr<FlutterPlatformNodeDelegate> root =
bridge->GetFlutterPlatformNodeDelegateFromID(0);
std::shared_ptr<FlutterPlatformWindowDelegateTizen> window =
FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock();
auto geometry = engine->renderer_->GetWindowGeometry();
TizenRenderer::Geometry geometry = engine->renderer_->GetWindowGeometry();
window->SetGeometry(geometry.x, geometry.y, geometry.w, geometry.h);
window->SetRootNode(root);
return;
Expand Down
15 changes: 8 additions & 7 deletions shell/platform/tizen/flutter_tizen_texture_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ int64_t FlutterTizenTextureRegistrar::RegisterTexture(
return -1;
}
}
auto texture_gl = CreateExternalTexture(texture_info);
std::unique_ptr<ExternalTexture> texture_gl =
CreateExternalTexture(texture_info);
int64_t texture_id = texture_gl->TextureId();

{
Expand All @@ -54,11 +55,11 @@ int64_t FlutterTizenTextureRegistrar::RegisterTexture(
bool FlutterTizenTextureRegistrar::UnregisterTexture(int64_t texture_id) {
{
std::lock_guard<std::mutex> lock(map_mutex_);
auto it = textures_.find(texture_id);
if (it == textures_.end()) {
auto iter = textures_.find(texture_id);
if (iter == textures_.end()) {
return false;
}
textures_.erase(it);
textures_.erase(iter);
}
return engine_->UnregisterExternalTexture(texture_id);
}
Expand All @@ -76,11 +77,11 @@ bool FlutterTizenTextureRegistrar::PopulateTexture(
ExternalTexture* texture;
{
std::lock_guard<std::mutex> lock(map_mutex_);
auto it = textures_.find(texture_id);
if (it == textures_.end()) {
auto iter = textures_.find(texture_id);
if (iter == textures_.end()) {
return false;
}
texture = it->second.get();
texture = iter->second.get();
}
return texture->PopulateTexture(width, height, opengl_texture);
}
Expand Down
Loading

0 comments on commit fc30c34

Please sign in to comment.