]> git.lyx.org Git - lyx.git/blob - sigc++/macros/func_slot.h.m4
dont use threads, add inquiv operator for Aux_info
[lyx.git] / sigc++ / macros / func_slot.h.m4
1 dnl 
2 dnl Function slot templates
3 dnl 
4 dnl  Copyright (C) 1998 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 #include <sigc++/slot.h>
27
28 /*
29   SigC::slot() (function)
30   -----------------------
31   slot() can be applied to a function to form a Slot with a 
32   profile equivelent to the function.  To avoid warns be
33   sure to pass the address of the function.
34
35   Sample usage:
36
37     void foo(int,int);
38
39     Slot2<void,int,int> s=slot(&foo);
40
41 */
42
43 #ifdef SIGC_CXX_NAMESPACES
44 namespace SigC
45 {
46 #endif
47
48 // From which we build specific Slots and a set of
49 // functions for creating a slot of this type
50
51 dnl
52 dnl FUNCTION_SLOT([P1,P2,...])
53 dnl
54 define([FUNCTION_SLOT],[dnl
55 /****************************************************************
56 ***** Function Slot NUM($1)
57 ****************************************************************/
58 FUNCTION_SLOT_IMPL(R,[$1])
59
60 #ifndef SIGC_CXX_VOID_RETURN
61 #ifdef SIGC_CXX_PARTIAL_SPEC
62 FUNCTION_SLOT_IMPL(void,[$1])
63 #endif
64 #endif
65
66 template <LIST(class R,1,ARG_CLASS($1),[$1])>
67 inline __SLOT__(R,[$1])
68   slot(R (*func)(ARG_TYPE($1)))
69   {
70    return [FuncSlot]NUM($1)_<LIST(R,1,ARG_TYPE($1),[$1])>::create(func);
71   }
72
73 ])dnl
74
75 dnl
76 dnl FUNCTION_SLOT_IMPL(R,[P1,P2,...])
77 dnl
78 define([FUNCTION_SLOT_IMPL],[dnl
79 LINE(]__line__[)dnl
80 ifelse($1,void,[dnl
81 template <ARG_CLASS($2)>
82 struct [FuncSlot]NUM($2)_<LIST(void,1,ARG_TYPE($2),[$2])>
83 ],[dnl
84 template <LIST(class R,1,ARG_CLASS($2),[$2])>
85 struct [FuncSlot]NUM($2)_
86 ])dnl
87   {TYPEDEF_RTYPE($1,RType)
88    typedef $1     (*InFunc)(ARG_TYPE($2));
89    typedef RType (*Func)(ARG_TYPE($2));
90    typedef __SLOT__($1,[$2]) SlotType;
91
92 ifelse($1,void,[dnl
93    typedef CallDataFunc<IF([$2],[typename ])SlotType::Func,Func> CallData;
94 ],[dnl
95    typedef CallDataFunc<typename SlotType::Func,Func> CallData;
96 ])dnl
97
98    static RType callback(LIST(void* data,1,ARG_BOTH($2),[$2]))
99      {
100       ifelse($1,void,,return) (((CallData*)data)->func)(ARG_NAME($2));
101      }
102
103    static SlotData* create(InFunc func)
104      {
105       SlotData* tmp=manage(new SlotData());
106       CallData &data=reinterpret_cast<CallData&>(tmp->data_);
107       data.callback=&callback;
108       data.func=(Func)func;
109       return tmp;
110      }
111   };
112 ])dnl
113
114 FUNCTION_SLOT(ARGS(P,0))
115 FUNCTION_SLOT(ARGS(P,1))
116 FUNCTION_SLOT(ARGS(P,2))
117 FUNCTION_SLOT(ARGS(P,3))
118
119 #ifdef SIGC_CXX_NAMESPACES
120 } // namespace
121 #endif
122
123 #endif // __header__