[Bf-blender-cvs] [62f2204d65e] master: Cleanup: rename len to str_len for BLF functions

Campbell Barton noreply at git.blender.org
Mon Aug 23 07:28:56 CEST 2021


Commit: 62f2204d65ef52b5efc38cb3657f1f97fa73acd7
Author: Campbell Barton
Date:   Mon Aug 23 15:01:52 2021 +1000
Branches: master
https://developer.blender.org/rB62f2204d65ef52b5efc38cb3657f1f97fa73acd7

Cleanup: rename len to str_len for BLF functions

Make it obvious which variable this is the length of.

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

M	source/blender/blenfont/BLF_api.h
M	source/blender/blenfont/intern/blf.c
M	source/blender/blenfont/intern/blf_default.c
M	source/blender/blenfont/intern/blf_font.c
M	source/blender/blenfont/intern/blf_internal.h

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

diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index eb3f9805240..4de7e704a7e 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -98,13 +98,13 @@ void BLF_batch_draw_flush(void);
 void BLF_batch_draw_end(void);
 
 /* Draw the string using the current font. */
-void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+void BLF_draw_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info)
     ATTR_NONNULL(2);
-void BLF_draw(int fontid, const char *str, size_t len) ATTR_NONNULL(2);
-void BLF_draw_ascii_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2);
+void BLF_draw_ascii_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info)
     ATTR_NONNULL(2);
-void BLF_draw_ascii(int fontid, const char *str, size_t len) ATTR_NONNULL(2);
-int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth) ATTR_NONNULL(2);
+void BLF_draw_ascii(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2);
+int BLF_draw_mono(int fontid, const char *str, size_t str_len, int cwidth) ATTR_NONNULL(2);
 
 typedef bool (*BLF_GlyphBoundsFn)(const char *str,
                                   const size_t str_step_ofs,
@@ -116,43 +116,45 @@ typedef bool (*BLF_GlyphBoundsFn)(const char *str,
 
 void BLF_boundbox_foreach_glyph_ex(int fontid,
                                    const char *str,
-                                   size_t len,
+                                   size_t str_len,
                                    BLF_GlyphBoundsFn user_fn,
                                    void *user_data,
                                    struct ResultBLF *r_info) ATTR_NONNULL(2);
 void BLF_boundbox_foreach_glyph(int fontid,
                                 const char *str,
-                                size_t len,
+                                size_t str_len,
                                 BLF_GlyphBoundsFn user_fn,
                                 void *user_data) ATTR_NONNULL(2);
 
 /* Get the string byte offset that fits within a given width */
-size_t BLF_width_to_strlen(int fontid, const char *str, size_t len, float width, float *r_width)
-    ATTR_NONNULL(2);
+size_t BLF_width_to_strlen(
+    int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_NONNULL(2);
 /* Same as BLF_width_to_strlen but search from the string end */
-size_t BLF_width_to_rstrlen(int fontid, const char *str, size_t len, float width, float *r_width)
-    ATTR_NONNULL(2);
+size_t BLF_width_to_rstrlen(
+    int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_NONNULL(2);
 
 /* This function return the bounding box of the string
  * and are not multiplied by the aspect.
  */
 void BLF_boundbox_ex(int fontid,
                      const char *str,
-                     size_t len,
+                     size_t str_len,
                      struct rctf *box,
                      struct ResultBLF *r_info) ATTR_NONNULL(2);
-void BLF_boundbox(int fontid, const char *str, size_t len, struct rctf *box) ATTR_NONNULL();
+void BLF_boundbox(int fontid, const char *str, size_t str_len, struct rctf *box) ATTR_NONNULL();
 
 /* The next both function return the width and height
  * of the string, using the current font and both value
  * are multiplied by the aspect of the font.
  */
-float BLF_width_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+float BLF_width_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info)
     ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
-float BLF_width(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-float BLF_height_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+float BLF_width(int fontid, const char *str, size_t str_len) ATTR_WARN_UNUSED_RESULT
+    ATTR_NONNULL();
+float BLF_height_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info)
     ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
-float BLF_height(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float BLF_height(int fontid, const char *str, size_t str_len) ATTR_WARN_UNUSED_RESULT
+    ATTR_NONNULL();
 
 /* Return dimensions of the font without any sample text. */
 int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT;
@@ -163,8 +165,8 @@ float BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT;
 /* The following function return the width and height of the string, but
  * just in one call, so avoid extra freetype2 stuff.
  */
-void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_width, float *r_height)
-    ATTR_NONNULL();
+void BLF_width_and_height(
+    int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL();
 
 /* For fixed width fonts only, returns the width of a
  * character.
@@ -221,9 +223,9 @@ void BLF_buffer_col(int fontid, const float rgba[4]) ATTR_NONNULL(2);
 /* Draw the string into the buffer, this function draw in both buffer,
  * float and unsigned char _BUT_ it's not necessary set both buffer, NULL is valid here.
  */
-void BLF_draw_buffer_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+void BLF_draw_buffer_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info)
     ATTR_NONNULL(2);
-void BLF_draw_buffer(int fontid, const char *str, size_t len) ATTR_NONNULL(2);
+void BLF_draw_buffer(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2);
 
 /* Add a path to the font dir paths. */
 void BLF_dir_add(const char *path) ATTR_NONNULL();
@@ -254,8 +256,9 @@ void BLF_default_dpi(int dpi);
 void BLF_default_set(int fontid);
 int BLF_default(void); /* get default font ID so we can pass it to other functions */
 /* Draw the string using the default font, size and dpi. */
-void BLF_draw_default(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
-void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
+void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL();
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t str_len)
+    ATTR_NONNULL();
 /* Set size and DPI, and return default font ID. */
 int BLF_set_default(void);
 
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 2f9eb0753ac..86d67c80fd4 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -521,7 +521,7 @@ static void blf_draw_gl__end(FontBLF *font)
   }
 }
 
-void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+void BLF_draw_ex(int fontid, const char *str, const size_t str_len, struct ResultBLF *r_info)
 {
   FontBLF *font = blf_get(fontid);
 
@@ -530,27 +530,27 @@ void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_in
   if (font) {
     blf_draw_gl__start(font);
     if (font->flags & BLF_WORD_WRAP) {
-      blf_font_draw__wrap(font, str, len, r_info);
+      blf_font_draw__wrap(font, str, str_len, r_info);
     }
     else {
-      blf_font_draw(font, str, len, r_info);
+      blf_font_draw(font, str, str_len, r_info);
     }
     blf_draw_gl__end(font);
   }
 }
-void BLF_draw(int fontid, const char *str, size_t len)
+void BLF_draw(int fontid, const char *str, const size_t str_len)
 {
-  if (len == 0 || str[0] == '\0') {
+  if (str_len == 0 || str[0] == '\0') {
     return;
   }
 
   /* Avoid bgl usage to corrupt BLF drawing. */
   GPU_bgl_end();
 
-  BLF_draw_ex(fontid, str, len, NULL);
+  BLF_draw_ex(fontid, str, str_len, NULL);
 }
 
-void BLF_draw_ascii_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
+void BLF_draw_ascii_ex(int fontid, const char *str, const size_t str_len, struct ResultBLF *r_info)
 {
   FontBLF *font = blf_get(fontid);
 
@@ -560,27 +560,27 @@ void BLF_draw_ascii_ex(int fontid, const char *str, size_t len, struct ResultBLF
     blf_draw_gl__start(font);
     if (font->flags & BLF_WORD_WRAP) {
       /* Use non-ASCII draw function for word-wrap. */
-      blf_font_draw__wrap(font, str, len, r_info);
+      blf_font_draw__wrap(font, str, str_len, r_info);
     }
     else {
-      blf_font_draw_ascii(font, str, len, r_info);
+      blf_font_draw_ascii(font, str, str_len, r_info);
     }
     blf_draw_gl__end(font);
   }
 }
 
-void BLF_draw_ascii(int fontid, const char *str, size_t len)
+void BLF_draw_ascii(int fontid, const char *str, const size_t str_len)
 {
-  if (len == 0 || str[0] == '\0') {
+  if (str_len == 0 || str[0] == '\0') {
     return;
   }
 
-  BLF_draw_ascii_ex(fontid, str, len, NULL);
+  BLF_draw_ascii_ex(fontid, str, str_len, NULL);
 }
 
-int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
+int BLF_draw_mono(int fontid, const char *str, const size_t str_len, int cwidth)
 {
-  if (len == 0 || str[0] == '\0') {
+  if (str_len == 0 || str[0] == '\0') {
     return 0;
   }
 
@@ -589,7 +589,7 @@ int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
 
   if (font) {
     blf_draw_gl__start(font);
-    columns = blf_font_draw_mono(font, str, len, cwidth);
+    columns = blf_font_draw_mono(font, str, str_len, cwidth);
     blf_draw_gl__end(font);
   }
 
@@ -606,7 +606,7 @@ int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
  */
 void BLF_boundbox_foreach_glyph_ex(int fontid,
                                    const char *str,
-                                   size_t len,
+                                   size_t str_len,
                                    BLF_GlyphBoundsFn user_fn,
                                    void *user_data,
                                    struct ResultBLF *r_info)
@@ -621,25 +621,26 @@ void BLF_boundbox_foreach_glyph_ex(int fontid,
       BLI_assert(0);
     }
     else {
-      blf_font_boundbox_foreach_glyph(font, str, len, user_fn, user_data, r_info);
+      blf_font_boundbox_foreach_glyph(font, str, str_len, user_fn, user_data, r_info);
     }
   }
 }
 
 void BLF_boundbox_foreach_glyph(
-    int fontid, co

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list