Moved params to core and some code cleanup
This commit is contained in:
1 parent
8e0183a7d7
commit
720e55bfcc
5 files changed
+53
-77
No files matched your search
@@ -1,28 +1,13 @@
|
||||
# This file is useful to format all the source files and header in this library using clang-format
|
||||
|
||||
.PHONY: all cmc dev sac utl tests FORCE
|
||||
ARGS = --verbose
|
||||
|
||||
all: cmc cor dev ext sac utl tests
|
||||
all: src tests
|
||||
|
||||
cmc: FORCE
|
||||
clang-format --style=file -i ./src/cmc/*.h
|
||||
|
||||
cor: FORCE
|
||||
clang-format --style=file -i ./src/cor/*.h
|
||||
|
||||
dev: FORCE
|
||||
clang-format --style=file -i ./src/dev/*.h
|
||||
|
||||
ext: FORCE
|
||||
clang-format --style=file -i ./src/ext/**/*.h
|
||||
|
||||
sac: FORCE
|
||||
clang-format --style=file -i ./src/sac/*.h
|
||||
|
||||
utl: FORCE
|
||||
clang-format --style=file -i ./src/utl/*.h
|
||||
src: FORCE
|
||||
find ./src/ -iname *.h | xargs clang-format --style=file --verbose -i
|
||||
|
||||
tests: FORCE
|
||||
clang-format --style=file -i ./tests/main/unt/*.c ./tests/main/main.c ./tests/*.c
|
||||
find ./tests/ -iname *.c -o -iname *.h | xargs clang-format --style=file --verbose -i
|
||||
|
||||
FORCE:
|
||||
+1
-1
@@ -95,5 +95,5 @@ os.remove(TMP_FILE)
|
||||
|
||||
# Format all files
|
||||
print('Formating files...')
|
||||
subprocess.call(['clang-format', '--style=file', '-i', f'{OUTPUT_DIR}/*.c'])
|
||||
subprocess.call(['clang-format', '--style=file', '-i', f'{OUTPUT_DIR}/*.c', '--verbose'])
|
||||
print('Done')
|
||||
+3
-4
@@ -676,10 +676,9 @@ static const char *cmc_cmc_string_fmt_treeset = "struct %s<%s> "
|
||||
{ \
|
||||
if (_set_->f_val->cpy) \
|
||||
CMC_(PFX, _insert) \
|
||||
(result, \
|
||||
_set_->f_val->cpy(CMC_(PFX, _iter_value)(&iter))); \
|
||||
else \
|
||||
CMC_(PFX, _insert)(result, CMC_(PFX, _iter_value)(&iter)); \
|
||||
(result, _set_->f_val->cpy(CMC_(PFX, _iter_value)(&iter))); \
|
||||
else CMC_(PFX, _insert)(result, \
|
||||
CMC_(PFX, _iter_value)(&iter)); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
|
||||
+44
-1
@@ -10,6 +10,13 @@
|
||||
|
||||
/**
|
||||
* Core includes and macros for the entire library.
|
||||
*
|
||||
* Here you will find:
|
||||
* - CMC_
|
||||
* - CMC_TO_STRING
|
||||
* - CMC_INTERNAL_PREFIX_[ITER|NODE|ENTRY|FKEY|FVAL]
|
||||
* - CMC_DEF_[ITER|NODE|ENTRY|FKEY|FVAL]
|
||||
* - CMC_PARAM_[PFX|SNAME|SIZE|K|V]
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_CORE_H
|
||||
@@ -25,7 +32,6 @@
|
||||
#include "alloc.h"
|
||||
#include "callbacks.h"
|
||||
#include "flags.h"
|
||||
#include "params.h"
|
||||
|
||||
#define CMC__(A, B) A##B
|
||||
#define CMC_(A, B) CMC__(A, B)
|
||||
@@ -53,6 +59,43 @@
|
||||
#define CMC_DEF_FVAL(SNAME) CMC_(SNAME, CMC_INTERNAL_PREFIX_FVAL)
|
||||
#define CMC_DEF_FKEY(SNAME) CMC_(SNAME, CMC_INTERNAL_PREFIX_FKEY)
|
||||
|
||||
/**
|
||||
* A PARAM is a unified way to pass arguments to all macros that generate code.
|
||||
* It is a tuple that contains the following parameters in order:
|
||||
*
|
||||
* PFX - Functions prefix
|
||||
* SNAME - `struct` name
|
||||
* SIZE - Size for SAC library
|
||||
* K - Key type
|
||||
* V - Value type
|
||||
*
|
||||
* PARAM := (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
/*
|
||||
for i in range(5):
|
||||
print(f"#define CMC_TUP_{i}_({', '.join(chr(x) for x in range(65, 65 + i + 1))}, ...) {chr(65 + i)}\n#define CMC_TUP_{i}(TUP) CMC_TUP_{i}_ TUP")
|
||||
*/
|
||||
// clang-format on
|
||||
|
||||
#define CMC_TUP_0_(A, ...) A
|
||||
#define CMC_TUP_0(TUP) CMC_TUP_0_ TUP
|
||||
#define CMC_TUP_1_(A, B, ...) B
|
||||
#define CMC_TUP_1(TUP) CMC_TUP_1_ TUP
|
||||
#define CMC_TUP_2_(A, B, C, ...) C
|
||||
#define CMC_TUP_2(TUP) CMC_TUP_2_ TUP
|
||||
#define CMC_TUP_3_(A, B, C, D, ...) D
|
||||
#define CMC_TUP_3(TUP) CMC_TUP_3_ TUP
|
||||
#define CMC_TUP_4_(A, B, C, D, E, ...) E
|
||||
#define CMC_TUP_4(TUP) CMC_TUP_4_ TUP
|
||||
|
||||
#define CMC_PARAM_PFX CMC_TUP_0
|
||||
#define CMC_PARAM_SNAME CMC_TUP_1
|
||||
#define CMC_PARAM_SIZE CMC_TUP_2
|
||||
#define CMC_PARAM_K CMC_TUP_3
|
||||
#define CMC_PARAM_V CMC_TUP_4
|
||||
|
||||
/**
|
||||
* struct cmc_string
|
||||
*
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* params.h
|
||||
*
|
||||
* Creation Date: 25/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A PARAM is a unified way to pass arguments to all macros that generate code.
|
||||
* It is a tuple that contains the following parameters in order:
|
||||
*
|
||||
* PFX - Functions prefix
|
||||
* SNAME - `struct` name
|
||||
* SIZE - Size for SAC library
|
||||
* K - Key type
|
||||
* V - Value type
|
||||
*
|
||||
* PARAM := (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_PARAMS_H
|
||||
#define CMC_COR_PARAMS_H
|
||||
|
||||
// clang-format off
|
||||
/*
|
||||
for i in range(5):
|
||||
print(f"#define CMC_TUP_{i}_({', '.join(chr(x) for x in range(65, 65 + i + 1))}, ...) {chr(65 + i)}\n#define CMC_TUP_{i}(TUP) CMC_TUP_{i}_ TUP")
|
||||
*/
|
||||
// clang-format on
|
||||
|
||||
#define CMC_TUP_0_(A, ...) A
|
||||
#define CMC_TUP_0(TUP) CMC_TUP_0_ TUP
|
||||
#define CMC_TUP_1_(A, B, ...) B
|
||||
#define CMC_TUP_1(TUP) CMC_TUP_1_ TUP
|
||||
#define CMC_TUP_2_(A, B, C, ...) C
|
||||
#define CMC_TUP_2(TUP) CMC_TUP_2_ TUP
|
||||
#define CMC_TUP_3_(A, B, C, D, ...) D
|
||||
#define CMC_TUP_3(TUP) CMC_TUP_3_ TUP
|
||||
#define CMC_TUP_4_(A, B, C, D, E, ...) E
|
||||
#define CMC_TUP_4(TUP) CMC_TUP_4_ TUP
|
||||
|
||||
#define CMC_PARAM_PFX CMC_TUP_0
|
||||
#define CMC_PARAM_SNAME CMC_TUP_1
|
||||
#define CMC_PARAM_SIZE CMC_TUP_2
|
||||
#define CMC_PARAM_K CMC_TUP_3
|
||||
#define CMC_PARAM_V CMC_TUP_4
|
||||
|
||||
#endif /* CMC_COR_PARAMS_H */
|
||||
Reference in new issue
Block a user