diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 00:39:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 00:39:39 +0400 |
commit | 9892736206676c5b7fabc8d1184f9655511ff2dd (patch) | |
tree | 83562ac50c93fe3004959d35c1af4a5b380fdd97 /source/blender/blenlib | |
parent | cffaa42d3a34c6b310c3c87c98e1f8313881e473 (diff) |
code cleanup: header cleanup and remove some duplicate defines.
Diffstat (limited to 'source/blender/blenlib')
40 files changed, 756 insertions, 774 deletions
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h index 7a7529fa3c3..7a240e0e08a 100644 --- a/source/blender/blenlib/BLI_args.h +++ b/source/blender/blenlib/BLI_args.h @@ -37,7 +37,7 @@ struct bArgs; typedef struct bArgs bArgs; /* returns the number of extra arguments consumed by the function. 0 is normal value, -1 stops parsing arguments, other negative indicates skip */ -typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data); +typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data); struct bArgs *BLI_argsInit(int argc, const char **argv); void BLI_argsFree(struct bArgs *ba); diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 7069732eeb6..4fbed23d5e6 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -45,7 +45,7 @@ * * for (i=0; i<10; i++) { * BLI_array_grow_one(arr); - * arr[i] = something; + * arr[i] = something; * } * BLI_array_free(arr); * @@ -105,7 +105,7 @@ arr, \ sizeof(*arr) * _##arr##_count) \ ), \ - (void) (arr && ((void *)(arr) != (void*)_##arr##_static ? \ + (void) (arr && ((void *)(arr) != (void *)_##arr##_static ? \ (MEM_freeN(arr), arr) : \ arr) \ ), \ @@ -118,7 +118,7 @@ /* grow an array by a specified number of items */ #define BLI_array_grow_items(arr, num) ( \ ((void *)(arr) == NULL && (void *)(_##arr##_static) != NULL) ? \ - ((arr = (void*)_##arr##_static), (_##arr##_count += num)) : \ + ((arr = (void *)_##arr##_static), (_##arr##_count += num)) : \ _bli_array_grow_items(arr, num) \ ) diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index f19d6d6f465..02e5d6bd797 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -26,7 +26,7 @@ #ifndef __BLI_BITMAP_H__ #define __BLI_BITMAP_H__ -typedef unsigned int* BLI_bitmap; +typedef unsigned int *BLI_bitmap; /* warning: the bitmap does not keep track of its own size or check * for out-of-bounds access */ @@ -49,7 +49,7 @@ typedef unsigned int* BLI_bitmap; * with MEM_freeN() */ #define BLI_BITMAP_NEW(_tot, _alloc_string) \ ((BLI_bitmap)MEM_callocN(BLI_BITMAP_SIZE(_tot), \ - _alloc_string)) + _alloc_string)) /* get the value of a single bit at '_index' */ #define BLI_BITMAP_GET(_bitmap, _index) \ @@ -73,7 +73,7 @@ typedef unsigned int* BLI_bitmap; BLI_BITMAP_SET(_bitmap, _index); \ else \ BLI_BITMAP_CLEAR(_bitmap, _index); \ - } while(0) + } while (0) /* resize bitmap to have space for '_tot' bits */ #define BLI_BITMAP_RESIZE(_bitmap, _tot) \ diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index 27b373e6eb8..52b839d11a9 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -48,13 +48,13 @@ void BLI_bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVi void BLI_bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata); int BLI_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); -#define BLI_BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ -#define BLI_BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ -#define BLI_BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ -#define BLI_BPATH_TRAVERSE_SKIP_MULTIFILE (1<<4) /* skip paths where a single dir is used with an array of files, eg. - * sequence strip images and pointcache. in this case only use the first - * file, this is needed for directory manipulation functions which might - * otherwise modify the same directory multiple times */ +#define BLI_BPATH_TRAVERSE_ABS (1 << 0) /* convert paths to absolute */ +#define BLI_BPATH_TRAVERSE_SKIP_LIBRARY (1 << 2) /* skip library paths */ +#define BLI_BPATH_TRAVERSE_SKIP_PACKED (1 << 3) /* skip packed data */ +#define BLI_BPATH_TRAVERSE_SKIP_MULTIFILE (1 << 4) /* skip paths where a single dir is used with an array of files, eg. + * sequence strip images and pointcache. in this case only use the first + * file, this is needed for directory manipulation functions which might + * otherwise modify the same directory multiple times */ /* high level funcs */ diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index bfc336781aa..1e95510f6ec 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -56,7 +56,7 @@ typedef enum { typedef struct { struct bCallbackFuncStore *next, *prev; - void (* func)(struct Main *, struct ID *, void *arg); + void (*func)(struct Main *, struct ID *, void *arg); void *arg; short alloc; } bCallbackFuncStore; @@ -70,6 +70,6 @@ void BLI_callback_global_finalize(void); /* This is blenlib internal only, unrelated to above */ -void callLocalErrorCallBack(const char* msg); +void callLocalErrorCallBack(const char *msg); #endif /* __BLI_CALLBACKS_H__ */ diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index 7443d7a07fe..92356b24403 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -58,7 +58,7 @@ typedef struct DLRBT_Node { /* Red/Black defines for tree_col */ typedef enum eDLRBT_Colors { - DLRBT_BLACK= 0, + DLRBT_BLACK = 0, DLRBT_RED, } eDLRBT_Colors; @@ -67,10 +67,10 @@ typedef enum eDLRBT_Colors { /* The Tree Data */ typedef struct DLRBT_Tree { /* ListBase capabilities */ - void *first, *last; /* these should be based on DLRBT_Node-s */ + void *first, *last; /* these should be based on DLRBT_Node-s */ /* Root Node */ - void *root; /* this should be based on DLRBT_Node-s */ + void *root; /* this should be based on DLRBT_Node-s */ } DLRBT_Tree; /* Callback Types --------------------------------- */ @@ -87,7 +87,7 @@ typedef short (*DLRBT_Comparator_FP)(void *node, void *data); typedef DLRBT_Node *(*DLRBT_NAlloc_FP)(void *data); /* update an existing node instance accordingly to be in sync with the given data * - * - node: <DLRBT_Node> the node to update + * - node: <DLRBT_Node> the node to update * - data: pointer to the relevant data or values stored in the bitpattern dependent on the function */ typedef void (*DLRBT_NUpdate_FP)(void *node, void *data); @@ -137,7 +137,7 @@ short BLI_dlrbTree_contains(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void * /* Add the given data to the tree, and return the node added */ // NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, - DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data); + DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data); /* Remove the given element from the tree and balance again */ diff --git a/source/blender/blenlib/BLI_dynlib.h b/source/blender/blenlib/BLI_dynlib.h index d7c8706a7b8..7d5eb888021 100644 --- a/source/blender/blenlib/BLI_dynlib.h +++ b/source/blender/blenlib/BLI_dynlib.h @@ -35,9 +35,9 @@ typedef struct DynamicLibrary DynamicLibrary; DynamicLibrary *BLI_dynlib_open(char *name); -void *BLI_dynlib_find_symbol(DynamicLibrary* lib, const char *symname); -char *BLI_dynlib_get_error_as_string(DynamicLibrary* lib); -void BLI_dynlib_close(DynamicLibrary* lib); +void *BLI_dynlib_find_symbol(DynamicLibrary *lib, const char *symname); +char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib); +void BLI_dynlib_close(DynamicLibrary *lib); #endif /* __BLI_DYNLIB_H__ */ diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h index f2e62d6e6bd..3b7f2d6bbaf 100644 --- a/source/blender/blenlib/BLI_dynstr.h +++ b/source/blender/blenlib/BLI_dynstr.h @@ -42,23 +42,23 @@ struct DynStr; - /** The abstract DynStr type */ +/** The abstract DynStr type */ typedef struct DynStr DynStr; - /** - * Create a new DynStr. - * - * \return Pointer to a new DynStr. - */ -DynStr* BLI_dynstr_new (void); +/** + * Create a new DynStr. + * + * \return Pointer to a new DynStr. + */ +DynStr *BLI_dynstr_new(void); - /** - * Append a c-string to a DynStr. - * - * \param ds The DynStr to append to. - * \param cstr The c-string to append. - */ -void BLI_dynstr_append (DynStr *ds, const char *cstr); +/** + * Append a c-string to a DynStr. + * + * \param ds The DynStr to append to. + * \param cstr The c-string to append. + */ +void BLI_dynstr_append(DynStr *ds, const char *cstr); /** * Append a length clamped c-string to a DynStr. @@ -67,38 +67,38 @@ void BLI_dynstr_append (DynStr *ds, const char *cstr); * \param cstr The c-string to append. * \param len The maximum length of the c-string to copy. */ -void BLI_dynstr_nappend (DynStr *ds, const char *cstr, int len); +void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len); - /** - * Append a c-string to a DynStr, but with formatting like printf. - * - * \param ds The DynStr to append to. - * \param format The printf format string to use. - */ -void BLI_dynstr_appendf (DynStr *ds, const char *format, ...) +/** + * Append a c-string to a DynStr, but with formatting like printf. + * + * \param ds The DynStr to append to. + * \param format The printf format string to use. + */ +void BLI_dynstr_appendf(DynStr *ds, const char *format, ...) #ifdef __GNUC__ -__attribute__ ((format (printf, 2, 3))) +__attribute__ ((format(printf, 2, 3))) #endif ; -void BLI_dynstr_vappendf (DynStr *ds, const char *format, va_list args); +void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args); - /** - * Find the length of a DynStr. - * - * \param ds The DynStr of interest. - * \return The length of \a ds. - */ -int BLI_dynstr_get_len (DynStr *ds); +/** + * Find the length of a DynStr. + * + * \param ds The DynStr of interest. + * \return The length of \a ds. + */ +int BLI_dynstr_get_len(DynStr *ds); - /** - * Get a DynStr's contents as a c-string. - * <i> The returned c-string should be freed - * using MEM_freeN. </i> - * - * \param ds The DynStr of interest. - * \return The contents of \a ds as a c-string. - */ -char* BLI_dynstr_get_cstring (DynStr *ds); +/** + * Get a DynStr's contents as a c-string. + * <i> The returned c-string should be freed + * using MEM_freeN. </i> + * + * \param ds The DynStr of interest. + * \return The contents of \a ds as a c-string. + */ +char *BLI_dynstr_get_cstring(DynStr *ds); /** * Get a DynStr's contents as a c-string. @@ -109,14 +109,14 @@ char* BLI_dynstr_get_cstring (DynStr *ds); * \param str The string to fill. * \return The contents of \a ds as a c-string. */ -void BLI_dynstr_get_cstring_ex (DynStr *ds, char *str); +void BLI_dynstr_get_cstring_ex(DynStr *ds, char *str); - /** - * Free the DynStr - * - * \param ds The DynStr to free. - */ -void BLI_dynstr_free (DynStr *ds); +/** + * Free the DynStr + * + * \param ds The DynStr to free. + */ +void BLI_dynstr_free(DynStr *ds); #endif diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h index b00ac683eb1..8d7d3b05653 100644 --- a/source/blender/blenlib/BLI_edgehash.h +++ b/source/blender/blenlib/BLI_edgehash.h @@ -39,62 +39,62 @@ struct EdgeHashIterator; typedef struct EdgeHash EdgeHash; typedef struct EdgeHashIterator EdgeHashIterator; -typedef void (*EdgeHashFreeFP)(void *key); +typedef void (*EdgeHashFreeFP)(void *key); -EdgeHash* BLI_edgehash_new (void); -void BLI_edgehash_free (EdgeHash *eh, EdgeHashFreeFP valfreefp); +EdgeHash *BLI_edgehash_new(void); +void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp); - /* Insert edge (v0,v1) into hash with given value, does - * not check for duplicates. - */ -void BLI_edgehash_insert (EdgeHash *eh, unsigned int v0, unsigned int v1, void *val); +/* Insert edge (v0,v1) into hash with given value, does + * not check for duplicates. + */ +void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val); - /* Return value for given edge (v0,v1), or NULL if - * if key does not exist in hash. (If need exists - * to differentiate between key-value being NULL and - * lack of key then see BLI_edgehash_lookup_p(). - */ -void* BLI_edgehash_lookup (EdgeHash *eh, unsigned int v0, unsigned int v1); +/* Return value for given edge (v0,v1), or NULL if + * if key does not exist in hash. (If need exists + * to differentiate between key-value being NULL and + * lack of key then see BLI_edgehash_lookup_p(). + */ +void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1); - /* Return pointer to value for given edge (v0,v1), - * or NULL if key does not exist in hash. - */ -void** BLI_edgehash_lookup_p (EdgeHash *eh, unsigned int v0, unsigned int v1); +/* Return pointer to value for given edge (v0,v1), + * or NULL if key does not exist in hash. + */ +void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1); - /* Return boolean true/false if edge (v0,v1) in hash. */ -int BLI_edgehash_haskey (EdgeHash *eh, unsigned int v0, unsigned int v1); +/* Return boolean true/false if edge (v0,v1) in hash. */ +int BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1); - /* Return number of keys in hash. */ -int BLI_edgehash_size (EdgeHash *eh); +/* Return number of keys in hash. */ +int BLI_edgehash_size(EdgeHash *eh); - /* Remove all edges from hash. */ -void BLI_edgehash_clear (EdgeHash *eh, EdgeHashFreeFP valfreefp); +/* Remove all edges from hash. */ +void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp); /***/ - /** - * Create a new EdgeHashIterator. The hash table must not be mutated - * while the iterator is in use, and the iterator will step exactly - * BLI_edgehash_size(gh) times before becoming done. - */ -EdgeHashIterator* BLI_edgehashIterator_new (EdgeHash *eh); +/** + * Create a new EdgeHashIterator. The hash table must not be mutated + * while the iterator is in use, and the iterator will step exactly + * BLI_edgehash_size(gh) times before becoming done. + */ +EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh); + +/* Free an EdgeHashIterator. */ +void BLI_edgehashIterator_free(EdgeHashIterator *ehi); - /* Free an EdgeHashIterator. */ -void BLI_edgehashIterator_free (EdgeHashIterator *ehi); +/* Retrieve the key from an iterator. */ +void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r); - /* Retrieve the key from an iterator. */ -void BLI_edgehashIterator_getKey (EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r); - - /* Retrieve the value from an iterator. */ -void* BLI_edgehashIterator_getValue (EdgeHashIterator *ehi); +/* Retrieve the value from an iterator. */ +void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi); - /* Set the value for an iterator. */ -void BLI_edgehashIterator_setValue (EdgeHashIterator *ehi, void *val); +/* Set the value for an iterator. */ +void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val); - /* Steps the iterator to the next index. */ -void BLI_edgehashIterator_step (EdgeHashIterator *ehi); +/* Steps the iterator to the next index. */ +void BLI_edgehashIterator_step(EdgeHashIterator *ehi); - /* Determine if an iterator is done. */ -int BLI_edgehashIterator_isDone (EdgeHashIterator *ehi); +/* Determine if an iterator is done. */ +int BLI_edgehashIterator_isDone(EdgeHashIterator *ehi); #endif diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 1bf4efca8a0..ca810ee5b93 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -84,10 +84,10 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r); size_t BLI_file_descriptor_size(int file); size_t BLI_file_size(const char *file); - /* compare if one was last modified before the other */ +/* compare if one was last modified before the other */ int BLI_file_older(const char *file1, const char *file2); - /* read ascii file as lines, empty list if reading fails */ +/* read ascii file as lines, empty list if reading fails */ struct LinkNode *BLI_file_read_as_lines(const char *file); void BLI_file_free_lines(struct LinkNode *lines); diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h index d9f8549e8f5..a19909a8f26 100644 --- a/source/blender/blenlib/BLI_fileops_types.h +++ b/source/blender/blenlib/BLI_fileops_types.h @@ -41,35 +41,34 @@ typedef unsigned int mode_t; struct ImBuf; -struct direntry{ - char *string; - mode_t type; - char *relname; - char *path; -#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) +struct direntry { + char *string; + mode_t type; + char *relname; + char *path; +#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER >= 1500) struct _stat64 s; #elif defined(__MINGW32__) struct _stati64 s; #else - struct stat s; + struct stat s; #endif unsigned int flags; - char size[16]; - char mode1[4]; - char mode2[4]; - char mode3[4]; - char owner[16]; - char time[8]; - char date[16]; - char extra[16]; - void *poin; - int nr; + char size[16]; + char mode1[4]; + char mode2[4]; + char mode3[4]; + char owner[16]; + char time[8]; + char date[16]; + char extra[16]; + void *poin; + int nr; struct ImBuf *image; unsigned int selflag; /* selection flag */ }; -struct dirlink -{ +struct dirlink { struct dirlink *next, *prev; char *name; }; diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h index 5914d150d56..6c466759010 100644 --- a/source/blender/blenlib/BLI_fnmatch.h +++ b/source/blender/blenlib/BLI_fnmatch.h @@ -17,23 +17,23 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __BLI_FNMATCH_H__ -#define __BLI_FNMATCH_H__ +#ifndef __BLI_FNMATCH_H__ +#define __BLI_FNMATCH_H__ /** \file BLI_fnmatch.h * \ingroup bli */ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif -#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) -#undef __P -#define __P(protos) protos +#if defined(__cplusplus) || (defined(__STDC__) && __STDC__) +#undef __P +#define __P(protos) protos #else /* Not C++ or ANSI C. */ -#undef __P -#define __P(protos) () +#undef __P +#define __P(protos) () /* We can get away without defining `const' here only because in this file * it is used only inside the prototype for `fnmatch', which is elided in * non-ANSI C where `const' is problematical. */ @@ -42,30 +42,30 @@ extern "C" { /* We #undef these before defining them because some losing systems * (HP-UX A.08.07 for example) define these in <unistd.h>. */ -#undef FNM_PATHNAME -#undef FNM_NOESCAPE -#undef FNM_PERIOD +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD /* Bits set in the FLAGS argument to `fnmatch'. */ -#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ - -#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) || defined( __SUNPRO_C) -#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ -#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ + +#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined(_GNU_SOURCE) || defined(__SUNPRO_C) +#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ #endif /* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 +#define FNM_NOMATCH 1 /* Match STRING against the filename pattern PATTERN, * returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch __P ((const char *__pattern, const char *__string, - int __flags)); +extern int fnmatch __P((const char *__pattern, const char *__string, + int __flags)); -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index b178538edf2..b2532d0e486 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -37,10 +37,10 @@ extern "C" { #endif -typedef unsigned int (*GHashHashFP) (const void *key); -typedef int (*GHashCmpFP) (const void *a, const void *b); -typedef void (*GHashKeyFreeFP) (void *key); -typedef void (*GHashValFreeFP) (void *val); +typedef unsigned int (*GHashHashFP) (const void *key); +typedef int (*GHashCmpFP) (const void *a, const void *b); +typedef void (*GHashKeyFreeFP) (void *key); +typedef void (*GHashValFreeFP) (void *val); typedef struct Entry { struct Entry *next; @@ -49,8 +49,8 @@ typedef struct Entry { } Entry; typedef struct GHash { - GHashHashFP hashfp; - GHashCmpFP cmpfp; + GHashHashFP hashfp; + GHashCmpFP cmpfp; Entry **buckets; struct BLI_mempool *entrypool; @@ -65,71 +65,71 @@ typedef struct GHashIterator { /* *** */ -GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); -void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); +void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); void BLI_ghash_insert(GHash *gh, void *key, void *val); -void * BLI_ghash_lookup(GHash *gh, const void *key); +void *BLI_ghash_lookup(GHash *gh, const void *key); int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); int BLI_ghash_haskey(GHash *gh, void *key); -int BLI_ghash_size (GHash *gh); +int BLI_ghash_size(GHash *gh); /* *** */ - /** - * Create a new GHashIterator. The hash table must not be mutated - * while the iterator is in use, and the iterator will step exactly - * BLI_ghash_size(gh) times before becoming done. - * - * \param gh The GHash to iterate over. - * \return Pointer to a new DynStr. - */ -GHashIterator* BLI_ghashIterator_new (GHash *gh); - /** - * Init an already allocated GHashIterator. The hash table must not - * be mutated while the iterator is in use, and the iterator will - * step exactly BLI_ghash_size(gh) times before becoming done. - * - * \param ghi The GHashIterator to initialize. - * \param gh The GHash to iterate over. - */ +/** + * Create a new GHashIterator. The hash table must not be mutated + * while the iterator is in use, and the iterator will step exactly + * BLI_ghash_size(gh) times before becoming done. + * + * \param gh The GHash to iterate over. + * \return Pointer to a new DynStr. + */ +GHashIterator *BLI_ghashIterator_new(GHash *gh); +/** + * Init an already allocated GHashIterator. The hash table must not + * be mutated while the iterator is in use, and the iterator will + * step exactly BLI_ghash_size(gh) times before becoming done. + * + * \param ghi The GHashIterator to initialize. + * \param gh The GHash to iterate over. + */ void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh); - /** - * Free a GHashIterator. - * - * \param ghi The iterator to free. - */ -void BLI_ghashIterator_free (GHashIterator *ghi); - - /** - * Retrieve the key from an iterator. - * - * \param ghi The iterator. - * \return The key at the current index, or NULL if the - * iterator is done. - */ -void* BLI_ghashIterator_getKey (GHashIterator *ghi); - /** - * Retrieve the value from an iterator. - * - * \param ghi The iterator. - * \return The value at the current index, or NULL if the - * iterator is done. - */ -void* BLI_ghashIterator_getValue (GHashIterator *ghi); - /** - * Steps the iterator to the next index. - * - * \param ghi The iterator. - */ -void BLI_ghashIterator_step (GHashIterator *ghi); - /** - * Determine if an iterator is done (has reached the end of - * the hash table). - * - * \param ghi The iterator. - * \return True if done, False otherwise. - */ -int BLI_ghashIterator_isDone (GHashIterator *ghi); +/** + * Free a GHashIterator. + * + * \param ghi The iterator to free. + */ +void BLI_ghashIterator_free(GHashIterator *ghi); + +/** + * Retrieve the key from an iterator. + * + * \param ghi The iterator. + * \return The key at the current index, or NULL if the + * iterator is done. + */ +void *BLI_ghashIterator_getKey(GHashIterator *ghi); +/** + * Retrieve the value from an iterator. + * + * \param ghi The iterator. + * \return The value at the current index, or NULL if the + * iterator is done. + */ +void *BLI_ghashIterator_getValue(GHashIterator *ghi); +/** + * Steps the iterator to the next index. + * + * \param ghi The iterator. + */ +void BLI_ghashIterator_step(GHashIterator *ghi); +/** + * Determine if an iterator is done (has reached the end of + * the hash table). + * + * \param ghi The iterator. + * \return True if done, False otherwise. + */ +int BLI_ghashIterator_isDone(GHashIterator *ghi); #define GHASH_ITER(gh_iter_, ghash_) \ for (BLI_ghashIterator_init(&gh_iter_, ghash_); \ @@ -138,24 +138,24 @@ int BLI_ghashIterator_isDone (GHashIterator *ghi); /* *** */ -unsigned int BLI_ghashutil_ptrhash (const void *key); -int BLI_ghashutil_ptrcmp (const void *a, const void *b); +unsigned int BLI_ghashutil_ptrhash(const void *key); +int BLI_ghashutil_ptrcmp(const void *a, const void *b); -unsigned int BLI_ghashutil_strhash (const void *key); -int BLI_ghashutil_strcmp (const void *a, const void *b); +unsigned int BLI_ghashutil_strhash(const void *key); +int BLI_ghashutil_strcmp(const void *a, const void *b); -unsigned int BLI_ghashutil_inthash (const void *ptr); -int BLI_ghashutil_intcmp (const void *a, const void *b); +unsigned int BLI_ghashutil_inthash(const void *ptr); +int BLI_ghashutil_intcmp(const void *a, const void *b); typedef struct GHashPair { const void *first; const void *second; } GHashPair; -GHashPair* BLI_ghashutil_pairalloc (const void *first, const void *second); -unsigned int BLI_ghashutil_pairhash (const void *ptr); -int BLI_ghashutil_paircmp (const void *a, const void *b); -void BLI_ghashutil_pairfree (void *ptr); +GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second); +unsigned int BLI_ghashutil_pairhash(const void *ptr); +int BLI_ghashutil_paircmp(const void *a, const void *b); +void BLI_ghashutil_pairfree(void *ptr); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_graph.h b/source/blender/blenlib/BLI_graph.h index 52613f9869f..d45523aac7d 100644 --- a/source/blender/blenlib/BLI_graph.h +++ b/source/blender/blenlib/BLI_graph.h @@ -37,10 +37,10 @@ struct BArc; struct RadialArc; -typedef void (*FreeArc)(struct BArc*); -typedef void (*FreeNode)(struct BNode*); -typedef void (*RadialSymmetry)(struct BNode* root_node, struct RadialArc* ring, int total); -typedef void (*AxialSymmetry)(struct BNode* root_node, struct BNode* node1, struct BNode* node2, struct BArc* arc1, struct BArc* arc2); +typedef void (*FreeArc)(struct BArc *); +typedef void (*FreeNode)(struct BNode *); +typedef void (*RadialSymmetry)(struct BNode *root_node, struct RadialArc *ring, int total); +typedef void (*AxialSymmetry)(struct BNode *root_node, struct BNode *node1, struct BNode *node2, struct BArc *arc1, struct BArc *arc2); /* IF YOU MODIFY THOSE TYPES, YOU NEED TO UPDATE ALL THOSE THAT "INHERIT" FROM THEM * @@ -49,16 +49,16 @@ typedef void (*AxialSymmetry)(struct BNode* root_node, struct BNode* node1, stru * */ typedef struct BGraph { - ListBase arcs; - ListBase nodes; + ListBase arcs; + ListBase nodes; float length; /* function pointer to deal with custom fonctionnality */ - FreeArc free_arc; - FreeNode free_node; - RadialSymmetry radial_symmetry; - AxialSymmetry axial_symmetry; + FreeArc free_arc; + FreeNode free_node; + RadialSymmetry radial_symmetry; + AxialSymmetry axial_symmetry; } BGraph; typedef struct BNode { @@ -90,30 +90,30 @@ typedef struct BArc { struct BArcIterator; -void* IT_head(void* iter); -void* IT_tail(void* iter); -void* IT_peek(void* iter, int n); -void* IT_next(void* iter); -void* IT_nextN(void* iter, int n); -void* IT_previous(void* iter); -int IT_stopped(void* iter); - -typedef void* (*HeadFct)(void* iter); -typedef void* (*TailFct)(void* iter); -typedef void* (*PeekFct)(void* iter, int n); -typedef void* (*NextFct)(void* iter); -typedef void* (*NextNFct)(void* iter, int n); -typedef void* (*PreviousFct)(void* iter); -typedef int (*StoppedFct)(void* iter); +void *IT_head(void *iter); +void *IT_tail(void *iter); +void *IT_peek(void *iter, int n); +void *IT_next(void *iter); +void *IT_nextN(void *iter, int n); +void *IT_previous(void *iter); +int IT_stopped(void *iter); + +typedef void * (*HeadFct)(void *iter); +typedef void * (*TailFct)(void *iter); +typedef void * (*PeekFct)(void *iter, int n); +typedef void * (*NextFct)(void *iter); +typedef void * (*NextNFct)(void *iter, int n); +typedef void * (*PreviousFct)(void *iter); +typedef int (*StoppedFct)(void *iter); typedef struct BArcIterator { - HeadFct head; - TailFct tail; - PeekFct peek; - NextFct next; - NextNFct nextN; - PreviousFct previous; - StoppedFct stopped; + HeadFct head; + TailFct tail; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; float *p, *no; float size; @@ -123,8 +123,7 @@ typedef struct BArcIterator { } BArcIterator; /* Helper structure for radial symmetry */ -typedef struct RadialArc -{ +typedef struct RadialArc { struct BArc *arc; float n[3]; /* normalized vector joining the nodes of the arc */ } RadialArc; @@ -141,7 +140,7 @@ void BLI_flagArcs(BGraph *graph, int flag); int BLI_hasAdjacencyList(BGraph *rg); void BLI_buildAdjacencyList(BGraph *rg); -void BLI_rebuildAdjacencyListForNode(BGraph* rg, BNode *node); +void BLI_rebuildAdjacencyListForNode(BGraph *rg, BNode *node); void BLI_freeAdjacencyList(BGraph *rg); int BLI_FlagSubgraphs(BGraph *graph); @@ -156,11 +155,11 @@ void BLI_calcGraphLength(BGraph *graph); void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced); void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced); void BLI_removeDoubleNodes(BGraph *graph, float limit); -BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit); +BNode *BLI_FindNodeByPosition(BGraph *graph, float *p, float limit); -BArc * BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v); +BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v); -int BLI_isGraphCyclic(BGraph *graph); +int BLI_isGraphCyclic(BGraph *graph); /*------------ Symmetry handling ------------*/ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit); @@ -168,19 +167,19 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit); void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3]); /* BNode symmetry flags */ -#define SYM_TOPOLOGICAL 1 -#define SYM_PHYSICAL 2 +#define SYM_TOPOLOGICAL 1 +#define SYM_PHYSICAL 2 /* the following two are exclusive */ -#define SYM_AXIAL 4 -#define SYM_RADIAL 8 +#define SYM_AXIAL 4 +#define SYM_RADIAL 8 /* BArc symmetry flags * * axial symmetry sides */ -#define SYM_SIDE_POSITIVE 1 -#define SYM_SIDE_NEGATIVE 2 +#define SYM_SIDE_POSITIVE 1 +#define SYM_SIDE_NEGATIVE 2 /* Anything higher is the order in radial symmetry */ -#define SYM_SIDE_RADIAL 3 +#define SYM_SIDE_RADIAL 3 #endif /*__BLI_GRAPH_H__*/ diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h index 29c31c19047..b4cb1edd45a 100644 --- a/source/blender/blenlib/BLI_gsqueue.h +++ b/source/blender/blenlib/BLI_gsqueue.h @@ -36,64 +36,64 @@ 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); +/** + * 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 - */ -int BLI_gsqueue_is_empty(GSQueue *gq); +/** + * Query if the queue is empty + */ +int BLI_gsqueue_is_empty(GSQueue *gq); - /** - * Query number elements in the queue - */ -int BLI_gsqueue_size(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 + * 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); +/** + * 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 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); +/** + * 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); +/** + * Free the queue + */ +void BLI_gsqueue_free(GSQueue *gq); #endif /* __BLI_GSQUEUE_H__ */ diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index 5ceccda96e4..b378f2bb365 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -38,35 +38,35 @@ struct HeapNode; typedef struct Heap Heap; typedef struct HeapNode HeapNode; -typedef void (*HeapFreeFP)(void *ptr); +typedef void (*HeapFreeFP)(void *ptr); /* Creates a new heap. BLI_memarena is used for allocating nodes. Removed nodes * are recycled, so memory usage will not shrink. */ -Heap* BLI_heap_new (void); -void BLI_heap_free (Heap *heap, HeapFreeFP ptrfreefp); +Heap *BLI_heap_new(void); +void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp); /* Insert heap node with a value (often a 'cost') and pointer into the heap, * duplicate values are allowed. */ -HeapNode* BLI_heap_insert (Heap *heap, float value, void *ptr); +HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr); /* Remove a heap node. */ -void BLI_heap_remove (Heap *heap, HeapNode *node); +void BLI_heap_remove(Heap *heap, HeapNode *node); /* Return 0 if the heap is empty, 1 otherwise. */ -int BLI_heap_empty (Heap *heap); +int BLI_heap_empty(Heap *heap); /* Return the size of the heap. */ -int BLI_heap_size (Heap *heap); +int BLI_heap_size(Heap *heap); /* Return the top node of the heap. This is the node with the lowest value. */ -HeapNode* BLI_heap_top (Heap *heap); +HeapNode *BLI_heap_top(Heap *heap); /* Pop the top node off the heap and return it's pointer. */ -void* BLI_heap_popmin (Heap *heap); +void *BLI_heap_popmin(Heap *heap); /* Return the value or pointer of a heap node. */ -float BLI_heap_node_value (HeapNode *heap); -void* BLI_heap_node_ptr (HeapNode *heap); +float BLI_heap_node_value(HeapNode *heap); +void *BLI_heap_node_ptr(HeapNode *heap); #endif diff --git a/source/blender/blenlib/BLI_jitter.h b/source/blender/blenlib/BLI_jitter.h index c2a6250c154..432bf73ad90 100644 --- a/source/blender/blenlib/BLI_jitter.h +++ b/source/blender/blenlib/BLI_jitter.h @@ -32,7 +32,7 @@ * \ingroup bli */ -void BLI_jitter_init(float *jitarr, int num); +void BLI_jitter_init(float *jitarr, int num); void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1); void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2); diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index ff3017fef03..7041c122ff9 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -49,37 +49,34 @@ typedef struct BVHTreeOverlap { int indexB; } BVHTreeOverlap; -typedef struct BVHTreeNearest -{ - int index; /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */ - float co[3]; /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ - float no[3]; /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ - float dist; /* squared distance to search arround */ +typedef struct BVHTreeNearest { + int index; /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */ + float co[3]; /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ + float no[3]; /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ + float dist; /* squared distance to search arround */ } BVHTreeNearest; -typedef struct BVHTreeRay -{ - float origin[3]; /* ray origin */ - float direction[3]; /* ray direction */ - float radius; /* radius around ray */ +typedef struct BVHTreeRay { + float origin[3]; /* ray origin */ + float direction[3]; /* ray direction */ + float radius; /* radius around ray */ } BVHTreeRay; -typedef struct BVHTreeRayHit -{ - int index; /* index of the tree node (untouched if no hit is found) */ - float co[3]; /* coordinates of the hit point */ - float no[3]; /* normal on hit point */ - float dist; /* distance to the hit point */ +typedef struct BVHTreeRayHit { + int index; /* index of the tree node (untouched if no hit is found) */ + float co[3]; /* coordinates of the hit point */ + float no[3]; /* normal on hit point */ + float dist; /* distance to the hit point */ } BVHTreeRayHit; /* callback must update nearest in case it finds a nearest result */ -typedef void (*BVHTree_NearestPointCallback) (void *userdata, int index, const float *co, BVHTreeNearest *nearest); +typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const float *co, BVHTreeNearest *nearest); /* callback must update hit in case it finds a nearest successful hit */ -typedef void (*BVHTree_RayCastCallback) (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit); +typedef void (*BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit); /* callback to range search query */ -typedef void (*BVHTree_RangeQuery) (void *userdata, int index, float squared_dist); +typedef void (*BVHTree_RangeQuery)(void *userdata, int index, float squared_dist); BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis); void BLI_bvhtree_free(BVHTree *tree); diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h index a58f58020d7..ae5e32d73eb 100644 --- a/source/blender/blenlib/BLI_kdtree.h +++ b/source/blender/blenlib/BLI_kdtree.h @@ -46,7 +46,7 @@ typedef struct KDTreeNearest { } KDTreeNearest; /* Creates or free a kdtree */ -KDTree* BLI_kdtree_new(int maxsize); +KDTree *BLI_kdtree_new(int maxsize); void BLI_kdtree_free(KDTree *tree); /* Construction: first insert points, then call balance. Normal is optional. */ @@ -56,12 +56,11 @@ void BLI_kdtree_balance(KDTree *tree); /* Find nearest returns index, and -1 if no node is found. * Find n nearest returns number of points found, with results in nearest. * Normal is optional, but if given will limit results to points in normal direction from co. */ -int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest); -int BLI_kdtree_find_n_nearest(KDTree *tree, int n, float *co, float *nor, KDTreeNearest *nearest); +int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest); +int BLI_kdtree_find_n_nearest(KDTree *tree, int n, float *co, float *nor, KDTreeNearest *nearest); /* Range search returns number of points found, with results in nearest */ /* Normal is optional, but if given will limit results to points in normal direction from co. */ /* Remember to free nearest after use! */ int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest); #endif - diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h index 664beb4eb98..da56a300b9b 100644 --- a/source/blender/blenlib/BLI_linklist.h +++ b/source/blender/blenlib/BLI_linklist.h @@ -46,20 +46,19 @@ typedef struct LinkNode { void *link; } LinkNode; -int BLI_linklist_length (struct LinkNode *list); -int BLI_linklist_index (struct LinkNode *list, void *ptr); +int BLI_linklist_length(struct LinkNode *list); +int BLI_linklist_index(struct LinkNode *list, void *ptr); -struct LinkNode *BLI_linklist_find (struct LinkNode *list, int index); +struct LinkNode *BLI_linklist_find(struct LinkNode *list, int index); -void BLI_linklist_reverse (struct LinkNode **listp); +void BLI_linklist_reverse(struct LinkNode **listp); -void BLI_linklist_prepend (struct LinkNode **listp, void *ptr); -void BLI_linklist_append (struct LinkNode **listp, void *ptr); -void BLI_linklist_prepend_arena (struct LinkNode **listp, void *ptr, struct MemArena *ma); -void BLI_linklist_insert_after (struct LinkNode **listp, void *ptr); +void BLI_linklist_prepend(struct LinkNode **listp, void *ptr); +void BLI_linklist_append(struct LinkNode **listp, void *ptr); +void BLI_linklist_prepend_arena(struct LinkNode **listp, void *ptr, struct MemArena *ma); +void BLI_linklist_insert_after(struct LinkNode **listp, void *ptr); -void BLI_linklist_free (struct LinkNode *list, LinkNodeFreeFP freefunc); -void BLI_linklist_apply (struct LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata); +void BLI_linklist_free(struct LinkNode *list, LinkNodeFreeFP freefunc); +void BLI_linklist_apply(struct LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata); #endif - diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 7e5f1f2a72a..02065c4b86f 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -127,19 +127,19 @@ #endif #ifdef WIN32 -#ifndef FREE_WINDOWS -#define isnan(n) _isnan(n) -#define finite _finite -#define hypot _hypot -#endif +# ifndef FREE_WINDOWS +# define isnan(n) _isnan(n) +# define finite _finite +# define hypot _hypot +# endif #endif #ifndef SWAP -#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } +# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } #endif #ifndef CLAMP -#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c) +# define CLAMP(a, b, c) if ((a) < (b)) (a) = (b); else if ((a) > (c)) (a) = (c) #endif #ifdef __BLI_MATH_INLINE_H__ diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 4771fdbcb69..afdb5d40bd5 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -37,19 +37,19 @@ extern "C" { #include "BLI_math_inline.h" /* primaries */ -#define BLI_XYZ_SMPTE 0 -#define BLI_XYZ_REC709_SRGB 1 -#define BLI_XYZ_CIE 2 +#define BLI_XYZ_SMPTE 0 +#define BLI_XYZ_REC709_SRGB 1 +#define BLI_XYZ_CIE 2 /* built-in profiles */ -#define BLI_PR_NONE 0 -#define BLI_PR_SRGB 1 -#define BLI_PR_REC709 2 +#define BLI_PR_NONE 0 +#define BLI_PR_SRGB 1 +#define BLI_PR_REC709 2 /* YCbCr */ -#define BLI_YCC_ITU_BT601 0 -#define BLI_YCC_ITU_BT709 1 -#define BLI_YCC_JFIF_0_255 2 +#define BLI_YCC_ITU_BT601 0 +#define BLI_YCC_ITU_BT709 1 +#define BLI_YCC_JFIF_0_255 2 /******************* Conversion to RGB ********************/ @@ -101,8 +101,8 @@ void BLI_init_srgb_conversion(void); int constrain_rgb(float *r, float *g, float *b); void minmax_rgb(short c[3]); -void rgb_float_set_hue_float_offset(float * rgb, float hue_offset); -void rgb_byte_set_hue_float_offset(unsigned char * rgb, float hue_offset); +void rgb_float_set_hue_float_offset(float *rgb, float hue_offset); +void rgb_byte_set_hue_float_offset(unsigned char *rgb, float hue_offset); void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]); void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4]); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 85129d5b68d..0560a3f6e64 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -67,23 +67,23 @@ float dist_to_plane_v3(const float p[3], const float plane_co[3], const float pl float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]); -void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); -void closest_to_plane_v3(float r[3], const float plane_co[3], const float plane_no_unit[3], const float pt[3]); +void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); +void closest_to_plane_v3(float r[3], const float plane_co[3], const float plane_no_unit[3], const float pt[3]); float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3]); float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2]); -void limit_dist_v3(float v1[3], float v2[3], const float dist); +void limit_dist_v3(float v1[3], float v2[3], const float dist); /******************************* Intersection ********************************/ /* TODO int return value consistency */ /* line-line */ -#define ISECT_LINE_LINE_COLINEAR -1 -#define ISECT_LINE_LINE_NONE 0 -#define ISECT_LINE_LINE_EXACT 1 -#define ISECT_LINE_LINE_CROSS 2 +#define ISECT_LINE_LINE_COLINEAR -1 +#define ISECT_LINE_LINE_NONE 0 +#define ISECT_LINE_LINE_EXACT 1 +#define ISECT_LINE_LINE_CROSS 2 int isect_line_line_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]); int isect_line_line_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]); @@ -139,13 +139,13 @@ void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], /* line/ray triangle */ int isect_line_tri_v3(const float p1[3], const float p2[3], - const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]); int isect_ray_tri_v3(const float p1[3], const float d[3], - const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]); int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], - const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float threshold); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float threshold); int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], - const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon); /* point in polygon */ int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]); @@ -161,10 +161,10 @@ void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[ /* other */ int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius, - const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3]); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3]); int isect_axial_line_tri_v3(const int axis, const float co1[3], const float co2[3], - const float v0[3], const float v1[3], const float v2[3], float *r_lambda); + const float v0[3], const float v1[3], const float v2[3], float *r_lambda); int isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]); @@ -176,20 +176,20 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, /* tri or quad, d can be NULL */ void interp_weights_face_v3(float w[4], - const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]); + const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]); void interp_weights_poly_v3(float w[], float v[][3], const int n, const float p[3]); void interp_cubic_v3(float x[3], float v[3], - const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t); + const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t); int interp_sparse_array(float *array, const int list_size, const float invalid); void barycentric_transform(float pt_tar[3], float const pt_src[3], - const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], - const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]); + const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], + const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]); void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], - const float co[2], float w[3]); + const float co[2], float w[3]); void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]); void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]); @@ -197,21 +197,21 @@ void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const f /***************************** View & Projection *****************************/ void lookat_m4(float mat[4][4], float vx, float vy, - float vz, float px, float py, float pz, float twist); + float vz, float px, float py, float pz, float twist); void polarview_m4(float mat[4][4], float dist, float azimuth, - float incidence, float twist); + float incidence, float twist); void perspective_m4(float mat[4][4], const float left, const float right, - const float bottom, const float top, const float nearClip, const float farClip); + const float bottom, const float top, const float nearClip, const float farClip); void orthographic_m4(float mat[4][4], const float left, const float right, - const float bottom, const float top, const float nearClip, const float farClip); + const float bottom, const float top, const float nearClip, const float farClip); void window_translate_m4(float winmat[][4], float perspmat[][4], - const float x, const float y); + const float x, const float y); int box_clip_bounds_m4(float boundbox[2][3], - const float bounds[4], float winmat[4][4]); + const float bounds[4], float winmat[4][4]); void box_minmax_bounds_m4(float min[3], float max[3], - float boundbox[2][3], float mat[4][4]); + float boundbox[2][3], float mat[4][4]); /********************************** Mapping **********************************/ @@ -221,11 +221,11 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f /********************************** Normals **********************************/ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3], - float n4[3], const float f_no[3], const float co1[3], const float co2[3], - const float co3[3], const float co4[3]); + float n4[3], const float f_no[3], const float co1[3], const float co2[3], + const float co3[3], const float co4[3]); void accumulate_vertex_normals_poly(float **vertnos, float polyno[3], - float **vertcos, float vdiffs[][3], int nverts); + float **vertcos, float vdiffs[][3], int nverts); /********************************* Tangents **********************************/ @@ -236,15 +236,15 @@ typedef struct VertexTangent { float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]); void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, - const float tang[3], const float uv[2]); + const float tang[3], const float uv[2]); void tangent_from_uv(float uv1[2], float uv2[2], float uv3[2], - float co1[3], float co2[3], float co3[3], float n[3], float tang[3]); + float co1[3], float co2[3], float co3[3], float n[3], float tang[3]); /******************************** Vector Clouds ******************************/ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, - float (*rpos)[3], float *rweight, - float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3]); + float (*rpos)[3], float *rweight, + float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3]); /****************************** Spherical Harmonics *************************/ @@ -266,7 +266,7 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f); /********************************* Form Factor *******************************/ float form_factor_hemi_poly(float p[3], float n[3], - float v1[3], float v2[3], float v3[3], float v4[3]); + float v1[3], float v2[3], float v3[3], float v4[3]); void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3]); diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 1d99fd4fa27..8e9955beb61 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -36,13 +36,13 @@ extern "C" { /********************************* Init **************************************/ -#define MAT4_UNITY {{ 1.0, 0.0, 0.0, 0.0},\ - { 0.0, 1.0, 0.0, 0.0},\ - { 0.0, 0.0, 1.0, 0.0},\ +#define MAT4_UNITY {{ 1.0, 0.0, 0.0, 0.0}, \ + { 0.0, 1.0, 0.0, 0.0}, \ + { 0.0, 0.0, 1.0, 0.0}, \ { 0.0, 0.0, 0.0, 1.0}} -#define MAT3_UNITY {{ 1.0, 0.0, 0.0},\ - { 0.0, 1.0, 0.0},\ +#define MAT3_UNITY {{ 1.0, 0.0, 0.0}, \ + { 0.0, 1.0, 0.0}, \ { 0.0, 0.0, 1.0}} void zero_m3(float R[3][3]); @@ -76,11 +76,11 @@ void mult_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); void mult_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]); void mul_serie_m3(float R[3][3], - float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], - float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]); + float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], + float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]); void mul_serie_m4(float R[4][4], - float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], - float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]); + float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4], + float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]); void mul_m4_v3(float M[4][4], float r[3]); void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]); @@ -131,13 +131,11 @@ int is_uniform_scaled_m3(float mat[3][3]); void adjoint_m3_m3(float R[3][3], float A[3][3]); void adjoint_m4_m4(float R[4][4], float A[4][4]); -float determinant_m2( - float a, float b, - float c, float d); -float determinant_m3( - float a, float b, float c, - float d, float e, float f, - float g, float h, float i); +float determinant_m2(float a, float b, + float c, float d); +float determinant_m3(float a, float b, float c, + float d, float e, float f, + float g, float h, float i); float determinant_m4(float A[4][4]); void svd_m4(float U[4][4], float s[4], float V[4][4], float A[4][4]); @@ -165,13 +163,13 @@ void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[][3]); void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4]); void loc_eul_size_to_mat4(float R[4][4], - const float loc[3], const float eul[3], const float size[3]); + const float loc[3], const float eul[3], const float size[3]); void loc_eulO_size_to_mat4(float R[4][4], - const float loc[3], const float eul[3], const float size[3], const short order); + const float loc[3], const float eul[3], const float size[3], const short order); void loc_quat_size_to_mat4(float R[4][4], - const float loc[3], const float quat[4], const float size[3]); + const float loc[3], const float quat[4], const float size[3]); void loc_axisangle_size_to_mat4(float R[4][4], - const float loc[3], const float axis[4], const float angle, const float size[3]); + const float loc[3], const float axis[4], const float angle, const float size[3]); void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], const float t); void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], const float t); diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 62b81530c65..912534e0aca 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -34,12 +34,12 @@ extern "C" { #endif -#define RAD2DEG(_rad) ((_rad)*(180.0/M_PI)) -#define DEG2RAD(_deg) ((_deg)*(M_PI/180.0)) +#define RAD2DEG(_rad) ((_rad) * (180.0 / M_PI)) +#define DEG2RAD(_deg) ((_deg) * (M_PI / 180.0)) -#define RAD2DEGF(_rad) ((_rad)*(float)(180.0/M_PI)) -#define DEG2RADF(_deg) ((_deg)*(float)(M_PI/180.0)) +#define RAD2DEGF(_rad) ((_rad) * (float)(180.0 / M_PI)) +#define DEG2RADF(_deg) ((_deg) * (float)(M_PI / 180.0)) /******************************** Quaternions ********************************/ /* stored in (w, x, y, z) order */ @@ -171,10 +171,10 @@ typedef struct DualQuat { void copy_dq_dq(DualQuat *r, DualQuat *dq); void normalize_dq(DualQuat *dq, float totw); void add_weighted_dq_dq(DualQuat *r, DualQuat *dq, float weight); -void mul_v3m3_dq(float r[3], float R[3][3], DualQuat *dq); +void mul_v3m3_dq(float r[3], float R[3][3], DualQuat * dq); -void mat4_to_dquat(DualQuat *r, float base[4][4], float M[4][4]); -void dquat_to_mat4(float R[4][4], DualQuat *dq); +void mat4_to_dquat(DualQuat * r, float base[4][4], float M[4][4]); +void dquat_to_mat4(float R[4][4], DualQuat * dq); void quat_apply_track(float quat[4], short axis, short upflag); void vec_apply_track(float vec[3], short axis); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 249f2265440..d0f883e1c99 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -189,7 +189,7 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3]); float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]); void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]); void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]); -void angle_poly_v3(float* angles, const float* verts[3], int len); +void angle_poly_v3(float *angles, const float *verts[3], int len); /********************************* Geometry **********************************/ @@ -237,4 +237,3 @@ void fill_vn_fl(float *array_tar, const int size, const float val); #endif #endif /* __BLI_MATH_VECTOR_H__ */ - diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index 508cc03d848..abba03ece9d 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -41,25 +41,25 @@ extern "C" { #endif - /* A reasonable standard buffer size, big - * enough to not cause much internal fragmentation, - * small enough not to waste resources - */ -#define BLI_MEMARENA_STD_BUFSIZE (1<<14) +/* A reasonable standard buffer size, big + * enough to not cause much internal fragmentation, + * small enough not to waste resources + */ +#define BLI_MEMARENA_STD_BUFSIZE (1 << 14) struct MemArena; typedef struct MemArena MemArena; -struct MemArena* BLI_memarena_new (int bufsize, const char *name); -void BLI_memarena_free (struct MemArena *ma); +struct MemArena *BLI_memarena_new(int bufsize, const char *name); +void BLI_memarena_free(struct MemArena *ma); -void BLI_memarena_use_malloc (struct MemArena *ma); -void BLI_memarena_use_calloc (struct MemArena *ma); +void BLI_memarena_use_malloc(struct MemArena *ma); +void BLI_memarena_use_calloc(struct MemArena *ma); -void BLI_memarena_use_align(struct MemArena *ma, int align); +void BLI_memarena_use_align(struct MemArena *ma, int align); -void* BLI_memarena_alloc (struct MemArena *ma, int size); +void *BLI_memarena_alloc(struct MemArena *ma, int size); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h index 9f5475ced25..d9457fbaae7 100644 --- a/source/blender/blenlib/BLI_noise.h +++ b/source/blender/blenlib/BLI_noise.h @@ -54,7 +54,7 @@ float mg_HeteroTerrain(float x, float y, float z, float H, float lacunarity, flo float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis); float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis); /* newnoise: voronoi */ -void voronoi(float x, float y, float z, float* da, float* pa, float me, int dtype); +void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype); /* newnoise: cellNoise & cellNoiseV (for vector/point/color) */ float cellNoise(float x, float y, float z); void cellNoiseV(float x, float y, float z, float *ca); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 1d085a46a19..3664d7bcd77 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -48,29 +48,29 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); /* folder_id */ /* general, will find based on user/local/system priority */ -#define BLENDER_DATAFILES 2 +#define BLENDER_DATAFILES 2 /* user-specific */ -#define BLENDER_USER_CONFIG 31 -#define BLENDER_USER_DATAFILES 32 -#define BLENDER_USER_SCRIPTS 33 -#define BLENDER_USER_PLUGINS 34 -#define BLENDER_USER_AUTOSAVE 35 +#define BLENDER_USER_CONFIG 31 +#define BLENDER_USER_DATAFILES 32 +#define BLENDER_USER_SCRIPTS 33 +#define BLENDER_USER_PLUGINS 34 +#define BLENDER_USER_AUTOSAVE 35 /* system */ -#define BLENDER_SYSTEM_DATAFILES 52 -#define BLENDER_SYSTEM_SCRIPTS 53 -#define BLENDER_SYSTEM_PLUGINS 54 -#define BLENDER_SYSTEM_PYTHON 54 +#define BLENDER_SYSTEM_DATAFILES 52 +#define BLENDER_SYSTEM_SCRIPTS 53 +#define BLENDER_SYSTEM_PLUGINS 54 +#define BLENDER_SYSTEM_PYTHON 54 /* for BLI_get_folder_version only */ -#define BLENDER_RESOURCE_PATH_USER 0 -#define BLENDER_RESOURCE_PATH_LOCAL 1 -#define BLENDER_RESOURCE_PATH_SYSTEM 2 +#define BLENDER_RESOURCE_PATH_USER 0 +#define BLENDER_RESOURCE_PATH_LOCAL 1 +#define BLENDER_RESOURCE_PATH_SYSTEM 2 -#define BLENDER_STARTUP_FILE "startup.blend" -#define BLENDER_BOOKMARK_FILE "bookmarks.txt" -#define BLENDER_HISTORY_FILE "recent-files.txt" +#define BLENDER_STARTUP_FILE "startup.blend" +#define BLENDER_BOOKMARK_FILE "bookmarks.txt" +#define BLENDER_HISTORY_FILE "recent-files.txt" #ifdef WIN32 #define SEP '\\' @@ -81,7 +81,7 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); #endif void BLI_setenv(const char *env, const char *val); -void BLI_setenv_if_new(const char *env, const char* val); +void BLI_setenv_if_new(const char *env, const char *val); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); void BLI_make_exist(char *dir); @@ -93,11 +93,11 @@ void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *BLI_path_basename(char *path); int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); char *BLI_last_slash(const char *string); -int BLI_add_slash(char *string); +int BLI_add_slash(char *string); void BLI_del_slash(char *string); char *BLI_first_slash(char *string); -void BLI_getlastdir(const char* dir, char *last, const size_t maxlen); +void BLI_getlastdir(const char *dir, char *last, const size_t maxlen); int BLI_testextensie(const char *str, const char *ext); int BLI_testextensie_array(const char *str, const char **ext_array); int BLI_testextensie_glob(const char *str, const char *ext_fnmatch); @@ -105,7 +105,7 @@ int BLI_replace_extension(char *path, size_t maxlen, const char *ext); int BLI_ensure_extension(char *path, size_t maxlen, const char *ext); void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len); -void BLI_newname(char * name, int add); +void BLI_newname(char *name, int add); int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen); void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic); int BLI_split_name_num(char *left, int *nr, const char *name, const char delim); @@ -165,19 +165,19 @@ void BLI_path_rel(char *file, const char *relfile); */ void BLI_char_switch(char *string, char from, char to); - /* Initialize path to program executable */ +/* Initialize path to program executable */ void BLI_init_program_path(const char *argv0); - /* Initialize path to temporary directory. - * NOTE: On Window userdir will be set to the temporary directory! */ +/* Initialize path to temporary directory. + * NOTE: On Window userdir will be set to the temporary directory! */ void BLI_init_temporary_dir(char *userdir); - /* Path to executable */ +/* Path to executable */ const char *BLI_program_path(void); - /* Path to directory of executable */ +/* Path to directory of executable */ const char *BLI_program_dir(void); - /* Path to temporary directory (with trailing slash) */ +/* Path to temporary directory (with trailing slash) */ const char *BLI_temporary_dir(void); - /* Path to the system temporary directory (with trailing slash) */ +/* 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_rand.h b/source/blender/blenlib/BLI_rand.h index d4d6563ac99..7dd6c8575c9 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -40,59 +40,59 @@ struct RNG; typedef struct RNG RNG; -struct RNG* rng_new (unsigned int seed); -void rng_free (struct RNG* rng); +struct RNG *rng_new(unsigned int seed); +void rng_free(struct RNG *rng); -void rng_seed (struct RNG* rng, unsigned int seed); +void rng_seed(struct RNG *rng, unsigned int seed); void rng_srandom(struct RNG *rng, unsigned int seed); -int rng_getInt (struct RNG* rng); -double rng_getDouble (struct RNG* rng); -float rng_getFloat (struct RNG* rng); -void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems); +int rng_getInt(struct RNG *rng); +double rng_getDouble(struct RNG *rng); +float rng_getFloat(struct RNG *rng); +void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems); - /** Note that skipping is as slow as generating n numbers! */ -void rng_skip (struct RNG *rng, int n); +/** Note that skipping is as slow as generating n numbers! */ +void rng_skip(struct RNG *rng, int n); - /** Seed the random number generator */ -void BLI_srand (unsigned int seed); +/** Seed the random number generator */ +void BLI_srand(unsigned int seed); - /** Better seed for the random number generator, using noise.c hash[] */ -void BLI_srandom (unsigned int seed); +/** Better seed for the random number generator, using noise.c hash[] */ +void BLI_srandom(unsigned int seed); - /** Return a pseudo-random number N where 0<=N<(2^31) */ -int BLI_rand (void); +/** Return a pseudo-random number N where 0<=N<(2^31) */ +int BLI_rand(void); - /** Return a pseudo-random number N where 0.0<=N<1.0 */ -double BLI_drand (void); +/** Return a pseudo-random number N where 0.0<=N<1.0 */ +double BLI_drand(void); - /** Return a pseudo-random number N where 0.0f<=N<1.0f */ -float BLI_frand (void); +/** Return a pseudo-random number N where 0.0f<=N<1.0f */ +float BLI_frand(void); - /** Fills a block of memory starting at \a addr - * and extending \a len bytes with pseudo-random - * contents. This routine does not use nor modify - * the state of the BLI random number generator. - */ -void BLI_fillrand (void *addr, int len); +/** Fills a block of memory starting at \a addr + * and extending \a len bytes with pseudo-random + * contents. This routine does not use nor modify + * the state of the BLI random number generator. + */ +void BLI_fillrand(void *addr, int len); - /** Shuffle an array randomly using the given seed. - * contents. This routine does not use nor modify - * the state of the BLI random number generator. - */ -void BLI_array_randomize (void *data, int elemSize, int numElems, unsigned int seed); +/** Shuffle an array randomly using the given seed. + * contents. This routine does not use nor modify + * the state of the BLI random number generator. + */ +void BLI_array_randomize(void *data, int elemSize, int numElems, unsigned int seed); - /** Better seed for the random number generator, using noise.c hash[] */ - /** Allows up to BLENDER_MAX_THREADS threads to address */ -void BLI_thread_srandom (int thread, unsigned int seed); +/** Better seed for the random number generator, using noise.c hash[] */ +/** Allows up to BLENDER_MAX_THREADS threads to address */ +void BLI_thread_srandom(int thread, unsigned int seed); - /** Return a pseudo-random number N where 0<=N<(2^31) */ - /** Allows up to BLENDER_MAX_THREADS threads to address */ -int BLI_thread_rand (int thread); +/** Return a pseudo-random number N where 0<=N<(2^31) */ +/** Allows up to BLENDER_MAX_THREADS threads to address */ +int BLI_thread_rand(int thread); - /** Return a pseudo-random number N where 0.0f<=N<1.0f */ - /** Allows up to BLENDER_MAX_THREADS threads to address */ -float BLI_thread_frand (int thread); +/** Return a pseudo-random number N where 0.0f<=N<1.0f */ +/** Allows up to BLENDER_MAX_THREADS threads to address */ +float BLI_thread_frand(int thread); diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 7ce19ce8583..0cf32eeb276 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -58,7 +58,7 @@ void BLI_resize_rcti(struct rcti *rect, int x, int y); void BLI_resize_rctf(struct rctf *rect, float x, float y); int BLI_in_rcti(struct rcti *rect, int x, int y); int BLI_in_rctf(struct rctf *rect, float x, float y); -int BLI_segment_in_rcti(struct rcti *rect, int s1[2], int s2[2]); +int BLI_segment_in_rcti(struct rcti *rect, int s1[2], int s2[2]); // int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); // NOT NEEDED YET int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest); int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest); diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index 081d5ccfb66..ceef378358b 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -41,8 +41,7 @@ struct ScanFillVert; extern "C" { #endif -typedef struct ScanFillContext -{ +typedef struct ScanFillContext { ListBase fillvertbase; ListBase filledgebase; ListBase fillfacebase; @@ -61,13 +60,12 @@ typedef struct ScanFillContext } ScanFillContext; /* note; changing this also might affect the undo copy in editmesh.c */ -typedef struct ScanFillVert -{ +typedef struct ScanFillVert { struct ScanFillVert *next, *prev; union { struct ScanFillVert *v; void *p; - intptr_t l; + intptr_t l; } tmp; float co[3]; /* vertex location */ float xy[2]; /* 2D copy of vertex location (using dominant axis) */ @@ -76,16 +74,14 @@ typedef struct ScanFillVert unsigned char f, h; } ScanFillVert; -typedef struct ScanFillEdge -{ +typedef struct ScanFillEdge { struct ScanFillEdge *next, *prev; struct ScanFillVert *v1, *v2; short poly_nr; unsigned char f; } ScanFillEdge; -typedef struct ScanFillFace -{ +typedef struct ScanFillFace { struct ScanFillFace *next, *prev; struct ScanFillVert *v1, *v2, *v3; } ScanFillFace; @@ -97,7 +93,7 @@ struct ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanF int BLI_scanfill_begin(ScanFillContext *sf_ctx); int BLI_scanfill_calc(ScanFillContext *sf_ctx, const short do_quad_tri_speedup); int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, - const float nor_proj[3]); + const float nor_proj[3]); void BLI_scanfill_end(ScanFillContext *sf_ctx); /* These callbacks are needed to make the lib finction properly */ @@ -108,7 +104,7 @@ void BLI_scanfill_end(ScanFillContext *sf_ctx); * \param f The function to use as callback * \attention used in creator.c */ -void BLI_setErrorCallBack(void (*f)(const char*)); +void BLI_setErrorCallBack(void (*f)(const char *)); /** * Set a function to be able to interrupt the execution of processing diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h index 50631769ba9..09dd254c3fa 100644 --- a/source/blender/blenlib/BLI_smallhash.h +++ b/source/blender/blenlib/BLI_smallhash.h @@ -43,7 +43,7 @@ typedef struct { } SmallHashEntry; /*how much stack space to use before dynamically allocating memory*/ -#define SMSTACKSIZE 521 +#define SMSTACKSIZE 521 typedef struct SmallHash { SmallHashEntry *table; SmallHashEntry _stacktable[SMSTACKSIZE]; @@ -59,15 +59,15 @@ typedef struct { int i; } SmallHashIter; -void BLI_smallhash_init(SmallHash *hash); -void BLI_smallhash_release(SmallHash *hash); -void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item); -void BLI_smallhash_remove(SmallHash *hash, uintptr_t key); -void * BLI_smallhash_lookup(SmallHash *hash, uintptr_t key); -int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key); -int BLI_smallhash_count(SmallHash *hash); -void * BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key); -void * BLI_smallhash_iternew(SmallHash *hash, SmallHashIter *iter, uintptr_t *key); +void BLI_smallhash_init(SmallHash *hash); +void BLI_smallhash_release(SmallHash *hash); +void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item); +void BLI_smallhash_remove(SmallHash *hash, uintptr_t key); +void *BLI_smallhash_lookup(SmallHash *hash, uintptr_t key); +int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key); +int BLI_smallhash_count(SmallHash *hash); +void *BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key); +void *BLI_smallhash_iternew(SmallHash *hash, SmallHashIter *iter, uintptr_t *key); /* void BLI_smallhash_print(SmallHash *hash); */ /* UNUSED */ #endif /* __BLI_SMALLHASH_H__ */ diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index ec36d587d92..c8f439c677f 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -36,95 +36,95 @@ extern "C" { #endif - /** - * Duplicates the cstring \a str into a newly mallocN'd - * string and returns it. - * - * \param str The string to be duplicated - * \retval Returns the duplicated string - */ +/** + * Duplicates the cstring \a str into a newly mallocN'd + * string and returns it. + * + * \param str The string to be duplicated + * \retval Returns the duplicated string + */ char *BLI_strdup(const char *str); - /** - * Duplicates the first \a len bytes of cstring \a str - * into a newly mallocN'd string and returns it. \a str - * is assumed to be at least len bytes long. - * - * \param str The string to be duplicated - * \param len The number of bytes to duplicate - * \retval Returns the duplicated string - */ +/** + * Duplicates the first \a len bytes of cstring \a str + * into a newly mallocN'd string and returns it. \a str + * is assumed to be at least len bytes long. + * + * \param str The string to be duplicated + * \param len The number of bytes to duplicate + * \retval Returns the duplicated string + */ char *BLI_strdupn(const char *str, const size_t len); - /** - * Appends the two strings, and returns new mallocN'ed string - * \param str1 first string for copy - * \param str2 second string for append - * \retval Returns dst - */ +/** + * Appends the two strings, and returns new mallocN'ed string + * \param str1 first string for copy + * \param str2 second string for append + * \retval Returns dst + */ char *BLI_strdupcat(const char *str1, const char *str2); - /** - * Like strncpy but ensures dst is always - * '\0' terminated. - * - * \param dst Destination for copy - * \param src Source string to copy - * \param maxncpy Maximum number of characters to copy (generally - * the size of dst) - * \retval Returns dst - */ +/** + * Like strncpy but ensures dst is always + * '\0' terminated. + * + * \param dst Destination for copy + * \param src Source string to copy + * \param maxncpy Maximum number of characters to copy (generally + * the size of dst) + * \retval Returns dst + */ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); - /* Makes a copy of the text within the "" that appear after some text 'blahblah' - * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples" - * - * - str: is the entire string to chop - * - prefix: is the part of the string to leave out - * - * Assume that the strings returned must be freed afterwards, and that the inputs will contain - * data we want... - */ +/* Makes a copy of the text within the "" that appear after some text 'blahblah' + * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples" + * + * - str: is the entire string to chop + * - prefix: is the part of the string to leave out + * + * Assume that the strings returned must be freed afterwards, and that the inputs will contain + * data we want... + */ char *BLI_getQuotedStr(const char *str, const char *prefix); - /** - * Returns a copy of the cstring \a str into a newly mallocN'd - * string with all instances of oldText replaced with newText, - * and returns it. - * - * \param str The string to replace occurrences of oldText in - * \param oldText The text in the string to find and replace - * \param newText The text in the string to find and replace - * \retval Returns the duplicated string - */ +/** + * Returns a copy of the cstring \a str into a newly mallocN'd + * string with all instances of oldText replaced with newText, + * and returns it. + * + * \param str The string to replace occurrences of oldText in + * \param oldText The text in the string to find and replace + * \param newText The text in the string to find and replace + * \retval Returns the duplicated string + */ char *BLI_replacestr(char *str, const char *oldText, const char *newText); - /* - * Replacement for snprintf - */ +/* + * Replacement for snprintf + */ size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...) #ifdef __GNUC__ -__attribute__ ((format (printf, 3, 4))) +__attribute__ ((format(printf, 3, 4))) #endif ; - /* - * Print formatted string into a newly mallocN'd string - * and return it. - */ +/* + * Print formatted string into a newly mallocN'd string + * and return it. + */ char *BLI_sprintfN(const char *format, ...) #ifdef __GNUC__ -__attribute__ ((format (printf, 1, 2))) +__attribute__ ((format(printf, 1, 2))) #endif ; size_t BLI_strescape(char *dst, const char *src, const size_t maxlen); - /** - * Compare two strings without regard to case. - * - * \retval True if the strings are equal, false otherwise. - */ +/** + * Compare two strings without regard to case. + * + * \retval True if the strings are equal, false otherwise. + */ int BLI_strcaseeq(const char *a, const char *b); char *BLI_strcasestr(const char *s, const char *find); diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 7799c32c4b7..56ed4beba53 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -37,17 +37,17 @@ int BLI_utf8_invalid_byte(const char *str, int length); int BLI_utf8_invalid_strip(char *str, int length); int BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */ - /* copied from glib */ +/* copied from glib */ unsigned int BLI_str_utf8_as_unicode(const char *p); unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index); unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index); -size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf); +size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf); char *BLI_str_find_prev_char_utf8(const char *str, const char *p); char *BLI_str_find_next_char_utf8(const char *p, const char *end); char *BLI_str_prev_char_utf8(const char *p); - /* wchar_t functions, copied from blenders own font.c originally */ +/* wchar_t functions, copied from blenders own font.c originally */ size_t BLI_wstrlen_utf8(const wchar_t *src); size_t BLI_strlen_utf8(const char *strc); size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy); diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index a4698ab4dd0..b13da9f0dd4 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -35,7 +35,7 @@ #include <pthread.h> /* for tables, button in UI, etc */ -#define BLENDER_MAX_THREADS 64 +#define BLENDER_MAX_THREADS 64 struct ListBase; @@ -44,15 +44,15 @@ struct ListBase; /*this is run once at startup*/ void BLI_threadapi_init(void); -void BLI_init_threads (struct ListBase *threadbase, void *(*do_thread)(void *), int tot); -int BLI_available_threads(struct ListBase *threadbase); -int BLI_available_thread_index(struct ListBase *threadbase); -void BLI_insert_thread (struct ListBase *threadbase, void *callerdata); -void BLI_remove_thread (struct ListBase *threadbase, void *callerdata); -void BLI_remove_thread_index(struct ListBase *threadbase, int index); -void BLI_remove_threads(struct ListBase *threadbase); -void BLI_end_threads (struct ListBase *threadbase); -int BLI_thread_is_main(void); +void BLI_init_threads(struct ListBase *threadbase, void *(*do_thread)(void *), int tot); +int BLI_available_threads(struct ListBase *threadbase); +int BLI_available_thread_index(struct ListBase *threadbase); +void BLI_insert_thread(struct ListBase *threadbase, void *callerdata); +void BLI_remove_thread(struct ListBase *threadbase, void *callerdata); +void BLI_remove_thread_index(struct ListBase *threadbase, int index); +void BLI_remove_threads(struct ListBase *threadbase); +void BLI_end_threads(struct ListBase *threadbase); +int BLI_thread_is_main(void); void BLI_begin_threaded_malloc(void); @@ -60,28 +60,28 @@ void BLI_end_threaded_malloc(void); /* System Information */ -int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */ +int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */ /* Global Mutex Locks * * One custom lock available now. can be extended. */ -#define LOCK_IMAGE 0 -#define LOCK_PREVIEW 1 -#define LOCK_VIEWER 2 -#define LOCK_CUSTOM1 3 -#define LOCK_RCACHE 4 -#define LOCK_OPENGL 5 -#define LOCK_NODES 6 -#define LOCK_MOVIECLIP 7 +#define LOCK_IMAGE 0 +#define LOCK_PREVIEW 1 +#define LOCK_VIEWER 2 +#define LOCK_CUSTOM1 3 +#define LOCK_RCACHE 4 +#define LOCK_OPENGL 5 +#define LOCK_NODES 6 +#define LOCK_MOVIECLIP 7 -void BLI_lock_thread(int type); -void BLI_unlock_thread(int type); +void BLI_lock_thread(int type); +void BLI_unlock_thread(int type); /* Mutex Lock */ typedef pthread_mutex_t ThreadMutex; -#define BLI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define BLI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER void BLI_mutex_init(ThreadMutex *mutex); void BLI_mutex_lock(ThreadMutex *mutex); @@ -90,8 +90,8 @@ void BLI_mutex_end(ThreadMutex *mutex); /* Read/Write Mutex Lock */ -#define THREAD_LOCK_READ 1 -#define THREAD_LOCK_WRITE 2 +#define THREAD_LOCK_READ 1 +#define THREAD_LOCK_WRITE 2 typedef pthread_rwlock_t ThreadRWMutex; diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 18c2aa3313c..d027a3da2ef 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -41,16 +41,16 @@ #endif -#define ELEM(a, b, c) ( (a)==(b) || (a)==(c) ) -#define ELEM3(a, b, c, d) ( ELEM(a, b, c) || (a)==(d) ) -#define ELEM4(a, b, c, d, e) ( ELEM(a, b, c) || ELEM(a, d, e) ) -#define ELEM5(a, b, c, d, e, f) ( ELEM(a, b, c) || ELEM3(a, d, e, f) ) -#define ELEM6(a, b, c, d, e, f, g) ( ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) -#define ELEM7(a, b, c, d, e, f, g, h) ( ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) -#define ELEM8(a, b, c, d, e, f, g, h, i) ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) -#define ELEM9(a, b, c, d, e, f, g, h, i, j) ( ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) -#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) ( ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) -#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) ( ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) +#define ELEM(a, b, c) ((a) == (b) || (a) == (c)) +#define ELEM3(a, b, c, d) (ELEM(a, b, c) || (a) == (d) ) +#define ELEM4(a, b, c, d, e) (ELEM(a, b, c) || ELEM(a, d, e) ) +#define ELEM5(a, b, c, d, e, f) (ELEM(a, b, c) || ELEM3(a, d, e, f) ) +#define ELEM6(a, b, c, d, e, f, g) (ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) +#define ELEM7(a, b, c, d, e, f, g, h) (ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) +#define ELEM8(a, b, c, d, e, f, g, h, i) (ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) +#define ELEM9(a, b, c, d, e, f, g, h, i, j) (ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) +#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) (ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) +#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) (ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) /* shift around elements */ #define SHIFT3(type, a, b, c) { \ @@ -59,7 +59,7 @@ a = c; \ c = b; \ b = tmp; \ - } (void)0 +} (void)0 #define SHIFT4(type, a, b, c, d) { \ type tmp; \ tmp = a; \ @@ -67,16 +67,16 @@ d = c; \ c = b; \ b = tmp; \ - } (void)0 +} (void)0 /* min/max */ -#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) -#define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) -#define MIN4(x,y,z,a) MIN2( MIN2((x),(y)) , MIN2((z),(a)) ) +#define MIN2(x, y) ( (x) < (y) ? (x) : (y) ) +#define MIN3(x, y, z) MIN2(MIN2((x), (y)), (z) ) +#define MIN4(x, y, z, a) MIN2(MIN2((x), (y)), MIN2((z), (a)) ) -#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) -#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) ) -#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) ) +#define MAX2(x, y) ( (x) > (y) ? (x) : (y) ) +#define MAX3(x, y, z) MAX2(MAX2((x), (y)), (z) ) +#define MAX4(x, y, z, a) MAX2(MAX2((x), (y)), MAX2((z), (a)) ) #define INIT_MINMAX(min, max) { \ (min)[0] = (min)[1] = (min)[2] = 1.0e30f; \ @@ -114,70 +114,71 @@ /* some math and copy defines */ #ifndef SWAP -# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } +# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } #endif -#define ABS(a) ( (a)<0 ? (-(a)) : (a) ) +#define ABS(a) ( (a) < 0 ? (-(a)) : (a) ) -#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) -#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) -#define USHORTTOUCHAR(val) ((unsigned char)(((val) >= 65535-128)? 255: ((val)+128)>>8)) +#define FTOCHAR(val) ((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : (char)((255.0f * (val)) + 0.5f)) +#define FTOUSHORT(val) ((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (unsigned short)(val * 65535.0f + 0.5f)) +#define USHORTTOUCHAR(val) ((unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8)) #define F3TOCHAR3(v2, v1) { \ - (v1)[0]= FTOCHAR((v2[0])); \ - (v1)[1]= FTOCHAR((v2[1])); \ - (v1)[2]= FTOCHAR((v2[2])); \ - } (void)0 + (v1)[0] = FTOCHAR((v2[0])); \ + (v1)[1] = FTOCHAR((v2[1])); \ + (v1)[2] = FTOCHAR((v2[2])); \ +} (void)0 #define F3TOCHAR4(v2, v1) { \ - (v1)[0]= FTOCHAR((v2[0])); \ - (v1)[1]= FTOCHAR((v2[1])); \ - (v1)[2]= FTOCHAR((v2[2])); \ - (v1)[3]= 255; \ - } (void)0 + (v1)[0] = FTOCHAR((v2[0])); \ + (v1)[1] = FTOCHAR((v2[1])); \ + (v1)[2] = FTOCHAR((v2[2])); \ + (v1)[3] = 255; \ +} (void)0 #define F4TOCHAR4(v2, v1) { \ - (v1)[0]= FTOCHAR((v2[0])); \ - (v1)[1]= FTOCHAR((v2[1])); \ - (v1)[2]= FTOCHAR((v2[2])); \ - (v1)[3]= FTOCHAR((v2[3])); \ - } (void)0 + (v1)[0] = FTOCHAR((v2[0])); \ + (v1)[1] = FTOCHAR((v2[1])); \ + (v1)[2] = FTOCHAR((v2[2])); \ + (v1)[3] = FTOCHAR((v2[3])); \ +} (void)0 #define VECCOPY(v1, v2) { \ - *(v1)= *(v2); \ - *(v1+1)= *(v2+1); \ - *(v1+2)= *(v2+2); \ - } (void)0 + *(v1) = *(v2); \ + *(v1 + 1) = *(v2 + 1); \ + *(v1 + 2) = *(v2 + 2); \ +} (void)0 #define VECCOPY2D(v1, v2) { \ - *(v1)= *(v2); \ - *(v1+1)= *(v2+1); \ - } (void)0 -#define VECADD(v1,v2,v3) { \ - *(v1)= *(v2) + *(v3); \ - *(v1+1)= *(v2+1) + *(v3+1); \ - *(v1+2)= *(v2+2) + *(v3+2); \ - } (void)0 -#define VECSUB(v1,v2,v3) { \ - *(v1)= *(v2) - *(v3); \ - *(v1+1)= *(v2+1) - *(v3+1); \ - *(v1+2)= *(v2+2) - *(v3+2); \ - } (void)0 -#define VECSUB2D(v1,v2,v3) { \ - *(v1)= *(v2) - *(v3); \ - *(v1+1)= *(v2+1) - *(v3+1); \ - } (void)0 -#define VECADDFAC(v1,v2,v3,fac) { \ - *(v1)= *(v2) + *(v3)*(fac); \ - *(v1+1)= *(v2+1) + *(v3+1)*(fac); \ - *(v1+2)= *(v2+2) + *(v3+2)*(fac); \ - } (void)0 -#define VECSUBFAC(v1,v2,v3,fac) { \ - *(v1)= *(v2) - *(v3)*(fac); \ - *(v1+1)= *(v2+1) - *(v3+1)*(fac); \ - *(v1+2)= *(v2+2) - *(v3+2)*(fac); \ - } (void)0 - -#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] ) + *(v1) = *(v2); \ + *(v1 + 1) = *(v2 + 1); \ +} (void)0 +#define VECADD(v1, v2, v3) { \ + *(v1) = *(v2) + *(v3); \ + *(v1 + 1) = *(v2 + 1) + *(v3 + 1); \ + *(v1 + 2) = *(v2 + 2) + *(v3 + 2); \ +} (void)0 +#define VECSUB(v1, v2, v3) { \ + *(v1) = *(v2) - *(v3); \ + *(v1 + 1) = *(v2 + 1) - *(v3 + 1); \ + *(v1 + 2) = *(v2 + 2) - *(v3 + 2); \ +} (void)0 +#define VECSUB2D(v1, v2, v3) { \ + *(v1) = *(v2) - *(v3); \ + *(v1 + 1) = *(v2 + 1) - *(v3 + 1); \ +} (void)0 +#define VECADDFAC(v1, v2, v3, fac) { \ + *(v1) = *(v2) + *(v3) * (fac); \ + *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (fac); \ + *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (fac); \ +} (void)0 +#define VECSUBFAC(v1, v2, v3, fac) { \ + *(v1) = *(v2) - *(v3) * (fac); \ + *(v1 + 1) = *(v2 + 1) - *(v3 + 1) * (fac); \ + *(v1 + 2) = *(v2 + 2) - *(v3 + 2) * (fac); \ +} (void)0 + +#define INPR(v1, v2) ( (v1)[0] * (v2)[0] + (v1)[1] * (v2)[1] + (v1)[2] * (v2)[2]) /* some misc stuff.... */ -#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c) -#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a)) +#define CLAMP(a, b, c) if ((a) < (b)) (a) = (b); else if ((a) > (c)) (a) = (c) + +#define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a)) #define CLAMPTEST(a, b, c) \ if ((b) < (c)) { \ CLAMP(a, b, c); \ @@ -186,16 +187,16 @@ CLAMP(a, c, b); \ } (void) -#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1) -#define IS_EQF(a,b) ((fabsf((float)(a)-(b)) >= (float) FLT_EPSILON) ? 0 : 1) +#define IS_EQ(a, b) ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? 0 : 1) +#define IS_EQF(a, b) ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? 0 : 1) -#define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0))) -#define IN_RANGE(a, b, c) ((b < c)? ((b<a && a<c)? 1:0) : ((c<a && a<b)? 1:0)) -#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0)) +#define IS_EQT(a, b, c) ((a > b) ? (((a - b) <= c) ? 1 : 0) : ((((b - a) <= c) ? 1 : 0))) +#define IN_RANGE(a, b, c) ((b < c) ? ((b < a && a < c) ? 1 : 0) : ((c < a && a < b) ? 1 : 0)) +#define IN_RANGE_INCL(a, b, c) ((b < c) ? ((b <= a && a <= c) ? 1 : 0) : ((c <= a && a <= b) ? 1 : 0)) /* array helpers */ #define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \ - (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1))) + (arr_dtype *)((char *)arr_start + (elem_size * (tot - 1))) #define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ( \ (item >= arr_start) && \ @@ -205,24 +206,24 @@ /* This one rotates the bytes in an int64, int (32) and short (16) */ #define SWITCH_INT64(a) { \ char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i= p_i[0]; p_i[0]= p_i[7]; p_i[7]= s_i; \ - s_i= p_i[1]; p_i[1]= p_i[6]; p_i[6]= s_i; \ - s_i= p_i[2]; p_i[2]= p_i[5]; p_i[5]= s_i; \ - s_i= p_i[3]; p_i[3]= p_i[4]; p_i[4]= s_i; \ + p_i = (char *)&(a); \ + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; \ } (void)0 #define SWITCH_INT(a) { \ char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i= p_i[0]; p_i[0]= p_i[3]; p_i[3]= s_i; \ - s_i= p_i[1]; p_i[1]= p_i[2]; p_i[2]= s_i; \ + p_i = (char *)&(a); \ + s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; \ + s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; \ } (void)0 #define SWITCH_SHORT(a) { \ char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; \ + p_i = (char *)&(a); \ + s_i = p_i[0]; p_i[0] = p_i[1]; p_i[1] = s_i; \ } (void)0 diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index 0020ba308af..a63ec8e9f61 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -47,20 +47,19 @@ typedef struct VFontData { // float resol[MAX_VF_CHARS]; // float width[MAX_VF_CHARS]; // float *points[MAX_VF_CHARS]; - char name[128]; + char name[128]; } VFontData; typedef struct VChar { struct VChar *next, *prev; - ListBase nurbsbase; - intptr_t index; - float resol; - float width; + ListBase nurbsbase; + intptr_t index; + float resol; + float width; float *points; } VChar; -struct TmpFont -{ +struct TmpFont { struct TmpFont *next, *prev; struct PackedFile *pf; struct VFont *vfont; @@ -74,13 +73,9 @@ struct TmpFont * \retval A new VFontData structure, or NULL * if unable to load. */ - VFontData* -BLI_vfontdata_from_freetypefont( - struct PackedFile *pf); +VFontData *BLI_vfontdata_from_freetypefont(struct PackedFile *pf); - int -BLI_vfontchar_from_freetypefont( - struct VFont *vfont, unsigned long character); +int BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character); #endif diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index a0ab88e8baf..70c7f1d9cae 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -52,7 +52,7 @@ #ifndef WIN32_SKIP_HKEY_PROTECTION # undef HKEY -# define HKEY WIN32_HKEY // prevent competing definitions +# define HKEY WIN32_HKEY /* prevent competing definitions */ # include <windows.h> # undef HKEY #else @@ -85,10 +85,10 @@ extern "C" { #define MAXPATHLEN MAX_PATH #ifndef S_ISREG -# define S_ISREG(x) (((x)&_S_IFREG) == _S_IFREG) +# define S_ISREG(x) (((x) & _S_IFREG) == _S_IFREG) #endif #ifndef S_ISDIR -# define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR) +# define S_ISDIR(x) (((x) & _S_IFDIR) == _S_IFDIR) #endif /* defines for using ISO C++ conformant names */ @@ -139,9 +139,9 @@ typedef struct _DIR { } DIR; void RegisterBlendExtension(void); -DIR *opendir (const char *path); +DIR *opendir(const char *path); struct dirent *readdir(DIR *dp); -int closedir (DIR *dp); +int closedir(DIR *dp); void get_default_root(char *root); int check_file_chars(char *filename); const char *dirname(char *path); diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h index c3c10239a8e..6153007be80 100644 --- a/source/blender/blenlib/PIL_time.h +++ b/source/blender/blenlib/PIL_time.h @@ -39,39 +39,39 @@ extern "C" { #endif extern - /** Return an indication of time, expressed as - * seconds since some fixed point. Successive calls - * are guaranteed to generate values greater than or - * equal to the last call. - */ -double PIL_check_seconds_timer (void); +/** Return an indication of time, expressed as + * seconds since some fixed point. Successive calls + * are guaranteed to generate values greater than or + * equal to the last call. + */ +double PIL_check_seconds_timer(void); - /** - * Platform-independent sleep function. - * \param ms Number of milliseconds to sleep - */ -void PIL_sleep_ms (int ms); +/** + * Platform-independent sleep function. + * \param ms Number of milliseconds to sleep + */ +void PIL_sleep_ms(int ms); /** Utility defines for timing. * requires BLI_utildefines.h for 'AT' * TIMEIT_VALUE returns the time since TIMEIT_START was called. */ -#define TIMEIT_START(var) \ -{ \ - double _timeit_##var= PIL_check_seconds_timer(); \ - printf("time start (" #var "): " AT "\n"); \ - fflush(stdout); \ - { \ +#define TIMEIT_START(var) \ + { \ + double _timeit_##var = PIL_check_seconds_timer(); \ + printf("time start (" #var "): " AT "\n"); \ + fflush(stdout); \ + { (void) \ #define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var) -#define TIMEIT_END(var) \ - } \ - printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var)); \ - fflush(stdout); \ -} \ +#define TIMEIT_END(var) \ + } \ + printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var)); \ + fflush(stdout); \ +} (void) \ #ifdef __cplusplus } |