Cleanup: make remaining blenlib headers work in C++

Differential Revision: https://developer.blender.org/D6988

Reviewers: brecht
This commit is contained in:
Jacques Lucke 2020-03-02 15:04:53 +01:00
parent 5afa4b1dc8
commit cf93b65a65
41 changed files with 328 additions and 0 deletions

View File

@ -25,6 +25,10 @@
* \brief A general argument parsing module.
*/
#ifdef __cplusplus
extern "C" {
#endif
struct bArgs;
typedef struct bArgs bArgs;
@ -71,4 +75,8 @@ void BLI_argsPrintOtherDoc(struct bArgs *ba);
void BLI_argsPrint(struct bArgs *ba);
const char **BLI_argsArgv(struct bArgs *ba);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -22,6 +22,10 @@
* \brief Efficient in-memory storage of multiple similar arrays.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BArrayState BArrayState;
typedef struct BArrayStore BArrayStore;
@ -46,4 +50,8 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
/* only for tests */
bool BLI_array_store_is_valid(BArrayStore *bs);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ARRAY_STORE_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct BArrayStore;
struct BArrayStore_AtSize {
@ -40,4 +44,8 @@ void BLI_array_store_at_size_calc_memory_usage(struct BArrayStore_AtSize *bs_str
size_t *r_size_expanded,
size_t *r_size_compacted);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ARRAY_STORE_UTILS_H__ */

View File

@ -24,6 +24,10 @@
#include "BLI_compiler_typecheck.h"
#ifdef __cplusplus
extern "C" {
#endif
void _bli_array_reverse(void *arr, unsigned int arr_len, size_t arr_stride);
#define BLI_array_reverse(arr, arr_len) _bli_array_reverse(arr, arr_len, sizeof(*(arr)))
@ -85,4 +89,8 @@ bool _bli_array_iter_span(const void *arr,
bool _bli_array_is_zeroed(const void *arr, unsigned int arr_len, size_t arr_stride);
#define BLI_array_is_zeroed(arr, arr_len) _bli_array_is_zeroed(arr, arr_len, sizeof(*(arr)))
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ARRAY_UTILS_H__ */

View File

@ -29,6 +29,10 @@
#include "BLI_bitmap.h"
#ifdef __cplusplus
extern "C" {
#endif
/* -------------------------------------------------------------------- */
typedef struct BLI_AStarGNLink {
@ -114,4 +118,8 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
BLI_AStarSolution *r_solution,
const int max_steps);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ASTAR_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int BLI_bitmap;
/* warning: the bitmap does not keep track of its own size or check
@ -109,4 +113,8 @@ void BLI_bitmap_copy_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits);
void BLI_bitmap_and_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits);
void BLI_bitmap_or_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
void BLI_bitmap_draw_2d_line_v2v2i(const int p1[2],
const int p2[2],
bool (*callback)(int, int, void *),
@ -41,4 +45,8 @@ void BLI_bitmap_draw_2d_poly_v2i_n(const int xmin,
void (*callback)(int x, int x_end, int y, void *),
void *user_data);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_BITMAP_DRAW_2D_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct ListBase;
/* Box Packer */
@ -57,4 +61,8 @@ void BLI_box_pack_2d_fixedarea(struct ListBase *boxes,
int height,
struct ListBase *packed);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_BOXPACK_2D_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BLI_Buffer {
void *data;
const size_t elem_size;
@ -93,4 +97,8 @@ void _bli_buffer_free(BLI_Buffer *buffer);
#define BLI_buffer_field_free(name_) _bli_buffer_free(name_)
#ifdef __cplusplus
}
#endif
#endif /* __BLI_BUFFER_H__ */

View File

@ -21,10 +21,18 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points[]);
int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[]);
float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], unsigned int n);
float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_CONVEXHULL_2D_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Interface for Constrained Delaunay Triangulation (CDT) in 2D.
*
@ -202,4 +206,8 @@ CDT_result *BLI_delaunay_2d_cdt_calc(const CDT_input *input, const CDT_output_ty
void BLI_delaunay_2d_cdt_free(CDT_result *result);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_DELAUNAY_2D_H__ */

View File

@ -46,10 +46,18 @@
* \endcode
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Dial Dial;
Dial *BLI_dial_initialize(const float start_position[2], float threshold);
float BLI_dial_angle(Dial *dial, const float current_position[2]);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_DIAL_2D_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Double-Linked Red-Black Tree Implementation:
*
* This is simply a Red-Black Tree implementation whose nodes can later
@ -159,4 +163,8 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node);
/* ********************************************** */
#ifdef __cplusplus
}
#endif
#endif /* __BLI_DLRBTREE_H__ */

View File

@ -24,6 +24,10 @@
#ifndef __BLI_DYNLIB_H__
#define __BLI_DYNLIB_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DynamicLibrary DynamicLibrary;
DynamicLibrary *BLI_dynlib_open(const char *name);
@ -31,4 +35,8 @@ 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);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_DYNLIB_H__ */

View File

@ -34,6 +34,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct DynStr;
/** The abstract DynStr type */
@ -57,4 +61,8 @@ void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict str) ATTR
void BLI_dynstr_clear(DynStr *ds) ATTR_NONNULL();
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL();
#ifdef __cplusplus
}
#endif
#endif /* __BLI_DYNSTR_H__ */

View File

@ -23,6 +23,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct EdgeHash;
typedef struct EdgeHash EdgeHash;
@ -150,4 +154,8 @@ BLI_INLINE bool BLI_edgesetIterator_isDone(EdgeSetIterator *esi)
return esi->index >= esi->length;
}
#ifdef __cplusplus
}
#endif
#endif /* __BLI_EDGEHASH_H__ */

View File

@ -23,6 +23,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
/* BLI_endian_switch_inline.h */
BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_NONNULL(1);
BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) ATTR_NONNULL(1);
@ -43,6 +47,10 @@ void BLI_endian_switch_int64_array(int64_t *val, const int size) ATTR_NONNULL(1)
void BLI_endian_switch_uint64_array(uint64_t *val, const int size) ATTR_NONNULL(1);
void BLI_endian_switch_double_array(double *val, const int size) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif
#include "BLI_endian_switch_inline.h"
#endif /* __BLI_ENDIAN_SWITCH_H__ */

View File

@ -17,6 +17,10 @@
#ifndef __BLI_ENDIAN_SWITCH_INLINE_H__
#define __BLI_ENDIAN_SWITCH_INLINE_H__
#ifdef __cplusplus
extern "C" {
#endif
/* only include from header */
#ifndef __BLI_ENDIAN_SWITCH_H__
# error "this file isnt to be directly included"
@ -85,4 +89,8 @@ BLI_INLINE void BLI_endian_switch_double(double *val)
BLI_endian_switch_uint64((uint64_t *)val);
}
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ENDIAN_SWITCH_INLINE_H__ */

View File

@ -27,6 +27,10 @@
#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(WIN32)
typedef unsigned int mode_t;
#endif
@ -57,4 +61,8 @@ struct dirlink {
char *name;
};
#ifdef __cplusplus
}
#endif
#endif /* __BLI_FILEOPS_TYPES_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
* result is always in little endian byte order, so that a byte-wise
* output yields to the wanted ASCII representation of the message
@ -36,4 +40,8 @@ int BLI_hash_md5_stream(FILE *stream, void *resblock);
char *BLI_hash_md5_to_hexdigest(void *resblock, char r_hex_digest[33]);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_HASH_MD5_H__ */

View File

@ -23,6 +23,10 @@
#include "BLI_sys_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BLI_HashMurmur2A {
uint32_t hash;
uint32_t tail;
@ -40,4 +44,8 @@ uint32_t BLI_hash_mm2a_end(BLI_HashMurmur2A *mm2);
uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_HASH_MM2A_H__ */

View File

@ -22,6 +22,10 @@
* \brief A min-heap / priority queue ADT
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Heap;
struct HeapNode;
typedef struct Heap Heap;
@ -52,4 +56,8 @@ void *BLI_heap_node_ptr(const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNU
/* only for gtest */
bool BLI_heap_is_valid(const Heap *heap);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_HEAP_H__ */

View File

@ -22,6 +22,10 @@
* \brief A min-heap / priority queue ADT
*/
#ifdef __cplusplus
extern "C" {
#endif
struct HeapSimple;
typedef struct HeapSimple HeapSimple;
@ -37,4 +41,8 @@ uint BLI_heapsimple_len(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NON
float BLI_heapsimple_top_value(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
void *BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_HEAP_SIMPLE_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BLI_Iterator {
void *current; /* current pointer we iterate over */
void *data; /* stored data required for this iterator */
@ -51,4 +55,8 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
} \
((void)0)
#ifdef __cplusplus
}
#endif
#endif /* __BLI_ITERATOR_H__ */

View File

@ -24,8 +24,16 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
void BLI_jitter_init(float (*jitarr)[2], int num);
void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float radius1);
void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float radius2);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_JITTER_2D_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct rcti;
void BLI_lasso_boundbox(struct rcti *rect, const int mcords[][2], const unsigned int moves);
@ -40,4 +44,8 @@ bool BLI_lasso_is_edge_inside(const int mcords[][2],
int y1,
const int error_value);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_LASSO_2D_H__ */

View File

@ -26,6 +26,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct BLI_mempool;
struct MemArena;
@ -93,4 +97,8 @@ LinkNode *BLI_linklist_sort_r(LinkNode *list,
#define BLI_linklist_append_alloca(list_pair, ptr) \
BLI_linklist_append_nlink(list_pair, ptr, alloca(sizeof(LinkNode)))
#ifdef __cplusplus
}
#endif
#endif /* __BLI_LINKLIST_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
void BLI_bicubic_interpolation_fl(
const float *buffer, float *output, int width, int height, int components, float u, float v);
@ -88,4 +92,8 @@ void BLI_ewa_filter(const int width,
void *customdata,
float result[4]);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_MATH_INTERP_H__ */

View File

@ -22,9 +22,17 @@
* \brief Generic memory manipulation API.
*/
#ifdef __cplusplus
extern "C" {
#endif
/* it may be defined already */
#ifndef __BLI_UTILDEFINES_H__
bool BLI_memory_is_zero(const void *arr, const size_t size);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BLI_MEMORY_UTILS_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct MemArena;
void BLI_polyfill_calc_arena(const float (*coords)[2],
@ -38,4 +42,8 @@ void BLI_polyfill_calc(const float (*coords)[2],
/* default size of polyfill arena */
#define BLI_POLYFILL_ARENA_SIZE MEM_SIZE_OPTIMAL(1 << 14)
#ifdef __cplusplus
}
#endif
#endif /* __BLI_POLYFILL_2D_H__ */

View File

@ -21,6 +21,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Heap;
struct MemArena;
@ -44,4 +48,8 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
/* avoid realloc's when creating new structures for polyfill ngons */
#define BLI_POLYFILL_ALLOC_NGON_RESERVE 64
#ifdef __cplusplus
}
#endif
#endif /* __BLI_POLYFILL_2D_BEAUTIFY_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Quadric {
double a2, ab, ac, ad, b2, bc, bd, c2, cd, d2;
} Quadric;
@ -43,4 +47,8 @@ void BLI_quadric_mul(Quadric *a, const double scalar);
double BLI_quadric_evaluate(const Quadric *q, const double v[3]);
bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_QUADRIC_H__ */

View File

@ -26,6 +26,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uintptr_t key;
void *val;
@ -74,4 +78,8 @@ void **BLI_smallhash_iternew_p(const SmallHash *sh, SmallHashIter *iter, uintptr
double BLI_smallhash_calc_quality(SmallHash *sh);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BLI_SMALLHASH_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* \note keep \a sort_value first,
* so cmp functions can be reused.
@ -57,4 +61,8 @@ int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_);
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_);
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_SORT_UTILS_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum eStrCursorJumpType {
STRCUR_JUMP_NONE,
STRCUR_JUMP_DELIM,
@ -52,4 +56,8 @@ void BLI_str_cursor_step_utf32(const char32_t *str,
eStrCursorJumpType jump,
bool use_init_step);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_STRING_CURSOR_UTF8_H__ */

View File

@ -26,6 +26,10 @@
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
extern "C" {
#endif
size_t BLI_timecode_string_from_time(char *str,
const size_t len,
const int brevity_level,
@ -42,4 +46,8 @@ size_t BLI_timecode_string_from_time_seconds(char *str,
const int brevity_level,
const float time_seconds) ATTR_NONNULL();
#ifdef __cplusplus
}
#endif
#endif /* __BLI_TIMECODE_H__ */

View File

@ -26,6 +26,10 @@
* \ingroup BLI
*/
#ifdef __cplusplus
extern "C" {
#endif
/* ret < 0: the timer will be removed.
* ret >= 0: the timer will be called again in ret seconds */
typedef double (*BLI_timer_func)(uintptr_t uuid, void *user_data);
@ -54,4 +58,8 @@ void BLI_timer_free(void);
* is properly configured for the new file. */
void BLI_timer_on_file_load(void);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_TIMER_H__ */

View File

@ -20,6 +20,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Object;
struct ProjCameraInfo;
@ -46,4 +50,8 @@ void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotma
/* so we can adjust scale with keeping the struct private */
void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x, float scale_y);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -28,6 +28,10 @@
#include "DNA_listBase.h"
#ifdef __cplusplus
extern "C" {
#endif
struct PackedFile;
struct VFont;
@ -52,4 +56,8 @@ VFontData *BLI_vfontdata_copy(const VFontData *vfont_src, const int flag);
VChar *BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character);
VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int flag);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -26,6 +26,10 @@ struct ListBase;
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct VoronoiSite {
float co[2];
float color[3];
@ -74,4 +78,8 @@ void BLI_voronoi_triangulate(const VoronoiSite *sites,
int (**triangles_r)[3],
int *triangles_total_r);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_VORONOI_2D_H__ */

View File

@ -24,6 +24,10 @@
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Find the index number of a voxel, given x/y/z integer coords and resolution vector. */
#define BLI_VOXEL_INDEX(x, y, z, res) \
@ -36,4 +40,8 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3
float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float co[3]);
float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline);
#ifdef __cplusplus
}
#endif
#endif /* __BLI_VOXEL_H__ */