2 dnl Convert 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 convert() alters a Slot by assigning a conversion function
31 which can completely alter the parameter types of a slot.
33 Only convert functions for changing with same number of
34 arguments is compiled by default. See examples/custom_convert.h.m4
35 for details on how to build non standard ones.
38 int my_string_to_char(Callback1<int,const char*> *d,const string &s)
43 Slot1<int,const string &> s2=convert(slot(f),my_string_to_char);
47 #include <sigc++/adaptor.h>
49 #ifdef SIGC_CXX_NAMESPACES
55 dnl ADAPTOR_CONVERT_SLOT([P1..PN],[C0..CN])
57 define([ADAPTOR_CONVERT_SLOT],[dnl
58 /****************************************************************
59 ***** Adaptor Convert Slot NUM($1)
60 ****************************************************************/
61 ADAPTOR_CONVERT_SLOT_IMPL(R1,[$1],[$2])
63 #ifndef SIGC_CXX_VOID_RETURN
64 #ifdef SIGC_CXX_PARTIAL_SPEC
65 ADAPTOR_CONVERT_SLOT_IMPL(void,[$1],[$2])
69 template <LIST(class R1,1,ARG_CLASS($1),[$1],[
70 class R2],1,ARG_CLASS($2),[$2])>
72 convert(const __SLOT__(R2,[$2]) &s,
73 [R1 (*func)](LIST([Callback]NUM($2)PROT(<LIST(R2,1,ARG_TYPE($2),[$2])>)*,1,ARG_TYPE($1),[$1])))
74 {return [AdaptorConvertSlot]NUM($1)[_]NUM($2)<LIST(R1,1,ARG_TYPE($1),[$1],[
75 R2],1,ARG_TYPE($2),[$2])>::create(s.obj(),func);
81 dnl ADAPTOR_CONVERT_SLOT_IMPL(R,[P1..PN],[C0..CN])
83 define([ADAPTOR_CONVERT_SLOT_IMPL],[dnl
86 template <LIST(ARG_CLASS($2),[$2],[
87 class R2],1,ARG_CLASS($3),[$3])>
88 struct [AdaptorConvertSlot]NUM($2)[_]NUM($3)
89 <LIST(void,1,ARG_TYPE($2),[$2],[
90 R2],1,ARG_TYPE($3),[$3])>
93 template <LIST(class $1,1,ARG_CLASS($2),[$2],[
94 class R2],1,ARG_CLASS($3),[$3])>
95 struct [AdaptorConvertSlot]NUM($2)[_]NUM($3): public AdaptorSlot_
97 {TYPEDEF_RTYPE($1,RType)
98 typedef __SLOT__($1,[$2]) SlotType;
99 typedef __SLOT__(R2,[$3]) InSlotType;
100 typedef typename InSlotType::Callback Callback;
101 typedef RType (*Func) (LIST(Callback*,1,ARG_TYPE($2),[$2]));
102 typedef $1 (*InFunc)(LIST(Callback*,1,ARG_TYPE($2),[$2]));
103 typedef CallDataObj3<typename SlotType::Func,Callback,Func> CallData;
105 static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
107 CallData* data=(CallData*)d;
108 ifelse($1,void,,return) (data->func)(LIST(data->obj,1,ARG_NAME($2),[$2]));
111 static SlotData* create(SlotData *s,InFunc func)
113 SlotData* tmp=(SlotData*)s;
114 AdaptorNode *node=new AdaptorNode();
115 copy_callback(tmp,node);
116 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
117 data.callback=&callback;
118 data.func=(Func)func;
119 data.obj=(Callback*)&(node->data_);
126 ADAPTOR_CONVERT_SLOT(ARGS(P,1),ARGS(Q,1))
127 ADAPTOR_CONVERT_SLOT(ARGS(P,2),ARGS(Q,2))
128 ADAPTOR_CONVERT_SLOT(ARGS(P,3),ARGS(Q,3))
130 #ifdef SIGC_CXX_NAMESPACES