MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to
- Michael Polak, Svojsikova 7, 169 00 Praha 6 Czech Republic */
-/* ------------------------------------------------------------------- */
-#ifndef __CLL1H__
-#define __CLL1H__
+ You should have received a copy of the GNU Lesser General Public License
+ along with C<<1 header file; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#ifndef _CLL1_H
+#define _CLL1_H
#include <string.h>
#include <malloc.h>
#define push(A,B) ((A && A!=B)?A->_next=B:0,B=A)
#define pop(A,B) (B?((A?free(A):0),A=B=B->_next):(A=NULL))
#define append(A,B) if(B) { void *N=A; A->_next=NULL; for_search(A,B,!A->_next) {A->_next=N; break;}} else push(A,B);
-#define remove(A,B,C) { void **_D=NULL; for_search(A,B,C) { if(_D)*_D=A->_next; else B=A->_next; free(A); A=NULL;} else _D=(void *)&(A->_next); }
+#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. */
/* ------------------------------------------------------------------- */
#define loop while(TRUE)
-#define repeat(N) _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 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() */
#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); }
-#ifdef USE_LIBRARY_MYSQL
/* ------------------------------------------------------------------- */
/* 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 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 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
#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))