2 dnl Adaptor Rettype 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 rettype() alters a Slot by changing the return type.
32 Only allowed conversions or conversions to void can properly
33 be implemented. The type must always be specified as a
40 Slot1<void,int> s1=rettype<void>(slot(&f));
41 Slot1<float,int> s2=rettype<float>(slot(&f));
45 #include <sigc++/adaptor.h>
47 #ifdef SIGC_CXX_NAMESPACES
52 define([FORMAT_ARG_CBASSIGN],[node->LOWER([$1])_=LOWER([$1]);])
53 define([FORMAT_ARG_CBNAME],[node->LOWER([$1])_])
54 define([FORMAT_ARG_CBBIND],[[$1] LOWER([$1])_;])
56 define([ARG_CBASSIGN],[PROT(ARG_LOOP([FORMAT_ARG_CBASSIGN],[[
58 define([ARG_CBNAME],[PROT(ARG_LOOP([FORMAT_ARG_CBNAME],[[,]],$*))])
59 define([ARG_CBBIND],[PROT(ARG_LOOP([FORMAT_ARG_CBBIND],[[
63 dnl ADAPTOR_RETTYPE_SLOT([P1..PN],[C0..CN])
65 define([ADAPTOR_RETTYPE_SLOT],[dnl
66 /****************************************************************
67 ***** Adaptor Rettype Slot NUM($1)
68 ****************************************************************/
69 ADAPTOR_RETTYPE_SLOT_IMPL(R1,[$1],[$2])
71 #ifndef SIGC_CXX_VOID_RETURN
72 #ifdef SIGC_CXX_PARTIAL_SPEC
73 ADAPTOR_RETTYPE_SLOT_IMPL(void,[$1],[$2])
79 template <LIST(class R1,1,class R2,1,ARG_CLASS($1),[$1])>
81 rettype(const __SLOT__(R2,[$1]) &s)
82 {return [AdaptorRettypeSlot]NUM($1)_<LIST(R1,1,[
83 ]ARG_TYPE($1),[$1],R2,1)>::create(s.obj());
88 dnl ADAPTOR_RETTYPE_SLOT_IMPL(R,[P1..PN],[C0..CN])
90 define([ADAPTOR_RETTYPE_SLOT_IMPL],[dnl
96 struct [AdaptorRettypeSlot]NUM($2)[_]
101 template <LIST(class R1,1,[
102 ]ARG_CLASS($2),[$2],[
104 struct [AdaptorRettypeSlot]NUM($2)[_]
106 : public AdaptorSlot_
107 {TYPEDEF_RTYPE($1,RType)
108 typedef __SLOT__($1,[$2]) SlotType;
109 typedef __SLOT__(R2,[$2]) InSlotType;
110 typedef AdaptorNode Node;
111 typedef CallDataObj2<typename SlotType::Func,Node> CallData;
113 static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
115 CallData* data=(CallData*)d;
116 Node* node=data->obj;
118 ((typename InSlotType::Callback&)(node->data_))(ARG_NAME($2));
120 return RType(((typename InSlotType::Callback&)(node->data_))(ARG_NAME($2)));
123 static SlotData* create(SlotData *s)
125 SlotData* tmp=(SlotData*)s;
126 Node *node=new Node();
127 copy_callback(tmp,node);
128 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
129 data.callback=&callback;
136 ADAPTOR_RETTYPE_SLOT(ARGS(P,0))
137 ADAPTOR_RETTYPE_SLOT(ARGS(P,1))
138 ADAPTOR_RETTYPE_SLOT(ARGS(P,2))
140 #ifdef SIGC_CXX_NAMESPACES