From 7dc67479a675cde6b5b4691e6e834b81483c6993 Mon Sep 17 00:00:00 2001 From: xchaos Date: Thu, 31 Jul 2008 12:51:45 +0000 Subject: [PATCH] simplification, object redefiniton git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@73 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cll1.h b/cll1.h index 14abb4e..b8405b0 100644 --- a/cll1.h +++ b/cll1.h @@ -1,4 +1,4 @@ -/* .----------------------------------------------------------------------. + /* .----------------------------------------------------------------------. / C<<1 header file - C language style sheet - GNU C/ANSI C99 compliant / Cumbersome Extraction and Report Language - http://cll1h.arachne.cz/ '---------------------------------------------------------------------- */ @@ -104,7 +104,6 @@ extern unsigned RANDOM_SEED; #define dict(TYPE) tree(TYPE); str __key #define array(TYPE) tree(TYPE); int __key #define interface(TYPE) TYPE __interface -#define this_must_be(TYPE) TYPE this /* .----------------------------------------------------------------------. / 5. C<<1 string manipulation, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ @@ -177,9 +176,9 @@ extern unsigned RANDOM_SEED; /* .----------------------------------------------------------------------. / 8. C<<1 object oriented infrastructure, updated 2008-02-04 '----------------------------------------------------------------------- */ -#define I_must_be(TYPE) TYPE self, void *_method -#define we_can_be(TYPE) TYPE _we, void *_method -#define we_can_be_whatever void *_we, void *_method +/* too non-C: #define I_must_be(TYPE) TYPE self, void *_method * */ +#define member_of(TYPE) TYPE _we +#define anonymous void *_we #define I_am(TYPE) TYPE self=(TYPE)_we #define def_community(METATYPE,ITYPE) def_mem(METATYPE) { ITYPE __interface; }; #define def_method(RET,NAME,...) RET (*NAME)(__VA_ARGS__) @@ -190,8 +189,8 @@ extern unsigned RANDOM_SEED; #define construct_object(MTYPE,...) (void *)_init_##TYPE##_() #define init_object(TYPE,...) (TYPE)_init_##TYPE##_(__VA_ARGS__) #define init_polymorph(TYPE,COMMUNITY,...) (COMMUNITY)_init_##TYPE##_(__VA_ARGS__) -#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 _(METHOD,...) ( _ASSERT(ARG1(__VA_ARGS__,)), (*( ARG1(__VA_ARGS__,)->__interface->METHOD )) ( __VA_ARGS__ ) ) +#define __(METHOD,...) ( _ASSERT(ARG1(__VA_ARGS__,)), (*( __cll1_seekmethod(ARG1(__VA_ARGS__,)->__interface,METHOD) )) ( __VA_ARGS__ ) ) #define call(OBJTYPE,METHOD,...) { int _N=0; OBJTYPE _OBJ; /* <-' */ while( (_OBJ=(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. -- 2.30.2