]> git.lyx.org Git - lyx.git/blob - sigc++/macros/object_slot.h.m4
visual support for \displaystyle
[lyx.git] / sigc++ / macros / object_slot.h.m4
1 dnl 
2 dnl Object Slot Templates
3 dnl 
4 dnl  Copyright (C) 1998-1999 Karl Nelson <kenelson@ece.ucdavis.edu>
5 dnl 
6 dnl  This library is free software; you can redistribute it and/or
7 dnl  modify it under the terms of the GNU Library General Public
8 dnl  License as published by the Free Software Foundation; either
9 dnl  version 2 of the License, or (at your option) any later version.
10 dnl 
11 dnl  This library is distributed in the hope that it will be useful,
12 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl  Library General Public License for more details.
15 dnl 
16 dnl  You should have received a copy of the GNU Library General Public
17 dnl  License along with this library; if not, write to the Free
18 dnl  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 dnl 
20 // -*- c++ -*-
21 dnl Ignore the next line
22 /* This is a generated file, do not edit.  Generated from __file__ */
23 include(template.macros.m4)
24 #ifndef __header__
25 #define __header__
26
27 /*
28   SigC::slot() (obj)
29   -----------------------
30   slot() can be applied to a object method to form a Slot with a 
31   profile equivelent to the method.  At the same time an instance
32   of that object must be specified.  The object must be derived
33   from SigC::Object.
34
35   Sample usage:
36
37     struct A: public SigC::Object
38       {
39        void foo(int,int);
40       } a;
41
42     Slot2<void,int,int> s=slot(a,&A::foo);
43
44 */
45
46
47 #include <sigc++/slot.h>
48 #include <sigc++/scope.h>
49
50 #ifdef SIGC_CXX_NAMESPACES
51 namespace SigC
52 {
53 #endif
54
55 dnl
56 dnl OBJECT_SLOT
57 dnl
58 define([OBJECT_SLOT],[dnl
59 /****************************************************************
60 ***** Object Slot NUM($1)
61 ****************************************************************/
62 OBJECT_SLOT_IMPL(R,[$1])
63
64 #ifndef SIGC_CXX_VOID_RETURN
65 #ifdef SIGC_CXX_PARTIAL_SPEC
66 OBJECT_SLOT_IMPL(void,[$1])
67 #endif
68 #endif
69
70 template <LIST(class R,1,ARG_CLASS($1),[$1],[class O,class O2],1)>
71 inline __SLOT__(R,[$1])
72   slot(O* &obj,R (O2::*func)(ARG_TYPE($1)))
73   {
74     return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
75              ::create(obj,func);
76   }
77
78 template <LIST(class R,1,ARG_CLASS($1),[$1],[class O,class O2],1)>
79 inline __SLOT__(R,[$1])
80   slot(O* const &obj,R (O2::*func)(ARG_TYPE($1)))
81   {
82     return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
83              ::create(obj,func);
84   }
85
86 template <LIST(class R,1,ARG_CLASS($1),[$1],[class O,class O2],1)>
87 inline __SLOT__(R,[$1])
88   slot(O &obj,R (O2::*func)(ARG_TYPE($1)))
89   {
90     return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
91              ::create(&obj,func);
92   }
93
94
95 ])dnl
96
97 dnl
98 dnl OBJECT_SLOT_IMPL(R,[P1,P2,...])
99 dnl
100 define([OBJECT_SLOT_IMPL],[dnl
101 LINE(]__line__[)dnl
102 ifelse($1,void,[dnl
103 template <LIST(ARG_CLASS($2),[$2],class Obj,1)>
104 struct [ObjectSlot]NUM($2)_<LIST(void,1,ARG_TYPE($2),[$2],Obj,1)>
105 ],[dnl
106 template <LIST(class R,1,ARG_CLASS($2),[$2],class Obj,1)>
107 struct [ObjectSlot]NUM($2)_
108 ])dnl
109   {TYPEDEF_RTYPE($1,RType)
110    typedef $1     (Obj::*InFunc)(ARG_TYPE($2));
111    typedef RType (Obj::*Func)(ARG_TYPE($2));
112    typedef __SLOT__($1,[$2]) SlotType;
113    typedef CallDataObj3<typename SlotType::Func,Obj,Func> CallData;
114
115    static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
116      {
117       CallData* data=(CallData*)d;
118       ifelse($1,void,,return) ((data->obj)->*(data->func))(ARG_NAME($2));
119      }
120
121    static SlotData* create(Obj* obj,InFunc func)
122      {
123       if (!obj) return 0;
124       SlotData* tmp=manage(new SlotData());
125       CallData &data=reinterpret_cast<CallData&>(tmp->data_);
126       data.callback=&callback;
127       data.obj=obj;
128       data.func=(Func)func;
129       obj->register_data(tmp->receiver());
130       return tmp;
131      }
132   };
133
134 ])dnl
135
136 OBJECT_SLOT(ARGS(P,0))
137 OBJECT_SLOT(ARGS(P,1))
138 OBJECT_SLOT(ARGS(P,2))
139 OBJECT_SLOT(ARGS(P,3))
140
141 #ifdef SIGC_CXX_NAMESPACES
142 } // namespace
143 #endif
144
145 #endif