commit f90b972f752d868d43167ee3d9cc0b56952d7d31
parent ee6384813a8c2101d4fb24364aaada40c4d28d04
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Sun, 24 Sep 2023 23:13:14 -0700
Rename typedef options in dict and table
Diffstat:
8 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/inc/dict/impl/declare.h b/inc/dict/impl/declare.h
@@ -1,7 +1,7 @@
typedef struct {
RTable table;
DICT_V default_val;
-} DICT_D;
+} DICT_NAME;
#define DICT_SPEC &(RDictTableSpec){ \
.ksize = sizeof(DICT_K), \
@@ -13,33 +13,33 @@ typedef struct {
}
static inline UNUSED int
-DICT_METHOD(init)(DICT_D *d, usize hint) {
+DICT_METHOD(init)(DICT_NAME *d, usize hint) {
memset(&d->default_val, 0, sizeof(DICT_V));
return r_dict_table_init(&d->table, hint, DICT_SPEC);
}
static inline UNUSED void
-DICT_METHOD(free)(DICT_D *d) {
+DICT_METHOD(free)(DICT_NAME *d) {
r_dict_table_free(&d->table, DICT_SPEC);
}
static inline UNUSED usize
-DICT_METHOD(len)(DICT_D *d) {
+DICT_METHOD(len)(DICT_NAME *d) {
return r_dict_table_len(&d->table, DICT_SPEC);
}
static inline UNUSED void
-DICT_METHOD(set_default)(DICT_D *d, DICT_V v) {
+DICT_METHOD(set_default)(DICT_NAME *d, DICT_V v) {
d->default_val = v;
}
static inline UNUSED DICT_V
-DICT_METHOD(get_default)(DICT_D *d) {
+DICT_METHOD(get_default)(DICT_NAME *d) {
return d->default_val;
}
static inline UNUSED DICT_V *
-DICT_METHOD(ptr)(DICT_D *d, DICT_K k) {
+DICT_METHOD(ptr)(DICT_NAME *d, DICT_K k) {
u64 h = DICT_HASH(&k, d->table.seed, sizeof(DICT_K));
void *vp = 0;
r_dict_table_acc(&d->table, &vp, &k, h, DICT_SPEC);
@@ -47,7 +47,7 @@ DICT_METHOD(ptr)(DICT_D *d, DICT_K k) {
}
static inline UNUSED bool
-DICT_METHOD(get)(DICT_D *d, DICT_V *v, DICT_K k) {
+DICT_METHOD(get)(DICT_NAME *d, DICT_V *v, DICT_K k) {
u64 h = DICT_HASH(&k, d->table.seed, sizeof(DICT_K));
void *vp;
int r = r_dict_table_acc(&d->table, &vp, &k, h, DICT_SPEC);
@@ -56,7 +56,7 @@ DICT_METHOD(get)(DICT_D *d, DICT_V *v, DICT_K k) {
}
static inline UNUSED bool
-DICT_METHOD(set)(DICT_D *d, DICT_K k, DICT_V v) {
+DICT_METHOD(set)(DICT_NAME *d, DICT_K k, DICT_V v) {
u64 h = DICT_HASH(&k, d->table.seed, sizeof(DICT_K));
void *vp;
int r = r_dict_table_acc(&d->table, &vp, &k, h, DICT_SPEC);
@@ -65,7 +65,7 @@ DICT_METHOD(set)(DICT_D *d, DICT_K k, DICT_V v) {
}
static inline UNUSED int
-DICT_METHOD(put)(DICT_D *d, DICT_K k, DICT_V v) {
+DICT_METHOD(put)(DICT_NAME *d, DICT_K k, DICT_V v) {
u64 h = DICT_HASH(&k, d->table.seed, sizeof(DICT_K));
void *vp;
int r = r_dict_table_ins(&d->table, &vp, &k, h, DICT_SPEC);
@@ -74,7 +74,7 @@ DICT_METHOD(put)(DICT_D *d, DICT_K k, DICT_V v) {
}
static inline UNUSED bool
-DICT_METHOD(del)(DICT_D *d, DICT_V *v, DICT_K k) {
+DICT_METHOD(del)(DICT_NAME *d, DICT_V *v, DICT_K k) {
u64 h = DICT_HASH(&k, d->table.seed, sizeof(DICT_K));
void *vp;
int r = r_dict_table_del(&d->table, &vp, &k, h, DICT_SPEC);
@@ -83,7 +83,7 @@ DICT_METHOD(del)(DICT_D *d, DICT_V *v, DICT_K k) {
}
static inline UNUSED void
-DICT_METHOD(clr)(DICT_D *d) {
+DICT_METHOD(clr)(DICT_NAME *d) {
r_dict_table_clr(&d->table, DICT_SPEC);
}
diff --git a/inc/dict/impl/macro.h b/inc/dict/impl/macro.h
@@ -1,5 +1,5 @@
-#ifndef DICT_D
-#error "rcx/dict: DICT_D must be defined"
+#ifndef DICT_NAME
+#error "rcx/dict: DICT_NAME must be defined"
#endif
#ifndef DICT_K
diff --git a/inc/dict/impl/table.h b/inc/dict/impl/table.h
@@ -1,3 +1,3 @@
-#define TABLE_S RDictTableSpec
+#define TABLE_SPEC_NAME RDictTableSpec
#define TABLE_METHOD(name) r_dict_table_##name
#include "../../table/declare.h"
\ No newline at end of file
diff --git a/inc/dict/impl/unmacro.h b/inc/dict/impl/unmacro.h
@@ -5,4 +5,4 @@
#undef DICT_EQ
#undef DICT_V
#undef DICT_K
-#undef DICT_D
+#undef DICT_NAME
diff --git a/inc/table/impl/declare.h b/inc/table/impl/declare.h
@@ -12,7 +12,7 @@ typedef struct {
TABLE_HASH_FIELD
TABLE_ALLOCZ_FIELD
TABLE_FREE_FIELD
-} TABLE_S;
+} TABLE_SPEC_NAME;
#endif
/* TODO: Add methods for shrinking the table and reserving space? */
diff --git a/inc/table/impl/macro.h b/inc/table/impl/macro.h
@@ -47,10 +47,10 @@
#endif
#ifdef TABLE_USE_SPEC
-#ifndef TABLE_S
-#error "rcx/table: TABLE_S must be defined"
+#ifndef TABLE_SPEC_NAME
+#error "rcx/table: TABLE_SPEC_NAME must be defined"
#endif
-#define TABLE_SPEC_PARAM , TABLE_S *s_
+#define TABLE_SPEC_PARAM , TABLE_SPEC_NAME *s_
#define TABLE_SPEC , s_
#undef TABLE_USE_SPEC
#endif
diff --git a/inc/table/impl/unmacro.h b/inc/table/impl/unmacro.h
@@ -5,7 +5,7 @@
#undef TABLE_METHOD
#undef TABLE_SPEC
#undef TABLE_SPEC_PARAM
-#undef TABLE_S
+#undef TABLE_SPEC_NAME
#undef TABLE_FREE_FIELD
#undef TABLE_FREE
#undef TABLE_ALLOCZ_FIELD
diff --git a/src/dict/impl/table.c b/src/dict/impl/table.c
@@ -1,5 +1,5 @@
#include "dict/impl/table.h"
-#define TABLE_S RDictTableSpec
+#define TABLE_SPEC_NAME RDictTableSpec
#define TABLE_METHOD(name) r_dict_table_##name
#include "table/define.h"
\ No newline at end of file