diff --git a/src/Autoarr/Autoarr.h b/src/Autoarr/Autoarr.h index 45cf50c..b059d00 100644 --- a/src/Autoarr/Autoarr.h +++ b/src/Autoarr/Autoarr.h @@ -23,20 +23,20 @@ Autoarr_declare(u64) Autoarr_declare(Unitype) -#define Autoarr_foreach(ar,elem,codeblock)({ \ +#define Autoarr_foreach(ar, elem, codeblock...) { \ if(ar->blocks_count>0) { \ typeof(**ar->values) elem; \ for(u16 blockI=0;blockIblocks_count-1;blockI++) \ for(u32 elemI=0;elemImax_block_length;elemI++){ \ elem=ar->values[blockI][elemI]; \ - (codeblock); \ + { codeblock; } \ } \ for(u16 elemI=0;elemIblock_length;elemI++){ \ elem=ar->values[ar->blocks_count-1][elemI]; \ - (codeblock); \ + { codeblock; } \ } \ } \ -}) +} #if __cplusplus } diff --git a/src/Autoarr/Autoarr_define.h b/src/Autoarr/Autoarr_define.h index ec54f7a..a7badc4 100644 --- a/src/Autoarr/Autoarr_define.h +++ b/src/Autoarr/Autoarr_define.h @@ -50,11 +50,11 @@ void __Autoarr_##type##_freeWithoutMembers(Autoarr_##type* ar, bool freePtr){ \ \ void __Autoarr_##type##_freeWithMembers(Autoarr_##type* ar, bool freePtr){ \ if(ktDescriptor_##type.freeMembers!=NULL) { \ - Autoarr_foreach(ar, el, ({ \ + Autoarr_foreach(ar, el, \ void* members_ptr=⪙ \ if(TYPE_IS_PTR) members_ptr=*(type**)members_ptr; \ ktDescriptor_##type.freeMembers(members_ptr); \ - })); \ + ); \ } \ __Autoarr_##type##_freeWithoutMembers(ar, freePtr);\ } \ diff --git a/src/DtsodParser/DtsodV24_serialize.c b/src/DtsodParser/DtsodV24_serialize.c index 99804a7..1c81feb 100644 --- a/src/DtsodParser/DtsodV24_serialize.c +++ b/src/DtsodParser/DtsodV24_serialize.c @@ -55,12 +55,12 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){ AppendTabs(); addc('['); tabs++; - Autoarr_foreach(((Autoarr_Unitype*)(u.VoidPtr)), e, ({ + Autoarr_foreach(((Autoarr_Unitype*)(u.VoidPtr)), e, addc('\n'); AppendTabs(); try(AppendValue(e),__,;); addc(','); - })); + ); StringBuilder_rmchar(b); addc('\n'); tabs--; @@ -75,11 +75,11 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){ else if(u.typeId==ktid_ptrName(Hashtable)){ // check hashtable is blank bool hashtableNotBlank=false; - Hashtable_foreach(((Hashtable*)u.VoidPtr), __, ({ + Hashtable_foreach(((Hashtable*)u.VoidPtr), __, hashtableNotBlank=true; if(__.key) {} // weird way to disable warning break; - })); + ); if(hashtableNotBlank){ addc('\n'); @@ -109,7 +109,7 @@ Maybe __serialize(StringBuilder* _b, u8 _tabs, Hashtable* dtsod){ }; SerializeSharedData* shared=&_shared; - Hashtable_foreach(dtsod, p, ({ + Hashtable_foreach(dtsod, p, AppendTabs(); StringBuilder_append_cptr(b,p.key); addc(':'); @@ -117,7 +117,7 @@ Maybe __serialize(StringBuilder* _b, u8 _tabs, Hashtable* dtsod){ try(AppendValue(p.value),__,;); addc(';'); addc('\n'); - })); + ); return MaybeNull; } diff --git a/src/Hashtable/Hashtable.h b/src/Hashtable/Hashtable.h index ba7755f..48c57b8 100644 --- a/src/Hashtable/Hashtable.h +++ b/src/Hashtable/Hashtable.h @@ -33,13 +33,13 @@ Unitype* Hashtable_getPtr(Hashtable* ht, char* key); Unitype Hashtable_get(Hashtable* ht, char* key); bool Hashtable_try_get(Hashtable* ht, char* key, Unitype* output); -#define Hashtable_foreach(HT, EL, codeblock)({ \ +#define Hashtable_foreach(HT, EL, codeblock...) { \ u16 hmax=Hashtable_height(HT); \ for(u16 h=0; hrows[h]; \ Autoarr_foreach(AR, EL, codeblock); \ } \ -}) +} #if __cplusplus } diff --git a/src/LinkedList/LinkedList.h b/src/LinkedList/LinkedList.h index 441d6bf..f8435d6 100644 --- a/src/LinkedList/LinkedList.h +++ b/src/LinkedList/LinkedList.h @@ -16,7 +16,7 @@ extern "C" { #define LLNode_create(TYPE, VALUE) LLNode_##TYPE##_create(VALUE) #define LinkedList_create(TYPE) LinkedList_##TYPE##_create() -#define LinkedList_free(LLIST) ({ LLIST->_functions->freeMembers(LLIST); free(LLIST); }) +#define LinkedList_free(LLIST) ({ LLIST->_functions->freeMembers(LLIST); free(LLIST); }) void LinkedList_addToBeginning(void* _llist, void* _new_node); diff --git a/src/String/StringBuilder.c b/src/String/StringBuilder.c index ead636b..91139e8 100644 --- a/src/String/StringBuilder.c +++ b/src/String/StringBuilder.c @@ -13,9 +13,9 @@ void complete_buf(StringBuilder* b){ if(!len) return; string str={.length=len, .ptr=malloc(len)}; u32 i=0; - Autoarr_foreach(b->curr_buf, c, ({ + Autoarr_foreach(b->curr_buf, c, str.ptr[i++]=c; - })); + ); Autoarr_add(b->compl_bufs,str); Autoarr_free(b->curr_buf, true); b->curr_buf=Autoarr_create(i8,BL_C,BL_L); @@ -47,17 +47,17 @@ void StringBuilder_free(StringBuilder* b){ string StringBuilder_build(StringBuilder* b){ complete_buf(b); u32 len=0; - Autoarr_foreach(b->compl_bufs, cs, ({ + Autoarr_foreach(b->compl_bufs, cs, len+=cs.length; - })); + ); string str= { .length=len, .ptr=malloc(len+1) }; str.ptr[len]='\0'; u32 i=0; - Autoarr_foreach(b->compl_bufs, cs, ({ + Autoarr_foreach(b->compl_bufs, cs, for(u32 n=0;n \e[92m\"%s\"\n",p); free(p); - })); + ); } \ No newline at end of file diff --git a/tests/tests.h b/tests/tests.h index 616721a..2788cac 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -21,7 +21,7 @@ void test_type_system(); inline void test_all(){ kprintf("\e[97mkerep tests are starting!\n"); - optime(__func__, 1, ({ + optime(__func__, 1, test_type_system(); test_string(); test_safethrow(); @@ -35,7 +35,7 @@ inline void test_all(){ test_hashtable(); test_dtsod(); kprintf("\e[96m--------------------------------------\e[0m\n"); - })); + ); } #define PRINT_SIZEOF(T) kprintf("\e[94m" #T " size: \e[96m" IFWIN("%llu", "%lu") "\n", sizeof(T))