2 dnl Bind 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)
30 bind() alters a Slot by fixing arguments to certain values.
32 Argument fixing starts from the last argument. The slot is
33 destroyed in the process and a new one is created, so references
34 holding onto the slot will no longer be valid.
36 Up to two arguments can be bound at a time with the default
42 Slot2<void,int,int> s1=slot(f);
44 Slot1<void,int> s2=bind(s1,1); // s1 is invalid
45 s2(2); // call f with arguments 2,1
50 Slot2<void,int,int> s1=slot(f);
52 Slot0<void> s2=bind(s1,1,2); // s1 is invalid
53 s2(); // call f with arguments 1,2
58 struct B :public A {};
62 Slot0<void> s2=bind(s1, b); // B* converted to A*
66 #include <sigc++/adaptor.h>
67 #include <sigc++/scope.h>
69 #ifdef SIGC_CXX_NAMESPACES
74 define([FORMAT_ARG_CBASSIGN],[node->LOWER([$1])_=LOWER([$1]);])
75 define([FORMAT_ARG_CBNAME],[node->LOWER([$1])_])
76 define([FORMAT_ARG_CBBIND],[[$1] LOWER([$1])_;])
78 define([ARG_CBASSIGN],[PROT(ARG_LOOP([FORMAT_ARG_CBASSIGN],[[
80 define([ARG_CBNAME],[PROT(ARG_LOOP([FORMAT_ARG_CBNAME],[[,]],$*))])
81 define([ARG_CBBIND],[PROT(ARG_LOOP([FORMAT_ARG_CBBIND],[[
85 dnl ADAPTOR_BIND_SLOT([P1..PN],[C0..CM],[A0..AM])
87 define([ADAPTOR_BIND_SLOT],[dnl
88 /****************************************************************
89 ***** Adaptor Bind Slot NUM($1) arguments, NUM($2) hidden arguments
90 ****************************************************************/
91 ADAPTOR_BIND_SLOT_IMPL(R,[$1],[$2])
93 #ifndef SIGC_CXX_VOID_RETURN
94 #ifdef SIGC_CXX_PARTIAL_SPEC
95 ADAPTOR_BIND_SLOT_IMPL(void,[$1],[$2])
99 template <LIST(ARG_CLASS($3),[$3],[
101 ]ARG_CLASS($1),[$1],[
102 ]ARG_CLASS($2),[$2])>
105 bind(const [Slot]eval(NUM($1)+NUM($2))<LIST(R,1,ARG_TYPE($1),[$1],ARG_TYPE($2),[$2])> &s,
107 {return [AdaptorBindSlot]NUM($1)[_]NUM($2)<LIST(R,1,[
109 ]ARG_TYPE($2),[$2])>::create(s.data(),ARG_NAME($3));
116 dnl ADAPTOR_BIND_SLOT_IMPL(R,[P1..PN],[C0..CN])
118 define([ADAPTOR_BIND_SLOT_IMPL],[dnl
121 template <LIST(ARG_CLASS($2),[$2],[
122 ]ARG_CLASS($3),[$3])>
123 struct [AdaptorBindSlot]NUM($2)[_]NUM($3)
124 <LIST(void,1,ARG_TYPE($2),[$2],[
125 ]ARG_TYPE($3),[$3])> : public AdaptorSlot_
127 template <LIST(class R,1,[
128 ]ARG_CLASS($2),[$2],[
129 ]ARG_CLASS($3),[$3])>
130 struct [AdaptorBindSlot]NUM($2)[_]NUM($3): public AdaptorSlot_
132 {TYPEDEF_RTYPE($1,RType)
133 typedef __SLOT__($1,[$2]) SlotType;
134 typedef __SLOT__($1,[$2],[$3]) InSlotType;
136 struct Node:public AdaptorNode
145 typedef CallDataObj2<typename SlotType::Func,Node> CallData;
147 static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
149 CallData* data=(CallData*)d;
150 Node* node=data->obj;
151 ifelse($1,void,,return) ((typename InSlotType::Callback&)(node->data_))(LIST(ARG_NAME($2),[$2],[
152 ]ARG_CBNAME($3),[$3]));
154 static SlotData* create(SlotData *s,ARG_BOTH($3))
156 Node *node=new Node(ARG_NAME($3));
157 copy_callback(s,node);
158 CallData &data=reinterpret_cast<CallData&>(s->data_);
159 data.callback=&callback;
166 ADAPTOR_BIND_SLOT(ARGS(P,0),ARGS(C,1),ARGS(A,1))
167 ADAPTOR_BIND_SLOT(ARGS(P,1),ARGS(C,1),ARGS(A,1))
168 ADAPTOR_BIND_SLOT(ARGS(P,2),ARGS(C,1),ARGS(A,1))
169 ADAPTOR_BIND_SLOT(ARGS(P,3),ARGS(C,1),ARGS(A,1))
171 ADAPTOR_BIND_SLOT(ARGS(P,0),ARGS(C,2),ARGS(A,2))
172 ADAPTOR_BIND_SLOT(ARGS(P,1),ARGS(C,2),ARGS(A,2))
173 ADAPTOR_BIND_SLOT(ARGS(P,2),ARGS(C,2),ARGS(A,2))
174 ADAPTOR_BIND_SLOT(ARGS(P,3),ARGS(C,2),ARGS(A,2))
176 #ifdef SIGC_CXX_NAMESPACES