2 dnl Bind Slot Templates
4 dnl Copyright (C) 1998-1999 Karl Nelson <kenelson@ece.ucdavis.edu>
5 dnl Copyright (C) 2000 Carl Nygard <cnygard@bellatlantic.net>
7 dnl This library is free software; you can redistribute it and/or
8 dnl modify it under the terms of the GNU Library General Public
9 dnl License as published by the Free Software Foundation; either
10 dnl version 2 of the License, or (at your option) any later version.
12 dnl This library is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 dnl Library General Public License for more details.
17 dnl You should have received a copy of the GNU Library General Public
18 dnl License along with this library; if not, write to the Free
19 dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 dnl Ignore the next line
23 /* This is a generated file, do not edit. Generated from __file__ */
24 /* This was also shamelessly copied, hacked, munched, and carefully
25 * tweaked from KNelson's original bind.h.m4
28 include(template.macros.m4)
35 retbind() alters a Slot by fixing the return value to certain values
37 Return value fixing ignores any slot return value. The slot is
38 destroyed in the process and a new one is created, so references
39 holding onto the slot will no longer be valid.
41 Typecasting may be necessary to match arguments between the
42 slot and the binding return value. Types must be an exact match.
43 To insure the proper type, the type can be explicitly specified
44 on template instantation.
49 Slot2<void,int,int> s1=slot(f);
51 Slot1<int,int,int> s2=retbind(s1,1); // s1 is invalid
52 cout << "s2: " << s2(2,1) << endl;
57 struct B :public A {};
61 Slot0<A*> s2=retbind<A*>(s1,b); // B* must be told to match A*
65 #include <sigc++/adaptor.h>
66 #include <sigc++/scope.h>
68 #ifdef SIGC_CXX_NAMESPACES
74 dnl ADAPTOR_RETBIND_SLOT([P1..PN])
76 define([ADAPTOR_RETBIND_SLOT],[dnl
77 /****************************************************************
78 ***** Adaptor RetBind Slot NUM($1) arguments
79 ****************************************************************/
80 ADAPTOR_RETBIND_SLOT_IMPL(R,[$1])
82 #ifndef SIGC_CXX_VOID_RETURN
83 #ifdef SIGC_CXX_PARTIAL_SPEC
84 ADAPTOR_RETBIND_SLOT_IMPL(void,[$1])
88 template <LIST(class Ret,1,[
92 retbind(const [Slot]NUM($1)<LIST(R,1,ARG_TYPE($1),[$1])> &s,
94 {return [AdaptorRetBindSlot]NUM($1)<LIST(Ret,1,R,1,[
95 ]ARG_TYPE($1),[$1])>::create(s.data(),ret);
102 dnl ADAPTOR_RETBIND_SLOT_IMPL(R,[P1..PN])
104 define([ADAPTOR_RETBIND_SLOT_IMPL],[dnl
107 template <LIST(class Ret,1,ARG_CLASS($2),[$2])>
108 struct [AdaptorRetBindSlot]NUM($2)
110 ]ARG_TYPE($2),[$2])> : public AdaptorSlot_
112 template <LIST(class Ret,1,class $1,1,[
113 ]ARG_CLASS($2),[$2])>
114 struct [AdaptorRetBindSlot]NUM($2): public AdaptorSlot_
116 {TYPEDEF_RTYPE(Ret,RType)
117 typedef __SLOT__(Ret,[$2]) SlotType;
118 typedef __SLOT__($1,[$2]) InSlotType;
120 struct Node:public AdaptorNode
125 typedef CallDataObj2<typename SlotType::Func,Node> CallData;
127 static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
129 CallData* data=(CallData*)d;
130 Node* node=data->obj;
131 ((typename InSlotType::Callback&)(node->data_))(LIST(ARG_NAME($2),[$2]));
134 static SlotData* create(SlotData *s,Ret ret)
136 SlotData* tmp=(SlotData*)s;
137 Node *node=new Node();
138 copy_callback(tmp,node);
140 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
141 data.callback=&callback;
148 ADAPTOR_RETBIND_SLOT(ARGS(P,0))
149 ADAPTOR_RETBIND_SLOT(ARGS(P,1))
150 ADAPTOR_RETBIND_SLOT(ARGS(P,2))
151 ADAPTOR_RETBIND_SLOT(ARGS(P,3))
153 #ifdef SIGC_CXX_NAMESPACES