project structure changed for clion

This commit is contained in:
Timerix22 2022-05-08 13:59:28 +03:00
parent 703bd4bef4
commit c6c70c6fcc
46 changed files with 92 additions and 29 deletions

1
.gitignore vendored
View File

@ -6,7 +6,6 @@ obj/
.vs/
.vscode/
.vshistory/
.idea/
.editorconfig
*.user

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

31
.idea/misc.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CidrRootsConfiguration">
<sourceRoots>
<file path="$PROJECT_DIR$/src" />
<file path="$PROJECT_DIR$/tests" />
</sourceRoots>
<excludeRoots>
<file path="$PROJECT_DIR$/.vscode" />
<file path="$PROJECT_DIR$/bin" />
</excludeRoots>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="buildOptions" value=" " />
<option name="buildTarget" value="build_lib" />
<option name="cleanTarget" value="clear_bin" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,10 +1,10 @@
SRC=$(wildcard [^tests]**/*.c)
SRC=$(wildcard src/**/*.c) $(wildcard src/*.c)
TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c)
OUTDIR=bin
CMP=gcc
OPT_ARGS=-O2 -flto
WARN_ARGS=-Wall -Wno-discarded-qualifiers -std=c17
OPT_ARGS=-O2 -std=c17
WARN_ARGS=-Wall -Wno-discarded-qualifiers
all: clear_c clear_bin build_test build_lib
@ -26,11 +26,11 @@ clang: all
TEST_FILE=kerep_test.com
TEST_ARGS=$(WARN_ARGS) $(SRC) $(TESTS) -o $(OUTDIR)/$(TEST_FILE)
build_test:
build_test:
@echo -e '\n\e[96m-------------[build_test]-------------\e[0m'
$(CMP) $(OPT_ARGS) $(TEST_ARGS)
build_test_dbg:
build_test_dbg:
@echo -e '\n\e[96m-----------[build_test_dbg]-----------\e[0m'
$(CMP) -g -O0 $(TEST_ARGS).dbg
@ -39,7 +39,7 @@ LIB_ARGS=$(OPT_ARGS) $(WARN_ARGS)\
$(SRC) tests/test_marshalling.c
LIB_FILE=kerep.so
build_lib:
build_lib:
@echo -e '\n\e[96m-------------[build_lib]--------------\e[0m'
$(CMP) $(LIB_ARGS) -o $(OUTDIR)/$(LIB_FILE)
@ -47,12 +47,17 @@ build_lib:
###### Run tasks #######
######################################
test: clear_c build_test
@echo -e '\n\e[96m-------------[build_test]-------------\e[0m'
tabs 4
@echo -e '\n\e[96m----------------[test]----------------\e[0m'
@tabs 4
$(OUTDIR)/$(TEST_FILE)
test_dbg: clear_c build_test
@echo -e '\n\e[96m--------------[test_dbg]--------------\e[0m'
@tabs 4
$(OUTDIR)/$(TEST_FILE)
valgrind: clear_c build_test_dbg
@echo -e '\n\e[96m--------------[valgrind]--------------\e[0m'
tabs 4
@tabs 4
valgrind -s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \
--leak-check=full --show-leak-kinds=all $(OUTDIR)/$(TEST_FILE).dbg

View File

@ -39,7 +39,7 @@ void Hashtable_expand(Hashtable* ht){
uint32 arlen=Autoarr_length(ar);
for(uint16 k=0;k<arlen;k++){
KVPair p=Autoarr_get(ar,k);
uint16 newrown=hash32(p.key)%HT_HEIGHTS[ht->hein];
uint16 newrown=ihash(p.key)%HT_HEIGHTS[ht->hein];
Autoarr(KVPair)* newar=newrows[newrown];
Autoarr_add(newar,p);
}
@ -53,7 +53,7 @@ void Hashtable_expand(Hashtable* ht){
}
Autoarr(KVPair)* getrow(Hashtable* ht, char* key, bool can_expand){
uint32 hash=hash32(key);
uint32 hash=ihash(key);
Autoarr(KVPair)* ar=ht->rows[hash%HT_HEIGHTS[ht->hein]];
if(can_expand && Autoarr_length(ar)==Autoarr_max_length(ar))
optime("expand",1,(Hashtable_expand(ht)));

View File

@ -1,13 +1,13 @@
#include "hash.h"
uint32 hash32(char *str){
uint32 ihash(char *str){
uint32 hash=5381;
for (char c=*str;c;c=*(++str))
hash=((hash<<5)+hash)+c;
return hash;
}
uint64 hash64(char* str){
uint64 lhash(char* str){
uint64 hash = 0;
for (char c=*str;c;c=*(++str))
hash=c+(hash<<6)+(hash<<16)-hash;

View File

@ -7,9 +7,9 @@ extern "C" {
#include "../base/base.h"
// djb2 hash function from http:// www.cse.yorku.ca/~oz/hash.html
uint32 hash32(char *str);
uint32 ihash(char *str);
// sdbm hash function
uint64 hash64(char* str);
uint64 lhash(char* str);
#if __cplusplus
}

View File

@ -5,7 +5,7 @@ extern "C" {
#endif
#include "../Autoarr/Autoarr.h"
#include "../String/string.h"
#include "string.h"
declare_Autoarr(string)

View File

@ -1,4 +1,4 @@
#include "../String/string.h"
#include "string.h"
// copies str content to new char pointer value (adding '\0' at the end)
char* string_extract(string str){

View File

@ -42,10 +42,12 @@ void Maybe_free(Maybe e){
free(e.errmsg);
Unitype_free(e.value);
}
void printMaybe(Maybe e){
if(e.errmsg) printf("%s\n",e.errmsg);
else printuni(e.value);
}
char* __doNothing(char* a) {return a;}
char* __unknownErr() {return "UNKNOWN ERROR";}
char* __unknownErr() {return "UNKNOWN ERROR";}

View File

@ -57,7 +57,7 @@ char* __unknownErr( );
#define tryLast(_funcCall, _rezult) Maybe _rezult=_funcCall; if(_rezult.errmsg){\
_rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__);\
__EXIT(_rezult.errmsg);\
}else
}else
#if __cplusplus
}

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "../Autoarr/Autoarr.h"
#include "../src/Autoarr/Autoarr.h"
static void printautoarr(Autoarr(uint16)* ar){
printf("\e[94mAutoarr(uint16): "

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "../DtsodParser/DtsodV24.h"
#include "../src/DtsodParser/DtsodV24.h"
const char text[]=
"list_of_lists: [ [\"sss\"]];"
@ -33,7 +33,7 @@ void print_dtsod(Hashtable* dtsod){
}
void test_dtsod(){
optime(__func__,1,({
//optime(__func__,1,({
printf("\e[96m-------------[test_dtsod]-------------\n");
Hashtable* dtsod;
char* s;
@ -61,5 +61,5 @@ void test_dtsod(){
}));
free(s);
}));
//}));
}

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "../Hashtable/Hashtable.h"
#include "../src/Hashtable/Hashtable.h"
void print_hashtable(Hashtable* ht){
printf("\e[94mHashtable: "

View File

@ -1,4 +1,4 @@
#include "../Hashtable/KeyValuePair.h"
#include "../src/Hashtable/KeyValuePair.h"
EXPORT void CALL test_marshalling(char* text, KVPair** kptr){
KVPair* k=malloc(sizeof(KVPair));

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "../SearchTree/SearchTree.h"
#include "../src/SearchTree/SearchTree.h"
void printstnode(STNode* node){
printf("\e[94mSTNode: "

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "../String/string.h"
#include "../src/String/string.h"
void test_string(){
optime(__func__,1,({

View File

@ -1,6 +1,6 @@
#pragma once
#include "../base/base.h"
#include "../src/base/base.h"
void printuni(Unitype v);