diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-07 18:05:49 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-07 18:05:49 +0000 |
commit | ba177923d7b60800ae2e01f80fc10dc8ad1594bb (patch) | |
tree | 5a464a811ba7bd2302b7a0f3602fc66d4a7423a3 /gensigs.bld | |
parent | 8ef256aeff4c75e7a6d3fc2b9e4882869ce5f8ac (diff) | |
download | libbu++-ba177923d7b60800ae2e01f80fc10dc8ad1594bb.tar.gz libbu++-ba177923d7b60800ae2e01f80fc10dc8ad1594bb.tar.bz2 libbu++-ba177923d7b60800ae2e01f80fc10dc8ad1594bb.tar.xz libbu++-ba177923d7b60800ae2e01f80fc10dc8ad1594bb.zip |
Packaging tweaks. It works better with a tarball now.
Diffstat (limited to 'gensigs.bld')
-rw-r--r-- | gensigs.bld | 330 |
1 files changed, 165 insertions, 165 deletions
diff --git a/gensigs.bld b/gensigs.bld index 344eb62..c452356 100644 --- a/gensigs.bld +++ b/gensigs.bld | |||
@@ -1,171 +1,171 @@ | |||
1 | function genSigs( outName ) | 1 | function genSigs( outName ) |
2 | { | 2 | { |
3 | if exists( outName ) then | 3 | if exists( outName ) then |
4 | { | 4 | { |
5 | unlink( outName ); | 5 | unlink( outName ); |
6 | } | 6 | } |
7 | fOut = open(outName, "w"); | 7 | fOut = open(outName, "w"); |
8 | fOut.write( | 8 | fOut.write( |
9 | "/*\n" | 9 | "/*\n" |
10 | " * Copyright (C) 2007-2012 Xagasoft, All rights reserved.\n" | 10 | " * Copyright (C) 2007-2012 Xagasoft, All rights reserved.\n" |
11 | " *\n" | 11 | " *\n" |
12 | " * This file is part of the libbu++ library and is released under the\n" | 12 | " * This file is part of the libbu++ library and is released under the\n" |
13 | " * terms of the license contained in the file LICENSE.\n" | 13 | " * terms of the license contained in the file LICENSE.\n" |
14 | " */\n" | 14 | " */\n" |
15 | "\n" | 15 | "\n" |
16 | "#ifndef BU_SIGNALS_H\n" | 16 | "#ifndef BU_SIGNALS_H\n" |
17 | "#define BU_SIGNALS_H\n" | 17 | "#define BU_SIGNALS_H\n" |
18 | "\n" | 18 | "\n" |
19 | "#include \"bu/util.h\"\n" | 19 | "#include \"bu/util.h\"\n" |
20 | "#include \"bu/exceptionbase.h\"\n" | 20 | "#include \"bu/exceptionbase.h\"\n" |
21 | "\n" | 21 | "\n" |
22 | "namespace Bu\n" | 22 | "namespace Bu\n" |
23 | "{\n" | 23 | "{\n" |
24 | " subExceptionDecl( SignalException );\n" | 24 | " subExceptionDecl( SignalException );\n" |
25 | "\n" | 25 | "\n" |
26 | ); | 26 | ); |
27 | 27 | ||
28 | for i in range( 0, 10 ) do | 28 | for i in range( 0, 10 ) do |
29 | { | 29 | { |
30 | templParams = "typename ret"; | 30 | templParams = "typename ret"; |
31 | funcParams = ""; | 31 | funcParams = ""; |
32 | funcAnonParams = ""; | 32 | funcAnonParams = ""; |
33 | templCallParams = "ret"; | 33 | templCallParams = "ret"; |
34 | funcCallParams = ""; | 34 | funcCallParams = ""; |
35 | if i >= 1 then | 35 | if i >= 1 then |
36 | { | 36 | { |
37 | for p in range( 1, i ) do | 37 | for p in range( 1, i ) do |
38 | { | 38 | { |
39 | if p > 1 then | 39 | if p > 1 then |
40 | { | 40 | { |
41 | funcCallParams << ", "; | 41 | funcCallParams << ", "; |
42 | funcParams << ", "; | 42 | funcParams << ", "; |
43 | funcAnonParams << ", "; | 43 | funcAnonParams << ", "; |
44 | } | 44 | } |
45 | templParams << ", typename p${p}t"; | 45 | templParams << ", typename p${p}t"; |
46 | funcParams << "p${p}t p${p}"; | 46 | funcParams << "p${p}t p${p}"; |
47 | funcAnonParams << "p${p}t"; | 47 | funcAnonParams << "p${p}t"; |
48 | templCallParams << ", p${p}t"; | 48 | templCallParams << ", p${p}t"; |
49 | funcCallParams << "p${p}"; | 49 | funcCallParams << "p${p}"; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | fOut.write( | 52 | fOut.write( |
53 | "#ifndef BU_SIGNAL_PARAM_COUNT_${i}\n" | 53 | "#ifndef BU_SIGNAL_PARAM_COUNT_${i}\n" |
54 | "#define BU_SIGNAL_PARAM_COUNT_${i}\n" | 54 | "#define BU_SIGNAL_PARAM_COUNT_${i}\n" |
55 | " //\n" | 55 | " //\n" |
56 | " // ${i} Parameter(s)\n" | 56 | " // ${i} Parameter(s)\n" |
57 | " //\n" | 57 | " //\n" |
58 | " template<${templParams}>\n" | 58 | " template<${templParams}>\n" |
59 | " class _Slot${i}\n" | 59 | " class _Slot${i}\n" |
60 | " {\n" | 60 | " {\n" |
61 | " public:\n" | 61 | " public:\n" |
62 | " _Slot${i}() { }\n" | 62 | " _Slot${i}() { }\n" |
63 | " virtual ~_Slot${i}() { }\n" | 63 | " virtual ~_Slot${i}() { }\n" |
64 | " virtual ret operator()( ${funcParams} )=0;\n" | 64 | " virtual ret operator()( ${funcParams} )=0;\n" |
65 | " virtual _Slot${i}<${templCallParams}> *clone() const=0;\n" | 65 | " virtual _Slot${i}<${templCallParams}> *clone() const=0;\n" |
66 | " };\n" | 66 | " };\n" |
67 | " \n" | 67 | " \n" |
68 | " template<typename cls, ${templParams}>\n" | 68 | " template<typename cls, ${templParams}>\n" |
69 | " class __Slot${i} : public _Slot${i}<${templCallParams}>\n" | 69 | " class __Slot${i} : public _Slot${i}<${templCallParams}>\n" |
70 | " {\n" | 70 | " {\n" |
71 | " public:\n" | 71 | " public:\n" |
72 | " __Slot${i}( cls *pCls, ret (cls::*pFnc)( ${funcAnonParams} ) ) :\n" | 72 | " __Slot${i}( cls *pCls, ret (cls::*pFnc)( ${funcAnonParams} ) ) :\n" |
73 | " pCls( pCls ), pFnc( pFnc ) { }\n" | 73 | " pCls( pCls ), pFnc( pFnc ) { }\n" |
74 | " virtual ~__Slot${i}() { }\n" | 74 | " virtual ~__Slot${i}() { }\n" |
75 | " \n" | 75 | " \n" |
76 | " virtual ret operator()( ${funcParams} )\n" | 76 | " virtual ret operator()( ${funcParams} )\n" |
77 | " {\n" | 77 | " {\n" |
78 | " return (pCls->*pFnc)( ${funcCallParams} );\n" | 78 | " return (pCls->*pFnc)( ${funcCallParams} );\n" |
79 | " }\n" | 79 | " }\n" |
80 | " \n" | 80 | " \n" |
81 | " virtual _Slot${i}<${templCallParams}> *clone() const\n" | 81 | " virtual _Slot${i}<${templCallParams}> *clone() const\n" |
82 | " {\n" | 82 | " {\n" |
83 | " return new __Slot${i}<cls, ${templCallParams}>( pCls, pFnc );\n" | 83 | " return new __Slot${i}<cls, ${templCallParams}>( pCls, pFnc );\n" |
84 | " }\n" | 84 | " }\n" |
85 | " \n" | 85 | " \n" |
86 | " private:\n" | 86 | " private:\n" |
87 | " cls *pCls;\n" | 87 | " cls *pCls;\n" |
88 | " ret (cls::*pFnc)( ${funcAnonParams} );\n" | 88 | " ret (cls::*pFnc)( ${funcAnonParams} );\n" |
89 | " };\n" | 89 | " };\n" |
90 | " \n" | 90 | " \n" |
91 | " template<${templParams}>\n" | 91 | " template<${templParams}>\n" |
92 | " class __Slot${i}F : public _Slot${i}<${templCallParams}>\n" | 92 | " class __Slot${i}F : public _Slot${i}<${templCallParams}>\n" |
93 | " {\n" | 93 | " {\n" |
94 | " public:\n" | 94 | " public:\n" |
95 | " __Slot${i}F( ret (*pFnc)( ${funcAnonParams} ) ) :\n" | 95 | " __Slot${i}F( ret (*pFnc)( ${funcAnonParams} ) ) :\n" |
96 | " pFnc( pFnc ) { }\n" | 96 | " pFnc( pFnc ) { }\n" |
97 | " virtual ~__Slot${i}F() { }\n" | 97 | " virtual ~__Slot${i}F() { }\n" |
98 | " \n" | 98 | " \n" |
99 | " virtual ret operator()( ${funcParams} )\n" | 99 | " virtual ret operator()( ${funcParams} )\n" |
100 | " {\n" | 100 | " {\n" |
101 | " return (*pFnc)( ${funcCallParams} );\n" | 101 | " return (*pFnc)( ${funcCallParams} );\n" |
102 | " }\n" | 102 | " }\n" |
103 | " \n" | 103 | " \n" |
104 | " virtual _Slot${i}<${templCallParams}> *clone() const\n" | 104 | " virtual _Slot${i}<${templCallParams}> *clone() const\n" |
105 | " {\n" | 105 | " {\n" |
106 | " return new __Slot${i}F<${templCallParams}>( pFnc );\n" | 106 | " return new __Slot${i}F<${templCallParams}>( pFnc );\n" |
107 | " }\n" | 107 | " }\n" |
108 | " \n" | 108 | " \n" |
109 | " private:\n" | 109 | " private:\n" |
110 | " ret (*pFnc)( ${funcAnonParams} );\n" | 110 | " ret (*pFnc)( ${funcAnonParams} );\n" |
111 | " };\n" | 111 | " };\n" |
112 | " \n" | 112 | " \n" |
113 | " template<${templParams}>\n" | 113 | " template<${templParams}>\n" |
114 | " class Signal${i}\n" | 114 | " class Signal${i}\n" |
115 | " {\n" | 115 | " {\n" |
116 | " public:\n" | 116 | " public:\n" |
117 | " Signal${i}() : pCb( NULL ) { }\n" | 117 | " Signal${i}() : pCb( NULL ) { }\n" |
118 | " Signal${i}( _Slot${i}<${templCallParams}> *pCb ) : pCb( pCb ) { }\n" | 118 | " Signal${i}( _Slot${i}<${templCallParams}> *pCb ) : pCb( pCb ) { }\n" |
119 | " Signal${i}( const Signal${i}<${templCallParams}> &rSrc ) :\n" | 119 | " Signal${i}( const Signal${i}<${templCallParams}> &rSrc ) :\n" |
120 | " pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { }\n" | 120 | " pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { }\n" |
121 | " virtual ~Signal${i}() { delete pCb; pCb = NULL; }\n" | 121 | " virtual ~Signal${i}() { delete pCb; pCb = NULL; }\n" |
122 | " \n" | 122 | " \n" |
123 | " ret operator()( ${funcParams} )\n" | 123 | " ret operator()( ${funcParams} )\n" |
124 | " {\n" | 124 | " {\n" |
125 | " if( !pCb ) throw SignalException(\"Uninitialized signal called.\");\n" | 125 | " if( !pCb ) throw SignalException(\"Uninitialized signal called.\");\n" |
126 | " return (*pCb)( ${funcCallParams} );\n" | 126 | " return (*pCb)( ${funcCallParams} );\n" |
127 | " }\n" | 127 | " }\n" |
128 | " \n" | 128 | " \n" |
129 | " bool isSet() const { return pCb != NULL; }\n" | 129 | " bool isSet() const { return pCb != NULL; }\n" |
130 | " operator bool() const { return isSet(); }\n" | 130 | " operator bool() const { return isSet(); }\n" |
131 | " \n" | 131 | " \n" |
132 | " Signal${i}<${templCallParams}> &operator=( const Signal${i}<${templCallParams}> &rhs )\n" | 132 | " Signal${i}<${templCallParams}> &operator=( const Signal${i}<${templCallParams}> &rhs )\n" |
133 | " {\n" | 133 | " {\n" |
134 | " pCb = rhs.pCb->clone();\n" | 134 | " pCb = rhs.pCb->clone();\n" |
135 | " return *this;\n" | 135 | " return *this;\n" |
136 | " }\n" | 136 | " }\n" |
137 | " \n" | 137 | " \n" |
138 | " private:\n" | 138 | " private:\n" |
139 | " _Slot${i}<${templCallParams}> *pCb;\n" | 139 | " _Slot${i}<${templCallParams}> *pCb;\n" |
140 | " };\n" | 140 | " };\n" |
141 | " \n" | 141 | " \n" |
142 | " template<typename cls, ${templParams}>\n" | 142 | " template<typename cls, ${templParams}>\n" |
143 | " Signal${i}<${templCallParams}> slot( cls *pCls, ret (cls::*pFnc)( ${funcAnonParams} ) )\n" | 143 | " Signal${i}<${templCallParams}> slot( cls *pCls, ret (cls::*pFnc)( ${funcAnonParams} ) )\n" |
144 | " {\n" | 144 | " {\n" |
145 | " if( !pCls || !pFnc ) throw SignalException(\"NULL pointer in slot().\");\n" | 145 | " if( !pCls || !pFnc ) throw SignalException(\"NULL pointer in slot().\");\n" |
146 | " return Signal${i}<${templCallParams}>(\n" | 146 | " return Signal${i}<${templCallParams}>(\n" |
147 | " new __Slot${i}<cls, ${templCallParams}>( pCls, pFnc )\n" | 147 | " new __Slot${i}<cls, ${templCallParams}>( pCls, pFnc )\n" |
148 | " );\n" | 148 | " );\n" |
149 | " }\n" | 149 | " }\n" |
150 | " \n" | 150 | " \n" |
151 | " template<${templParams}>\n" | 151 | " template<${templParams}>\n" |
152 | " Signal${i}<${templCallParams}> slot( ret (*pFnc)( ${funcAnonParams} ) )\n" | 152 | " Signal${i}<${templCallParams}> slot( ret (*pFnc)( ${funcAnonParams} ) )\n" |
153 | " {\n" | 153 | " {\n" |
154 | " if( !pFnc ) throw SignalException(\"NULL pointer in slot().\");\n" | 154 | " if( !pFnc ) throw SignalException(\"NULL pointer in slot().\");\n" |
155 | " return Signal${i}<${templCallParams}>(\n" | 155 | " return Signal${i}<${templCallParams}>(\n" |
156 | " new __Slot${i}F<${templCallParams}>( pFnc )\n" | 156 | " new __Slot${i}F<${templCallParams}>( pFnc )\n" |
157 | " );\n" | 157 | " );\n" |
158 | " }\n" | 158 | " }\n" |
159 | "#endif // BU_SIGNAL_PARAM_COUNT_${i}\n" | 159 | "#endif // BU_SIGNAL_PARAM_COUNT_${i}\n" |
160 | "\n" | 160 | "\n" |
161 | ); | 161 | ); |
162 | } | 162 | } |
163 | 163 | ||
164 | fOut.write( | 164 | fOut.write( |
165 | "};\n" | 165 | "};\n" |
166 | "\n" | 166 | "\n" |
167 | "#endif\n" | 167 | "#endif\n" |
168 | ); | 168 | ); |
169 | fOut.close(); | 169 | fOut.close(); |
170 | } | 170 | } |
171 | 171 | ||