[Bf-blender-cvs] [3a7dc572dc9] master: Cleanup: use 'u' prefixed unsigned types for GHOST

Campbell Barton noreply at git.blender.org
Mon Sep 26 02:54:39 CEST 2022


Commit: 3a7dc572dc9bbad35bdff3a3aeca8eab0ccb3fb7
Author: Campbell Barton
Date:   Mon Sep 26 10:32:09 2022 +1000
Branches: master
https://developer.blender.org/rB3a7dc572dc9bbad35bdff3a3aeca8eab0ccb3fb7

Cleanup: use 'u' prefixed unsigned types for GHOST

===================================================================

M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_Context.cpp
M	intern/ghost/intern/GHOST_ContextEGL.cpp
M	intern/ghost/intern/GHOST_ContextGLX.cpp
M	intern/ghost/intern/GHOST_ContextWGL.cpp
M	intern/ghost/intern/GHOST_DropTargetWin32.cpp
M	intern/ghost/intern/GHOST_DropTargetX11.cpp
M	intern/ghost/intern/GHOST_ImeWin32.cpp
M	intern/ghost/intern/GHOST_NDOFManager.cpp
M	intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
M	intern/ghost/intern/GHOST_PathUtils.cpp
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_Window.cpp
M	intern/ghost/intern/GHOST_WindowSDL.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp
M	intern/ghost/intern/GHOST_WindowX11.h
M	intern/ghost/intern/GHOST_Wintab.cpp
M	intern/ghost/intern/GHOST_XrControllerModel.cpp

===================================================================

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 80a71bb7dfe..182eb6eb7d2 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -11,6 +11,12 @@
 
 #ifdef WITH_CXX_GUARDEDALLOC
 #  include "MEM_guardedalloc.h"
+#else
+/* Convenience unsigned abbreviations (#WITH_CXX_GUARDEDALLOC defines these). */
+typedef unsigned int uint;
+typedef unsigned short ushort;
+typedef unsigned long ulong;
+typedef unsigned char uchar;
 #endif
 
 #if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus)
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 710512881e8..1ec7d2f926c 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -722,14 +722,14 @@ GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle)
   return context->releaseDrawingContext();
 }
 
-unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle)
+uint GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle)
 {
   GHOST_IContext *context = (GHOST_IContext *)contexthandle;
 
   return context->getDefaultFramebuffer();
 }
 
-unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle)
+uint GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle)
 {
   GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
 
@@ -1125,8 +1125,7 @@ void *GHOST_XrGetActionCustomdata(GHOST_XrContextHandle xr_contexthandle,
   return 0;
 }
 
-unsigned int GHOST_XrGetActionCount(GHOST_XrContextHandle xr_contexthandle,
-                                    const char *action_set_name)
+uint GHOST_XrGetActionCount(GHOST_XrContextHandle xr_contexthandle, const char *action_set_name)
 {
   GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
   GHOST_XrSession *xr_session = xr_context->getSession();
diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp
index aa379efbc1f..17ee39d952c 100644
--- a/intern/ghost/intern/GHOST_Context.cpp
+++ b/intern/ghost/intern/GHOST_Context.cpp
@@ -100,15 +100,10 @@ bool win32_chk(bool result, const char *file, int line, const char *text)
     }
 
 #  ifndef NDEBUG
-    _ftprintf(stderr,
-              "%s(%d):[%s] -> Win32 Error# (%lu): %s",
-              file,
-              line,
-              text,
-              (unsigned long)error,
-              msg);
+    _ftprintf(
+        stderr, "%s(%d):[%s] -> Win32 Error# (%lu): %s", file, line, text, ulong(error), msg);
 #  else
-    _ftprintf(stderr, "Win32 Error# (%lu): %s", (unsigned long)error, msg);
+    _ftprintf(stderr, "Win32 Error# (%lu): %s", ulong(error), msg);
 #  endif
 
     SetLastError(NO_ERROR);
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp
index ef13133d3a3..fb1865630e3 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -127,13 +127,13 @@ static bool egl_chk(bool result,
             file,
             line,
             text,
-            static_cast<unsigned int>(error),
+            uint(error),
             code ? code : "<Unknown>",
             msg ? msg : "<Unknown>");
 #else
     fprintf(stderr,
             "EGL Error (0x%04X): %s: %s\n",
-            static_cast<unsigned int>(error),
+            uint(error),
             code ? code : "<Unknown>",
             msg ? msg : "<Unknown>");
     (void)(file);
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index ed1c874c236..e5f2e707f32 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -264,7 +264,7 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
   GHOST_TSuccess success;
 
   if (m_context != nullptr) {
-    const unsigned char *version;
+    const uchar *version;
 
     if (!s_sharedContext) {
       s_sharedContext = m_context;
@@ -316,7 +316,7 @@ GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval)
 GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
 {
   if (epoxy_has_glx_extension(m_display, DefaultScreen(m_display), "GLX_EXT_swap_control")) {
-    unsigned int interval = 0;
+    uint interval = 0;
 
     ::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval);
 
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index d3c190a13b1..0b1cf56c549 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -437,7 +437,7 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlp
 
   makeAttribList(iAttributes, stereoVisual, needAlpha);
 
-  UINT nNumFormats;
+  uint nNumFormats;
   WIN32_CHK(wglChoosePixelFormatARB(
       m_hDC, &(iAttributes[0]), NULL, _MAX_PIXEL_FORMATS, iPixelFormats, &nNumFormats));
 
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
index a38af619662..86483118b3d 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
@@ -212,13 +212,13 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *p_data_object)
     if (p_data_object->GetData(&fmtetc, &stgmed) == S_OK) {
       const HDROP hdrop = (HDROP)::GlobalLock(stgmed.hGlobal);
 
-      const UINT totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0);
+      const uint totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0);
       if (totfiles) {
         str_array = (GHOST_TStringArray *)::malloc(sizeof(GHOST_TStringArray));
         str_array->count = 0;
         str_array->strings = (uint8_t **)::malloc(totfiles * sizeof(uint8_t *));
 
-        for (UINT nfile = 0; nfile < totfiles; nfile++) {
+        for (uint nfile = 0; nfile < totfiles; nfile++) {
           WCHAR fpath[MAX_PATH];
           if (::DragQueryFileW(hdrop, nfile, fpath, MAX_PATH) > 0) {
             char *temp_path;
diff --git a/intern/ghost/intern/GHOST_DropTargetX11.cpp b/intern/ghost/intern/GHOST_DropTargetX11.cpp
index 1403639a36f..b37aa410198 100644
--- a/intern/ghost/intern/GHOST_DropTargetX11.cpp
+++ b/intern/ghost/intern/GHOST_DropTargetX11.cpp
@@ -107,7 +107,7 @@ char *GHOST_DropTargetX11::FileUrlDecode(char *fileUrl)
   return nullptr;
 }
 
-void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dropBufferSize)
+void *GHOST_DropTargetX11::getURIListGhostData(uchar *dropBuffer, int dropBufferSize)
 {
   GHOST_TStringArray *strArray = nullptr;
   int totPaths = 0, curLength = 0;
@@ -157,12 +157,10 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
   return strArray;
 }
 
-void *GHOST_DropTargetX11::getGhostData(Atom dropType,
-                                        unsigned char *dropBuffer,
-                                        int dropBufferSize)
+void *GHOST_DropTargetX11::getGhostData(Atom dropType, uchar *dropBuffer, int dropBufferSize)
 {
   void *data = nullptr;
-  unsigned char *tmpBuffer = (unsigned char *)malloc(dropBufferSize + 1);
+  uchar *tmpBuffer = (uchar *)malloc(dropBufferSize + 1);
   bool needsFree = true;
 
   /* Ensure nil-terminator. */
@@ -201,7 +199,7 @@ void *GHOST_DropTargetX11::getGhostData(Atom dropType,
 bool GHOST_DropTargetX11::GHOST_HandleClientMessage(XEvent *event)
 {
   Atom dropType;
-  unsigned char *dropBuffer;
+  uchar *dropBuffer;
   int dropBufferSize, dropX, dropY;
 
   if (xdnd_get_drop(m_system->getXDisplay(),
diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp
index 0a62359cd77..780d93ac995 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.cpp
+++ b/intern/ghost/intern/GHOST_ImeWin32.cpp
@@ -270,7 +270,7 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c
   else if (IsLanguage(IMELANG_CHINESE)) {
     int clause_size = ImmGetCompositionStringW(imm_context, GCS_COMPCLAUSE, NULL, 0);
     if (clause_size) {
-      static std::vector<unsigned long> clauses;
+      static std::vector<ulong> clauses;
       clause_size = clause_size / sizeof(clauses[0]);
       clauses.resize(clause_size);
       ImmGetCompositionStringW(
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index 0945f542803..b1bd5287d24 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -150,7 +150,7 @@ GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys)
   memset(m_rotation, 0, sizeof(m_rotation));
 }
 
-bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short product_id)
+bool GHOST_NDOFManager::setDevice(ushort vendor_id, ushort product_id)
 {
   /* Call this function until it returns true
    * it's a good idea to stop calling it after that, as it will "forget"
diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
index 6cf9aa1ed04..94bf0337371 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
@@ -31,7 +31,7 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys)
     if (command_output) {
       char line[MAX_LINE_LENGTH] = {0};
       while (fgets(line, MAX_LINE_LENGTH, command_output)) {
-        unsigned short vendor_id = 0, product_id = 0;
+        ushort vendor_id = 0, product_id = 0;
         if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) {
           if (setDevice(vendor_id, product_id)) {
             break; /* stop looking once the first 3D mouse is found */
diff --git a/intern/ghost/intern/GHOST_PathUtils.cpp b/intern/ghost/intern/GHOST_PathUtils.cpp
index bcccd369460..2161708fb3c 100644
--- a/intern/ghost/intern/GHOST_PathUtils.cpp
+++ b/intern/ghost/intern/GHOST_PathUtils.cpp
@@ -25,14 +25,14 @@ using DecodeState_e = enum DecodeState_e {
 
 void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src)
 {
-  const unsigned int buf_src_len = strlen(buf_src);
+  const uint buf_src_len = strlen(buf_src);
   DecodeState_e state = STATE_SEARCH;
-  unsigned int ascii_character;
+  uint ascii_character;
   char temp_num_bu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list