meta: rename to fx
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
#include <blue/ds/array.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <fx/ds/array.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
b_array *array = b_array_create();
|
||||
b_array_append(array, B_RV_INT(32));
|
||||
b_array_append(array, B_RV_INT(64));
|
||||
b_array_append(array, B_RV_INT(128));
|
||||
fx_array *array = fx_array_create();
|
||||
fx_array_append(array, FX_RV_INT(32));
|
||||
fx_array_append(array, FX_RV_INT(64));
|
||||
fx_array_append(array, FX_RV_INT(128));
|
||||
|
||||
b_iterator *it = b_iterator_begin(array);
|
||||
b_foreach_ptr(b_object, obj, it)
|
||||
fx_iterator *it = fx_iterator_begin(array);
|
||||
fx_foreach_ptr(fx_object, obj, it)
|
||||
{
|
||||
printf("object %p\n", obj);
|
||||
}
|
||||
b_iterator_unref(it);
|
||||
fx_iterator_unref(it);
|
||||
|
||||
b_array_unref(array);
|
||||
fx_array_unref(array);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
#include <CuTest.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
|
||||
static void test_string_create(CuTest *tc)
|
||||
{
|
||||
b_string *str = b_string_create();
|
||||
fx_string *str = fx_string_create();
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 0, b_string_get_size(str, B_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "", b_string_ptr(str));
|
||||
CuAssertIntEquals(tc, 0, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "", fx_string_ptr(str));
|
||||
|
||||
b_string_unref(str);
|
||||
fx_string_unref(str);
|
||||
|
||||
str = b_string_create_from_c('A', 8);
|
||||
str = fx_string_create_from_c('A', 8);
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 8, b_string_get_size(str, B_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "AAAAAAAA", b_string_ptr(str));
|
||||
CuAssertIntEquals(tc, 8, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "AAAAAAAA", fx_string_ptr(str));
|
||||
|
||||
b_string_unref(str);
|
||||
fx_string_unref(str);
|
||||
|
||||
str = b_string_create_from_cstr("Hello, world!");
|
||||
str = fx_string_create_from_cstr("Hello, world!");
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 13, b_string_get_size(str, B_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "Hello, world!", b_string_ptr(str));
|
||||
CuAssertIntEquals(tc, 13, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "Hello, world!", fx_string_ptr(str));
|
||||
|
||||
b_string_unref(str);
|
||||
fx_string_unref(str);
|
||||
}
|
||||
|
||||
static void test_string_length(CuTest *tc)
|
||||
{
|
||||
const char *cstr = "Hello, \033[91;1mworld!";
|
||||
b_string *s = b_string_create_from_cstr(cstr);
|
||||
fx_string *s = fx_string_create_from_cstr(cstr);
|
||||
|
||||
CuAssertIntEquals(tc, 13, b_string_get_size(s, B_STRLEN_IGNORE_ESC));
|
||||
CuAssertIntEquals(tc, 20, b_string_get_size(s, B_STRLEN_NORMAL));
|
||||
CuAssertIntEquals(tc, 13, fx_string_get_size(s, FX_STRLEN_IGNORE_ESC));
|
||||
CuAssertIntEquals(tc, 20, fx_string_get_size(s, FX_STRLEN_NORMAL));
|
||||
|
||||
b_string_unref(s);
|
||||
fx_string_unref(s);
|
||||
}
|
||||
|
||||
CuSuite *get_all_tests(void)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <blue/ds/number.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
b_number *number = b_number_create_float(6.8);
|
||||
fx_number *number = fx_number_create_float(6.8);
|
||||
|
||||
printf("number=%zd\n", B_NUMBER_IVAL(number));
|
||||
b_number_unref(number);
|
||||
printf("number=%zd\n", FX_NUMBER_IVAL(number));
|
||||
fx_number_unref(number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
b_string *string = B_CSTR("Hello, world!");
|
||||
fx_string *string = FX_CSTR("Hello, world!");
|
||||
printf("string object = ");
|
||||
b_object_to_string(string, b_stdout);
|
||||
fx_object_to_string(string, fx_stdout);
|
||||
printf("\n");
|
||||
b_string_unref(string);
|
||||
fx_string_unref(string);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include <blue/core/stream.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
size_t nr_read = 0;
|
||||
b_stringstream *dest_stream = b_stringstream_create();
|
||||
b_stream_buffer *buf = b_stream_buffer_create_dynamic(1024);
|
||||
b_stream_read_all_bytes_s(b_stdin, dest_stream, buf, &nr_read);
|
||||
fx_stringstream *dest_stream = fx_stringstream_create();
|
||||
fx_stream_buffer *buf = fx_stream_buffer_create_dynamic(1024);
|
||||
fx_stream_read_all_bytes_s(fx_stdin, dest_stream, buf, &nr_read);
|
||||
|
||||
printf("done. read %zu bytes total.\n", nr_read);
|
||||
printf("%s\n", b_stringstream_ptr(dest_stream));
|
||||
printf("%s\n", fx_stringstream_ptr(dest_stream));
|
||||
|
||||
b_stringstream_unref(dest_stream);
|
||||
b_stream_buffer_unref(buf);
|
||||
fx_stringstream_unref(dest_stream);
|
||||
fx_stream_buffer_unref(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("-------------\n");
|
||||
b_string *str = b_string_create_from_cstr("Hello, world!\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
fx_string *str = fx_string_create_from_cstr("Hello, world!\n");
|
||||
printf("%s\n", fx_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
|
||||
b_string_insert_cstr(str, "WOW!", 4);
|
||||
fx_string_insert_cstr(str, "WOW!", 4);
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
printf("%s\n", fx_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
|
||||
b_string_replace(str, 4, 4, "+");
|
||||
fx_string_replace(str, 4, 4, "+");
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
printf("%s\n", fx_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
printf("-------------\n");
|
||||
|
||||
b_string_unref(str);
|
||||
fx_string_unref(str);
|
||||
|
||||
b_stringstream *strv = b_stringstream_create();
|
||||
b_stream_write_string(strv, "Hello", NULL);
|
||||
b_stream_write_string(strv, ", world", NULL);
|
||||
b_stream_write_string(strv, "!", NULL);
|
||||
fx_stringstream *strv = fx_stringstream_create();
|
||||
fx_stream_write_string(strv, "Hello", NULL);
|
||||
fx_stream_write_string(strv, ", world", NULL);
|
||||
fx_stream_write_string(strv, "!", NULL);
|
||||
|
||||
char *s = b_stringstream_steal(strv);
|
||||
b_stringstream_unref(strv);
|
||||
char *s = fx_stringstream_steal(strv);
|
||||
fx_stringstream_unref(strv);
|
||||
|
||||
printf("%s\n", s);
|
||||
free(s);
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/ds/dict.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/tree.h>
|
||||
#include <fx/core/btree.h>
|
||||
#include <fx/core/iterator.h>
|
||||
#include <fx/ds/dict.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/ds/tree.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NITEMS 16
|
||||
|
||||
struct tree_item {
|
||||
int value;
|
||||
b_tree_node node;
|
||||
fx_tree_node node;
|
||||
};
|
||||
|
||||
struct btree_item {
|
||||
int value;
|
||||
b_btree_node node;
|
||||
fx_bst_node node;
|
||||
};
|
||||
|
||||
B_BTREE_DEFINE_SIMPLE_GET(struct btree_item, int, node, value, get_node)
|
||||
B_BTREE_DEFINE_SIMPLE_INSERT(struct btree_item, node, value, put_node)
|
||||
FX_BTREE_DEFINE_SIMPLE_GET(struct btree_item, int, node, value, get_node)
|
||||
FX_BTREE_DEFINE_SIMPLE_INSERT(struct btree_item, node, value, put_node)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
b_dict *dict = b_dict_create();
|
||||
b_dict_put(dict, "hello", B_RV_INT(32));
|
||||
b_dict_put(dict, "world", B_RV_INT(64));
|
||||
b_dict_put(dict, "more", B_RV_INT(128));
|
||||
b_dict_put(dict, "other", B_RV_INT(256));
|
||||
fx_dict *dict = fx_dict_create();
|
||||
fx_dict_put(dict, "hello", FX_RV_INT(32));
|
||||
fx_dict_put(dict, "world", FX_RV_INT(64));
|
||||
fx_dict_put(dict, "more", FX_RV_INT(128));
|
||||
fx_dict_put(dict, "other", FX_RV_INT(256));
|
||||
|
||||
b_iterator *it = b_iterator_begin(dict);
|
||||
fx_iterator *it = fx_iterator_begin(dict);
|
||||
|
||||
size_t i = 0;
|
||||
b_foreach(b_dict_item *, item, it)
|
||||
fx_foreach(fx_dict_item *, item, it)
|
||||
{
|
||||
printf("item %zu: %s=%d\n", i++, b_string_ptr(item->key),
|
||||
b_number_get_int(item->value));
|
||||
printf("item %zu: %s=%d\n", i++, fx_string_ptr(item->key),
|
||||
fx_number_get_int(item->value));
|
||||
}
|
||||
|
||||
b_iterator_unref(it);
|
||||
fx_iterator_unref(it);
|
||||
|
||||
b_tree *tree = b_tree_create();
|
||||
fx_tree *tree = fx_tree_create();
|
||||
struct tree_item items2[NITEMS];
|
||||
|
||||
for (int i = 0; i < NITEMS; i++) {
|
||||
items2[i].value = i;
|
||||
items2[i].node = B_TREE_NODE_INIT;
|
||||
items2[i].node = FX_TREE_NODE_INIT;
|
||||
}
|
||||
|
||||
b_tree_set_root(tree, &items2[0].node);
|
||||
fx_tree_set_root(tree, &items2[0].node);
|
||||
|
||||
b_tree_node_add_child(&items2[0].node, &items2[1].node);
|
||||
b_tree_node_add_child(&items2[0].node, &items2[2].node);
|
||||
b_tree_node_add_child(&items2[0].node, &items2[3].node);
|
||||
b_tree_node_add_child(&items2[0].node, &items2[7].node);
|
||||
b_tree_node_add_child(&items2[1].node, &items2[4].node);
|
||||
b_tree_node_add_child(&items2[1].node, &items2[5].node);
|
||||
b_tree_node_add_child(&items2[4].node, &items2[6].node);
|
||||
fx_tree_node_add_child(&items2[0].node, &items2[1].node);
|
||||
fx_tree_node_add_child(&items2[0].node, &items2[2].node);
|
||||
fx_tree_node_add_child(&items2[0].node, &items2[3].node);
|
||||
fx_tree_node_add_child(&items2[0].node, &items2[7].node);
|
||||
fx_tree_node_add_child(&items2[1].node, &items2[4].node);
|
||||
fx_tree_node_add_child(&items2[1].node, &items2[5].node);
|
||||
fx_tree_node_add_child(&items2[4].node, &items2[6].node);
|
||||
|
||||
#if 0
|
||||
it = b_iterator_begin(tree);
|
||||
b_tree_iterator it2;
|
||||
b_tree_foreach(&it2, tree)
|
||||
it = fx_iterator_begin(tree);
|
||||
fx_tree_iterator it2;
|
||||
fx_tree_foreach(&it2, tree)
|
||||
{
|
||||
struct tree_item *item = b_unbox(struct tree_item, it2.node, node);
|
||||
struct tree_item *item = fx_unbox(struct tree_item, it2.node, node);
|
||||
|
||||
for (size_t i = 0; i < it2.depth; i++) {
|
||||
fputs(" ", stdout);
|
||||
@@ -71,7 +71,7 @@ int main(void)
|
||||
printf("%u\n", item->value);
|
||||
}
|
||||
|
||||
b_btree btree = {0};
|
||||
fx_bst btree = {0};
|
||||
struct btree_item items3[NITEMS] = {0};
|
||||
for (int i = 0; i < NITEMS; i++) {
|
||||
items3[i].value = i;
|
||||
@@ -80,10 +80,10 @@ int main(void)
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
b_btree_iterator it3;
|
||||
b_btree_foreach (&it3, &btree) {
|
||||
fx_bst_iterator it3;
|
||||
fx_bst_foreach (&it3, &btree) {
|
||||
struct btree_item *item
|
||||
= b_unbox(struct btree_item, it3.node, node);
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
|
||||
for (size_t i = 0; i < it3.depth; i++) {
|
||||
fputs(" ", stdout);
|
||||
@@ -92,23 +92,23 @@ int main(void)
|
||||
printf("%d\n", item->value);
|
||||
}
|
||||
|
||||
b_btree_iterator_begin(&btree, &it3);
|
||||
while (b_btree_iterator_is_valid(&it3)) {
|
||||
fx_bst_iterator_begin(&btree, &it3);
|
||||
while (fx_bst_iterator_is_valid(&it3)) {
|
||||
struct btree_item *item
|
||||
= b_unbox(struct btree_item, it3.node, node);
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
|
||||
if (item->value == 9) {
|
||||
b_btree_iterator_erase(&it3);
|
||||
fx_bst_iterator_erase(&it3);
|
||||
} else {
|
||||
b_btree_iterator_next(&it3);
|
||||
fx_bst_iterator_next(&it3);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
b_btree_foreach (&it3, &btree) {
|
||||
fx_bst_foreach (&it3, &btree) {
|
||||
struct btree_item *item
|
||||
= b_unbox(struct btree_item, it3.node, node);
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
|
||||
for (size_t i = 0; i < it3.depth; i++) {
|
||||
fputs(" ", stdout);
|
||||
@@ -117,9 +117,9 @@ int main(void)
|
||||
printf("%d\n", item->value);
|
||||
}
|
||||
|
||||
b_tree_unref(tree);
|
||||
fx_tree_unref(tree);
|
||||
#endif
|
||||
b_dict_unref(dict);
|
||||
fx_dict_unref(dict);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("здравс\u26A0твуите\n");
|
||||
b_string *str = b_string_create_from_cstr("здравствуите");
|
||||
const char *s = b_string_ptr(str);
|
||||
fx_string *str = fx_string_create_from_cstr("здравствуите");
|
||||
const char *s = fx_string_ptr(str);
|
||||
printf("%s\n", s);
|
||||
printf("len: %zu\n", b_string_get_size(str, B_STRLEN_NORMAL));
|
||||
printf("codepoints: %zu\n", b_string_get_size(str, B_STRLEN_CODEPOINTS));
|
||||
printf("len: %zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
printf("codepoints: %zu\n", fx_string_get_size(str, FX_STRLEN_CODEPOINTS));
|
||||
|
||||
const char *delims[] = {"в"};
|
||||
size_t nr_delims = sizeof delims / sizeof delims[0];
|
||||
|
||||
b_iterator *it = b_string_tokenise(str, delims, nr_delims, 0);
|
||||
b_foreach(const char *, tok, it)
|
||||
fx_iterator *it = fx_string_tokenise(str, delims, nr_delims, 0);
|
||||
fx_foreach(const char *, tok, it)
|
||||
{
|
||||
printf("%s\n", tok);
|
||||
}
|
||||
b_iterator_unref(it);
|
||||
b_string_unref(str);
|
||||
fx_iterator_unref(it);
|
||||
fx_string_unref(str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include <blue/ds/uuid.h>
|
||||
#include <fx/ds/uuid.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
b_uuid *uuid = b_uuid_create_from_cstr(
|
||||
fx_uuid *uuid = fx_uuid_create_from_cstr(
|
||||
"5b80ad1f-367f-4a1f-88f3-b3a6f8d1f63d");
|
||||
char str[B_UUID_STRING_MAX];
|
||||
b_uuid_to_cstr(uuid, str);
|
||||
char str[FX_UUID_STRING_MAX];
|
||||
fx_uuid_to_cstr(uuid, str);
|
||||
printf("%s\n", str);
|
||||
|
||||
b_uuid_unref(uuid);
|
||||
fx_uuid_unref(uuid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user