Skip to content

Commit 65ab52d

Browse files
committed
Resolve some linter warnings (flutter-tizen#92)
* Resolve some linter warnings * Remove TODOs * Resolve google-runtime-references warning
1 parent 05123d4 commit 65ab52d

10 files changed

+67
-65
lines changed

shell/platform/tizen/channels/platform_view_channel.cc

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
1919
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
2020
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
2121
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
22-
if (std::holds_alternative<std::string>(value))
22+
if (std::holds_alternative<std::string>(value)) {
2323
return std::get<std::string>(value);
24+
}
2425
}
2526
return std::string();
2627
}
@@ -30,8 +31,9 @@ int ExtractIntFromMap(const flutter::EncodableValue& arguments,
3031
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
3132
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
3233
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
33-
if (std::holds_alternative<int>(value))
34+
if (std::holds_alternative<int>(value)) {
3435
return std::get<int>(value);
36+
}
3537
}
3638
return -1;
3739
}
@@ -41,8 +43,9 @@ double ExtractDoubleFromMap(const flutter::EncodableValue& arguments,
4143
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
4244
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
4345
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
44-
if (std::holds_alternative<double>(value))
46+
if (std::holds_alternative<double>(value)) {
4547
return std::get<double>(value);
48+
}
4649
}
4750
return -1;
4851
}
@@ -53,8 +56,9 @@ flutter::EncodableMap ExtractMapFromMap(
5356
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
5457
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
5558
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
56-
if (std::holds_alternative<flutter::EncodableMap>(value))
59+
if (std::holds_alternative<flutter::EncodableMap>(value)) {
5760
return std::get<flutter::EncodableMap>(value);
61+
}
5862
}
5963
return flutter::EncodableMap();
6064
}
@@ -65,8 +69,9 @@ flutter::EncodableList ExtractListFromMap(
6569
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
6670
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
6771
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
68-
if (std::holds_alternative<flutter::EncodableList>(value))
72+
if (std::holds_alternative<flutter::EncodableList>(value)) {
6973
return std::get<flutter::EncodableList>(value);
74+
}
7075
}
7176
return flutter::EncodableList();
7277
}

shell/platform/tizen/channels/text_input_channel.cc

+22-22
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ static const char* GetImfMethod() {
4141
Eina_List* modules;
4242

4343
modules = ecore_imf_context_available_ids_get();
44-
if (!modules)
44+
if (!modules) {
4545
return nullptr;
46+
}
4647

4748
void* module;
48-
EINA_LIST_FREE(modules, module) { return (const char*)module; }
49+
EINA_LIST_FREE(modules, module) { return static_cast<const char*>(module); }
4950

5051
return nullptr;
5152
}
@@ -59,29 +60,29 @@ static bool IsASCIIPrintableKey(char c) {
5960

6061
static bool TextInputTypeToEcoreIMFInputPanelLayout(
6162
std::string text_input_type,
62-
Ecore_IMF_Input_Panel_Layout& panel_layout) {
63+
Ecore_IMF_Input_Panel_Layout* panel_layout) {
6364
if (text_input_type == "TextInputType.text" ||
6465
text_input_type == "TextInputType.multiline") {
65-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
66+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
6667
} else if (text_input_type == "TextInputType.number") {
67-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
68+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
6869
} else if (text_input_type == "TextInputType.phone") {
69-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
70+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
7071
} else if (text_input_type == "TextInputType.datetime") {
71-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME;
72+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME;
7273
} else if (text_input_type == "TextInputType.emailAddress") {
73-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
74+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
7475
} else if (text_input_type == "TextInputType.url") {
75-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
76+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
7677
} else if (text_input_type == "TextInputType.visiblePassword") {
77-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
78+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
7879
} else if (text_input_type == "TextInputType.name" ||
7980
text_input_type == "TextInputType.address") {
8081
FT_LOGW(
8182
"Actual requested text input type is [%s], but select "
8283
"TextInputType.text as fallback type",
8384
text_input_type.c_str());
84-
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
85+
*panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
8586
} else {
8687
return false;
8788
}
@@ -91,11 +92,11 @@ static bool TextInputTypeToEcoreIMFInputPanelLayout(
9192
void TextInputChannel::CommitCallback(void* data,
9293
Ecore_IMF_Context* ctx,
9394
void* event_info) {
94-
TextInputChannel* self = (TextInputChannel*)data;
95+
TextInputChannel* self = static_cast<TextInputChannel*>(data);
9596
if (!self) {
9697
return;
9798
}
98-
char* str = (char*)event_info;
99+
char* str = static_cast<char*>(event_info);
99100
if (self->engine_ && self->engine_->platform_view_channel &&
100101
self->engine_->platform_view_channel->CurrentFocusedViewId() > -1) {
101102
self->engine_->platform_view_channel->DispatchCompositionEndEvent(str);
@@ -108,7 +109,7 @@ void TextInputChannel::CommitCallback(void* data,
108109
void TextInputChannel::PreeditCallback(void* data,
109110
Ecore_IMF_Context* ctx,
110111
void* event_info) {
111-
TextInputChannel* self = (TextInputChannel*)data;
112+
TextInputChannel* self = static_cast<TextInputChannel*>(data);
112113
if (!self) {
113114
return;
114115
}
@@ -130,14 +131,12 @@ void TextInputChannel::PreeditCallback(void* data,
130131
void TextInputChannel::PrivateCommandCallback(void* data,
131132
Ecore_IMF_Context* ctx,
132133
void* event_info) {
133-
// TODO
134134
FT_UNIMPLEMENTED();
135135
}
136136

137137
void TextInputChannel::DeleteSurroundingCallback(void* data,
138138
Ecore_IMF_Context* ctx,
139139
void* event_info) {
140-
// TODO
141140
FT_UNIMPLEMENTED();
142141
}
143142

@@ -150,7 +149,7 @@ void TextInputChannel::InputPanelStateChangedCallback(
150149
FT_LOGW("No Data");
151150
return;
152151
}
153-
TextInputChannel* self = (TextInputChannel*)data;
152+
TextInputChannel* self = static_cast<TextInputChannel*>(data);
154153
switch (value) {
155154
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
156155
self->SetSoftwareKeyboardShowing();
@@ -173,7 +172,7 @@ void TextInputChannel::InputPanelGeometryChangedCallback(
173172
FT_LOGW("No Data");
174173
return;
175174
}
176-
TextInputChannel* self = (TextInputChannel*)data;
175+
TextInputChannel* self = static_cast<TextInputChannel*>(data);
177176
ecore_imf_context_input_panel_geometry_get(
178177
self->imf_context_, &self->current_keyboard_geometry_.x,
179178
&self->current_keyboard_geometry_.y, &self->current_keyboard_geometry_.w,
@@ -263,7 +262,8 @@ TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger,
263262
}
264263
if (imf_context_) {
265264
ecore_imf_context_client_window_set(
266-
imf_context_, (void*)engine_->renderer->GetWindowId());
265+
imf_context_,
266+
reinterpret_cast<void*>(engine_->renderer->GetWindowId()));
267267
RegisterIMFCallback();
268268
} else {
269269
FT_LOGE("Failed to create imfContext");
@@ -296,7 +296,7 @@ void TextInputChannel::HandleMethodCall(
296296
} else if (method.compare(kHideMethod) == 0) {
297297
HideSoftwareKeyboard();
298298
} else if (method.compare(kSetPlatformViewClient) == 0) {
299-
// TODO: implement if necessary
299+
FT_UNIMPLEMENTED();
300300
} else if (method.compare(kClearClientMethod) == 0) {
301301
active_model_ = nullptr;
302302
} else if (method.compare(kSetClientMethod) == 0) {
@@ -403,7 +403,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
403403
bool handled = false;
404404

405405
#ifdef TIZEN_RENDERER_EVAS_GL
406-
// TODO: Hardware keyboard not supported when running in Evas GL mode.
406+
// Hardware keyboard not supported when running in Evas GL mode.
407407
bool isIME = true;
408408
#else
409409
bool isIME = ecore_imf_context_keyboard_mode_get(imf_context_) ==
@@ -618,7 +618,7 @@ void TextInputChannel::ShowSoftwareKeyboard() {
618618
if (imf_context_ && !is_software_keyboard_showing_) {
619619
is_software_keyboard_showing_ = true;
620620
Ecore_IMF_Input_Panel_Layout panel_layout;
621-
if (TextInputTypeToEcoreIMFInputPanelLayout(input_type_, panel_layout)) {
621+
if (TextInputTypeToEcoreIMFInputPanelLayout(input_type_, &panel_layout)) {
622622
ecore_imf_context_input_panel_layout_set(imf_context_, panel_layout);
623623
}
624624
ecore_imf_context_input_panel_show(imf_context_);

shell/platform/tizen/external_texture_surface_gl.cc

+11-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
7676
int attribs[] = {EVAS_GL_IMAGE_PRESERVED, GL_TRUE, 0};
7777
EvasGLImage egl_src_image = evasglCreateImageForContext(
7878
g_evas_gl, evas_gl_current_context_get(g_evas_gl),
79-
EVAS_GL_NATIVE_SURFACE_TIZEN, (void*)(intptr_t)tbm_surface, attribs);
79+
EVAS_GL_NATIVE_SURFACE_TIZEN, tbm_surface, attribs);
8080
if (!egl_src_image) {
8181
return false;
8282
}
@@ -100,12 +100,13 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
100100
}
101101
#else
102102
PFNEGLCREATEIMAGEKHRPROC n_eglCreateImageKHR =
103-
(PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
103+
reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(
104+
eglGetProcAddress("eglCreateImageKHR"));
104105
const EGLint attribs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE,
105106
EGL_NONE};
106-
EGLImageKHR egl_src_image = n_eglCreateImageKHR(
107-
eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN,
108-
(EGLClientBuffer)tbm_surface, attribs);
107+
EGLImageKHR egl_src_image =
108+
n_eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT,
109+
EGL_NATIVE_SURFACE_TIZEN, tbm_surface, attribs);
109110

110111
if (!egl_src_image) {
111112
FT_LOGE("[texture id:%ld] egl_src_image create fail!!, errorcode == %d",
@@ -127,20 +128,21 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
127128
glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture);
128129
}
129130
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES =
130-
(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress(
131-
"glEGLImageTargetTexture2DOES");
131+
reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(
132+
eglGetProcAddress("glEGLImageTargetTexture2DOES"));
132133
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image);
133134
if (egl_src_image) {
134135
PFNEGLDESTROYIMAGEKHRPROC n_eglDestroyImageKHR =
135-
(PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
136+
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(
137+
eglGetProcAddress("eglDestroyImageKHR"));
136138
n_eglDestroyImageKHR(eglGetCurrentDisplay(), egl_src_image);
137139
}
138140
#endif
139141

140142
opengl_texture->target = GL_TEXTURE_EXTERNAL_OES;
141143
opengl_texture->name = state_->gl_texture;
142144
opengl_texture->format = GL_RGBA8;
143-
opengl_texture->destruction_callback = (VoidCallback)OnCollectTexture;
145+
opengl_texture->destruction_callback = OnCollectTexture;
144146
auto* weak_texture = new std::weak_ptr<ExternalTexture>(shared_from_this());
145147
opengl_texture->user_data = weak_texture;
146148
opengl_texture->width = width;

shell/platform/tizen/flutter_tizen_engine.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t width,
334334
// https://docs.tizen.org/application/native/guides/ui/efl/multiple-screens
335335
double dpi = 72.0;
336336
if (renderer && device_profile != DeviceProfile::kTV) {
337-
dpi = (double)renderer->GetDpi();
337+
dpi = static_cast<double>(renderer->GetDpi());
338338
}
339339
double profile_factor = 1.0;
340340
if (device_profile == DeviceProfile::kWearable) {

shell/platform/tizen/tizen_event_loop.cc

+4-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void TizenEventLoop::ExcuteTaskEvents(void* data,
8080
auto* p_task = reinterpret_cast<Task*>(buffer);
8181

8282
const double flutter_duration =
83-
((double)(p_task->fire_time.time_since_epoch().count()) -
83+
(static_cast<double>(p_task->fire_time.time_since_epoch().count()) -
8484
FlutterEngineGetCurrentTime()) /
8585
1000000000.0;
8686
if (flutter_duration > 0) {
@@ -118,10 +118,9 @@ TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id,
118118
TizenRenderer* renderer)
119119
: TizenEventLoop(main_thread_id, on_task_expired), renderer_(renderer) {
120120
evas_object_image_pixels_get_callback_set(
121-
(Evas_Object*)static_cast<TizenRendererEvasGL*>(renderer_)
122-
->GetImageHandle(),
121+
static_cast<TizenRendererEvasGL*>(renderer_)->GetImageHandle(),
123122
[](void* data, Evas_Object* o) { // Render callback
124-
TizenRenderEventLoop* self = (TizenRenderEventLoop*)data;
123+
TizenRenderEventLoop* self = static_cast<TizenRenderEventLoop*>(data);
125124
{
126125
std::lock_guard<std::mutex> lock(self->expired_tasks_mutex_);
127126
for (const auto& task : self->expired_tasks_) {
@@ -142,8 +141,7 @@ void TizenRenderEventLoop::OnTaskExpired() {
142141
expired_tasks_count = expired_tasks_.size();
143142
if (!has_pending_renderer_callback_ && expired_tasks_count) {
144143
evas_object_image_pixels_dirty_set(
145-
(Evas_Object*)static_cast<TizenRendererEvasGL*>(renderer_)
146-
->GetImageHandle(),
144+
static_cast<TizenRendererEvasGL*>(renderer_)->GetImageHandle(),
147145
EINA_TRUE);
148146
has_pending_renderer_callback_ = true;
149147
} else {

shell/platform/tizen/tizen_log.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static pthread_t stderr_thread;
1414
static bool is_running = false;
1515

1616
static void* LoggingFunction(void* arg) {
17-
int* pipe = (int*)arg;
17+
int* pipe = static_cast<int*>(arg);
1818
auto priority = pipe == stdout_pipe ? DLOG_INFO : DLOG_ERROR;
1919

2020
ssize_t size;

shell/platform/tizen/tizen_renderer_ecore_wl2.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int32_t TizenRendererEcoreWl2::GetDpi() {
227227
}
228228

229229
uintptr_t TizenRendererEcoreWl2::GetWindowId() {
230-
return (uintptr_t)ecore_wl2_window_id_get(ecore_wl2_window_);
230+
return ecore_wl2_window_id_get(ecore_wl2_window_);
231231
}
232232

233233
bool TizenRendererEcoreWl2::InitializeRenderer() {
@@ -306,13 +306,11 @@ bool TizenRendererEcoreWl2::SetupEglWindow(int32_t width, int32_t height) {
306306
}
307307

308308
EGLDisplay TizenRendererEcoreWl2::GetEGLDisplay() {
309-
return eglGetDisplay(
310-
(EGLNativeDisplayType)ecore_wl2_display_get(ecore_wl2_display_));
309+
return eglGetDisplay(ecore_wl2_display_get(ecore_wl2_display_));
311310
}
312311

313312
EGLNativeWindowType TizenRendererEcoreWl2::GetEGLNativeWindowType() {
314-
return (EGLNativeWindowType)ecore_wl2_egl_window_native_get(
315-
ecore_wl2_egl_window_);
313+
return ecore_wl2_egl_window_native_get(ecore_wl2_egl_window_);
316314
}
317315

318316
void TizenRendererEcoreWl2::DestroyEglWindow() {

shell/platform/tizen/tizen_renderer_evas_gl.cc

+10-12
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ uintptr_t TizenRendererEvasGL::GetWindowId() {
562562
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)));
563563
}
564564

565-
void* TizenRendererEvasGL::GetImageHandle() {
566-
return (void*)graphics_adapter_;
565+
Evas_Object* TizenRendererEvasGL::GetImageHandle() {
566+
return graphics_adapter_;
567567
}
568568

569569
bool TizenRendererEvasGL::InitializeRenderer() {
@@ -577,7 +577,7 @@ bool TizenRendererEvasGL::InitializeRenderer() {
577577
}
578578

579579
void TizenRendererEvasGL::Show() {
580-
evas_object_show((Evas_Object*)GetImageHandle());
580+
evas_object_show(GetImageHandle());
581581
evas_object_show(evas_window_);
582582
}
583583

@@ -588,8 +588,7 @@ void TizenRendererEvasGL::DestroyRenderer() {
588588

589589
bool TizenRendererEvasGL::SetupEvasGL() {
590590
int32_t width, height;
591-
evas_gl_ = evas_gl_new(
592-
evas_object_evas_get((Evas_Object*)SetupEvasWindow(width, height)));
591+
evas_gl_ = evas_gl_new(evas_object_evas_get(SetupEvasWindow(width, height)));
593592
if (!evas_gl_) {
594593
FT_LOGE("SetupEvasWindow fail");
595594
return false;
@@ -628,12 +627,13 @@ bool TizenRendererEvasGL::SetupEvasGL() {
628627

629628
Evas_Native_Surface ns;
630629
evas_gl_native_surface_get(evas_gl_, gl_surface_, &ns);
631-
evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), &ns);
630+
evas_object_image_native_surface_set(GetImageHandle(), &ns);
632631

633632
return true;
634633
}
635634

636-
void* TizenRendererEvasGL::SetupEvasWindow(int32_t& width, int32_t& height) {
635+
Evas_Object* TizenRendererEvasGL::SetupEvasWindow(int32_t& width,
636+
int32_t& height) {
637637
elm_config_accel_preference_set("hw:opengl");
638638

639639
evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
@@ -665,12 +665,11 @@ void* TizenRendererEvasGL::SetupEvasWindow(int32_t& width, int32_t& height) {
665665
evas_object_image_alpha_set(graphics_adapter_, EINA_TRUE);
666666
elm_win_resize_object_add(evas_window_, graphics_adapter_);
667667

668-
int rotations[4] = {0, 90, 180, 270};
669-
elm_win_wm_rotation_available_rotations_set(evas_window_,
670-
(const int*)(&rotations), 4);
668+
const int rotations[4] = {0, 90, 180, 270};
669+
elm_win_wm_rotation_available_rotations_set(evas_window_, &rotations[0], 4);
671670
evas_object_smart_callback_add(evas_window_, "rotation,changed",
672671
RotationEventCb, this);
673-
return (void*)evas_window_;
672+
return evas_window_;
674673
}
675674

676675
void TizenRendererEvasGL::DestroyEvasGL() {
@@ -693,7 +692,6 @@ void TizenRendererEvasGL::RotationEventCb(void* data,
693692
Evas_Object* obj,
694693
void* event_info) {
695694
auto* self = reinterpret_cast<TizenRendererEvasGL*>(data);
696-
// TODO : Use current window rotation degree
697695
FT_UNIMPLEMENTED();
698696
self->delegate_.OnOrientationChange(0);
699697
}

0 commit comments

Comments
 (0)