2 dnl Function slot templates
4 dnl Copyright (C) 1998 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)
26 #include <sigc++/slot.h>
29 SigC::slot() (function)
30 -----------------------
31 slot() can be applied to a function to form a Slot with a
32 profile equivelent to the function. To avoid warns be
33 sure to pass the address of the function.
39 Slot2<void,int,int> s=slot(&foo);
43 #ifdef SIGC_CXX_NAMESPACES
48 // From which we build specific Slots and a set of
49 // functions for creating a slot of this type
52 dnl FUNCTION_SLOT([P1,P2,...])
54 define([FUNCTION_SLOT],[dnl
55 /****************************************************************
56 ***** Function Slot NUM($1)
57 ****************************************************************/
58 FUNCTION_SLOT_IMPL(R,[$1])
60 #ifndef SIGC_CXX_VOID_RETURN
61 #ifdef SIGC_CXX_PARTIAL_SPEC
62 FUNCTION_SLOT_IMPL(void,[$1])
66 template <LIST(class R,1,ARG_CLASS($1),[$1])>
67 inline __SLOT__(R,[$1])
68 slot(R (*func)(ARG_TYPE($1)))
70 return [FuncSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1])>::create(func);
76 dnl FUNCTION_SLOT_IMPL(R,[P1,P2,...])
78 define([FUNCTION_SLOT_IMPL],[dnl
81 template <ARG_CLASS($2)>
82 struct [FuncSlot]NUM($2)_<LIST(void,1,ARG_TYPE($2),[$2])>
84 template <LIST(class R,1,ARG_CLASS($2),[$2])>
85 struct [FuncSlot]NUM($2)_
87 {TYPEDEF_RTYPE($1,RType)
88 typedef $1 (*InFunc)(ARG_TYPE($2));
89 typedef RType (*Func)(ARG_TYPE($2));
90 typedef __SLOT__($1,[$2]) SlotType;
93 typedef CallDataFunc<IF([$2],[typename ])SlotType::Func,Func> CallData;
95 typedef CallDataFunc<typename SlotType::Func,Func> CallData;
98 static RType callback(LIST(void* data,1,ARG_BOTH($2),[$2]))
100 ifelse($1,void,,return) (((CallData*)data)->func)(ARG_NAME($2));
103 static SlotData* create(InFunc func)
105 SlotData* tmp=manage(new SlotData());
106 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
107 data.callback=&callback;
108 data.func=(Func)func;
114 FUNCTION_SLOT(ARGS(P,0))
115 FUNCTION_SLOT(ARGS(P,1))
116 FUNCTION_SLOT(ARGS(P,2))
117 FUNCTION_SLOT(ARGS(P,3))
119 #ifdef SIGC_CXX_NAMESPACES