add win32 (msvc) support

This commit is contained in:
2024-11-14 16:56:12 +00:00
parent c14c2e5500
commit d614e110df
35 changed files with 454 additions and 280 deletions

View File

@@ -1,5 +1,6 @@
#include <string.h>
#include <blue/object/bitmap.h>
#include <blue/core/bitop.h>
void b_bitmap_zero(b_bitmap_word *map, unsigned long nbits)
{
@@ -38,7 +39,6 @@ bool b_bitmap_check(const b_bitmap_word *map, unsigned long bit)
unsigned long mask = 1ul << offset;
return (map[index] & mask) != 0;
}
unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits)
@@ -47,7 +47,7 @@ unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits)
unsigned int set_bits = 0;
for (unsigned long i = 0; i < words; i++) {
set_bits += __builtin_popcountl(map[i]);
set_bits += b_popcountl(map[i]);
}
if (set_bits > nbits) {
@@ -63,7 +63,7 @@ unsigned int b_bitmap_count_clear(const b_bitmap_word *map, unsigned long nbits)
unsigned int clear_bits = 0;
for (unsigned long i = 0; i < words; i++) {
clear_bits += __builtin_popcountl(~map[i]);
clear_bits += b_popcountl(~map[i]);
}
if (clear_bits > nbits) {
@@ -91,7 +91,7 @@ unsigned int b_bitmap_highest_set(const b_bitmap_word *map, unsigned long nbits)
return B_BITMAP_NPOS;
}
return bit_index + (Z__B_BITS_PER_WORD - __builtin_ctzl(last_word) - 1);
return bit_index + (Z__B_BITS_PER_WORD - b_ctzl(last_word) - 1);
}
unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbits)
@@ -115,7 +115,7 @@ unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbit
return bit_index + Z__B_BITS_PER_WORD - 1;
}
return bit_index + (Z__B_BITS_PER_WORD - __builtin_ctzl(~last_word)) - 1;
return bit_index + (Z__B_BITS_PER_WORD - b_ctzl(~last_word)) - 1;
}
unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits)
@@ -137,7 +137,7 @@ unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits)
return B_BITMAP_NPOS;
}
return bit_index + __builtin_clzl(last_word);
return bit_index + b_clzl(last_word);
}
unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits)
@@ -163,5 +163,5 @@ unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits
return B_BITMAP_NPOS;
}
return bit_index + __builtin_clzl(~last_word);
return bit_index + b_clzl(~last_word);
}

View File

@@ -64,7 +64,7 @@ typedef struct b_array_iterator {
*
* @return A pointer to the new array, or NULL if an error occurred.
*/
extern b_array *b_array_create(void);
BLUE_API b_array *b_array_create(void);
/**
* Creates an b_array initialised with the contents of the provided b_object
@@ -81,7 +81,7 @@ extern b_array *b_array_create(void);
* @param nr_values The size of the `values` array.
* @return A pointer to the new b_array, or NULL if an error occurred.
*/
extern b_array *b_array_create_with_values(
BLUE_API b_array *b_array_create_with_values(
b_object *const *values, size_t nr_values);
/**
@@ -110,7 +110,7 @@ static inline void b_array_release(b_array *array)
*
* @param array The b_array to clear.
*/
extern void b_array_clear(b_array *array);
BLUE_API void b_array_clear(b_array *array);
/**
* Inserts an object at the end of an b_array. The reference count of the object
@@ -120,7 +120,7 @@ extern void b_array_clear(b_array *array);
* @param value The object to append.
* @return B_SUCCESS if the object was appended successfully, or an error code if an error occurred.
*/
extern b_status b_array_append(b_array *array, b_object *value);
BLUE_API b_status b_array_append(b_array *array, b_object *value);
/**
* Inserts an object at the beginning of an b_array. The reference count of the object
@@ -131,7 +131,7 @@ extern b_status b_array_append(b_array *array, b_object *value);
* @param value The object to prepend.
* @return B_SUCCESS if the object was prepended successfully, or an error code if an error occurred.
*/
extern b_status b_array_prepend(b_array *array, b_object *value);
BLUE_API b_status b_array_prepend(b_array *array, b_object *value);
/**
* Inserts an object into an b_array at a given index. The reference count of the object
@@ -145,7 +145,7 @@ extern b_status b_array_prepend(b_array *array, b_object *value);
* be inserted at the end of the b_array.
* @return B_SUCCESS if the object was inserted, or a status code describing any error that occurred.
*/
extern b_status b_array_insert(b_array *array, b_object *value, size_t at);
BLUE_API b_status b_array_insert(b_array *array, b_object *value, size_t at);
/**
* Removes the object at the specified index from an b_array. The reference count
@@ -157,7 +157,7 @@ extern b_status b_array_insert(b_array *array, b_object *value, size_t at);
* @param at The index of the object to be removed.
* @return B_SUCCESS if the object was removed, or a status code describing any error that occurred.
*/
extern b_status b_array_remove(b_array *array, size_t at);
BLUE_API b_status b_array_remove(b_array *array, size_t at);
/**
* Removes the object at the beginning of an b_array. The reference count
@@ -167,7 +167,7 @@ extern b_status b_array_remove(b_array *array, size_t at);
* @param array The b_array to remove the object from.
* @return B_SUCCESS if the object was removed, or a status code describing any error that occurred.
*/
extern b_status b_array_remove_front(b_array *array);
BLUE_API b_status b_array_remove_front(b_array *array);
/**
* Removes the object at the end of an b_array. The reference count
@@ -176,7 +176,7 @@ extern b_status b_array_remove_front(b_array *array);
* @param array The b_array to remove the object from.
* @return B_SUCCESS if the object was removed, or a status code describing any error that occurred.
*/
extern b_status b_array_remove_back(b_array *array);
BLUE_API b_status b_array_remove_back(b_array *array);
/**
* Removes the object at the specified index of an b_array, and returns a
@@ -191,7 +191,7 @@ extern b_status b_array_remove_back(b_array *array);
* @return An pointer to the removed object. This pointer is owned by the
* caller. Returns NULL if an error occurred.
*/
extern b_object *b_array_pop(b_array *array, size_t at);
BLUE_API b_object *b_array_pop(b_array *array, size_t at);
/**
* Removes the object at the beginning of an b_array, and returns a pointer to
@@ -204,7 +204,7 @@ extern b_object *b_array_pop(b_array *array, size_t at);
* @return An pointer to the removed object. This pointer is owned by the
* caller. Returns NULL if an error occurred.
*/
extern b_object *b_array_pop_front(b_array *array);
BLUE_API b_object *b_array_pop_front(b_array *array);
/**
* Removes the object at the end of an b_array, and returns a pointer to it. The
@@ -215,7 +215,7 @@ extern b_object *b_array_pop_front(b_array *array);
* @return An pointer to the removed object. This pointer is owned by the
* caller. Returns NULL if an error occurred.
*/
extern b_object *b_array_pop_back(b_array *array);
BLUE_API b_object *b_array_pop_back(b_array *array);
/**
* Returns an unowned pointer to the object at the given index of an b_array.
@@ -226,7 +226,7 @@ extern b_object *b_array_pop_back(b_array *array);
* @return A pointer to the object at the given index. This pointer is NOT owned
* by the caller. Returns NULL if an error occurred.
*/
extern b_object *b_array_at(const b_array *array, size_t at);
BLUE_API b_object *b_array_at(const b_array *array, size_t at);
/**
* Returns an owned pointer to the object at the given index of an b_array. The caller owns
@@ -237,7 +237,7 @@ extern b_object *b_array_at(const b_array *array, size_t at);
* @return A pointer to the object at the given index. This pointer is owned by the caller.
* Returns NULL if an error occurred.
*/
extern b_object *b_array_get(b_array *array, size_t at);
BLUE_API b_object *b_array_get(b_array *array, size_t at);
/**
* Returns the number of objects contained in an b_array.
@@ -245,7 +245,7 @@ extern b_object *b_array_get(b_array *array, size_t at);
* @param array The b_array.
* @return The number of objects contained in the b_array.
*/
extern size_t b_array_size(const b_array *array);
BLUE_API size_t b_array_size(const b_array *array);
/**
* Returns the current maximum capacity of an b_array. This represents the
@@ -255,7 +255,7 @@ extern size_t b_array_size(const b_array *array);
* @param array The b_array.
* @return The maximum capacity of the b_array.
*/
extern size_t b_array_capacity(const b_array *array);
BLUE_API size_t b_array_capacity(const b_array *array);
/**
* Initialise an b_array_iterator to pointer to the first object in an b_array.
@@ -265,7 +265,7 @@ extern size_t b_array_capacity(const b_array *array);
* @param it
* @return Always returns 0.
*/
extern int b_array_iterator_begin(b_array *array, b_array_iterator *it);
BLUE_API int b_array_iterator_begin(b_array *array, b_array_iterator *it);
/**
* Advances an b_array_iterator to pointer to the next object in an b_array.
@@ -273,7 +273,7 @@ extern int b_array_iterator_begin(b_array *array, b_array_iterator *it);
* @return True if the iterator contains a valid reference to an object, or
* False if the iterator has gone past the end of the array.
*/
extern bool b_array_iterator_next(b_array_iterator *it);
BLUE_API bool b_array_iterator_next(b_array_iterator *it);
/**
* Removes the object pointed to by an b_array_iterator from its container
@@ -284,7 +284,7 @@ extern bool b_array_iterator_next(b_array_iterator *it);
* @param it The iterator whose object should be removed.
* @return B_SUCCESS if the object was removed, or a status code describing the error that occurred.
*/
extern b_status b_array_iterator_erase(b_array_iterator *it);
BLUE_API b_status b_array_iterator_erase(b_array_iterator *it);
/**
* Checks whether or not an iterator contains a valid reference to an object.
@@ -295,7 +295,7 @@ extern b_status b_array_iterator_erase(b_array_iterator *it);
* @param it The iterator to check.
* @return True if the iterator is valid. False otherwise.
*/
extern bool b_array_iterator_is_valid(const b_array_iterator *it);
BLUE_API bool b_array_iterator_is_valid(const b_array_iterator *it);
#ifdef __cplusplus
}

View File

@@ -1,6 +1,7 @@
#ifndef BLUELIB_BITMAP_H_
#define BLUELIB_BITMAP_H_
#include <blue/core/misc.h>
#include <stdbool.h>
typedef unsigned long b_bitmap_word;
@@ -12,19 +13,19 @@ typedef unsigned long b_bitmap_word;
#define B_DECLARE_BITMAP(name, nbits) b_bitmap_word name[B_BITMAP_WORDS(nbits)]
extern void b_bitmap_zero(b_bitmap_word *map, unsigned long nbits);
extern void b_bitmap_fill(b_bitmap_word *map, unsigned long nbits);
extern void b_bitmap_set(b_bitmap_word *map, unsigned long bit);
extern void b_bitmap_clear(b_bitmap_word *map, unsigned long bit);
extern bool b_bitmap_check(const b_bitmap_word *map, unsigned long bit);
BLUE_API void b_bitmap_zero(b_bitmap_word *map, unsigned long nbits);
BLUE_API void b_bitmap_fill(b_bitmap_word *map, unsigned long nbits);
BLUE_API void b_bitmap_set(b_bitmap_word *map, unsigned long bit);
BLUE_API void b_bitmap_clear(b_bitmap_word *map, unsigned long bit);
BLUE_API bool b_bitmap_check(const b_bitmap_word *map, unsigned long bit);
extern unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits);
extern unsigned int b_bitmap_count_clear(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_count_clear(const b_bitmap_word *map, unsigned long nbits);
extern unsigned int b_bitmap_highest_set(const b_bitmap_word *map, unsigned long nbits);
extern unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbits);
extern unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits);
extern unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_highest_set(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits);
BLUE_API unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits);
#ifdef __cplusplus
}

View File

@@ -3,31 +3,30 @@
#include <blue/object/type.h>
#include <blue/object/object.h>
#include <blue/object/status.h>
#include <stddef.h>
#define B_BUFFER(p) ((b_buffer *)(p))
typedef struct b_buffer b_buffer;
extern b_buffer *b_buffer_create(size_t item_sz);
extern b_buffer *b_buffer_create_from_bytes(const void *p, size_t len);
extern b_buffer *b_buffer_create_from_array(const void *p, size_t item_sz, size_t len);
BLUE_API b_buffer *b_buffer_create(size_t item_sz);
BLUE_API b_buffer *b_buffer_create_from_bytes(const void *p, size_t len);
BLUE_API b_buffer *b_buffer_create_from_array(const void *p, size_t item_sz, size_t len);
static inline b_buffer *b_buffer_retain(b_buffer *buf) { return B_BUFFER(b_retain(B_OBJECT(buf))); }
static inline void b_buffer_release(b_buffer *buf) { b_release(B_OBJECT(buf)); }
extern void *b_buffer_steal(b_buffer *buf);
extern b_status b_buffer_reserve(b_buffer *buf, size_t capacity);
BLUE_API void *b_buffer_steal(b_buffer *buf);
BLUE_API b_status b_buffer_reserve(b_buffer *buf, size_t capacity);
extern b_status b_buffer_append(b_buffer *dest, const void *p, size_t count);
extern b_status b_buffer_prepend(b_buffer *dest, const void *p, size_t count);
extern b_status b_buffer_insert(b_buffer *dest, const void *p, size_t count, size_t at);
extern b_status b_buffer_clear(b_buffer *str);
BLUE_API b_status b_buffer_append(b_buffer *dest, const void *p, size_t count);
BLUE_API b_status b_buffer_prepend(b_buffer *dest, const void *p, size_t count);
BLUE_API b_status b_buffer_insert(b_buffer *dest, const void *p, size_t count, size_t at);
BLUE_API b_status b_buffer_clear(b_buffer *str);
extern size_t b_buffer_get_size(const b_buffer *str);
extern size_t b_buffer_get_item_size(const b_buffer *str);
extern size_t b_buffer_get_capacity(const b_buffer *str);
BLUE_API size_t b_buffer_get_size(const b_buffer *str);
BLUE_API size_t b_buffer_get_item_size(const b_buffer *str);
BLUE_API size_t b_buffer_get_capacity(const b_buffer *str);
extern void *b_buffer_ptr(const b_buffer *str);
BLUE_API void *b_buffer_ptr(const b_buffer *str);
#endif

View File

@@ -41,8 +41,8 @@ typedef struct b_dict_item {
b_object *value;
} b_dict_item;
extern b_dict *b_dict_create(void);
extern b_dict *b_dict_create_with_items(const b_dict_item *items);
BLUE_API b_dict *b_dict_create(void);
BLUE_API b_dict *b_dict_create_with_items(const b_dict_item *items);
static inline b_dict *b_dict_retain(b_dict *dict)
{
@@ -53,17 +53,17 @@ static inline void b_dict_release(b_dict *dict)
b_release(B_OBJECT(dict));
}
extern b_status b_dict_put(b_dict *dict, const char *key, b_object *value);
extern b_object *b_dict_at(const b_dict *dict, const char *key);
extern b_object *b_dict_get(b_dict *dict, const char *key);
BLUE_API b_status b_dict_put(b_dict *dict, const char *key, b_object *value);
BLUE_API b_object *b_dict_at(const b_dict *dict, const char *key);
BLUE_API b_object *b_dict_get(b_dict *dict, const char *key);
extern bool b_dict_has_key(const b_dict *dict, const char *key);
extern size_t b_dict_get_size(const b_dict *dict);
extern bool b_dict_is_empty(const b_dict *dict);
BLUE_API bool b_dict_has_key(const b_dict *dict, const char *key);
BLUE_API size_t b_dict_get_size(const b_dict *dict);
BLUE_API bool b_dict_is_empty(const b_dict *dict);
extern int b_dict_iterator_begin(b_dict *dict, b_dict_iterator *it);
extern bool b_dict_iterator_next(b_dict_iterator *it);
extern b_status b_dict_iterator_erase(b_dict_iterator *it);
extern bool b_dict_iterator_is_valid(const b_dict_iterator *it);
BLUE_API int b_dict_iterator_begin(b_dict *dict, b_dict_iterator *it);
BLUE_API bool b_dict_iterator_next(b_dict_iterator *it);
BLUE_API b_status b_dict_iterator_erase(b_dict_iterator *it);
BLUE_API bool b_dict_iterator_is_valid(const b_dict_iterator *it);
#endif

View File

@@ -63,8 +63,8 @@ typedef struct b_hashmap_iterator {
b_queue_entry *_cqe;
} b_hashmap_iterator;
extern b_hashmap *b_hashmap_create(void);
extern b_hashmap *b_hashmap_create_with_items(const b_hashmap_item *items);
BLUE_API b_hashmap *b_hashmap_create(void);
BLUE_API b_hashmap *b_hashmap_create_with_items(const b_hashmap_item *items);
static inline b_hashmap *b_hashmap_retain(b_hashmap *hashmap)
{
@@ -75,18 +75,18 @@ static inline void b_hashmap_release(b_hashmap *hashmap)
b_release(B_OBJECT(hashmap));
}
extern b_status b_hashmap_put(
BLUE_API b_status b_hashmap_put(
b_hashmap *hashmap, const b_hashmap_key *key, const b_hashmap_value *value);
extern const b_hashmap_value *b_hashmap_get(
BLUE_API const b_hashmap_value *b_hashmap_get(
const b_hashmap *hashmap, const b_hashmap_key *key);
extern bool b_hashmap_has_key(const b_hashmap *hashmap, const b_hashmap_key *key);
extern size_t b_hashmap_get_size(const b_hashmap *hashmap);
extern bool b_hashmap_is_empty(const b_hashmap *hashmap);
BLUE_API bool b_hashmap_has_key(const b_hashmap *hashmap, const b_hashmap_key *key);
BLUE_API size_t b_hashmap_get_size(const b_hashmap *hashmap);
BLUE_API bool b_hashmap_is_empty(const b_hashmap *hashmap);
extern int b_hashmap_iterator_begin(b_hashmap *hashmap, b_hashmap_iterator *it);
extern bool b_hashmap_iterator_next(b_hashmap_iterator *it);
extern b_status b_hashmap_iterator_erase(b_hashmap_iterator *it);
extern bool b_hashmap_iterator_is_valid(const b_hashmap_iterator *it);
BLUE_API int b_hashmap_iterator_begin(b_hashmap *hashmap, b_hashmap_iterator *it);
BLUE_API bool b_hashmap_iterator_next(b_hashmap_iterator *it);
BLUE_API b_status b_hashmap_iterator_erase(b_hashmap_iterator *it);
BLUE_API bool b_hashmap_iterator_is_valid(const b_hashmap_iterator *it);
#endif

View File

@@ -90,7 +90,7 @@ typedef struct {
};
} b_i64;
extern b_number *b_number_create(b_number_type type, void *value_ptr);
BLUE_API b_number *b_number_create(b_number_type type, void *value_ptr);
static inline b_number *b_number_retain(b_number *number)
{
return B_NUMBER(b_retain(B_OBJECT(number)));
@@ -157,8 +157,8 @@ static inline b_number *b_number_create_size_t(size_t value)
return b_number_create(B_NUMBER_SIZE_T, &value);
}
extern b_number_type b_number_get_type(const b_number *number);
extern int b_number_get_value(
BLUE_API b_number_type b_number_get_type(const b_number *number);
BLUE_API int b_number_get_value(
const b_number *number, b_number_type type, void *value_ptr);
static inline int8_t b_number_get_int8(const b_number *number)
@@ -259,27 +259,27 @@ static inline size_t b_number_get_size_t(const b_number *number)
return v;
}
extern bool b_number_is_integer(const b_number *number);
extern bool b_number_is_float(const b_number *number);
BLUE_API bool b_number_is_integer(const b_number *number);
BLUE_API bool b_number_is_float(const b_number *number);
extern size_t b_number_data_size(const b_number *number);
BLUE_API size_t b_number_data_size(const b_number *number);
extern b_i16 b_i16_htob(uint16_t v);
extern b_i16 b_i16_htos(uint16_t v);
BLUE_API b_i16 b_i16_htob(uint16_t v);
BLUE_API b_i16 b_i16_htos(uint16_t v);
extern uint16_t b_i16_btoh(b_i16 v);
extern uint16_t b_i16_stoh(b_i16 v);
BLUE_API uint16_t b_i16_btoh(b_i16 v);
BLUE_API uint16_t b_i16_stoh(b_i16 v);
extern b_i32 b_i32_htob(uint32_t v);
extern b_i32 b_i32_htos(uint32_t v);
BLUE_API b_i32 b_i32_htob(uint32_t v);
BLUE_API b_i32 b_i32_htos(uint32_t v);
extern uint32_t b_i32_btoh(b_i32 v);
extern uint32_t b_i32_stoh(b_i32 v);
BLUE_API uint32_t b_i32_btoh(b_i32 v);
BLUE_API uint32_t b_i32_stoh(b_i32 v);
extern b_i64 b_i64_htob(uint64_t v);
extern b_i64 b_i64_htos(uint64_t v);
BLUE_API b_i64 b_i64_htob(uint64_t v);
BLUE_API b_i64 b_i64_htos(uint64_t v);
extern uint64_t b_i64_btoh(b_i64 v);
extern uint64_t b_i64_stoh(b_i64 v);
BLUE_API uint64_t b_i64_btoh(b_i64 v);
BLUE_API uint64_t b_i64_stoh(b_i64 v);
#endif

View File

@@ -25,14 +25,14 @@ typedef struct b_object {
const struct b_object_type *ob_type;
} b_object;
extern b_object *b_make_rvalue(b_object *obj);
BLUE_API b_object *b_make_rvalue(b_object *obj);
extern b_object *b_retain(b_object *obj);
extern void b_release(b_object *obj);
BLUE_API b_object *b_retain(b_object *obj);
BLUE_API void b_release(b_object *obj);
extern void b_to_string(b_object *obj, struct b_stringstream *out);
extern b_object_type_id b_typeid(const b_object *obj);
BLUE_API void b_to_string(b_object *obj, struct b_stringstream *out);
BLUE_API b_object_type_id b_typeid(const b_object *obj);
extern b_comparison_result_t b_compare(const b_object *a, const b_object *b);
BLUE_API b_comparison_result_t b_compare(const b_object *a, const b_object *b);
#endif

View File

@@ -24,9 +24,9 @@ typedef struct b_strv_builder {
unsigned char strv_alloc;
} b_strv_builder;
extern b_string *b_string_create(void);
extern b_string *b_string_create_from_cstr(const char *s);
extern b_string *b_string_create_from_c(char c, size_t count);
BLUE_API b_string *b_string_create(void);
BLUE_API b_string *b_string_create_from_cstr(const char *s);
BLUE_API b_string *b_string_create_from_c(char c, size_t count);
static inline b_string *b_string_retain(b_string *str)
{
@@ -36,42 +36,42 @@ static inline void b_string_release(b_string *str)
{
b_release(B_OBJECT(str));
}
extern char *b_string_steal(b_string *str);
extern b_status b_string_reserve(b_string *str, size_t capacity);
BLUE_API char *b_string_steal(b_string *str);
BLUE_API b_status b_string_reserve(b_string *str, size_t capacity);
extern void b_string_append_s(b_string *dest, const b_string *src);
extern void b_string_append_cstr(b_string *dest, const char *src);
extern void b_string_append_cstrf(b_string *dest, const char *format, ...);
extern void b_string_prepend_s(b_string *dest, const b_string *src);
extern void b_string_prepend_cstr(b_string *dest, const char *src);
extern void b_string_prepend_cstrf(b_string *dest, const char *format, ...);
extern void b_string_insert_s(b_string *dest, const b_string *src, size_t at);
extern void b_string_insert_cstr(b_string *dest, const char *src, size_t at);
extern void b_string_insert_cstrn(
BLUE_API void b_string_append_s(b_string *dest, const b_string *src);
BLUE_API void b_string_append_cstr(b_string *dest, const char *src);
BLUE_API void b_string_append_cstrf(b_string *dest, const char *format, ...);
BLUE_API void b_string_prepend_s(b_string *dest, const b_string *src);
BLUE_API void b_string_prepend_cstr(b_string *dest, const char *src);
BLUE_API void b_string_prepend_cstrf(b_string *dest, const char *format, ...);
BLUE_API void b_string_insert_s(b_string *dest, const b_string *src, size_t at);
BLUE_API void b_string_insert_cstr(b_string *dest, const char *src, size_t at);
BLUE_API void b_string_insert_cstrn(
b_string *dest, const char *src, size_t len, size_t at);
extern void b_string_insert_cstrf(
BLUE_API void b_string_insert_cstrf(
b_string *dest, size_t at, const char *format, ...);
extern void b_string_clear(b_string *str);
BLUE_API void b_string_clear(b_string *str);
extern size_t b_string_get_size(const b_string *str, b_strlen_flags flags);
extern size_t b_string_get_capacity(const b_string *str);
BLUE_API size_t b_string_get_size(const b_string *str, b_strlen_flags flags);
BLUE_API size_t b_string_get_capacity(const b_string *str);
extern const char *b_string_ptr(const b_string *str);
BLUE_API const char *b_string_ptr(const b_string *str);
extern void b_strv_builder_begin(b_strv_builder *strv, char *buf, size_t max);
extern void b_strv_builder_begin_dynamic(b_strv_builder *strv);
BLUE_API void b_strv_builder_begin(b_strv_builder *strv, char *buf, size_t max);
BLUE_API void b_strv_builder_begin_dynamic(b_strv_builder *strv);
extern b_status b_strv_builder_add(b_strv_builder *strv, const char *str);
extern b_status b_strv_builder_addf(b_strv_builder *strv, const char *format, ...);
extern b_status b_strv_builder_addv(b_strv_builder *strv, const char **strs);
extern b_status b_strv_builder_addvl(
BLUE_API b_status b_strv_builder_add(b_strv_builder *strv, const char *str);
BLUE_API b_status b_strv_builder_addf(b_strv_builder *strv, const char *format, ...);
BLUE_API b_status b_strv_builder_addv(b_strv_builder *strv, const char **strs);
BLUE_API b_status b_strv_builder_addvl(
b_strv_builder *strv, const char **strs, size_t count);
extern b_status b_strv_builder_add_many(b_strv_builder *strv, ...);
extern char *b_strv_builder_end(b_strv_builder *strv);
BLUE_API b_status b_strv_builder_add_many(b_strv_builder *strv, ...);
BLUE_API char *b_strv_builder_end(b_strv_builder *strv);
extern char *b_strdup(const char *s);
extern size_t b_strlen(const char *s, b_strlen_flags flags);
BLUE_API char *b_strdup(const char *s);
BLUE_API size_t b_strlen(const char *s, b_strlen_flags flags);
extern uint64_t b_cstr_hash(const char *s);
BLUE_API uint64_t b_cstr_hash(const char *s);
#endif

View File

@@ -6,20 +6,20 @@
typedef struct b_stringstream b_stringstream;
extern b_stringstream *b_stringstream_create(void);
extern b_string *b_stringstream_end(b_stringstream *f);
extern void b_stringstream_destroy(b_stringstream *f);
extern const b_string *b_stringstream_str(b_stringstream *f);
extern const char *b_stringstream_cstr(b_stringstream *f);
extern void b_stringstream_clear(b_stringstream *f);
BLUE_API b_stringstream *b_stringstream_create(void);
BLUE_API b_string *b_stringstream_end(b_stringstream *f);
BLUE_API void b_stringstream_destroy(b_stringstream *f);
BLUE_API const b_string *b_stringstream_str(b_stringstream *f);
BLUE_API const char *b_stringstream_cstr(b_stringstream *f);
BLUE_API void b_stringstream_clear(b_stringstream *f);
extern void b_stringstream_push_indent(b_stringstream *f, int indent);
extern void b_stringstream_push_indent_abs(b_stringstream *f, int indent);
extern void b_stringstream_pop_indent(b_stringstream *f);
BLUE_API void b_stringstream_push_indent(b_stringstream *f, int indent);
BLUE_API void b_stringstream_push_indent_abs(b_stringstream *f, int indent);
BLUE_API void b_stringstream_pop_indent(b_stringstream *f);
extern void b_stringstream_add(b_stringstream *f, const char *s);
extern void b_stringstream_addf(b_stringstream *f, const char *format, ...);
extern void b_stringstream_addvf(b_stringstream *f, const char *format, va_list arg);
extern void b_stringstream_add_str(b_stringstream *f, const b_string *str);
BLUE_API void b_stringstream_add(b_stringstream *f, const char *s);
BLUE_API void b_stringstream_addf(b_stringstream *f, const char *format, ...);
BLUE_API void b_stringstream_addvf(b_stringstream *f, const char *format, va_list arg);
BLUE_API void b_stringstream_add_str(b_stringstream *f, const b_string *str);
#endif

View File

@@ -41,7 +41,7 @@ typedef struct b_tree_iterator {
unsigned char _f01;
} b_tree_iterator;
extern b_tree *b_tree_create(void);
BLUE_API b_tree *b_tree_create(void);
static inline b_tree *b_tree_retain(b_tree *tree)
{
@@ -52,21 +52,21 @@ static inline void b_tree_release(b_tree *tree)
b_release(B_OBJECT(tree));
}
extern void b_tree_set_root(b_tree *tree, struct b_tree_node *node);
BLUE_API void b_tree_set_root(b_tree *tree, struct b_tree_node *node);
extern void b_tree_node_add_child(b_tree_node *parent, b_tree_node *child);
extern void b_tree_node_add_sibling(b_tree_node *node, b_tree_node *to_add);
BLUE_API void b_tree_node_add_child(b_tree_node *parent, b_tree_node *child);
BLUE_API void b_tree_node_add_sibling(b_tree_node *node, b_tree_node *to_add);
extern b_tree_node *b_tree_node_get_child(b_tree_node *node, size_t at);
extern b_tree_node *b_tree_node_get_parent(b_tree_node *node);
BLUE_API b_tree_node *b_tree_node_get_child(b_tree_node *node, size_t at);
BLUE_API b_tree_node *b_tree_node_get_parent(b_tree_node *node);
extern int b_tree_iterator_begin(b_tree *tree, b_tree_iterator *it);
extern int b_tree_iterator_begin_at_node(b_tree_node *node, b_tree_iterator *it);
extern int b_tree_iterator_begin_at_node_recursive(
BLUE_API int b_tree_iterator_begin(b_tree *tree, b_tree_iterator *it);
BLUE_API int b_tree_iterator_begin_at_node(b_tree_node *node, b_tree_iterator *it);
BLUE_API int b_tree_iterator_begin_at_node_recursive(
b_tree_node *node, b_tree_iterator *it);
extern bool b_tree_iterator_next(b_tree_iterator *it);
extern b_status b_tree_iterator_erase(b_tree_iterator *it);
extern bool b_tree_iterator_is_valid(const b_tree_iterator *it);
BLUE_API bool b_tree_iterator_next(b_tree_iterator *it);
BLUE_API b_status b_tree_iterator_erase(b_tree_iterator *it);
BLUE_API bool b_tree_iterator_is_valid(const b_tree_iterator *it);
#endif

View File

@@ -45,7 +45,7 @@ typedef struct b_object_type {
void (*t_to_string)(struct b_object *, struct b_stringstream *);
} b_object_type;
extern b_status b_object_type_register(b_object_type *type);
extern struct b_object *b_object_type_instantiate(const b_object_type *type);
BLUE_API b_status b_object_type_register(b_object_type *type);
BLUE_API struct b_object *b_object_type_instantiate(const b_object_type *type);
#endif

View File

@@ -19,17 +19,17 @@ typedef struct b_uuid_bytes {
unsigned char uuid_bytes[B_UUID_NBYTES];
} b_uuid_bytes;
extern b_uuid *b_uuid_create(void);
extern b_uuid *b_uuid_create_from_bytes(
BLUE_API b_uuid *b_uuid_create(void);
BLUE_API b_uuid *b_uuid_create_from_bytes(
unsigned char u00, unsigned char u01, unsigned char u02,
unsigned char u03, unsigned char u04, unsigned char u05,
unsigned char u06, unsigned char u07, unsigned char u08,
unsigned char u09, unsigned char u10, unsigned char u11, unsigned char u12,
unsigned char u13, unsigned char u14, unsigned char u15);
extern b_uuid *b_uuid_create_from_bytev(const unsigned char bytes[B_UUID_NBYTES]);
extern b_uuid *b_uuid_create_from_uuid_bytes(const b_uuid_bytes *bytes);
extern b_uuid *b_uuid_create_from_string(const struct b_string *string);
extern b_uuid *b_uuid_create_from_cstr(const char *s);
BLUE_API b_uuid *b_uuid_create_from_bytev(const unsigned char bytes[B_UUID_NBYTES]);
BLUE_API b_uuid *b_uuid_create_from_uuid_bytes(const b_uuid_bytes *bytes);
BLUE_API b_uuid *b_uuid_create_from_string(const struct b_string *string);
BLUE_API b_uuid *b_uuid_create_from_cstr(const char *s);
static inline b_uuid *b_uuid_retain(b_uuid *uuid)
{
@@ -40,13 +40,13 @@ static inline void b_uuid_release(b_uuid *uuid)
b_release(B_OBJECT(uuid));
}
extern b_status b_uuid_to_string(const b_uuid *uuid, struct b_string *out);
extern b_status b_uuid_to_cstr(const b_uuid *uuid, char out[B_UUID_STRING_MAX]);
extern b_status b_uuid_to_strv_builder(
BLUE_API b_status b_uuid_to_string(const b_uuid *uuid, struct b_string *out);
BLUE_API b_status b_uuid_to_cstr(const b_uuid *uuid, char out[B_UUID_STRING_MAX]);
BLUE_API b_status b_uuid_to_strv_builder(
const b_uuid *uuid, struct b_strv_builder *out);
extern void b_uuid_get_bytes(
BLUE_API void b_uuid_get_bytes(
const b_uuid *uuid, unsigned char bytes[B_UUID_NBYTES]);
extern void b_uuid_get_uuid_bytes(const b_uuid *uuid, b_uuid_bytes *bytes);
extern b_uuid_bytes *b_uuid_ptr(b_uuid *uuid);
BLUE_API void b_uuid_get_uuid_bytes(const b_uuid *uuid, b_uuid_bytes *bytes);
BLUE_API b_uuid_bytes *b_uuid_ptr(b_uuid *uuid);
#endif

View File

@@ -48,7 +48,7 @@ static char *string_ptr(struct b_string *str)
return str->s_data.d_inline;
}
return str->s_data.d_external;
return str->s_data.d_BLUE_APIal;
}
static int string_make_inline(struct b_string *str)
@@ -76,7 +76,7 @@ static int string_resize_large(struct b_string *str, size_t capacity)
}
str->s_max = capacity;
str->s_data.d_external = new_buffer;
str->s_data.d_BLUE_APIal = new_buffer;
return 0;
}
@@ -92,7 +92,7 @@ static int string_make_large(struct b_string *str, size_t capacity)
buffer[str->s_len] = '\0';
str->s_max = capacity;
str->s_data.d_external = buffer;
str->s_data.d_BLUE_APIal = buffer;
return 0;
}
@@ -178,7 +178,7 @@ char *b_string_steal(struct b_string *str)
dest = b_strdup(src);
} else {
dest = src;
str->s_data.d_external = NULL;
str->s_data.d_BLUE_APIal = NULL;
str->s_max = 0;
}
@@ -318,7 +318,7 @@ const char *b_string_ptr(const struct b_string *str)
return str->s_data.d_inline;
}
return str->s_data.d_external;
return str->s_data.d_BLUE_APIal;
}
static void string_release(struct b_object *obj)

View File

@@ -14,7 +14,7 @@ struct b_string {
unsigned int s_max;
union {
char d_inline[STRING_INLINE_CAPACITY + 1];
char *d_external;
char *d_BLUE_APIal;
} s_data;
};