summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/kit/array_ref.h40
-rw-r--r--source/kit/input_buffer.h2
-rw-r--r--source/kit/input_stream.c4
-rw-r--r--source/kit/input_stream.h2
-rw-r--r--source/kit/string_ref.h12
-rw-r--r--source/test/unittests/array_ref.test.c4
-rw-r--r--source/test/unittests/input_buffer.test.c2
-rw-r--r--source/test/unittests/input_stream.test.c4
-rw-r--r--source/test/unittests/lower_bound.test.c78
9 files changed, 74 insertions, 74 deletions
diff --git a/source/kit/array_ref.h b/source/kit/array_ref.h
index 8ed065b..9501eba 100644
--- a/source/kit/array_ref.h
+++ b/source/kit/array_ref.h
@@ -19,42 +19,42 @@ int kit_ar_compare(ptrdiff_t left_element_size, ptrdiff_t left_size,
ptrdiff_t right_element_size, ptrdiff_t right_size,
void const *right_data, kit_ar_compare_fn compare);
-#define KIT_AR(name_, type_) \
- struct { \
- ptrdiff_t size; \
- type_ *values; \
+#define KIT_AR_MUT(name_, type_) \
+ struct { \
+ ptrdiff_t size; \
+ type_ *values; \
} name_
-#define KIT_AR_CONST(name_, type_) \
- struct { \
- ptrdiff_t size; \
- type_ const *values; \
+#define KIT_AR(name_, type_) \
+ struct { \
+ ptrdiff_t size; \
+ type_ const *values; \
} name_
-#define KIT_AR_WRAP(name_, element_type_, array_) \
+#define KIT_AR_MUT_WRAP(name_, element_type_, array_) \
struct { \
ptrdiff_t size; \
element_type_ *values; \
} name_ = { .size = (sizeof(array_) / sizeof((array_)[0])), \
.values = (array_) }
-#define KIT_AR_CONST_WRAP(name_, element_type_, array_) \
+#define KIT_AR_WRAP(name_, element_type_, array_) \
struct { \
ptrdiff_t size; \
element_type_ const *values; \
} name_ = { .size = (sizeof(array_) / sizeof((array_)[0])), \
.values = (array_) }
-#define KIT_AR_TYPE(name_, element_type_) \
- typedef struct { \
- ptrdiff_t size; \
- element_type_ *values; \
+#define KIT_AR_MUT_TYPE(name_, element_type_) \
+ typedef struct { \
+ ptrdiff_t size; \
+ element_type_ *values; \
} name_
-#define KIT_AR_TYPE_CONST(name_, element_type_) \
- typedef struct { \
- ptrdiff_t size; \
- element_type_ const *values; \
+#define KIT_AR_TYPE(name_, element_type_) \
+ typedef struct { \
+ ptrdiff_t size; \
+ element_type_ const *values; \
} name_
#define KIT_AR_EQUAL(left_, right_) \
@@ -73,10 +73,10 @@ int kit_ar_compare(ptrdiff_t left_element_size, ptrdiff_t left_size,
# define ar_equal_bytes kit_ar_equal_bytes
# define ar_compare kit_ar_compare
+# define AR_MUT KIT_AR_MUT
# define AR KIT_AR
-# define AR_CONST KIT_AR_CONST
+# define AR_MUT_WRAP KIT_AR_MUT_WRAP
# define AR_WRAP KIT_AR_WRAP
-# define AR_CONST_WRAP KIT_AR_CONST_WRAP
# define AR_TYPE KIT_AR_TYPE
# define AR_TYPE_CONST KIT_AR_TYPE_CONST
# define AR_EQUAL KIT_AR_EQUAL
diff --git a/source/kit/input_buffer.h b/source/kit/input_buffer.h
index 4e62f83..1b47c4a 100644
--- a/source/kit/input_buffer.h
+++ b/source/kit/input_buffer.h
@@ -12,7 +12,7 @@ typedef struct {
int error;
ptrdiff_t offset;
void *internal;
- DA(data, char);
+ KIT_DA(data, char);
} kit_ib_handle_t;
kit_ib_handle_t kit_ib_wrap(kit_is_handle_t upstream,
diff --git a/source/kit/input_stream.c b/source/kit/input_stream.c
index 1eaf5eb..64a305e 100644
--- a/source/kit/input_stream.c
+++ b/source/kit/input_stream.c
@@ -12,7 +12,7 @@ typedef struct {
typedef struct {
ptrdiff_t type;
kit_allocator_t alloc;
- kit_cstr_t string;
+ kit_str_t string;
} kit_is_state_cstr_t;
static _Bool check_type(void *state, ptrdiff_t type) {
@@ -37,7 +37,7 @@ static ptrdiff_t read_cstr(void *state, kit_out_str_t destination) {
return size;
}
-kit_is_handle_t kit_is_wrap_string(kit_cstr_t string,
+kit_is_handle_t kit_is_wrap_string(kit_str_t string,
kit_allocator_t alloc) {
kit_is_handle_t in;
memset(&in, 0, sizeof in);
diff --git a/source/kit/input_stream.h b/source/kit/input_stream.h
index 90321f4..213d2ca 100644
--- a/source/kit/input_stream.h
+++ b/source/kit/input_stream.h
@@ -16,7 +16,7 @@ typedef struct {
kit_is_read_fn read;
} kit_is_handle_t;
-kit_is_handle_t kit_is_wrap_string(kit_cstr_t string,
+kit_is_handle_t kit_is_wrap_string(kit_str_t string,
kit_allocator_t alloc);
void kit_is_destroy(kit_is_handle_t in);
diff --git a/source/kit/string_ref.h b/source/kit/string_ref.h
index 0e3468a..8505564 100644
--- a/source/kit/string_ref.h
+++ b/source/kit/string_ref.h
@@ -7,23 +7,23 @@
extern "C" {
#endif
+KIT_AR_MUT_TYPE(kit_string_mut_t, char);
KIT_AR_TYPE(kit_string_ref_t, char);
-KIT_AR_TYPE_CONST(kit_string_cref_t, char);
-typedef kit_string_ref_t kit_out_str_t;
-typedef kit_string_cref_t kit_cstr_t;
+typedef kit_string_mut_t kit_out_str_t;
+typedef kit_string_ref_t kit_str_t;
#define KIT_SZ(name_, static_str_) \
- KIT_AR_CONST(name_, char) = { \
+ KIT_AR(name_, char) = { \
.size = (sizeof(static_str_) / sizeof((static_str_)[0])) - 1, \
.values = (static_str_) \
}
#ifndef KIT_DISABLE_SHORT_NAMES
+# define string_mut_t kit_string_mut_t
# define string_ref_t kit_string_ref_t
-# define string_cref_t kit_string_cref_t
# define out_str_t kit_out_str_t
-# define cstr_t kit_cstr_t
+# define str_t kit_str_t
# define SZ KIT_SZ
#endif
diff --git a/source/test/unittests/array_ref.test.c b/source/test/unittests/array_ref.test.c
index 62556f3..ac572b1 100644
--- a/source/test/unittests/array_ref.test.c
+++ b/source/test/unittests/array_ref.test.c
@@ -5,7 +5,7 @@
TEST("array ref const wrap") {
int foo[] = { 1, 2, 3 };
- AR_CONST_WRAP(ref, int, foo);
+ AR_WRAP(ref, int, foo);
REQUIRE(ref.size == 3);
REQUIRE(ref.values[0] == 1);
@@ -15,7 +15,7 @@ TEST("array ref const wrap") {
TEST("array ref wrap") {
int foo[] = { 1, 2, 3 };
- AR_WRAP(ref, int, foo);
+ AR_MUT_WRAP(ref, int, foo);
REQUIRE(ref.size == 3);
REQUIRE(ref.values[0] == 1);
diff --git a/source/test/unittests/input_buffer.test.c b/source/test/unittests/input_buffer.test.c
index 23499ee..a88b58b 100644
--- a/source/test/unittests/input_buffer.test.c
+++ b/source/test/unittests/input_buffer.test.c
@@ -4,7 +4,7 @@
#include "../../kit_test/test.h"
TEST("input buffer") {
- cstr_t text = { .size = 3, .values = "foo" };
+ str_t text = { .size = 3, .values = "foo" };
is_handle_t in = IS_WRAP_STRING(text);
ib_handle_t first = IB_WRAP(in);
diff --git a/source/test/unittests/input_stream.test.c b/source/test/unittests/input_stream.test.c
index e646983..7dce043 100644
--- a/source/test/unittests/input_stream.test.c
+++ b/source/test/unittests/input_stream.test.c
@@ -7,8 +7,8 @@ TEST("input stream wrap string") {
char foo[] = "test";
char bar[] = "test";
- cstr_t foo_ref = { .size = sizeof(foo) - 1, .values = foo };
- cstr_t bar_ref = { .size = sizeof(bar) - 1, .values = bar };
+ str_t foo_ref = { .size = sizeof(foo) - 1, .values = foo };
+ str_t bar_ref = { .size = sizeof(bar) - 1, .values = bar };
is_handle_t in = IS_WRAP_STRING(foo_ref);
diff --git a/source/test/unittests/lower_bound.test.c b/source/test/unittests/lower_bound.test.c
index 275acd6..225c6ba 100644
--- a/source/test/unittests/lower_bound.test.c
+++ b/source/test/unittests/lower_bound.test.c
@@ -13,7 +13,7 @@ static int kit_less_int_ref(int const *left, int const *right) {
}
TEST("lower bound empty") {
- AR_CONST(ref, int) = { .size = 0, .values = NULL };
+ AR(ref, int) = { .size = 0, .values = NULL };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 42, kit_less_int);
@@ -21,8 +21,8 @@ TEST("lower bound empty") {
}
TEST("lower bound single left") {
- int const v[1] = { 42 };
- AR_CONST(ref, int) = { .size = 1, .values = v };
+ int const v[1] = { 42 };
+ AR(ref, int) = { .size = 1, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 42, kit_less_int);
@@ -30,8 +30,8 @@ TEST("lower bound single left") {
}
TEST("lower bound single right") {
- int const v[1] = { 42 };
- AR_CONST(ref, int) = { .size = 1, .values = v };
+ int const v[1] = { 42 };
+ AR(ref, int) = { .size = 1, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 43, kit_less_int);
@@ -39,8 +39,8 @@ TEST("lower bound single right") {
}
TEST("lower bound first of four") {
- int const v[4] = { 1, 2, 3, 4 };
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 1, kit_less_int);
@@ -48,8 +48,8 @@ TEST("lower bound first of four") {
}
TEST("lower bound second of four") {
- int const v[4] = { 1, 2, 3, 4 };
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 2, kit_less_int);
@@ -57,8 +57,8 @@ TEST("lower bound second of four") {
}
TEST("lower bound third of four") {
- int const v[4] = { 1, 2, 3, 4 };
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 3, kit_less_int);
@@ -66,8 +66,8 @@ TEST("lower bound third of four") {
}
TEST("lower bound forth of four") {
- int const v[4] = { 1, 2, 3, 4 };
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 4, kit_less_int);
@@ -75,8 +75,8 @@ TEST("lower bound forth of four") {
}
TEST("lower bound fifth of four") {
- int const v[4] = { 1, 2, 3, 4 };
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 5, kit_less_int);
@@ -84,8 +84,8 @@ TEST("lower bound fifth of four") {
}
TEST("lower bound first of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 1, kit_less_int);
@@ -93,8 +93,8 @@ TEST("lower bound first of five") {
}
TEST("lower bound second of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 2, kit_less_int);
@@ -102,8 +102,8 @@ TEST("lower bound second of five") {
}
TEST("lower bound third of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 3, kit_less_int);
@@ -111,8 +111,8 @@ TEST("lower bound third of five") {
}
TEST("lower bound forth of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 4, kit_less_int);
@@ -120,8 +120,8 @@ TEST("lower bound forth of five") {
}
TEST("lower bound fifth of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 5, kit_less_int);
@@ -129,8 +129,8 @@ TEST("lower bound fifth of five") {
}
TEST("lower bound sixth of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND(index, ref, 6, kit_less_int);
@@ -138,9 +138,9 @@ TEST("lower bound sixth of five") {
}
TEST("lower bound ref first of four") {
- int const v[4] = { 1, 2, 3, 4 };
- int const value = 1;
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ int const value = 1;
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref);
@@ -148,9 +148,9 @@ TEST("lower bound ref first of four") {
}
TEST("lower bound ref second of four") {
- int const v[4] = { 1, 2, 3, 4 };
- int const value = 2;
- AR_CONST(ref, int) = { .size = 4, .values = v };
+ int const v[4] = { 1, 2, 3, 4 };
+ int const value = 2;
+ AR(ref, int) = { .size = 4, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref);
@@ -158,9 +158,9 @@ TEST("lower bound ref second of four") {
}
TEST("lower bound ref fifth of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- int const value = 5;
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ int const value = 5;
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref);
@@ -168,9 +168,9 @@ TEST("lower bound ref fifth of five") {
}
TEST("lower bound ref sixth of five") {
- int const v[5] = { 1, 2, 3, 4, 5 };
- int const value = 6;
- AR_CONST(ref, int) = { .size = 5, .values = v };
+ int const v[5] = { 1, 2, 3, 4, 5 };
+ int const value = 6;
+ AR(ref, int) = { .size = 5, .values = v };
ptrdiff_t index;
KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref);