From 7f13bdad04b8baa469ca5b7daab394f689733f52 Mon Sep 17 00:00:00 2001 From: xchaos Date: Wed, 16 Jan 2008 16:42:05 +0000 Subject: [PATCH] work in progress - nothing will compile git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@16 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 113 ++++++++++++++++++++++++++++----------------------- tools/cake.c | 12 ++++++ 2 files changed, 75 insertions(+), 50 deletions(-) create mode 100644 tools/cake.c diff --git a/cll1.h b/cll1.h index 261cd81..7a3f315 100644 --- a/cll1.h +++ b/cll1.h @@ -46,7 +46,10 @@ #define TRUE 1 #define FALSE 0 /* ------------------------------------------------------------------- */ -/* 2. C<<1 data types - updated 2008-01-07 by xCh. */ +/* 2. C<<1 basic data types - updated 2008-01-07 by xCh. */ +/* ------------------------------------------------------------------- */ +#define Create_str(ID,STRATOM) char *ID=get_str(STRATOM); +#define Create_mem() /* ------------------------------------------------------------------- */ #define list(T) struct T *_next #define tree(T) struct T *_next;struct T *_seek @@ -57,50 +60,76 @@ #define remove(A,B,C) { void **_D=NULL; for_search(A,B,C) { if(_D)*_D=A->_next; else B=A->_next; free(A); } else _D=(void *)&(A->_next); } #define drop(A,B) for( A=B; A || (B=NULL); B=A, A=A->_next, free(B) ) /* ------------------------------------------------------------------- */ -/* 3. C<<1 iterators - updated 2008-01-07 by xCh. */ +/* 3. C<<1 general iterators - updated 2008-01-07 by xCh. */ /* ------------------------------------------------------------------- */ #define loop while(TRUE) #define repeat(N) if(N>0) _NEW_I for_range(_I,1,N) #define for_range(VAR,FROM,TO) for( VAR=FROM ; FROM<=TO?VAR<=TO:VAR>=TO ; FROM<=TO?VAR++:VAR--) #define for_each(A,B) for(A=B; A; A=A->_next) #define for_search(A,B,C) for_each(A,B) if(C) -/*to do: #define for_file_lines(STR,F) _NEW_F for() */ -#ifdef USE_LIBRARY_MYSQL -#define for_mysql_query_results(ROW,QUERY) _NEW_(_Ratom,_Rstack,_RStack)for(_Ratom->R=(mysql_query(_Matom->M,QUERY)?NULL:mysql_use_result(_Matom->M)),ROW=(_Ratom->R?mysql_fetch_row(_Ratom->R):NULL);ROW;ROW=mysql_fetch_row(_Ratom->R)) -#endif +/* to do: #define for_file_lines(STR,F) _NEW_F for() */ +/* obsolete #define every(A,B) for( A=B; A; A=A->_next) */ +/* obsolete #define search(A,B,C) every(A,B) if(C) */ +/* obsolete #define find(A,B,C) search(A,B,C) break; if(A) */ +/* ------------------------------------------------------------------- */ +/* 4.C<<1 conditionals - updated 2008-01-07 by xCh. */ +/* ------------------------------------------------------------------- */ +#define if_exists(A,B,C) for_search(A,B,C) break; if(A) +/* ------------------------------------------------------------------- */ +/* 5. C<<1 argument handling, updated 2008-01-16 by xCh. */ +/* ------------------------------------------------------------------- */ +#define for_arguments _NEW_I if(argc>1) for(_I=1;_I=0) +#define USE_MODULE_CGI +#endif +#ifdef USE_MODULE_CGI +//todo getcgi(VAR) +//todo _init_cgi +//todo #define _QSTACK struct _QStack { char *Q; int _23; list(_QStack); } *_Qatom,*_Qstack=NULL; #endif -/*obsolete #define every(A,B) for( A=B; A; A=A->_next) */ -/*obsolete #define search(A,B,C) every(A,B) if(C) */ -/*obsolete #define find(A,B,C) search(A,B,C) break; if(A) */ - /* ------------------------------------------------------------------- */ -/* 4.C<<1 conditionals - updated 2008-01-07 by xCh. */ +/* 7. MySQL infrastructure and wrappers - updated 2007-12-19 by xCh. */ /* ------------------------------------------------------------------- */ -#define if_exists(A,B,C) for_search(A,B,C) break; if(A) - +#ifdef USE_LIBRARY_MYSQL +#define mysql_connect(S,U,P,D) (create(_Matom,_MStack) && push(_Matom,_Mstack) && (_Matom->M=mysql_init(NULL)),(_Matom->M && mysql_real_connect(_Matom->M,S,U,P,D,0,NULL,0)?_Matom->M:NULL)) +#define for_mysql_query_results(ROW,QUERY) _NEW_(_Ratom,_Rstack,_RStack)for(_Ratom->R=(mysql_query(_Matom->M,QUERY)?NULL:mysql_use_result(_Matom->M)),ROW=(_Ratom->R?mysql_fetch_row(_Ratom->R):NULL);ROW;ROW=mysql_fetch_row(_Ratom->R)) +#define _MSTACK struct _MStack { MYSQL *M; int _23; list(_MStack); } *_Matom,*_Mstack=NULL; +#define _RSTACK struct _RStack { MYSQL_RES *R; int _23; list(_RStack); } *_Ratom,*_Rstack=NULL; +#else +#define _MSTACK +#define _RSTACK +#endif /* ------------------------------------------------------------------- */ -/* old - from version 0.6 */ +/* old - from version 0.6 */ /* ------------------------------------------------------------------- */ -/* EXP macros for Dummysort sequences, updated 2003-05-29 by xCh. */ +/* ------------------------------------------------------------------- */ +/* EXP macros for dummysort sequences, updated 2003-05-29 by xCh. */ +/* ------------------------------------------------------------------- */ #define order_by(K1,K2) (K1>K2) #define desc_order_by(K1,K2) (K10) #define desc_sort_by(K1,K2) (strcasecmp(K1, K2)<0) #define ascii_by(K1,K2) (strcmp(K1, K2)>0) #define desc_ascii_by(K1,K2) (strcmp(K1, K2)<0) - -/* Dummysort sequences, updated 2003-05-29 by xCh. */ - +/* ------------------------------------------------------------------- */ +/* Dummysort sequences, updated 2003-05-29 by xCh. */ +/* ------------------------------------------------------------------- */ #define insert(A,B,EXP,K) { if(B) { void **_L=NULL, *H=B; for_search(B,H,EXP(B->K,A->K)) { if(_L) {*_L=A; A->_next=B; } else push(A,H); break; } else _L=(void *)&(B->_next); if(!B)*_L=A; B=H; } else push(A,B); } #define sort(A,B,EXP,K) { void *_C; A=B; B=NULL; do { _C=A->_next; A->_next=NULL; insert(A,B,EXP,K); A=_C; } while(_C); } - /* String macros & sequences, updated 2004-04-19 by xCh. */ #define eq(A,B) !strcmp(A,B) #define strcmpi(A,B) strcasecmp(A,B) +/* +obsolete #define strlwr(A) {char *_S=A; while(_&&*_S){*_S=tolower(*_S);_S++;}} #define strupr(A) {char *_S=A; while(_&&*_S){*_S=toupper(*_S);_S++;}} #define string(S,L) (S=(char *)malloc(L),*S=0) @@ -124,21 +153,17 @@ #define stroption(STR) if(eq(STR,_K)) #define match(KEY,VAL) {char *_K=KEY, *_V=VAL; FILE *_F=NULL; {{ #define assign(STR,SETVAR) stroption(STR) SETVAR=_V +*/ /* ------------------------------------------------------------------- */ /* Infrastructure, updated 2008-01-08 by xCh. */ /* ------------------------------------------------------------------- */ /* old #define program int _I; int main(int argc, char **argv) */ -#define _ISTACK struct _IStack { int I; int _23; list(_IStack); } *_Iatom,*_Istack=NULL; -#define _SSTACK struct _SStack { char *S; int _23; list(_SSTACK); } *_Satom,*_Sstack=NULL; -#define _FSTACK struct _FStack { FILE *F; int _23; list(_FSTACK); } *_Fatom,*_Fstack=NULL; -#ifdef USE_LIBRARY_MYSQL -#define _MSTACK struct _MStack { MYSQL *M; int _23; list(_MStack); } *_Matom,*_Mstack=NULL; -#define _RSTACK struct _RStack { MYSQL_RES *R; int _23; list(_RStack); } *_Ratom,*_Rstack=NULL; -#else -#define _MSTACK -#define _RSTACK -#endif -#define program _ISTACK _SSTACK _FSTACK _MSTACK _RSTACK int main(int argc, char **argv) +#define _ISTACK struct _IStack { int I; int _23; list(_IStack); } *_Iatom,*_Istack=NULL +#define _SSTACK struct _SStack { char *S; int _23; list(_SSTACK); } *_Satom,*_Sstack=NULL +#define _FSTACK struct _FStack { FILE *F; int _23; list(_FSTACK); } *_Fatom,*_Fstack=NULL + +#define define_ccl1_globals _ISTACK; _SSTACK; _FSTACK; _MSTACK; _RSTACK; _QSTACK +#define program define_cll1_globals; int main(int argc, char **argv) #define _NEW_(ATOM,STACK,TYPE) (create(ATOM,TYPE),ATOM->_23=1,push(ATOM,STACK);ATOM->_23||pop(ATOM,STACK)&&0;ATOM->_23--) #define _NEW_I for _NEW_(_Iatom,_Istack,_IStack) @@ -146,13 +171,7 @@ #define _NEW_S for(create(_Satom,_SStack),_Satom->_23=1,push(_Satom,_Sstack);_Satom->_23||pop(_Satom,_Sstack)&&0;_Satom->_23--) #define _I _Iatom->I #define _S _Satom->I - -/* Section For Dummies part 2, updated 2004-05-07 by xCh. */ - -#define arguments if(argc>1) for(_I=1;_IF /* I/O iterations, updated 2004-04-19 by xCh. */ @@ -194,26 +213,20 @@ #define textfile(TYPE,LINE) struct TYPE { char *LINE; char _eoln; list(TYPE); } #define date(S) { time_t _T; _T=time(NULL); duplicate(ctime(&_T),S); } -/* ------------------------------------------------------------------- */ -/* MySQL Infrastructure and basic macros - updated 2007-12-19 by xCh. */ -/* ------------------------------------------------------------------- */ -#ifdef USE_LIBRARY_MYSQL -#define mysql_connect(S,U,P,D) (create(_Matom,_MStack) && push(_Matom,_Mstack) && (_Matom->M=mysql_init(NULL)),(_Matom->M && mysql_real_connect(_Matom->M,S,U,P,D,0,NULL,0)?_Matom->M:NULL)) -#endif /* ------------------------------------------------------------------- */ /* Object infrastructure and basic macros - updated 2008-01-13 by xCh. */ /* unfinished */ -#define uses_interface(TYPE) struct TYPE *__class +#define bind_interface(TYPE) struct TYPE *__class #define method(NAME) -#define interface_implementation(IFACE,TYPE) struct TYPE *__get_##_##IFACE(void) { struct TYPE *_FACE=get_mem(TYPE); __bind_##_##IFACE(_FACE); return _IFC; } void __bind_##_##IFACE(struct TYPE *_FACE) +#define define_interface(IFACE,TYPE) struct TYPE *__get_##_##IFACE(void) { struct TYPE *_FACE=get_mem(TYPE); __bind_##_##IFACE(_FACE); return _IFC; } void __bind_##_##IFACE(struct TYPE *_FACE) #define bind_method(METHOD,FUNCTION) _IFACE->METHOD=FUNCTION #define get_interface(IFACE) __get_##_##IFACE(void) // must be function #define get_object(TYPE) (_CLL1_MALLOC(TYPE),CLL1_ASSERT(),) -#define _(OBJECT,FUNCTION) OBJECT==NULL?NULL::(*(OBJECT->__class->METHOD))(OBJECT +//#define _(OBJECT,FUNCTION) OBJECT==NULL?NULL::(*(OBJECT->__class->METHOD))(OBJECT #endif /* ------------------------------------------------------------------- */ /* some general ideas, unfinished */ -#define _CLL1_THROW(ERR) -#define _CLL1_TRY _NEW_E for(;;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { } -#define _CLL1_ASSERT(EXPR) assert(EXPR) -#define _CLL1_MALLOC(TYPE) malloc(sizeof(TYPE)) +//#define _CLL1_THROW(ERR) +//#define _CLL1_TRY _NEW_E for(;;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { } +//#define _CLL1_ASSERT(EXPR) assert(EXPR) +//#define _CLL1_MALLOC(TYPE) malloc(sizeof(TYPE)) diff --git a/tools/cake.c b/tools/cake.c new file mode 100644 index 0000000..78059fe --- /dev/null +++ b/tools/cake.c @@ -0,0 +1,12 @@ +#include "cll1.h" + +program +{ + for_arguments + { + + + } + + +} -- 2.30.2