2 dnl Object Slot Templates
4 dnl Copyright (C) 1998-1999 Karl Nelson <kenelson@ece.ucdavis.edu>
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.
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.
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.
21 dnl Ignore the next line
22 /* This is a generated file, do not edit. Generated from __file__ */
23 include(template.macros.m4)
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
37 struct A: public SigC::Object
42 Slot2<void,int,int> s=slot(a,&A::foo);
47 #include <sigc++/slot.h>
48 #include <sigc++/scope.h>
50 #ifdef SIGC_CXX_NAMESPACES
58 define([OBJECT_SLOT],[dnl
59 /****************************************************************
60 ***** Object Slot NUM($1)
61 ****************************************************************/
62 OBJECT_SLOT_IMPL(R,[$1])
64 #ifndef SIGC_CXX_VOID_RETURN
65 #ifdef SIGC_CXX_PARTIAL_SPEC
66 OBJECT_SLOT_IMPL(void,[$1])
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)))
74 return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
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)))
82 return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
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)))
90 return [ObjectSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1],O2,1)>
98 dnl OBJECT_SLOT_IMPL(R,[P1,P2,...])
100 define([OBJECT_SLOT_IMPL],[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)>
106 template <LIST(class R,1,ARG_CLASS($2),[$2],class Obj,1)>
107 struct [ObjectSlot]NUM($2)_
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;
115 static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
117 CallData* data=(CallData*)d;
118 ifelse($1,void,,return) ((data->obj)->*(data->func))(ARG_NAME($2));
121 static SlotData* create(Obj* obj,InFunc func)
124 SlotData* tmp=manage(new SlotData());
125 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
126 data.callback=&callback;
128 data.func=(Func)func;
129 obj->register_data(tmp->receiver());
136 OBJECT_SLOT(ARGS(P,0))
137 OBJECT_SLOT(ARGS(P,1))
138 OBJECT_SLOT(ARGS(P,2))
139 OBJECT_SLOT(ARGS(P,3))
141 #ifdef SIGC_CXX_NAMESPACES