From bce4b05df61258229122aa6a77aa67ac96462393 Mon Sep 17 00:00:00 2001 From: xchaos Date: Wed, 30 Jan 2008 23:44:06 +0000 Subject: [PATCH] Major header file rewrite and cleanup, but no new functions git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@49 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 190 +++++++++++++++---------- demos/advanced-hello-world.c | 6 +- demos/performance/test-performance.sh | 2 + demos/performance/test-performance2.sh | 2 +- 4 files changed, 118 insertions(+), 82 deletions(-) diff --git a/cll1.h b/cll1.h index 0a4b0ea..1b1d362 100644 --- a/cll1.h +++ b/cll1.h @@ -35,80 +35,80 @@ /* .----------------------------------------------------------------------. / 1. C<<1 header auto include, updated 2008-01-26 xCh. '---------------------------------------------------------------------- */ +#ifndef DISABLE_LIBRARY_LIBC #include #include #include #include #include #include -#ifdef USE_LIBRARY_MYSQL -#include -#endif #ifdef USE_LIBRARY_FASTCGI #include #else #include #endif +#endif +#ifdef USE_LIBRARY_MYSQL +#include +#endif /* .----------------------------------------------------------------------. / 2. C<<1 then buddhist section, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ #ifndef DISABLE_MODULE_THEN_BUDDHISM #define then -#define MAYBE (int)((RANDOM_SEED?random():(RANDOM_SEED=time(NULL),srandom(RANDOM_SEED),random()))%2) +#define boolean int +#define MAYBE (int)((RANDOM_SEED?random():(srandom(RANDOM_SEED=time(NULL)),random()))%2) #define WHOKNOWS (int)(srandom(time(NULL)),random()%2) #define create_var(ID,TYPE,INIT) TYPE ID=INIT #define define_var(ID,TYPE) TYPE ID #endif /* .----------------------------------------------------------------------. - / 3. C<<1 constants and optional keywords, updated 2008-01-26 xCh. + / 3. C<<1 almost then buddhist section, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ #define not ! #define and && #define or || -#define boolean int -#define bool_str(VALUE) ((VALUE)?"TRUE":"FALSE") #define TRUE 1 #define FALSE 0 -#define coalesce(VAR,NOTNULL) (VAR?VAR:(NOTNULL)) -#define mem struct -#define _GLOBALS time_t RANDOM_SEED=0; char *EOL="\n", *OFS=" ", *IFS=" \t\n", *NIL="NULL"; +#define coalesce(VAR,NOTNULLNORFALSE) (VAR?VAR:(NOTNULLNORFALSE)) +#define bool_str(VALUE) ((VALUE)?"TRUE":"FALSE") +#define _CLL1_GLOBALS char *NIL="NULL", *EOL="\n", *OFS=" ", *IFS=" \t\n"; time_t RANDOM_SEED=0; /* .----------------------------------------------------------------------. / 4. C<<1 data declaration and allocation, updated 2008-01-07 xCh. '----------------------------------------------------------------------- */ -#define create_str(ID,INIT) char *ID=INIT -#define define_str(ID) char *ID=NULL +#define mem struct +#define uses_mem(TYPE) struct *TYPE this #define create_mem(ID,...) struct _ARG1(__VA_ARGS__,) *ID=get_mem(__VA_ARGS__) +#define new_mem(ID,...) struct _ARG1(__VA_ARGS__,) *ID=init_mem(__VA_ARGS__) #define define_mem(ID,TYPE) struct TYPE *ID=NULL #define define_mems(ID1,ID2,TYPE) define_mem(ID1,TYPE); define_mem(ID2,TYPE) +#define get_mem(...) (struct _ARG1(__VA_ARGS__,)*)_cll1_malloc(sizeof(struct _ARG1(__VA_ARGS__,)), _ARG2(__VA_ARGS__,,) - 0 ) +#define init_mem(...) _mem_##TYPE##_( _ARG2(__VA_ARGS__,,) - 0 ) +#define construct_mem(TYPE) (struct TYPE *) _mem_##TYPE##_(void) { } #define create_list(ID1,I2,TYPE) create_mem(ID1,TYPE); struct TYPE *ID2=((ID1->__next=NULL),ID1) -#define create_context(ID) create_mem(ID,_MAtom) -#define define_context(ID) define_mem(ID,_MAtom) +#define create_str(ID,INIT) char *ID=INIT +#define define_str(ID) char *ID=NULL +#define get_str(...) (char *)_cll1_get_str(__VA_ARGS__,NIL) +#define create_context(ID) create_mem(ID,_CTXAtom) +#define define_context(ID) define_mem(ID,_CTXAtom) #define list(TYPE) struct TYPE *__next #define tree(TYPE) struct TYPE *__next; struct TYPE *__seek #define dictionary(TYPE) tree(TYPE); char *__key #define array(TYPE) tree(TYPE); int __key #define interface(TYPE) struct TYPE *__interface -#define get_str(...) (char *)_cll1_get_str(__VA_ARGS__,(void *)&_cll1_get_str) -#define get_mem(...) (struct _ARG1(__VA_ARGS__,)*)_cll1_malloc(sizeof(struct _ARG1(__VA_ARGS__,)), _ARG2(__VA_ARGS__,,) - 0 ) /* .----------------------------------------------------------------------. / 5. C<<1 string manipulation, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ #define eq(A,B) !strcmp(A,B) #define eqi(A,B) !strcasecmp(A,B) -#define print(...) _cll1_print(__VA_ARGS__,(void *)&_cll1_print) -#define fprint(...) _cll1_fprint(__VA_ARGS__,(void *)&_cll1_fprint) -#define file_print(...) _cll1_fprint(_F,__VA_ARGS__,(void *)&_cll1_fprint) -#define echo(...) _cll1_echo(__VA_ARGS__,(void *)&_cll1_echo) -#define fecho(...) _cll1_fecho(__VA_ARGS__,(void *)&_cll1_fecho) -#define file_echo(...) _cll1_fecho(_F,__VA_ARGS__,(void *)&_cll1_fecho) +#define print(...) _cll1_print(__VA_ARGS__,NIL) +#define fprint(...) _cll1_fprint(__VA_ARGS__,NIL) +#define file_print(...) _cll1_fprint(_F,__VA_ARGS__,NIL) +#define echo(...) _cll1_echo(__VA_ARGS__,NIL) +#define fecho(...) _cll1_fecho(__VA_ARGS__,NIL) +#define file_echo(...) _cll1_fecho(_F,__VA_ARGS__,NIL) #define suffix(A,B,C) (((A=strrchr(B,C))&&!(*(A++)=0))||(A=B)) #define prefix(A,B,C) ((A=B),((B=strchr(B,C))&&!(*(B++)=0)||(B=A))) -#define for_split_str(A,B,C) for(prefix(A,B,C);A;(A!=B)&&prefix(A,B,C)||(A=NULL)) -#define for_valid_split(A,B,C) for_split_str(A,B,C) if(*A) -#define switch_for_columns(A,B,C) _FOR_COLUMNS(A,B,C) switch(__I) -#define switch_for_valid_columns(A,B,C) _FOR_VALID_COLUMNS(A,B,C) switch (_I) -#define if_column_number(A,B,C,V) _FOR_COLUMNS(A,B,C) if(_I==V) -#define if_valid_column_number(A,B,C,V) _FOR_VALID_COLUMNS(A,B,C) if(_I==V) #define tr(STR,B,C) {char *_S=STR; /***/ while(S && *_S) {if(*_S==B)*_S=C; _S++;} } /* .----------------------------------------------------------------------. / 6. C<<1 data container manipulation, updated 2008-01-26 xCh. @@ -132,61 +132,78 @@ / 7. C<<1 builtin iterators and conditionals, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ #define loop while(TRUE) -#define repeat(N) if(N>0) _NEW_I for_range(_I,1,N) +#define repeat(N) if(N>0) _NEW(I,0) while(_I++=TO ; FROM<=TO?VAR++:VAR--) #define for_each(NODE,HEAD) for(NODE=HEAD; NODE; NODE=NODE->__next) #define for_search(NODE,HEAD,EXPR) for_each(NODE,HEAD) if(EXPR) -#define for_file_lines(STR,F) /* _NEW_F for() */ -#define for_ints(VAR,...) _NEW_I for( _I=0 ; (VAR=_cll1_it_ints(_I,__VA_ARGS__,-1))>=0 ; _I++) -#define for_strs(VAR,...) _NEW_I for( _I=0 ; (VAR=_cll1_it_strs(_I,__VA_ARGS__,(void *)&_cll1_it_strs))!=(void *)&_cll1_it_strs ; _I++) -#define if_exists(A,B,C) for_search(A,B,C) break; if(A) -#define for_args _NEW_I for(_I=1;_I1) -#define if_arg(VAL) if(eq(argv[_I],VAL)) +#define for_file_lines(STR,FNAME) /* _NEW(CTX,get_context()) file_read(FNAME) for(use_context(_CTX),STR=file_line(_F);release_context(_M),(*S && !feof(_F));STR=file_line(_F),end_context()) _CATCH */ +#define for_input_lines(S,L) /* _NEW(CTX,get_context()) for(use_context(_CTX),STR=file_get_line(stdin);release_context(_M),(*S && !feof(stdin));STR=file_get_line(stdin)) _CATCH */ +#define for_ints(VAR,...) _NEW(I,0) while((VAR=_cll1_for_ints(_I++,__VA_ARGS__,-1))>=0) +#define for_strs(VAR,...) _NEW(I,0) while((VAR=(char *)_cll1_for_ptrs(_I++,__VA_ARGS__,NIL))!=NIL) +#define for_args _NEW(I,1) while(_I++1) +#define switch_for_args for_args switch_str(this_arg) +#define switch_str(STR) _NEW(S,STR) +#define if_case(VAL) if(eq(argv[_I],VAL)) +#define for_fields(FIELD,STR) for_valid_split(FIELD,STR,OFS) +#define for_split_str(A,B,C) for(prefix(A,B,C);A;(A!=B)&&prefix(A,B,C)||(A=NULL)) +#define for_valid_split(A,B,C) for_split_str(A,B,C) if(*A) +#define switch_for_columns(A,B,C) _FOR_COLUMNS(A,B,C) switch(__I) +#define switch_for_valid_columns(A,B,C) _FOR_VALID_COLUMNS(A,B,C) switch (_I) +#define if_column_number(A,B,C,V) _FOR_COLUMNS(A,B,C) if(_I==V) +#define if_valid_column_number(A,B,C,V) _FOR_VALID_COLUMNS(A,B,C) if(_I==V) /* .----------------------------------------------------------------------. / 8. C<<1 object oriented infrastructure, updated 2008-01-26 '----------------------------------------------------------------------- */ +#define method_args void *_self, void *_method +#define I_am(TYPE) struct TYPE *self=(struct TYPE *)_self #define define_metaobject(METATYPE,ITYPE) struct METATYPE { struct ITYPE *__interface; }; -#define define_interface(MTYPE,ITYPE) struct ITYPE *_construct_##_##MTYPE##_##ITYPE(void *dummy, ...) { define_mem(_FACE,IFACE); va_list(ap); _FACE=get_mem(IFACE) _bind_##_##MTYPE##_##ITYPE(_FACE); return _FACE; } void _bind_##_##MTYPE##_##ITYPE(struct IFACE *_FACE) +#define define_interface(MTYPE,ITYPE) struct ITYPE *_interface_##MTYPE##ITYPE(void *dummy, ...) { define_mem(_FACE,IFACE); va_list(ap); _FACE=get_mem(IFACE) _bind_##MTYPE##ITYPE(_FACE); return _FACE; } void _bind_##MTYPE##ITYPE(struct IFACE *_FACE) #define bind_method(METHOD,FUNCTION) _FACE->METHOD=FUNCTION -#define construct_interface(MTYPE,...) _construct_##_##MTYPE##_##_ARG1(__VA_ARGS__)((void *)__get_##_##MTYPE##_##__VA_ARGS__) -#define get_object(TYPE,...) (struct TYPE *)_cll1_allocate_object(sizeof(struct TYPE), __VA_ARGS__) -#define construct_object(TYPE,...) -//#define _(OBJECT,...) ( _ASSERT(OBJECT), (*( OBJECT->interface->_ARG1(__VA_ARGS__,) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) -//#define __(OBJECT,...) ( _ASSERT(OBJECT), (*( __cll1_seekmethod(OBJECT->interface,_ARG1(__VA_ARGS__,)) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) +#define construct_interface(MTYPE,...) _interface_##MTYPE##_ARG1(__VA_ARGS__)((void *)__get_##MTYPE##__VA_ARGS__) +#define init_object(TYPE,...) _object_##TYPE##_(__VA_ARGS__) +#define construct_object(TYPE,...) (struct TYPE *)_object_##TYPE##_ +#define _(OBJECT,...) ( _ASSERT(OBJECT), (*( OBJECT->interface->_ARG1(__VA_ARGS__,) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) +#define __(OBJECT,...) ( _ASSERT(OBJECT), (*( __cll1_seekmethod(OBJECT->interface,_ARG1(__VA_ARGS__,)) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) +#define call(OBJTYPE,METHOD,...) { int _N=0; struct OBJTYPE *_OBJ; /* <-' */ while( (_OBJ=(struct OBJTYPE *)_cll1_for_ptrs(_N++,__VA_ARGS__,NIL))!=(struct OBJTYPE *)NIL ) _(_OBJ,METHOD); } /* .----------------------------------------------------------------------. / 9. implementation of C<<1 library functions, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ #define _MALLOC void *_cll1_malloc(size_t size,...) { /*temporary solution*/ return malloc(size); } -#define _CLL1_FPRINT(IOSTREAM,LASTARG) { int ofs=0; va_list ap; /* <-' */ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) { if(ofs)fputs(OFS,IOSTREAM);else ofs=1;/**/fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); fputs(EOL,IOSTREAM); } -#define _PRINT void _cll1_print(char *s,...) _CLL1_FPRINT(stdout,(void *)&_cll1_print) -#define _FPRINT void _cll1_fprint(FILE *f,char *s,...) _CLL1_FPRINT(f,(void *)&_cll1_fprint) -#define _CLL1_FECHO(IOSTREAM,LASTARG) { va_list ap; /* <-' */ for(va_start(ap,s);s!=LASTARG;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); } -#define _ECHO void _cll1_echo(char *s,...) _CLL1_FECHO(stdout,(void *)&_cll1_echo) -#define _FECHO void _cll1_fecho(FILE *f,char *s,...) _CLL1_FECHO(f,(void *)&_cll1_fecho) -#define _IT_INTS int _cll1_it_ints(int i, int n, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,n); while(n>=0 && j++=0 && j++_23=1,push(ATOM,STACK);ATOM->_23||pop(ATOM,STACK)&&0;ATOM->_23--) -#define _NEW_I for _NEW_(_Iatom,_Istack,_IAtom) -#define _NEW_S for _NEW_(_Satom,_Sstack,_SAtom) -#define _NEW_F for _NEW_(_Fatom,_Fstack,_FAtom) -#define _I (_Iatom->i) -#define _S (_Satom->s) +#define _ANYSTACK(TYPE,NAME) struct _##NAME##Atom { TYPE NAME; int C; list(_##NAME##Atom); } *_##NAME##atom,*_##NAME##stack=NULL; +//#define _ISTACK struct _IAtom { int i; int C; list(_IAtom); } *_Iatom,*_Istack=NULL; +//#define _SSTACK struct _SAtom { char *s; int C; list(_SAtom); } *_Satom,*_Sstack=NULL; +//#define _FSTACK struct _FAtom { FILE *F; int C; list(_FAtom); } *_Fatom,*_Fstack=NULL; +//#define _MSTACK struct _MAtom { void *ptr; size_t size; int C; tree(_MAtom); } *_Matom,*_Mstack=NULL; +#define _CLL1_STACKS _ANYSTACK(int,I) _ANYSTACK(char *,S) _ANYSTACK(FILE *,F) _ANYSTACK(void *,CTX) +//#define _NEW_(ATOM,STACK,TYPE) (ATOM=get_mem(TYPE),ATOM->C=1,push(ATOM,STACK);ATOM->C||(pop(ATOM,STACK),0);ATOM->C--) +#define _NEW(NAME,VALUE) for(_##NAME##atom=get_mem(_##NAME##Atom),_##NAME##atom->NAME=(VALUE),_##NAME##atom->C=1,push(_##NAME##atom,_##NAME##stack);_##NAME##atom->C||(pop(_##NAME##atom,_##NAME##stack),0);_##NAME##atom->C--) +//#define _NEW_I for _NEW_(_Iatom,_Istack,_IAtom) +//#define _NEW_S for _NEW_(_Satom,_Sstack,_SAtom) +//#define _NEW_F for _NEW_(_Fatom,_Fstack,_FAtom) +#define _I (_Iatom->I) +#define _S (_Satom->S) #define _F (_Satom->F) -#define _FOR_COLUMNS(A,B,C) _NEW_I for(_I=0,prefix(A,B,C);A;((A!=B)&&prefix(A,B,C)||(A=NULL)),_I++) -#define _FOR_VALID_COLUMNS(A,B,C) _NEW_I for(_I=0,prefix(A,B,C);A;((A!=B)&&prefix(A,B,C))||(A=NULL)) if(*A&&++_I) +#define _CTX (_CTXatom->CTX) +#define _FOR_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C)||(A=NULL) ),_I++ ) +#define _FOR_VALID_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C))||(A=NULL) ) if(*A&&++_I) /* .----------------------------------------------------------------------. / 11. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh. '----------------------------------------------------------------------- */ @@ -195,24 +212,39 @@ #define USE_MODULE_CGI #endif #ifdef USE_MODULE_CGI -#define cgi(MIME) { char *PTR; /***/ recycle_context(_CGI); _CGIdict=NULL; for_split_str(PTR,getenv("QUERY_STRING"),'&') /* _init_cgi */ if(MIME) printf("Content-type: %s\r\n\r\n",MIME); } +#define cgi(MIME) { char *PTR; /* <-' */ recycle_context(_CGI); _CGIdict=NULL; for_split_str(PTR,getenv("QUERY_STRING"),'&') /* _init_cgi */ if(MIME) printf("Content-type: %s\r\n\r\n",MIME); } //todo #define _GETCGI char *getcgi(VAR) { } -#define _CGIDICT define_context(_CGI); struct _CGIVariable { char *V; dictionary(_CGIVariable); } *_CGIvariable,*_CGIdict; +#define _CGI_GLOBALS define_context(_CGI); struct _CGIVariable { char *V; dictionary(_CGIVariable); } *_CGIvariable,*_CGIdict; #else -#define _CGIDICT +#define _CGI_GLOBALS #endif /* .----------------------------------------------------------------------. - / 12. MySQL infrastructure and wrappers, updated 2007-12-19 by xCh. + / 12. MySQL wrappers + SQL object interface, updated 2007-12-19 by xCh. '----------------------------------------------------------------------- */ #ifdef USE_LIBRARY_MYSQL -#define mysql_connect(S,U,P,D) ((_SQLCatom=get_mem(_SQLCAtom)) && push(_SQLCatom,_SQLCstack) && (_SQLCatom->C=mysql_init(NULL)),(_SQLCatom->C && mysql_real_connect(_SQLCatom->C,S,U,P,D,0,NULL,0)?_SQLCatom->C:NULL)) -#define for_mysql_query_results(ROW,QUERY) _NEW_(_SQLRatom,_SQLRstack,_SQLRAtom)for(_SQLRatom->R=(mysql_query(_SQLCatom->C,QUERY)?NULL:mysql_use_result(_SQLCatom->C)),ROW=(_SQLRatom->R?mysql_fetch_row(_SQLRatom->R):NULL);ROW;ROW=mysql_fetch_row(_SQLRatom->R)) -#define _SQLCSTACK struct _SQLCAtom { MYSQL *C; int _23; list(_SQLCAtom); } *_SQLCatom,*_SQLCstack=NULL; -#define _SQLRSTACK struct _SQLRAtom { MYSQL_RES *R; int _23; list(_SQLRAtom); } *_SQLRatom,*_SQLRstack=NULL; +#define define_sql(CONN) MYSQL *CONN +#define create_sql(CONN) MYSQL *ID=mysql_init(NULL) +#define sql_connect(CONN,S,U,P,D) mysql_real_connect(CONN,S,U,P,D,0,NULL,0) +//todo sql_query +//todo sql_queryf +//todo for_sql_query_results(ROW,CONN,QUERY) +//todo for_sql_queryf_results +#define if_db_connect(U,P,D) _NEW(SQLC,mysql_init(NULL)) for(;_SQLC && mysql_real_connect(_SQLC,"localhost",U,P,D,0,NULL,0);mysql_close(SQLC),SQLC=NULL) +#define for_db_query_results(ROW,QUERY) _NEW(MYSQLR,mysql_query(_MYSQLC,QUERY)) for( (_SQLR=(_MYSQLR?0:mysql_use_result(_MYSQLC))),(ROW=(_MYSQLR?mysql_fetch_row(_MYSQLR):NULL)) ; ROW ; ROW=mysql_fetch_row(_MYSQLR) ) +//todo db_query +//todo for_db_results +//todo for_db_queryf_results(ROW,...) +//todo db_queryf +#define _MYSQLC (_MYSQLCatom->MYSQLC) +#define _MYSQLR (_MYSQLRatom->MYSQLR) +#define _SQL_GLOBALS _ANYSTACK(MYSQL,MYSQLC) _ANYSTACK(MYSQL_RES,MYSQLR) #else -#define _SQLCSTACK -#define _SQLRSTACK +#define _SQL_GLOBALS #endif +//#ifdef USE_INTERFACE_SQL +//todo #define _SQL_OBJECT mem Sql { interface(SqlInterface); char *hostname; char *username; char *password; char *database; } +//todo #define _SQL_CONSTRUCT define_construct(Sql) { self->hostname="localhost"; } +//#endif /* ------------------------------------------------------------------- */ /* old - from version 0.6 */ /* =================================================================== */ @@ -241,10 +273,10 @@ obsolete */ /* I/O iterations, updated 2004-04-19 by xCh. */ -#define fparse(S,L,F) for(fgets(S,L,F);*S && !feof(F);fgets(S,L,F)) -#define input(S,L) fparse(S,L,stdin) -#define fstring(S,F) { int _C=0,_L=0; fpos_t _P; fgetpos(F,&_P); while(_C!='\n' && !feof(F)){ _C=fgetc(F); _L++; } string(S,_L); fsetpos(F,&_P);fgets(S,_L,F);fgetc(F);} -#define parses(S,F) {FILE *_F=fopen(F,"r"); if(_F) { while(!feof(_F)) { fstring(S,_F); +//#define fparse(S,L,F) for(fgets(S,L,F);*S && !feof(F);fgets(S,L,F)) +//#define input(S,L) fparse(S,L,stdin) +//#define fstring(S,F) { int _C=0,_L=0; fpos_t _P; fgetpos(F,&_P); while(_C!='\n' && !feof(F)){ _C=fgetc(F); _L++; } string(S,_L); fsetpos(F,&_P);fgets(S,_L,F);fgetc(F);} +//#define parses(S,F) {FILE *_F=fopen(F,"r"); if(_F) { while(!feof(_F)) { fstring(S,_F); //obsolete //#define parse(F) {char *_; FILE *_F=fopen(F,"r"); if(_F) { while(!feof(_F)) { fstring(_,_F); //#define fail }} else {{ @@ -274,9 +306,9 @@ obsolete /* .----------------------------------------------------------------------. / 99. We have have done our homework - now let's have some fun: '----------------------------------------------------------------------- */ -#define _DEF_VARIABLES _GLOBALS _ISTACK _SSTACK _FSTACK _MSTACK //_SQLCSTACK _SQLRSTACK _CGIDICT -#define _DEF_FUNCTIONS _MALLOC _ECHO _PRINT _FECHO _FPRINT _IT_INTS _IT_STRS // _GET_STR _GET_MEM -#define _DEF_INTERFACE //_CAKE _STD _X +#define _DEF_VARIABLES _CLL1_GLOBALS _CLL1_STACKS _SQL_GLOBALS _CGI_GLOBALS +#define _DEF_FUNCTIONS _MALLOC _ECHO _PRINT _FECHO _FPRINT _FOR_INTS _FOR_PTRS //_GET_STR _GET_MEM +#define _DEF_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC #define implement_cll1_library _DEF_VARIABLES _DEF_FUNCTIONS _DEF_INTERFACE #ifdef USE_PREPROCESSOR #include "_include.c" diff --git a/demos/advanced-hello-world.c b/demos/advanced-hello-world.c index 32a2be3..a5475ba 100644 --- a/demos/advanced-hello-world.c +++ b/demos/advanced-hello-world.c @@ -8,10 +8,12 @@ program print("Hello","world","!"); print("* NIL"); print("We can print",NULL,"safely."); - NIL="(anything)"; + NIL="(hic sunt crocodiles)"; print("We can print",NULL,"safely."); print("* coalesce():"); - print("We can",coalesce("print","everything"),coalesce(NULL,"everything"),"safely."); + print("We can",coalesce("print","everything"),"almost",coalesce(NULL,"anything"),"safely."); + echo("Surprisingly ->",NIL," (you can't see this)"); + print("<- nothing special here."); print("* OFS"); OFS=""; EOL=""; diff --git a/demos/performance/test-performance.sh b/demos/performance/test-performance.sh index 89a8b3e..5da7b51 100755 --- a/demos/performance/test-performance.sh +++ b/demos/performance/test-performance.sh @@ -1,4 +1,5 @@ #!/bin/bash +echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips echo "------------------------------------------------------------- Ruby" cat print.rb @@ -116,3 +117,4 @@ echo -n "Compiling..." time gcc -O2 fputs.c -o fputs echo -n "Running..." time ./fputs > /dev/null + diff --git a/demos/performance/test-performance2.sh b/demos/performance/test-performance2.sh index b545771..b99b9b1 100755 --- a/demos/performance/test-performance2.sh +++ b/demos/performance/test-performance2.sh @@ -1,4 +1,5 @@ #!/bin/bash +echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips echo "------------------------------------------------------------- Ruby" cat print2.rb @@ -108,4 +109,3 @@ echo -n "Compiling..." time gcc -O2 fputs2.c -o fputs2 echo -n "Running..." time ./fputs2 > /dev/null -echo -- 2.30.2