diff --git a/fx.collections/CMakeLists.txt b/fx.collections/CMakeLists.txt index 1ec4987..6afe017 100644 --- a/fx.collections/CMakeLists.txt +++ b/fx.collections/CMakeLists.txt @@ -1,3 +1,5 @@ include(../cmake/Templates.cmake) -add_fx_module(NAME ds DEPENDENCIES core) +add_fx_assembly( + NAME fx.collections + DEPENDENCIES fx) diff --git a/fx.collections/array.c b/fx.collections/array.c index 82b1e93..c7f5ff2 100644 --- a/fx.collections/array.c +++ b/fx.collections/array.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/fx.collections/bitbuffer.c b/fx.collections/bitbuffer.c index f997423..e81331b 100644 --- a/fx.collections/bitbuffer.c +++ b/fx.collections/bitbuffer.c @@ -1,4 +1,4 @@ -#include +#include /*** PRIVATE DATA *************************************************************/ diff --git a/fx.collections/bitmap.c b/fx.collections/bitmap.c index b943ab7..2816b0a 100644 --- a/fx.collections/bitmap.c +++ b/fx.collections/bitmap.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #define BITS_PER_WORD (8 * sizeof(bitmap_word_t)) @@ -36,11 +36,17 @@ static void bitmap_clear_bit(struct fx_bitmap_p *map, size_t bit) map->map_words[index] &= ~mask; } -static void bitmap_set_range(struct fx_bitmap_p *map, size_t first_bit, size_t nbits) +static void bitmap_set_range( + struct fx_bitmap_p *map, + size_t first_bit, + size_t nbits) { } -static void bitmap_clear_range(struct fx_bitmap_p *map, size_t first_bit, size_t nbits) +static void bitmap_clear_range( + struct fx_bitmap_p *map, + size_t first_bit, + size_t nbits) { } @@ -216,13 +222,21 @@ void fx_bitmap_clear_bit(fx_bitmap *map, size_t bit) void fx_bitmap_set_range(fx_bitmap *map, size_t first_bit, size_t nbits) { FX_CLASS_DISPATCH_STATIC_V( - FX_TYPE_BITMAP, bitmap_set_range, map, first_bit, nbits); + FX_TYPE_BITMAP, + bitmap_set_range, + map, + first_bit, + nbits); } void fx_bitmap_clear_range(fx_bitmap *map, size_t first_bit, size_t nbits) { FX_CLASS_DISPATCH_STATIC_V( - FX_TYPE_BITMAP, bitmap_clear_range, map, first_bit, nbits); + FX_TYPE_BITMAP, + bitmap_clear_range, + map, + first_bit, + nbits); } void fx_bitmap_set_all(fx_bitmap *map) @@ -247,7 +261,10 @@ size_t fx_bitmap_count_set_bits(const fx_bitmap *map) size_t fx_bitmap_count_clear_bits(const fx_bitmap *map) { - FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_BITMAP, bitmap_count_clear_bits, map); + FX_CLASS_DISPATCH_STATIC_0( + FX_TYPE_BITMAP, + bitmap_count_clear_bits, + map); } size_t fx_bitmap_highest_set_bit(const fx_bitmap *map) @@ -257,7 +274,10 @@ size_t fx_bitmap_highest_set_bit(const fx_bitmap *map) size_t fx_bitmap_highest_clear_bit(const fx_bitmap *map) { - FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_BITMAP, bitmap_highest_clear_bit, map); + FX_CLASS_DISPATCH_STATIC_0( + FX_TYPE_BITMAP, + bitmap_highest_clear_bit, + map); } size_t fx_bitmap_lowest_set_bit(const fx_bitmap *map) @@ -267,7 +287,10 @@ size_t fx_bitmap_lowest_set_bit(const fx_bitmap *map) size_t fx_bitmap_lowest_clear_bit(const fx_bitmap *map) { - FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_BITMAP, bitmap_lowest_clear_bit, map); + FX_CLASS_DISPATCH_STATIC_0( + FX_TYPE_BITMAP, + bitmap_lowest_clear_bit, + map); } /*** PUBLIC ALIAS FUNCTIONS ***************************************************/ @@ -285,7 +308,8 @@ static void bitmap_fini(fx_object *obj, void *priv) static void bitmap_to_string(const fx_object *obj, fx_stream *out) { - const struct fx_bitmap_p *map = fx_object_get_private(obj, FX_TYPE_BITMAP); + const struct fx_bitmap_p *map + = fx_object_get_private(obj, FX_TYPE_BITMAP); unsigned char *bytes = (unsigned char *)map->map_words; size_t nr_bytes = map->map_nr_words * sizeof(bitmap_word_t); @@ -294,10 +318,16 @@ static void bitmap_to_string(const fx_object *obj, fx_stream *out) for (size_t i = 0; i < nr_bytes - 1; i++) { c = bytes[i]; fx_stream_write_fmt( - out, NULL, "%c%c%c%c%c%c%c%c", c & 0x80 ? '1' : '0', - c & 0x40 ? '1' : '0', c & 0x20 ? '1' : '0', - c & 0x10 ? '1' : '0', c & 0x08 ? '1' : '0', - c & 0x04 ? '1' : '0', c & 0x02 ? '1' : '0', + out, + NULL, + "%c%c%c%c%c%c%c%c", + c & 0x80 ? '1' : '0', + c & 0x40 ? '1' : '0', + c & 0x20 ? '1' : '0', + c & 0x10 ? '1' : '0', + c & 0x08 ? '1' : '0', + c & 0x04 ? '1' : '0', + c & 0x02 ? '1' : '0', c & 0x01 ? '1' : '0'); } diff --git a/fx.collections/buffer.c b/fx.collections/buffer.c index 0fbba47..072304b 100644 --- a/fx.collections/buffer.c +++ b/fx.collections/buffer.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include @@ -21,7 +21,8 @@ static fx_status resize_buffer(struct fx_buffer_p *buffer, size_t new_capacity) { if (buffer->buf_cap < new_capacity) { void *new_data = realloc( - buffer->buf_data, new_capacity * buffer->buf_itemsz); + buffer->buf_data, + new_capacity * buffer->buf_itemsz); if (!new_data) { return FX_ERR_NO_MEMORY; } @@ -29,7 +30,8 @@ static fx_status resize_buffer(struct fx_buffer_p *buffer, size_t new_capacity) buffer->buf_data = new_data; } else { void *new_data = realloc( - buffer->buf_data, new_capacity * buffer->buf_itemsz); + buffer->buf_data, + new_capacity * buffer->buf_itemsz); if (!new_data) { return FX_ERR_NO_MEMORY; } @@ -78,7 +80,10 @@ static enum fx_status buffer_resize(struct fx_buffer_p *buf, size_t length) } static enum fx_status buffer_insert( - struct fx_buffer_p *buffer, const void *p, size_t count, size_t at) + struct fx_buffer_p *buffer, + const void *p, + size_t count, + size_t at) { if (at == FX_NPOS) { at = buffer->buf_len; @@ -110,7 +115,10 @@ static enum fx_status buffer_insert( return FX_SUCCESS; } -static enum fx_status buffer_remove(struct fx_buffer_p *buffer, size_t at, size_t count) +static enum fx_status buffer_remove( + struct fx_buffer_p *buffer, + size_t at, + size_t count) { if (at >= buffer->buf_len) { return FX_ERR_OUT_OF_BOUNDS; @@ -162,7 +170,9 @@ static enum fx_status buffer_clear(struct fx_buffer_p *buffer) } static enum fx_status buffer_push_back( - struct fx_buffer_p *buf, size_t count, void **p) + struct fx_buffer_p *buf, + size_t count, + void **p) { enum fx_status status = FX_SUCCESS; @@ -181,7 +191,9 @@ static enum fx_status buffer_push_back( } static enum fx_status buffer_push_front( - struct fx_buffer_p *buf, size_t count, void **p) + struct fx_buffer_p *buf, + size_t count, + void **p) { enum fx_status status = FX_SUCCESS; @@ -286,7 +298,10 @@ fx_buffer *fx_buffer_create_from_bytes(const void *buf, size_t len) return buffer; } -fx_buffer *fx_buffer_create_from_array(const void *buf, size_t item_sz, size_t len) +fx_buffer *fx_buffer_create_from_array( + const void *buf, + size_t item_sz, + size_t len) { fx_buffer *buffer = fx_object_create(FX_TYPE_BUFFER); if (!buffer) { @@ -325,14 +340,28 @@ enum fx_status fx_buffer_resize(fx_buffer *buf, size_t length) } enum fx_status fx_buffer_insert( - fx_buffer *buffer, const void *p, size_t count, size_t at) + fx_buffer *buffer, + const void *p, + size_t count, + size_t at) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_BUFFER, buffer_insert, buffer, p, count, at); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_BUFFER, + buffer_insert, + buffer, + p, + count, + at); } enum fx_status fx_buffer_remove(fx_buffer *buffer, size_t at, size_t count) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_BUFFER, buffer_remove, buffer, at, count); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_BUFFER, + buffer_remove, + buffer, + at, + count); } void *fx_buffer_ptr(const fx_buffer *buffer) @@ -362,12 +391,22 @@ enum fx_status fx_buffer_clear(fx_buffer *buffer) enum fx_status fx_buffer_push_back(fx_buffer *buf, size_t count, void **p) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_BUFFER, buffer_push_back, buf, count, p); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_BUFFER, + buffer_push_back, + buf, + count, + p); } enum fx_status fx_buffer_push_front(fx_buffer *buf, size_t count, void **p) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_BUFFER, buffer_push_front, buf, count, p); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_BUFFER, + buffer_push_front, + buf, + count, + p); } enum fx_status fx_buffer_pop_back(fx_buffer *buf, size_t count) diff --git a/fx.collections/datetime.c b/fx.collections/datetime.c index cb43bc5..6393090 100644 --- a/fx.collections/datetime.c +++ b/fx.collections/datetime.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include /*** PRIVATE DATA *************************************************************/ @@ -89,7 +89,8 @@ static bool is_zone_valid(const struct fx_datetime_p *dt) return false; } - if (!(dt->dt_zone_offset_minute >= 0 && dt->dt_zone_offset_minute <= 59)) { + if (!(dt->dt_zone_offset_minute >= 0 + && dt->dt_zone_offset_minute <= 59)) { return false; } @@ -309,12 +310,18 @@ fail: return NULL; } -static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream *out) +static enum fx_status encode_rfc3339( + const struct fx_datetime_p *dt, + fx_stream *out) { if (dt->dt_has_date) { fx_stream_write_fmt( - out, NULL, "%04ld-%02ld-%02ld", dt->dt_year, - dt->dt_month, dt->dt_day); + out, + NULL, + "%04ld-%02ld-%02ld", + dt->dt_year, + dt->dt_month, + dt->dt_day); } if (dt->dt_has_date && dt->dt_has_time) { @@ -323,7 +330,11 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream * if (dt->dt_has_time) { fx_stream_write_fmt( - out, NULL, "%02ld:%02ld:%02ld", dt->dt_hour, dt->dt_min, + out, + NULL, + "%02ld:%02ld:%02ld", + dt->dt_hour, + dt->dt_min, dt->dt_sec); if (dt->dt_msec > 0) { @@ -336,7 +347,9 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream * fx_stream_write_char(out, 'Z'); } else { fx_stream_write_fmt( - out, NULL, "%c%02ld:%02ld", + out, + NULL, + "%c%02ld:%02ld", dt->dt_zone_offset_negative ? '-' : '+', dt->dt_zone_offset_hour, dt->dt_zone_offset_minute); @@ -348,7 +361,9 @@ static enum fx_status encode_rfc3339(const struct fx_datetime_p *dt, fx_stream * } static void datetime_to_string( - const struct fx_datetime_p *dt, fx_datetime_format format, fx_stream *dest) + const struct fx_datetime_p *dt, + fx_datetime_format format, + fx_stream *dest) { switch (format) { case FX_DATETIME_FORMAT_RFC3339: @@ -453,10 +468,16 @@ fx_datetime *fx_datetime_parse(enum fx_datetime_format format, const char *s) } void fx_datetime_to_string( - const fx_datetime *dt, fx_datetime_format format, fx_stream *dest) + const fx_datetime *dt, + fx_datetime_format format, + fx_stream *dest) { FX_CLASS_DISPATCH_STATIC( - FX_TYPE_DATETIME, datetime_to_string, dt, format, dest); + FX_TYPE_DATETIME, + datetime_to_string, + dt, + format, + dest); } bool fx_datetime_is_localtime(const fx_datetime *dt) @@ -512,17 +533,25 @@ long fx_datetime_subsecond(const fx_datetime *dt) bool fx_datetime_zone_offset_is_negative(const fx_datetime *dt) { FX_CLASS_DISPATCH_STATIC_0( - FX_TYPE_DATETIME, datetime_zone_offset_is_negative, dt); + FX_TYPE_DATETIME, + datetime_zone_offset_is_negative, + dt); } long fx_datetime_zone_offset_hour(const fx_datetime *dt) { - FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_DATETIME, datetime_zone_offset_hour, dt); + FX_CLASS_DISPATCH_STATIC_0( + FX_TYPE_DATETIME, + datetime_zone_offset_hour, + dt); } long fx_datetime_zone_offset_minute(const fx_datetime *dt) { - FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_DATETIME, datetime_zone_offset_minute, dt); + FX_CLASS_DISPATCH_STATIC_0( + FX_TYPE_DATETIME, + datetime_zone_offset_minute, + dt); } /*** VIRTUAL FUNCTIONS ********************************************************/ @@ -543,8 +572,12 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out) if (dt->dt_has_date) { fx_stream_write_fmt( - out, NULL, "%04ld-%02ld-%02ld", dt->dt_year, - dt->dt_month, dt->dt_day); + out, + NULL, + "%04ld-%02ld-%02ld", + dt->dt_year, + dt->dt_month, + dt->dt_day); } if (dt->dt_has_date && dt->dt_has_time) { @@ -553,7 +586,11 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out) if (dt->dt_has_time) { fx_stream_write_fmt( - out, NULL, "%02ld:%02ld:%02ld", dt->dt_hour, dt->dt_min, + out, + NULL, + "%02ld:%02ld:%02ld", + dt->dt_hour, + dt->dt_min, dt->dt_sec); if (dt->dt_msec > 0) { @@ -562,7 +599,9 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out) if (!dt->dt_localtime) { fx_stream_write_fmt( - out, NULL, " %c%02ld:%02ld", + out, + NULL, + " %c%02ld:%02ld", dt->dt_zone_offset_negative ? '-' : '+', dt->dt_zone_offset_hour, dt->dt_zone_offset_minute); diff --git a/fx.collections/dict.c b/fx.collections/dict.c index bc528d1..cc948a4 100644 --- a/fx.collections/dict.c +++ b/fx.collections/dict.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/fx.collections/hashmap.c b/fx.collections/hashmap.c index 66cf184..c932964 100644 --- a/fx.collections/hashmap.c +++ b/fx.collections/hashmap.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -42,9 +42,16 @@ struct fx_hashmap_iterator_p { /*** PRIVATE FUNCTIONS ********************************************************/ static FX_BST_DEFINE_SIMPLE_GET( - struct fx_hashmap_bucket, uint64_t, bk_node, bk_hash, get_bucket); + struct fx_hashmap_bucket, + uint64_t, + bk_node, + bk_hash, + get_bucket); static FX_BST_DEFINE_SIMPLE_INSERT( - struct fx_hashmap_bucket, bk_node, bk_hash, put_bucket); + struct fx_hashmap_bucket, + bk_node, + bk_hash, + put_bucket); static uint64_t hash_data(const void *p, size_t size) { @@ -69,7 +76,8 @@ static uint64_t hash_key(const struct fx_hashmap_key *key) } static bool compare_key( - const struct fx_hashmap_key *a, const struct fx_hashmap_key *b) + const struct fx_hashmap_key *a, + const struct fx_hashmap_key *b) { const void *a_data = NULL, *fx_data = NULL; size_t a_len = 0, fx_len = 0; @@ -99,8 +107,10 @@ static bool compare_key( } static bool get_next_node( - struct fx_bst_node *cur_node, struct fx_queue_entry *cur_entry, - struct fx_bst_node **out_next_node, struct fx_queue_entry **out_next_entry) + struct fx_bst_node *cur_node, + struct fx_queue_entry *cur_entry, + struct fx_bst_node **out_next_node, + struct fx_queue_entry **out_next_entry) { struct fx_hashmap_bucket *cur_bucket = fx_unbox(struct fx_hashmap_bucket, cur_node, bk_node); @@ -122,8 +132,10 @@ static bool get_next_node( return false; } - struct fx_hashmap_bucket *next_bucket - = fx_unbox(struct fx_hashmap_bucket, next_node, bk_node); + struct fx_hashmap_bucket *next_bucket = fx_unbox( + struct fx_hashmap_bucket, + next_node, + bk_node); if (!next_bucket) { return false; } @@ -169,11 +181,13 @@ static struct fx_hashmap_bucket_item *create_bucket_item(void) } static fx_status hashmap_put( - struct fx_hashmap_p *hashmap, const fx_hashmap_key *key, + struct fx_hashmap_p *hashmap, + const fx_hashmap_key *key, const fx_hashmap_value *value) { uint64_t hash = hash_key(key); - struct fx_hashmap_bucket *bucket = get_bucket(&hashmap->h_buckets, hash); + struct fx_hashmap_bucket *bucket + = get_bucket(&hashmap->h_buckets, hash); if (!bucket) { bucket = create_bucket(); @@ -187,8 +201,10 @@ static fx_status hashmap_put( struct fx_queue_entry *entry = fx_queue_first(&bucket->bk_items); while (entry) { - struct fx_hashmap_bucket_item *item - = fx_unbox(struct fx_hashmap_bucket_item, entry, bi_entry); + struct fx_hashmap_bucket_item *item = fx_unbox( + struct fx_hashmap_bucket_item, + entry, + bi_entry); if (compare_key(&item->bi_key, key)) { memcpy(&item->bi_value, value, sizeof *value); @@ -213,19 +229,23 @@ static fx_status hashmap_put( } static const struct fx_hashmap_value *hashmap_get( - const struct fx_hashmap_p *hashmap, const struct fx_hashmap_key *key) + const struct fx_hashmap_p *hashmap, + const struct fx_hashmap_key *key) { uint64_t hash = hash_key(key); - struct fx_hashmap_bucket *bucket = get_bucket(&hashmap->h_buckets, hash); + struct fx_hashmap_bucket *bucket + = get_bucket(&hashmap->h_buckets, hash); if (!bucket) { return NULL; } struct fx_queue_entry *entry = fx_queue_first(&bucket->bk_items); while (entry) { - struct fx_hashmap_bucket_item *item - = fx_unbox(struct fx_hashmap_bucket_item, entry, bi_entry); + struct fx_hashmap_bucket_item *item = fx_unbox( + struct fx_hashmap_bucket_item, + entry, + bi_entry); if (compare_key(&item->bi_key, key)) { return &item->bi_value; @@ -238,18 +258,22 @@ static const struct fx_hashmap_value *hashmap_get( } static bool hashmap_has_key( - const struct fx_hashmap_p *hashmap, const fx_hashmap_key *key) + const struct fx_hashmap_p *hashmap, + const fx_hashmap_key *key) { uint64_t hash = hash_key(key); - struct fx_hashmap_bucket *bucket = get_bucket(&hashmap->h_buckets, hash); + struct fx_hashmap_bucket *bucket + = get_bucket(&hashmap->h_buckets, hash); if (!bucket) { return false; } struct fx_queue_entry *entry = fx_queue_first(&bucket->bk_items); while (entry) { - struct fx_hashmap_bucket_item *item - = fx_unbox(struct fx_hashmap_bucket_item, entry, bi_entry); + struct fx_hashmap_bucket_item *item = fx_unbox( + struct fx_hashmap_bucket_item, + entry, + bi_entry); if (compare_key(&item->bi_key, key)) { return true; @@ -276,8 +300,10 @@ static bool hashmap_is_empty(const struct fx_hashmap_p *hashmap) } fx_queue_entry *first_entry = fx_queue_first(&first_bucket->bk_items); - struct fx_hashmap_bucket_item *first_item - = fx_unbox(struct fx_hashmap_bucket_item, first_entry, bi_entry); + struct fx_hashmap_bucket_item *first_item = fx_unbox( + struct fx_hashmap_bucket_item, + first_entry, + bi_entry); if (!first_item) { return true; } @@ -286,7 +312,8 @@ static bool hashmap_is_empty(const struct fx_hashmap_p *hashmap) } static fx_status delete_item( - struct fx_hashmap_p *hashmap, struct fx_hashmap_bucket *bucket, + struct fx_hashmap_p *hashmap, + struct fx_hashmap_bucket *bucket, struct fx_hashmap_bucket_item *item) { fx_queue_delete(&bucket->bk_items, &item->bi_entry); @@ -313,7 +340,8 @@ static fx_status delete_item( /*** PUBLIC FUNCTIONS *********************************************************/ fx_hashmap *fx_hashmap_create( - fx_hashmap_key_destructor key_dtor, fx_hashmap_value_destructor value_dtor) + fx_hashmap_key_destructor key_dtor, + fx_hashmap_value_destructor value_dtor) { fx_hashmap *hashmap = fx_object_create(FX_TYPE_HASHMAP); if (!hashmap) { @@ -330,9 +358,11 @@ fx_hashmap *fx_hashmap_create_with_items(const fx_hashmap_item *items) return NULL; } - struct fx_hashmap_p *p = fx_object_get_private(hashmap, FX_TYPE_HASHMAP); + struct fx_hashmap_p *p + = fx_object_get_private(hashmap, FX_TYPE_HASHMAP); - for (size_t i = 0; items[i].key.key_data && items[i].key.key_size; i++) { + for (size_t i = 0; items[i].key.key_data && items[i].key.key_size; + i++) { hashmap_put(p, &items[i].key, &items[i].value); } @@ -340,20 +370,32 @@ fx_hashmap *fx_hashmap_create_with_items(const fx_hashmap_item *items) } fx_status fx_hashmap_put( - fx_hashmap *hashmap, const fx_hashmap_key *key, const fx_hashmap_value *value) + fx_hashmap *hashmap, + const fx_hashmap_key *key, + const fx_hashmap_value *value) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_HASHMAP, hashmap_put, hashmap, key, value); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_HASHMAP, + hashmap_put, + hashmap, + key, + value); } const struct fx_hashmap_value *fx_hashmap_get( - const fx_hashmap *hashmap, const struct fx_hashmap_key *key) + const fx_hashmap *hashmap, + const struct fx_hashmap_key *key) { FX_CLASS_DISPATCH_STATIC(FX_TYPE_HASHMAP, hashmap_get, hashmap, key); } bool fx_hashmap_has_key(const fx_hashmap *hashmap, const fx_hashmap_key *key) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_HASHMAP, hashmap_has_key, hashmap, key); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_HASHMAP, + hashmap_has_key, + hashmap, + key); } size_t fx_hashmap_get_size(const fx_hashmap *hashmap) @@ -368,7 +410,8 @@ bool fx_hashmap_is_empty(const fx_hashmap *hashmap) fx_iterator *fx_hashmap_begin(fx_hashmap *hashmap) { - fx_hashmap_iterator *it_obj = fx_object_create(FX_TYPE_HASHMAP_ITERATOR); + fx_hashmap_iterator *it_obj + = fx_object_create(FX_TYPE_HASHMAP_ITERATOR); struct fx_hashmap_iterator_p *it = fx_object_get_private(it_obj, FX_TYPE_HASHMAP_ITERATOR); @@ -391,9 +434,12 @@ fx_iterator *fx_hashmap_begin(fx_hashmap *hashmap) return it_obj; } - struct fx_queue_entry *first_entry = fx_queue_first(&first_bucket->bk_items); - struct fx_hashmap_bucket_item *first_item - = fx_unbox(struct fx_hashmap_bucket_item, first_entry, bi_entry); + struct fx_queue_entry *first_entry + = fx_queue_first(&first_bucket->bk_items); + struct fx_hashmap_bucket_item *first_item = fx_unbox( + struct fx_hashmap_bucket_item, + first_entry, + bi_entry); if (!first_item) { memset(&it->item, 0x0, sizeof it->item); fx_iterator_set_status(it_obj, FX_ERR_NO_DATA); @@ -435,8 +481,11 @@ static void hashmap_fini(fx_object *obj, void *priv) struct fx_queue_entry *entry = fx_queue_first(&b->bk_items); while (entry) { struct fx_hashmap_bucket_item *item = fx_unbox( - struct fx_hashmap_bucket_item, entry, bi_entry); - struct fx_queue_entry *next_entry = fx_queue_next(entry); + struct fx_hashmap_bucket_item, + entry, + bi_entry); + struct fx_queue_entry *next_entry + = fx_queue_next(entry); fx_queue_delete(&b->bk_items, entry); if (map->h_key_dtor) { @@ -444,7 +493,8 @@ static void hashmap_fini(fx_object *obj, void *priv) } if (map->h_value_dtor) { - map->h_value_dtor((void *)item->bi_value.value_data); + map->h_value_dtor( + (void *)item->bi_value.value_data); } free(item); @@ -524,7 +574,8 @@ static enum fx_status iterator_erase(fx_iterator *obj) if (next_item) { memcpy(&it->item.key, &next_item->bi_key, sizeof it->item.key); - memcpy(&it->item.value, &next_item->bi_value, + memcpy(&it->item.value, + &next_item->bi_value, sizeof it->item.value); it->_cbn = next_node; diff --git a/fx.collections/include/fx/ds/array.h b/fx.collections/include/fx/collections/array.h similarity index 94% rename from fx.collections/include/fx/ds/array.h rename to fx.collections/include/fx/collections/array.h index 302fe1e..4eec37d 100644 --- a/fx.collections/include/fx/ds/array.h +++ b/fx.collections/include/fx/collections/array.h @@ -9,10 +9,10 @@ #ifndef FX_DS_ARRAY_H_ #define FX_DS_ARRAY_H_ -#include -#include -#include -#include +#include +#include +#include +#include FX_DECLS_BEGIN; @@ -51,11 +51,13 @@ FX_TYPE_DEFAULT_CONSTRUCTOR(fx_array, FX_TYPE_ARRAY); * @return A pointer to the new fx_array, or NULL if an error occurred. */ FX_API fx_array *fx_array_create_with_values( - fx_object *const *values, size_t nr_values); + fx_object *const *values, + size_t nr_values); /** - * Remove all object references from an fx_array, resetting the size of the array to zero. - * The reference counts of all objects in the array will be decremented. + * Remove all object references from an fx_array, resetting the size of the + * array to zero. The reference counts of all objects in the array will be + * decremented. * * @param array The fx_array to clear. */ @@ -116,11 +118,12 @@ FX_API fx_status fx_array_remove(fx_array *array, size_t at); /** * Removes the object at the beginning of an fx_array. The reference count - * of the removed object will be decremented. The remaining objects will be moved - * to fill the empty space created by the object's removal. + * of the removed object will be decremented. The remaining objects will be + * moved to fill the empty space created by the object's removal. * * @param array The fx_array to remove the object from. - * @return FX_SUCCESS if the object was removed, or a status code describing any error that occurred. + * @return FX_SUCCESS if the object was removed, or a status code describing any + * error that occurred. */ FX_API fx_status fx_array_remove_front(fx_array *array); @@ -129,7 +132,8 @@ FX_API fx_status fx_array_remove_front(fx_array *array); * of the removed object will be decremented. * * @param array The fx_array to remove the object from. - * @return FX_SUCCESS if the object was removed, or a status code describing any error that occurred. + * @return FX_SUCCESS if the object was removed, or a status code describing any + * error that occurred. */ FX_API fx_status fx_array_remove_back(fx_array *array); @@ -162,8 +166,8 @@ FX_API fx_object *fx_array_pop(fx_array *array, size_t at); FX_API fx_object *fx_array_pop_front(fx_array *array); /** - * Removes the object at the end of an fx_array, and returns a pointer to it. The - * reference count of the removed object will NOT be decremented. The caller + * Removes the object at the end of an fx_array, and returns a pointer to it. + * The reference count of the removed object will NOT be decremented. The caller * becomes the owner of the array's reference to the object. * * @param array The fx_array to remove the object from. diff --git a/fx.collections/include/fx/ds/bitbuffer.h b/fx.collections/include/fx/collections/bitbuffer.h similarity index 62% rename from fx.collections/include/fx/ds/bitbuffer.h rename to fx.collections/include/fx/collections/bitbuffer.h index e840032..86b614c 100644 --- a/fx.collections/include/fx/ds/bitbuffer.h +++ b/fx.collections/include/fx/collections/bitbuffer.h @@ -1,7 +1,7 @@ #ifndef FX_DS_BITBUFFER_H_ #define FX_DS_BITBUFFER_H_ -#include +#include FX_DECLS_BEGIN; @@ -13,12 +13,18 @@ FX_TYPE_CLASS_DECLARATION_END(fx_bitbuffer); FX_API fx_status fx_bitbuffer_put_bit(fx_bitbuffer *buf, int bit); FX_API fx_status fx_bitbuffer_put_bool(fx_bitbuffer *buf, bool b); -FX_API fx_status fx_bitbuffer_put_int( - fx_bitbuffer *buf, uint64_t v, unsigned int nr_bits); +FX_API fx_status +fx_bitbuffer_put_int(fx_bitbuffer *buf, uint64_t v, unsigned int nr_bits); FX_API fx_status fx_bitbuffer_put_bytes( - fx_bitbuffer *buf, const void *p, size_t len, size_t bits_per_byte); + fx_bitbuffer *buf, + const void *p, + size_t len, + size_t bits_per_byte); FX_API fx_status fx_bitbuffer_put_string( - fx_bitbuffer *buf, const char *p, size_t len, size_t bits_per_char); + fx_bitbuffer *buf, + const char *p, + size_t len, + size_t bits_per_char); FX_DECLS_END; diff --git a/fx.collections/include/fx/ds/bitmap.h b/fx.collections/include/fx/collections/bitmap.h similarity index 89% rename from fx.collections/include/fx/ds/bitmap.h rename to fx.collections/include/fx/collections/bitmap.h index 3244b4f..30c170d 100644 --- a/fx.collections/include/fx/ds/bitmap.h +++ b/fx.collections/include/fx/collections/bitmap.h @@ -1,8 +1,8 @@ #ifndef FX_DS_BITMAP_H_ #define FX_DS_BITMAP_H_ -#include -#include +#include +#include #include FX_DECLS_BEGIN; @@ -21,7 +21,10 @@ FX_API fx_bitmap *fx_bitmap_create(size_t nr_bits); FX_API void fx_bitmap_set_bit(fx_bitmap *map, size_t bit); FX_API void fx_bitmap_clear_bit(fx_bitmap *map, size_t bit); FX_API void fx_bitmap_set_range(fx_bitmap *map, size_t first_bit, size_t nbits); -FX_API void fx_bitmap_clear_range(fx_bitmap *map, size_t first_bit, size_t nbits); +FX_API void fx_bitmap_clear_range( + fx_bitmap *map, + size_t first_bit, + size_t nbits); FX_API void fx_bitmap_set_all(fx_bitmap *map); FX_API void fx_bitmap_clear_all(fx_bitmap *map); diff --git a/fx.collections/include/fx/ds/buffer.h b/fx.collections/include/fx/collections/buffer.h similarity index 85% rename from fx.collections/include/fx/ds/buffer.h rename to fx.collections/include/fx/collections/buffer.h index f02e48e..d23170b 100644 --- a/fx.collections/include/fx/ds/buffer.h +++ b/fx.collections/include/fx/collections/buffer.h @@ -1,7 +1,7 @@ #ifndef FX_DS_BUFFER_H_ #define FX_DS_BUFFER_H_ -#include +#include #include FX_DECLS_BEGIN; @@ -18,16 +18,19 @@ FX_API fx_type fx_buffer_get_type(void); FX_API fx_buffer *fx_buffer_create(size_t item_sz); FX_API fx_buffer *fx_buffer_create_from_bytes(const void *p, size_t len); FX_API fx_buffer *fx_buffer_create_from_array( - const void *p, size_t item_sz, size_t len); + const void *p, + size_t item_sz, + size_t len); FX_API void *fx_buffer_steal(fx_buffer *buf); FX_API fx_status fx_buffer_reserve(fx_buffer *buf, size_t capacity); FX_API fx_status fx_buffer_resize(fx_buffer *buf, size_t length); FX_API fx_status fx_buffer_append(fx_buffer *dest, const void *p, size_t count); -FX_API fx_status fx_buffer_prepend(fx_buffer *dest, const void *p, size_t count); -FX_API fx_status fx_buffer_insert( - fx_buffer *dest, const void *p, size_t count, size_t at); +FX_API fx_status +fx_buffer_prepend(fx_buffer *dest, const void *p, size_t count); +FX_API fx_status +fx_buffer_insert(fx_buffer *dest, const void *p, size_t count, size_t at); FX_API fx_status fx_buffer_remove(fx_buffer *dest, size_t at, size_t count); FX_API fx_status fx_buffer_clear(fx_buffer *buf); diff --git a/fx.collections/include/fx/ds/datetime.h b/fx.collections/include/fx/collections/datetime.h similarity index 92% rename from fx.collections/include/fx/ds/datetime.h rename to fx.collections/include/fx/collections/datetime.h index ddf496a..6309156 100644 --- a/fx.collections/include/fx/ds/datetime.h +++ b/fx.collections/include/fx/collections/datetime.h @@ -1,9 +1,9 @@ #ifndef FX_DS_DATETIME_H_ #define FX_DS_DATETIME_H_ -#include -#include #include +#include +#include FX_DECLS_BEGIN; @@ -24,7 +24,8 @@ FX_TYPE_DEFAULT_CONSTRUCTOR(fx_datetime, FX_TYPE_DATETIME); FX_API fx_datetime *fx_datetime_parse(fx_datetime_format format, const char *s); FX_API void fx_datetime_to_string( - const fx_datetime *dt, fx_datetime_format format, + const fx_datetime *dt, + fx_datetime_format format, FX_TYPE_FWDREF(fx_stream) * dest); FX_API bool fx_datetime_is_localtime(const fx_datetime *dt); diff --git a/fx.collections/include/fx/ds/dict.h b/fx.collections/include/fx/collections/dict.h similarity index 81% rename from fx.collections/include/fx/ds/dict.h rename to fx.collections/include/fx/collections/dict.h index 9e15c6f..b5d5d35 100644 --- a/fx.collections/include/fx/ds/dict.h +++ b/fx.collections/include/fx/collections/dict.h @@ -1,12 +1,12 @@ #ifndef FX_DS_DICT_H_ #define FX_DS_DICT_H_ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include FX_DECLS_BEGIN; @@ -27,9 +27,10 @@ FX_TYPE_CLASS_DECLARATION_END(fx_dict_iterator) #define FX_DICT_ITEM(k, v) {.key = (k), .value = (v)} #define FX_DICT_ITEM_END {.key = NULL, .value = NULL} -#define fx_dict_foreach(it, dict) \ - for (int z__fx_unique_name() = fx_dict_iterator_begin(dict, it); \ - (it)->key != NULL; fx_dict_iterator_next(it)) +#define fx_dict_foreach(it, dict) \ + for (int z__fx_unique_name() = fx_dict_iterator_begin(dict, it); \ + (it)->key != NULL; \ + fx_dict_iterator_next(it)) typedef struct fx_dict_item { const fx_string *key; @@ -46,7 +47,8 @@ FX_API fx_dict *fx_dict_create_with_items(const fx_dict_item *items); #endif FX_API fx_status fx_dict_put(fx_dict *dict, const char *key, fx_object *value); -FX_API fx_status fx_dict_put_sk(fx_dict *dict, const fx_string *key, fx_object *value); +FX_API fx_status +fx_dict_put_sk(fx_dict *dict, const fx_string *key, fx_object *value); FX_API fx_object *fx_dict_at(const fx_dict *dict, const char *key); FX_API fx_object *fx_dict_at_sk(const fx_dict *dict, const fx_string *key); FX_API fx_object *fx_dict_get(fx_dict *dict, const char *key); diff --git a/fx.collections/include/fx/ds/hashmap.h b/fx.collections/include/fx/collections/hashmap.h similarity index 78% rename from fx.collections/include/fx/ds/hashmap.h rename to fx.collections/include/fx/collections/hashmap.h index aa03be1..853ccdd 100644 --- a/fx.collections/include/fx/ds/hashmap.h +++ b/fx.collections/include/fx/collections/hashmap.h @@ -1,11 +1,11 @@ #ifndef FX_DS_HASHMAP_H_ #define FX_DS_HASHMAP_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include FX_DECLS_BEGIN; @@ -27,14 +27,15 @@ FX_TYPE_CLASS_DECLARATION_END(fx_hashmap_iterator) #define FX_HASHMAP_KEY(k, ks) {.key_data = (k), .key_size = (ks)} #define FX_HASHMAP_VALUE(v, vs) {.value_data = (v), .value_size = (vs)} -#define FX_HASHMAP_ITEM(k, ks, v, vs) \ +#define FX_HASHMAP_ITEM(k, ks, v, vs) \ {.key = FX_HASHMAP_KEY(k, ks), .value = FX_HASHMAP_VALUE(v, vs)} #define FX_HASHMAP_ITEM_END {.key = {0}, .value = {0}} -#define fx_hashmap_foreach(it, hashmap) \ - for (int z__fx_unique_name() = fx_hashmap_iterator_begin(hashmap, it); \ - (it)->key != NULL; fx_hashmap_iterator_next(it)) +#define fx_hashmap_foreach(it, hashmap) \ + for (int z__fx_unique_name() = fx_hashmap_iterator_begin(hashmap, it); \ + (it)->key != NULL; \ + fx_hashmap_iterator_next(it)) typedef void (*fx_hashmap_key_destructor)(void *); typedef void (*fx_hashmap_value_destructor)(void *); @@ -63,15 +64,21 @@ FX_API fx_type fx_hashmap_get_type(void); FX_API fx_type fx_hashmap_iterator_get_type(void); FX_API fx_hashmap *fx_hashmap_create( - fx_hashmap_key_destructor key_dtor, fx_hashmap_value_destructor value_dtor); + fx_hashmap_key_destructor key_dtor, + fx_hashmap_value_destructor value_dtor); FX_API fx_hashmap *fx_hashmap_create_with_items(const fx_hashmap_item *items); FX_API fx_status fx_hashmap_put( - fx_hashmap *hashmap, const fx_hashmap_key *key, const fx_hashmap_value *value); + fx_hashmap *hashmap, + const fx_hashmap_key *key, + const fx_hashmap_value *value); FX_API const fx_hashmap_value *fx_hashmap_get( - const fx_hashmap *hashmap, const fx_hashmap_key *key); + const fx_hashmap *hashmap, + const fx_hashmap_key *key); -FX_API bool fx_hashmap_has_key(const fx_hashmap *hashmap, const fx_hashmap_key *key); +FX_API bool fx_hashmap_has_key( + const fx_hashmap *hashmap, + const fx_hashmap_key *key); FX_API size_t fx_hashmap_get_size(const fx_hashmap *hashmap); FX_API bool fx_hashmap_is_empty(const fx_hashmap *hashmap); diff --git a/fx.collections/include/fx/ds/list.h b/fx.collections/include/fx/collections/list.h similarity index 90% rename from fx.collections/include/fx/ds/list.h rename to fx.collections/include/fx/collections/list.h index 728397d..f0cf147 100644 --- a/fx.collections/include/fx/ds/list.h +++ b/fx.collections/include/fx/collections/list.h @@ -1,9 +1,9 @@ #ifndef FX_DS_LIST_H_ #define FX_DS_LIST_H_ -#include -#include -#include +#include +#include +#include FX_DECLS_BEGIN; @@ -39,9 +39,13 @@ FX_API fx_list_entry *fx_list_prev(const fx_list_entry *entry); FX_API size_t fx_list_length(const fx_list *q); FX_API fx_list_entry *fx_list_insert_before( - fx_list *q, void *ptr, fx_list_entry *before); + fx_list *q, + void *ptr, + fx_list_entry *before); FX_API fx_list_entry *fx_list_insert_after( - fx_list *q, void *ptr, fx_list_entry *after); + fx_list *q, + void *ptr, + fx_list_entry *after); FX_API fx_list_entry *fx_list_push_front(fx_list *q, void *ptr); FX_API fx_list_entry *fx_list_push_back(fx_list *q, void *ptr); diff --git a/fx.collections/include/fx/ds/number.h b/fx.collections/include/fx/collections/number.h similarity index 98% rename from fx.collections/include/fx/ds/number.h rename to fx.collections/include/fx/collections/number.h index 1bd06c9..0c20bc3 100644 --- a/fx.collections/include/fx/ds/number.h +++ b/fx.collections/include/fx/collections/number.h @@ -1,7 +1,7 @@ #ifndef FX_DS_NUMBER_H #define FX_DS_NUMBER_H -#include +#include #include FX_DECLS_BEGIN; @@ -133,7 +133,9 @@ static inline fx_number *fx_number_create_size_t(size_t value) FX_API fx_number_type fx_number_get_number_type(const fx_number *number); FX_API int fx_number_get_value( - const fx_number *number, fx_number_type type, void *value_ptr); + const fx_number *number, + fx_number_type type, + void *value_ptr); static inline int8_t fx_number_get_int8(const fx_number *number) { diff --git a/fx.collections/include/fx/ds/string.h b/fx.collections/include/fx/collections/string.h similarity index 97% rename from fx.collections/include/fx/ds/string.h rename to fx.collections/include/fx/collections/string.h index 669a6c6..1ad75f0 100644 --- a/fx.collections/include/fx/ds/string.h +++ b/fx.collections/include/fx/collections/string.h @@ -2,11 +2,11 @@ #define FX_DS_STRING_H_ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include FX_DECLS_BEGIN; diff --git a/fx.collections/include/fx/ds/tree.h b/fx.collections/include/fx/collections/tree.h similarity index 88% rename from fx.collections/include/fx/ds/tree.h rename to fx.collections/include/fx/collections/tree.h index 9767bff..be8846f 100644 --- a/fx.collections/include/fx/ds/tree.h +++ b/fx.collections/include/fx/collections/tree.h @@ -1,10 +1,10 @@ #ifndef FX_DS_TREE_H_ #define FX_DS_TREE_H_ -#include -#include -#include -#include +#include +#include +#include +#include FX_DECLS_BEGIN; @@ -22,7 +22,7 @@ FX_TYPE_CLASS_DECLARATION_END(fx_tree_iterator) #define FX_TREE_NODE_INIT ((fx_tree_node) {0}) -#define FX_TREE_CONTAINER(t, m, v) \ +#define FX_TREE_CONTAINER(t, m, v) \ ((void *)((v) ? (uintptr_t)(v) - (offsetof(t, m)) : 0)) typedef struct fx_tree_node { @@ -50,7 +50,8 @@ FX_API fx_iterator *fx_tree_node_begin(fx_tree_node *node); FX_API const fx_iterator *fx_tree_node_cbegin(const fx_tree_node *node); FX_API fx_iterator *fx_tree_node_begin_recursive(fx_tree_node *node); -FX_API const fx_iterator *fx_tree_node_cbegin_recursive(const fx_tree_node *node); +FX_API const fx_iterator *fx_tree_node_cbegin_recursive( + const fx_tree_node *node); FX_DECLS_END; diff --git a/fx.collections/include/fx/ds/uuid.h b/fx.collections/include/fx/collections/uuid.h similarity index 61% rename from fx.collections/include/fx/ds/uuid.h rename to fx.collections/include/fx/collections/uuid.h index 326c55f..0662bca 100644 --- a/fx.collections/include/fx/ds/uuid.h +++ b/fx.collections/include/fx/collections/uuid.h @@ -1,9 +1,9 @@ #ifndef FX_DS_UUID_H_ #define FX_DS_UUID_H_ -#include -#include -#include +#include +#include +#include #define FX_UUID_NBYTES 16 #define FX_UUID_STRING_MAX 37 @@ -29,19 +29,34 @@ FX_API fx_type fx_uuid_get_type(void); FX_TYPE_DEFAULT_CONSTRUCTOR(fx_uuid, FX_TYPE_UUID); FX_API fx_uuid *fx_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); -FX_API fx_uuid *fx_uuid_create_from_bytev(const unsigned char bytes[FX_UUID_NBYTES]); + 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); +FX_API fx_uuid *fx_uuid_create_from_bytev( + const unsigned char bytes[FX_UUID_NBYTES]); FX_API fx_uuid *fx_uuid_create_from_uuid_bytes(const fx_uuid_bytes *bytes); FX_API fx_uuid *fx_uuid_create_from_string(const fx_string *string); FX_API fx_uuid *fx_uuid_create_from_cstr(const char *s); -FX_API fx_status fx_uuid_to_cstr(const fx_uuid *uuid, char out[FX_UUID_STRING_MAX]); +FX_API fx_status fx_uuid_to_cstr( + const fx_uuid *uuid, + char out[FX_UUID_STRING_MAX]); FX_API void fx_uuid_get_bytes( - const fx_uuid *uuid, unsigned char bytes[FX_UUID_NBYTES]); + const fx_uuid *uuid, + unsigned char bytes[FX_UUID_NBYTES]); FX_API void fx_uuid_get_uuid_bytes(const fx_uuid *uuid, fx_uuid_bytes *bytes); FX_API fx_uuid_bytes *fx_uuid_ptr(fx_uuid *uuid); diff --git a/fx.collections/include/fx/ds.h b/fx.collections/include/fx/ds.h deleted file mode 100644 index e69de29..0000000 diff --git a/fx.collections/list.c b/fx.collections/list.c index 4059e4c..e06ab07 100644 --- a/fx.collections/list.c +++ b/fx.collections/list.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include @@ -109,7 +109,9 @@ static struct fx_list_entry *make_entry(void *item) } static struct fx_list_entry *list_insert_before( - struct fx_list_p *q, void *ptr, struct fx_list_entry *before) + struct fx_list_p *q, + void *ptr, + struct fx_list_entry *before) { struct fx_list_entry *entry = make_entry(ptr); if (!entry) { @@ -122,7 +124,9 @@ static struct fx_list_entry *list_insert_before( } static struct fx_list_entry *list_insert_after( - struct fx_list_p *q, void *ptr, struct fx_list_entry *after) + struct fx_list_p *q, + void *ptr, + struct fx_list_entry *after) { struct fx_list_entry *entry = make_entry(ptr); if (!entry) { @@ -226,7 +230,9 @@ static fx_status list_delete_item(struct fx_list_p *q, void *ptr) return FX_SUCCESS; } -static fx_status list_delete_entry(struct fx_list_p *q, struct fx_list_entry *entry) +static fx_status list_delete_entry( + struct fx_list_p *q, + struct fx_list_entry *entry) { fx_queue_delete(&q->l_queue, &entry->e_entry); q->l_len--; @@ -314,15 +320,29 @@ size_t fx_list_length(const fx_list *q) } struct fx_list_entry *fx_list_insert_before( - fx_list *q, void *ptr, struct fx_list_entry *before) + fx_list *q, + void *ptr, + struct fx_list_entry *before) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_insert_before, q, ptr, before); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_LIST, + list_insert_before, + q, + ptr, + before); } struct fx_list_entry *fx_list_insert_after( - fx_list *q, void *ptr, struct fx_list_entry *after) + fx_list *q, + void *ptr, + struct fx_list_entry *after) { - FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_insert_after, q, ptr, after); + FX_CLASS_DISPATCH_STATIC( + FX_TYPE_LIST, + list_insert_after, + q, + ptr, + after); } struct fx_list_entry *fx_list_push_front(fx_list *q, void *ptr) diff --git a/fx.collections/number.c b/fx.collections/number.c index 8a808ad..37ea313 100644 --- a/fx.collections/number.c +++ b/fx.collections/number.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include diff --git a/fx.collections/string.c b/fx.collections/string.c index a544fec..c8c2714 100644 --- a/fx.collections/string.c +++ b/fx.collections/string.c @@ -1,7 +1,7 @@ #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/fx.collections/tree.c b/fx.collections/tree.c index 87526f3..36a3a2f 100644 --- a/fx.collections/tree.c +++ b/fx.collections/tree.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -33,7 +33,9 @@ static void tree_set_root(struct fx_tree_p *tree, struct fx_tree_node *node) } static const struct fx_tree_node *next_node( - const struct fx_tree_node *node, bool recursive, int *depth_diff) + const struct fx_tree_node *node, + bool recursive, + int *depth_diff) { if (!node) { return NULL; @@ -101,7 +103,8 @@ static void remove_node(struct fx_tree_node *node) } static void reparent_children( - struct fx_tree_node *old_parent, struct fx_tree_node *new_parent) + struct fx_tree_node *old_parent, + struct fx_tree_node *new_parent) { struct fx_tree_node *last = NODE_FIRST_CHILD(new_parent); while (last && NODE_NEXT_SIBLING(last)) { @@ -132,7 +135,9 @@ void fx_tree_set_root(fx_tree *tree, struct fx_tree_node *node) FX_CLASS_DISPATCH_STATIC(FX_TYPE_TREE, tree_set_root, tree, node); } -void fx_tree_node_add_child(struct fx_tree_node *parent, struct fx_tree_node *child) +void fx_tree_node_add_child( + struct fx_tree_node *parent, + struct fx_tree_node *child) { if (NODE_PARENT(child)) { return; @@ -152,7 +157,9 @@ void fx_tree_node_add_child(struct fx_tree_node *parent, struct fx_tree_node *ch NODE_NEXT_SIBLING(cur) = child; } -void fx_tree_node_add_sibling(struct fx_tree_node *node, struct fx_tree_node *to_add) +void fx_tree_node_add_sibling( + struct fx_tree_node *node, + struct fx_tree_node *to_add) { if (NODE_PARENT(to_add) || !NODE_PARENT(node)) { return; @@ -161,7 +168,9 @@ void fx_tree_node_add_sibling(struct fx_tree_node *node, struct fx_tree_node *to fx_tree_node_add_child(NODE_PARENT(node), to_add); } -struct fx_tree_node *fx_tree_node_get_child(struct fx_tree_node *node, size_t at) +struct fx_tree_node *fx_tree_node_get_child( + struct fx_tree_node *node, + size_t at) { size_t i = 0; struct fx_tree_node *cur = NODE_FIRST_CHILD(node); @@ -233,7 +242,8 @@ fx_iterator *fx_tree_node_begin_recursive(struct fx_tree_node *node) return it_obj; } -const fx_iterator *fx_tree_node_cbegin_recursive(const struct fx_tree_node *node) +const fx_iterator *fx_tree_node_cbegin_recursive( + const struct fx_tree_node *node) { return fx_tree_node_begin_recursive((struct fx_tree_node *)node); } diff --git a/fx.collections/uuid.c b/fx.collections/uuid.c index 1cf63f5..86c62a9 100644 --- a/fx.collections/uuid.c +++ b/fx.collections/uuid.c @@ -1,7 +1,7 @@ #include -#include -#include -#include +#include +#include +#include #include #include #include