Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-25 11:33:28 +0300
committerCampbell Barton <campbell@blender.org>2022-09-25 13:17:08 +0300
commitf68cfd6bb078482c4a779a6e26a56e2734edb5b8 (patch)
tree2878e5b80dba5bdeba186d99661d604eb38879cd /intern
parentc7b247a118e302a3afc6473797e53b6af28b69e2 (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_DisplayManager.cpp6
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerSDL.cpp2
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerX11.cpp4
-rw-r--r--intern/ghost/intern/GHOST_EventManager.cpp2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp36
-rw-r--r--intern/ghost/intern/GHOST_TimerManager.cpp2
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.cpp8
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp4
-rw-r--r--intern/guardedalloc/intern/leak_detector.cc2
-rw-r--r--intern/sky/source/sky_model.cpp10
13 files changed, 44 insertions, 44 deletions
diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp
index fa15d05232d..55f4b29e009 100644
--- a/intern/ghost/intern/GHOST_DisplayManager.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManager.cpp
@@ -70,7 +70,7 @@ GHOST_TSuccess GHOST_DisplayManager::getDisplaySetting(uint8_t display,
uint8_t numDisplays;
success = getNumDisplays(numDisplays);
if (success == GHOST_kSuccess) {
- if (display < numDisplays && ((uint8_t)index < m_settings[display].size())) {
+ if (display < numDisplays && (uint8_t(index) < m_settings[display].size())) {
setting = m_settings[display][index];
}
else {
@@ -101,14 +101,14 @@ GHOST_TSuccess GHOST_DisplayManager::findMatch(uint8_t display,
"GHOST_DisplayManager::findMatch(): m_settingsInitialized=false");
int criteria[4] = {
- (int)setting.xPixels, (int)setting.yPixels, (int)setting.bpp, (int)setting.frequency};
+ int(setting.xPixels), int(setting.yPixels), int(setting.bpp), int(setting.frequency)};
int capabilities[4];
double field, score;
double best = 1e12; /* A big number. */
int found = 0;
/* Look at all the display modes. */
- for (int i = 0; (i < (int)m_settings[display].size()); i++) {
+ for (int i = 0; (i < int(m_settings[display].size())); i++) {
/* Store the capabilities of the display device. */
capabilities[0] = m_settings[display][i].xPixels;
capabilities[1] = m_settings[display][i].yPixels;
diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp
index a2fe6a41fb4..eed437adc6c 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp
@@ -109,7 +109,7 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
SDL_GetDisplayMode(display, i, &mode);
- if ((int)setting.xPixels > mode.w || (int)setting.yPixels > mode.h) {
+ if (int(setting.xPixels) > mode.w || int(setting.yPixels) > mode.h) {
continue;
}
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
index ab4a77cd660..53189c6551b 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp
@@ -185,8 +185,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting(
}
}
else {
- if (abs(calculate_rate(vidmodes[i]) - (int)setting.frequency) <
- abs(calculate_rate(vidmodes[best_fit]) - (int)setting.frequency)) {
+ if (abs(calculate_rate(vidmodes[i]) - int(setting.frequency)) <
+ abs(calculate_rate(vidmodes[best_fit]) - int(setting.frequency))) {
best_fit = i;
}
}
diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp
index 670631e4e16..184052aa6ab 100644
--- a/intern/ghost/intern/GHOST_EventManager.cpp
+++ b/intern/ghost/intern/GHOST_EventManager.cpp
@@ -31,7 +31,7 @@ GHOST_EventManager::~GHOST_EventManager()
uint32_t GHOST_EventManager::getNumEvents()
{
- return (uint32_t)m_events.size();
+ return uint32_t(m_events.size());
}
uint32_t GHOST_EventManager::getNumEvents(GHOST_TEventType type)
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index 746e3532b03..0945f542803 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -257,7 +257,7 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
}
if (m_buttonMask == 0) {
- m_buttonMask = (int)~(UINT_MAX << m_buttonCount);
+ m_buttonMask = int(~(UINT_MAX << m_buttonCount));
}
#ifdef DEBUG_NDOF_BUTTONS
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 76770e735fa..ad5c4dc85fb 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -413,7 +413,7 @@ static char convert_keyboard_event_to_ascii(const SDL_KeyboardEvent &sdl_sub_evt
}
}
}
- return (char)sym;
+ return char(sym);
}
/**
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index dd82d435397..4082cab4ccd 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -910,7 +910,7 @@ static wl_buffer *ghost_wl_buffer_create_for_image(struct wl_shm *shm,
wl_shm_pool_destroy(pool);
if (buffer) {
*r_buffer_data = buffer_data;
- *r_buffer_data_size = (size_t)buffer_size;
+ *r_buffer_data_size = size_t(buffer_size);
}
else {
/* Highly unlikely. */
@@ -1991,7 +1991,7 @@ static void tablet_tool_handle_pressure(void *data,
struct zwp_tablet_tool_v2 * /*zwp_tablet_tool_v2*/,
const uint32_t pressure)
{
- const float pressure_unit = (float)pressure / 65535;
+ const float pressure_unit = float(pressure) / 65535;
CLOG_INFO(LOG, 2, "pressure (%.4f)", pressure_unit);
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
@@ -2012,8 +2012,8 @@ static void tablet_tool_handle_tilt(void *data,
{
/* Map degrees to `-1.0..1.0`. */
const float tilt_unit[2] = {
- (float)(wl_fixed_to_double(tilt_x) / 90.0),
- (float)(wl_fixed_to_double(tilt_y) / 90.0),
+ float(wl_fixed_to_double(tilt_x) / 90.0),
+ float(wl_fixed_to_double(tilt_y) / 90.0),
};
CLOG_INFO(LOG, 2, "tilt (x=%.4f, y=%.4f)", UNPACK2(tilt_unit));
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 08ac0edb7ec..a383710256a 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -715,7 +715,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
XK_Super_R,
};
- for (int i = 0; i < (int)ARRAY_SIZE(modifiers); i++) {
+ for (int i = 0; i < int(ARRAY_SIZE(modifiers)); i++) {
KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
pushEvent(new GHOST_EventKey(getMilliSeconds(),
@@ -845,14 +845,14 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
}
else {
if (m_keycode_last_repeat_key == xke->keycode) {
- m_keycode_last_repeat_key = (uint)-1;
+ m_keycode_last_repeat_key = uint(-1);
}
}
}
}
else if (xe->type == EnterNotify) {
/* We can't tell how the key state changed, clear it to avoid stuck keys. */
- m_keycode_last_repeat_key = (uint)-1;
+ m_keycode_last_repeat_key = uint(-1);
}
#ifdef USE_XINPUT_HOTPLUG
@@ -1193,7 +1193,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
int i = 0;
while (true) {
/* Search character boundary. */
- if ((uchar)utf8_buf[i++] > 0x7f) {
+ if (uchar(utf8_buf[i++]) > 0x7f) {
for (; i < len; ++i) {
c = utf8_buf[i];
if (c < 0x80 || c > 0xbf) {
@@ -1523,7 +1523,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
((void)(val = data->axis_data[axis - axis_first]), true))
if (AXIS_VALUE_GET(2, axis_value)) {
- window->GetTabletData().Pressure = axis_value / ((float)xtablet.PressureLevels);
+ window->GetTabletData().Pressure = axis_value / float(xtablet.PressureLevels);
}
/* NOTE(@broken): the (short) cast and the & 0xffff is bizarre and unexplained anywhere,
@@ -1535,12 +1535,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* I don't think we need to cast to short here, but do not have a device to check this.
*/
if (AXIS_VALUE_GET(3, axis_value)) {
- window->GetTabletData().Xtilt = (short)(axis_value & 0xffff) /
- ((float)xtablet.XtiltLevels);
+ window->GetTabletData().Xtilt = short(axis_value & 0xffff) /
+ float(xtablet.XtiltLevels);
}
if (AXIS_VALUE_GET(4, axis_value)) {
- window->GetTabletData().Ytilt = (short)(axis_value & 0xffff) /
- ((float)xtablet.YtiltLevels);
+ window->GetTabletData().Ytilt = short(axis_value & 0xffff) /
+ float(xtablet.YtiltLevels);
}
# undef AXIS_VALUE_GET
@@ -1897,7 +1897,7 @@ static GHOST_TKey ghost_key_from_keysym(const KeySym key)
#undef GXMAP
-#define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
+#define MAKE_ID(a, b, c, d) (int(d) << 24 | int(c) << 16 | (b) << 8 | (a))
static GHOST_TKey ghost_key_from_keycode(const XkbDescPtr xkb_descr, const KeyCode keycode)
{
@@ -2020,7 +2020,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
win,
m_atom.XCLIP_OUT,
0,
- (long)pty_size,
+ long(pty_size),
False,
AnyPropertyType,
&pty_type,
@@ -2106,7 +2106,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
win,
m_atom.XCLIP_OUT,
0,
- (long)pty_size,
+ long(pty_size),
False,
AnyPropertyType,
&pty_type,
@@ -2363,10 +2363,10 @@ class DialogData {
bool isInsideButton(XEvent &e, uint button_num)
{
return (
- (e.xmotion.y > (int)(height - padding_y - button_height)) &&
- (e.xmotion.y < (int)(height - padding_y)) &&
- (e.xmotion.x > (int)(width - (padding_x + button_width) * button_num)) &&
- (e.xmotion.x < (int)(width - padding_x - (padding_x + button_width) * (button_num - 1))));
+ (e.xmotion.y > int(height - padding_y - button_height)) &&
+ (e.xmotion.y < int(height - padding_y)) &&
+ (e.xmotion.x > int(width - (padding_x + button_width) * button_num)) &&
+ (e.xmotion.x < int(width - padding_x - (padding_x + button_width) * (button_num - 1))));
}
};
@@ -2383,7 +2383,7 @@ static void split(const char *text, const char *seps, char ***str, int *count)
free(data);
data = strdup(text);
- *str = (char **)malloc((size_t)(*count) * sizeof(char *));
+ *str = (char **)malloc(size_t(*count) * sizeof(char *));
for (i = 0, tok = strtok(data, seps); tok != nullptr; tok = strtok(nullptr, seps), i++) {
(*str)[i] = strdup(tok);
}
@@ -2440,7 +2440,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
8,
PropModeReplace,
(const unsigned char *)title,
- (int)strlen(title));
+ int(strlen(title)));
XChangeProperty(
m_display, window, winType, XA_ATOM, 32, PropModeReplace, (unsigned char *)&typeDialog, 1);
diff --git a/intern/ghost/intern/GHOST_TimerManager.cpp b/intern/ghost/intern/GHOST_TimerManager.cpp
index e54c2515029..0cdaad20611 100644
--- a/intern/ghost/intern/GHOST_TimerManager.cpp
+++ b/intern/ghost/intern/GHOST_TimerManager.cpp
@@ -26,7 +26,7 @@ GHOST_TimerManager::~GHOST_TimerManager()
uint32_t GHOST_TimerManager::getNumTimers()
{
- return (uint32_t)m_timers.size();
+ return uint32_t(m_timers.size());
}
bool GHOST_TimerManager::getTimerFound(GHOST_TimerTask *timer)
diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp
index 59dc80cf7e6..64642abc2af 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.cpp
+++ b/intern/ghost/intern/GHOST_WindowSDL.cpp
@@ -485,7 +485,7 @@ static unsigned char sdl_std_cursor_arrow[] = {
#define sdl_std_cursor_HOT_Y_arrow -14
/* end cursor data */
-static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors] = {nullptr};
+static SDL_Cursor *sdl_std_cursor_array[int(GHOST_kStandardCursorNumCursors)] = {nullptr};
/* utility function mostly a copy of SDL_CreateCursor but allows us to change
* color and supports blenders flipped bits */
@@ -544,7 +544,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
if (sdl_std_cursor_array[0] == nullptr) {
#define DEF_CURSOR(name, ind) \
{ \
- sdl_std_cursor_array[(int)ind] = sdl_ghost_CreateCursor( \
+ sdl_std_cursor_array[int(ind)] = sdl_ghost_CreateCursor( \
sdl_std_cursor_##name, \
sdl_std_cursor_mask_##name, \
sdl_std_cursor_WIDTH_##name, \
@@ -580,7 +580,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
#undef DEF_CURSOR
}
- return sdl_std_cursor_array[(int)shape];
+ return sdl_std_cursor_array[int(shape)];
}
GHOST_TSuccess GHOST_WindowSDL::setWindowCursorGrab(GHOST_TGrabCursorMode /*mode*/)
@@ -641,5 +641,5 @@ uint16_t GHOST_WindowSDL::getDPIHint()
return 96;
}
- return (int)ddpi;
+ return int(ddpi);
}
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 113f453325d..a93b40502d4 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -442,7 +442,7 @@ void GHOST_WindowX11::refreshXInputDevices()
}
}
- XSelectExtensionEvent(m_display, m_window, xevents.data(), (int)xevents.size());
+ XSelectExtensionEvent(m_display, m_window, xevents.data(), int(xevents.size()));
}
}
@@ -899,7 +899,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
bool is_max, is_full, is_motif_full;
cur_state = getState();
- if (state == (int)cur_state) {
+ if (state == int(cur_state)) {
return GHOST_kSuccess;
}
diff --git a/intern/guardedalloc/intern/leak_detector.cc b/intern/guardedalloc/intern/leak_detector.cc
index 48df71e410d..288d78fd206 100644
--- a/intern/guardedalloc/intern/leak_detector.cc
+++ b/intern/guardedalloc/intern/leak_detector.cc
@@ -36,7 +36,7 @@ class MemLeakPrinter {
const size_t mem_in_use = MEM_get_memory_in_use();
printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
leaked_blocks,
- (double)mem_in_use / 1024 / 1024);
+ double(mem_in_use) / 1024 / 1024);
MEM_printmemlist();
if (fail_on_memleak) {
diff --git a/intern/sky/source/sky_model.cpp b/intern/sky/source/sky_model.cpp
index d67fe08772d..4181605b9e4 100644
--- a/intern/sky/source/sky_model.cpp
+++ b/intern/sky/source/sky_model.cpp
@@ -120,8 +120,8 @@ static void ArHosekSkyModel_CookConfiguration(ArHosekSkyModel_Dataset dataset,
{
const double *elev_matrix;
- int int_turbidity = (int)turbidity;
- double turbidity_rem = turbidity - (double)int_turbidity;
+ int int_turbidity = int(turbidity);
+ double turbidity_rem = turbidity - double(int_turbidity);
solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));
@@ -195,8 +195,8 @@ static double ArHosekSkyModel_CookRadianceConfiguration(ArHosekSkyModel_Radiance
{
const double *elev_matrix;
- int int_turbidity = (int)turbidity;
- double turbidity_rem = turbidity - (double)int_turbidity;
+ int int_turbidity = int(turbidity);
+ double turbidity_rem = turbidity - double(int_turbidity);
double res;
solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));
@@ -274,7 +274,7 @@ double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state,
double gamma,
double wavelength)
{
- int low_wl = (int)((wavelength - 320.0) / 40.0);
+ int low_wl = int((wavelength - 320.0) / 40.0);
if (low_wl < 0 || low_wl >= 11) {
return 0.0;