]> git.lyx.org Git - lyx.git/blob - sigc++/macros/rettype.h.m4
visual support for \displaystyle
[lyx.git] / sigc++ / macros / rettype.h.m4
1 dnl 
2 dnl Adaptor Rettype Templates
3 dnl 
4 dnl  Copyright (C) 1998-1999 Karl Nelson <kenelson@ece.ucdavis.edu>
5 dnl 
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.
10 dnl 
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.
15 dnl 
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.
19 dnl 
20 // -*- c++ -*-
21 dnl Ignore the next line
22 /* This is a generated file, do not edit.  Generated from __file__ */
23 include(template.macros.m4)
24 #ifndef __header__
25 #define __header__
26
27 /*
28   SigC::rettype
29   -------------
30   rettype() alters a Slot by changing the return type.
31
32   Only allowed conversions or conversions to void can properly
33   be implemented.  The type must always be specified as a
34   template parameter. 
35
36   Simple Sample usage:
37
38     int f(int);
39
40     Slot1<void,int>   s1=rettype<void>(slot(&f)); 
41     Slot1<float,int>  s2=rettype<float>(slot(&f)); 
42
43 */
44
45 #include <sigc++/adaptor.h>
46
47 #ifdef SIGC_CXX_NAMESPACES
48 namespace SigC
49 {
50 #endif
51
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])_;])
55
56 define([ARG_CBASSIGN],[PROT(ARG_LOOP([FORMAT_ARG_CBASSIGN],[[
57       ]],$*))])
58 define([ARG_CBNAME],[PROT(ARG_LOOP([FORMAT_ARG_CBNAME],[[,]],$*))])
59 define([ARG_CBBIND],[PROT(ARG_LOOP([FORMAT_ARG_CBBIND],[[
60       ]],$*))])
61
62 dnl
63 dnl ADAPTOR_RETTYPE_SLOT([P1..PN],[C0..CN])
64 dnl
65 define([ADAPTOR_RETTYPE_SLOT],[dnl
66 /****************************************************************
67 ***** Adaptor Rettype Slot NUM($1)
68 ****************************************************************/
69 ADAPTOR_RETTYPE_SLOT_IMPL(R1,[$1],[$2])
70
71 #ifndef SIGC_CXX_VOID_RETURN
72 #ifdef SIGC_CXX_PARTIAL_SPEC
73 ADAPTOR_RETTYPE_SLOT_IMPL(void,[$1],[$2])
74 #endif
75 #endif
76
77 LINE(]__line__[)dnl
78
79 template <LIST(class R1,1,class R2,1,ARG_CLASS($1),[$1])>
80 __SLOT__(R1,[$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());
84   }
85 ])dnl
86
87 dnl
88 dnl ADAPTOR_RETTYPE_SLOT_IMPL(R,[P1..PN],[C0..CN])
89 dnl
90 define([ADAPTOR_RETTYPE_SLOT_IMPL],[dnl
91 LINE(]__line__[)dnl
92 ifelse($1,void,[dnl
93 template <LIST([
94    ]ARG_CLASS($2),[$2],[
95    ]class R2,1)>
96 struct [AdaptorRettypeSlot]NUM($2)[_]
97 <LIST(void,1,[
98    ]ARG_TYPE($2),[$2],[
99    ]R2,1)>
100 ],[dnl
101 template <LIST(class R1,1,[
102    ]ARG_CLASS($2),[$2],[
103    ]class R2,1)>
104 struct [AdaptorRettypeSlot]NUM($2)[_]
105 ])dnl
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;
112
113    static RType callback(LIST(void* d,1,ARG_BOTH($2),[$2]))
114      {
115       CallData* data=(CallData*)d;
116       Node* node=data->obj;
117 ifelse($1,void,[dnl
118       ((typename InSlotType::Callback&)(node->data_))(ARG_NAME($2));
119 ],[dnl
120       return RType(((typename InSlotType::Callback&)(node->data_))(ARG_NAME($2)));
121 ])dnl
122      }
123    static SlotData* create(SlotData *s)
124      {
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;
130       data.obj=node;
131       return tmp;
132      }
133   };
134 ])dnl
135
136 ADAPTOR_RETTYPE_SLOT(ARGS(P,0))
137 ADAPTOR_RETTYPE_SLOT(ARGS(P,1))
138 ADAPTOR_RETTYPE_SLOT(ARGS(P,2))
139 ADAPTOR_RETTYPE_SLOT(ARGS(P,3))
140
141 #ifdef SIGC_CXX_NAMESPACES
142 } // namespace
143 #endif
144
145 #endif