diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_callbacks.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_gsqueue.h | 50 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_rect.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_vfontdata.h | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/gsqueue.c | 46 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 31 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 13 | ||||
-rw-r--r-- | source/blender/blenlib/intern/voronoi.c | 2 |
13 files changed, 99 insertions, 88 deletions
diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 1e95510f6ec..e3d5a80b27f 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -54,7 +54,7 @@ typedef enum { } eCbEvent; -typedef struct { +typedef struct bCallbackFuncStore { struct bCallbackFuncStore *next, *prev; void (*func)(struct Main *, struct ID *, void *arg); void *arg; diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h index b9d8a8f9d14..e002545d189 100644 --- a/source/blender/blenlib/BLI_gsqueue.h +++ b/source/blender/blenlib/BLI_gsqueue.h @@ -36,63 +36,13 @@ typedef struct _GSQueue GSQueue; -/** - * Create a new GSQueue. - * - * \param elem_size The size of the structures in the queue. - * \retval The new queue - */ GSQueue *BLI_gsqueue_new(int elem_size); - -/** - * Query if the queue is empty - */ bool BLI_gsqueue_is_empty(GSQueue *gq); - -/** - * Query number elements in the queue - */ int BLI_gsqueue_size(GSQueue *gq); - -/** - * Access the item at the head of the queue - * without removing it. - * - * \param item_r A pointer to an appropriately - * sized structure (the size passed to BLI_gsqueue_new) - */ void BLI_gsqueue_peek(GSQueue *gq, void *item_r); - -/** - * Access the item at the head of the queue - * and remove it. - * - * \param item_r A pointer to an appropriately - * sized structure (the size passed to BLI_gsqueue_new). - * Can be NULL if desired. - */ void BLI_gsqueue_pop(GSQueue *gq, void *item_r); - -/** - * Push an element onto the tail of the queue. - * - * \param item A pointer to an appropriately - * sized structure (the size passed to BLI_gsqueue_new). - */ void BLI_gsqueue_push(GSQueue *gq, void *item); - -/** - * Push an element back onto the head of the queue (so - * it would be returned from the next call to BLI_gsqueue_pop). - * - * \param item A pointer to an appropriately - * sized structure (the size passed to BLI_gsqueue_new). - */ void BLI_gsqueue_pushback(GSQueue *gq, void *item); - -/** - * Free the queue - */ void BLI_gsqueue_free(GSQueue *gq); #endif /* __BLI_GSQUEUE_H__ */ diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 94fa88801f0..7028c7c7530 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -118,7 +118,7 @@ int isect_ray_plane_v3(const float p1[3], const float d[3], float *r_lambda, const int clip); int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], - const float plane_co[3], const float plane_no[3], const short no_flip); + const float plane_co[3], const float plane_no[3], const bool no_flip); void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], const float plane_a_co[3], const float plane_a_no[3], @@ -170,7 +170,7 @@ int isect_axial_line_tri_v3(const int axis, const float co1[3], const float co2[ int clip_line_plane(float p1[3], float p2[3], const float plane[4]); -void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData); +void plot_line_v2v2i(const int p1[2], const int p2[2], bool (*callback)(int, int, void *), void *userData); /****************************** Interpolation ********************************/ diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 136a51cf55e..1ba3c8b619c 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -170,14 +170,6 @@ bool BLI_path_is_rel(const char *path); # define BLI_path_ncmp strncmp #endif -/** - * Change every \a from in \a string into \a to. The - * result will be in \a string - * - * \a string The string to work on - * \a from The character to replace - * \a to The character to replace with - */ void BLI_char_switch(char *string, char from, char to) #ifdef __GNUC__ __attribute__((nonnull(1))) @@ -190,13 +182,9 @@ void BLI_init_program_path(const char *argv0); * NOTE: On Window userdir will be set to the temporary directory! */ void BLI_init_temporary_dir(char *userdir); -/* Path to executable */ const char *BLI_program_path(void); -/* Path to directory of executable */ const char *BLI_program_dir(void); -/* Path to temporary directory (with trailing slash) */ const char *BLI_temporary_dir(void); -/* Path to the system temporary directory (with trailing slash) */ void BLI_system_temporary_dir(char *dir); #ifdef WITH_ICONV diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 9ce75de5ea8..ac0ae22c656 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -54,6 +54,8 @@ void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]); void BLI_rctf_translate(struct rctf *rect, float x, float y); void BLI_rcti_translate(struct rcti *rect, int x, int y); +void BLI_rcti_recenter(struct rcti *rect, int x, int y); +void BLI_rctf_recenter(struct rctf *rect, float x, float y); void BLI_rcti_resize(struct rcti *rect, int x, int y); void BLI_rctf_resize(struct rctf *rect, float x, float y); void BLI_rcti_scale(rcti *rect, const float scale); diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index ed7d10ab257..b0a57ee9288 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -53,14 +53,6 @@ typedef struct VChar { float *points; } VChar; -/** - * Construct a new VFontData structure from - * Freetype font data in a PackedFile. - * - * \param pf The font data. - * \retval A new VFontData structure, or NULL - * if unable to load. - */ VFontData *BLI_vfontdata_from_freetypefont(struct PackedFile *pf); int BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character); diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 29280c36222..8b3cfd07ee9 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -423,7 +423,7 @@ enum { /* error occured in callback and recursive walking should stop immediately */ RecursiveOp_Callback_Error = 2 -} recuresiveOp_Callback_Result; +}; typedef int (*RecursiveOp_Callback)(const char *from, const char *to); @@ -498,7 +498,7 @@ static int recursive_operation(const char *startfrom, const char *startto, break; } - n = scandir(startfrom, &dirlist, 0, alphasort); + n = scandir(startfrom, &dirlist, NULL, alphasort); if (n < 0) { /* error opening directory for listing */ perror("scandir"); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 2b3e2d233d9..24a8edae325 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -467,7 +467,14 @@ static int check_freetypefont(PackedFile *pf) return success; } - +/** + * Construct a new VFontData structure from + * Freetype font data in a PackedFile. + * + * \param pf The font data. + * \retval A new VFontData structure, or NULL + * if unable to load. + */ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf) { VFontData *vfd = NULL; diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c index 272f840296e..7f158bc3efb 100644 --- a/source/blender/blenlib/intern/gsqueue.c +++ b/source/blender/blenlib/intern/gsqueue.c @@ -47,6 +47,12 @@ struct _GSQueue { int elem_size; }; +/** + * Create a new GSQueue. + * + * \param elem_size The size of the structures in the queue. + * \retval The new queue + */ GSQueue *BLI_gsqueue_new(int elem_size) { GSQueue *gq = MEM_mallocN(sizeof(*gq), "gqueue_new"); @@ -56,11 +62,17 @@ GSQueue *BLI_gsqueue_new(int elem_size) return gq; } +/** + * Query if the queue is empty + */ bool BLI_gsqueue_is_empty(GSQueue *gq) { return (gq->head == NULL); } +/** + * Query number elements in the queue + */ int BLI_gsqueue_size(GSQueue *gq) { GSQueueElem *elem; @@ -72,10 +84,26 @@ int BLI_gsqueue_size(GSQueue *gq) return size; } +/** + * Access the item at the head of the queue + * without removing it. + * + * \param item_r A pointer to an appropriately + * sized structure (the size passed to BLI_gsqueue_new) + */ void BLI_gsqueue_peek(GSQueue *gq, void *item_r) { memcpy(item_r, &gq->head[1], gq->elem_size); } + +/** + * Access the item at the head of the queue + * and remove it. + * + * \param item_r A pointer to an appropriately + * sized structure (the size passed to BLI_gsqueue_new). + * Can be NULL if desired. + */ void BLI_gsqueue_pop(GSQueue *gq, void *item_r) { GSQueueElem *elem = gq->head; @@ -89,6 +117,13 @@ void BLI_gsqueue_pop(GSQueue *gq, void *item_r) if (item_r) memcpy(item_r, &elem[1], gq->elem_size); MEM_freeN(elem); } + +/** + * Push an element onto the tail of the queue. + * + * \param item A pointer to an appropriately + * sized structure (the size passed to BLI_gsqueue_new). + */ void BLI_gsqueue_push(GSQueue *gq, void *item) { GSQueueElem *elem; @@ -109,6 +144,14 @@ void BLI_gsqueue_push(GSQueue *gq, void *item) gq->tail = gq->tail->next = elem; } } + +/** + * Push an element back onto the head of the queue (so + * it would be returned from the next call to BLI_gsqueue_pop). + * + * \param item A pointer to an appropriately + * sized structure (the size passed to BLI_gsqueue_new). + */ void BLI_gsqueue_pushback(GSQueue *gq, void *item) { GSQueueElem *elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push"); @@ -123,6 +166,9 @@ void BLI_gsqueue_pushback(GSQueue *gq, void *item) } } +/** + * Free the queue + */ void BLI_gsqueue_free(GSQueue *gq) { while (gq->head) { diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 173c6d06861..579f397f833 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1087,7 +1087,7 @@ int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], */ int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], - const float plane_co[3], const float plane_no[3], const short no_flip) + const float plane_co[3], const float plane_no[3], const bool no_flip) { float l_vec[3]; /* l1 -> l2 normalized vector */ float p_no[3]; /* 'plane_no' normalized */ @@ -1997,7 +1997,7 @@ int clip_line_plane(float p1[3], float p2[3], const float plane[4]) } } -void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData) +void plot_line_v2v2i(const int p1[2], const int p2[2], bool (*callback)(int, int, void *), void *userData) { int x1 = p1[0]; int y1 = p1[1]; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index c3bc35a906b..f9cf913157b 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -122,6 +122,7 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu if (found_digit) break; } } + if (found_digit) { if (tail) strcpy(tail, &string[nume + 1]); if (head) { @@ -131,13 +132,14 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu if (numlen) *numlen = nume - nums + 1; return ((int)atoi(&(string[nums]))); } - if (tail) strcpy(tail, string + name_end); - if (head) { - strncpy(head, string, name_end); - head[name_end] = '\0'; + else { + if (tail) strcpy(tail, string + name_end); + if (head) { + BLI_strncpy(head, string, name_end); + } + if (numlen) *numlen = 0; + return 0; } - if (numlen) *numlen = 0; - return 0; } @@ -1364,7 +1366,12 @@ void BLI_clean(char *path) } /** - * Replaces occurrences of from with to in *string. + * Change every \a from in \a string into \a to. The + * result will be in \a string + * + * \param string The string to work on + * \param from The character to replace + * \param to The character to replace with */ void BLI_char_switch(char *string, char from, char to) { @@ -2060,11 +2067,17 @@ void BLI_init_program_path(const char *argv0) BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir)); } +/** + * Path to executable + */ const char *BLI_program_path(void) { return bprogname; } +/** + * Path to directory of executable + */ const char *BLI_program_dir(void) { return bprogdir; @@ -2137,7 +2150,7 @@ void BLI_init_temporary_dir(char *userdir) } /** - * Returns the path to the temporary directory. + * Path to temporary directory (with trailing slash) */ const char *BLI_temporary_dir(void) { @@ -2145,7 +2158,7 @@ const char *BLI_temporary_dir(void) } /** - * Puts in *dir path to OS-specific temporary directory. + * Path to the system temporary directory (with trailing slash) */ void BLI_system_temporary_dir(char *dir) { diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 127855161c0..91fcb5a5b83 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -296,6 +296,19 @@ void BLI_rctf_translate(rctf *rect, float x, float y) rect->ymax += y; } +void BLI_rcti_recenter(rcti *rect, int x, int y) +{ + const int dx = x - BLI_rcti_cent_x(rect); + const int dy = y - BLI_rcti_cent_y(rect); + BLI_rcti_translate(rect, dx, dy); +} +void BLI_rctf_recenter(rctf *rect, float x, float y) +{ + const float dx = x - BLI_rctf_cent_x(rect); + const float dy = y - BLI_rctf_cent_y(rect); + BLI_rctf_translate(rect, dx, dy); +} + /* change width & height around the central location */ void BLI_rcti_resize(rcti *rect, int x, int y) { diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 601b07c9a5d..7a545090090 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -44,7 +44,7 @@ enum { voronoiEventType_Site = 0, voronoiEventType_Circle = 1 -} voronoiEventType; +}; typedef struct VoronoiEvent { struct VoronoiEvent *next, *prev; |