And it uses my proposition for a enhanced cheap_rtti, I've applied it to 
every widget descendant on my svn copy of 1.3 trunk and it seems to work 
fine:

struct st_cheap_rtti {
         const char *class_name;
         st_cheap_rtti *(*cheap_rtti_info_func)(void);
     };

#define DECLARE_CLASS_CHEAP_RTTI_1(a1class_name) 
DECLARE_CLASS_CHEAP_RTTI_00(a1class_name, , 0)
#define DECLARE_CLASS_CHEAP_RTTI_2(a2class_name, a2base_class) \
     DECLARE_CLASS_CHEAP_RTTI_00(a2class_name, : public a2base_class, 
&a2base_class::cheap_rtti_info)

#define DECLARE_CLASS_CHEAP_RTTI_00(aclass_name, ainheritage, abase_class) \
class FL_EXPORT aclass_name ainheritage {\
public:\
     static st_cheap_rtti *cheap_rtti_info() {\
             static st_cheap_rtti scr = {#aclass_name, abase_class};\
            return &scr;\
         };\
     static const char *className(void) {return 
aclass_name::cheap_rtti_info()->class_name;}; \
     virtual const char *classId(void) {return aclass_name::className();};\
     virtual int inherits_from(const char *aclass_id) {\
         st_cheap_rtti *cri = aclass_name::cheap_rtti_info();\
         if (aclass_id == cri->class_name) return 1;\
         do {\
             cri = (*cri->cheap_rtti_info_func)();\
             if (!cri) break;\
             if (aclass_id == cri->class_name) return 1;\
         } while (cri->cheap_rtti_info_func);\
         return 0;\
     }\
private:


/** Fl_Widget is the base class for all widgets in FLTK.

     You can't create one of these because the constructor is not public.
     However you can subclass it.

     All "property" accessing methods, such as color(), parent(), or 
argument()
     are implemented as trivial inline functions and thus are as fast 
and small
     as accessing fields in a structure. Unless otherwise noted, the 
property
     setting methods such as color(n) or label(s) are also trivial inline
     functions, even if they change the widget's appearance. It is up to the
     user code to call redraw() after these.
  */
//class FL_EXPORT Fl_Widget {
DECLARE_CLASS_CHEAP_RTTI_1(Fl_Widget)

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to