Merge lp:~paul-lucas/zorba/bug-983628 into lp:zorba
- bug-983628
- Merge into trunk
Proposed by
Paul J. Lucas
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Rodolfo Ochoa | ||||
Approved revision: | 10771 | ||||
Merged at revision: | 10771 | ||||
Proposed branch: | lp:~paul-lucas/zorba/bug-983628 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
1609 lines (+986/-315) 6 files modified
src/zorbatypes/decimal.cpp (+15/-15) src/zorbatypes/decimal.h (+41/-43) src/zorbatypes/floatimpl.cpp (+3/-3) src/zorbatypes/floatimpl.h (+269/-73) src/zorbatypes/integer.cpp (+119/-7) src/zorbatypes/integer.h (+539/-174) |
||||
To merge this branch: | bzr merge lp:~paul-lucas/zorba/bug-983628 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rodolfo Ochoa | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+102367@code.launchpad.net |
Commit message
Removed use of is_arithmetic for Windows and "unrolled" all the types.
Description of the change
Removed use of is_arithmetic for Windows and "unrolled" all the types.
To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) : | # |
review:
Approve
Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-983628-2012-04-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/zorbatypes/decimal.cpp' |
2 | --- src/zorbatypes/decimal.cpp 2012-04-16 20:56:43 +0000 |
3 | +++ src/zorbatypes/decimal.cpp 2012-04-17 18:33:19 +0000 |
4 | @@ -31,10 +31,10 @@ |
5 | |
6 | #ifdef ZORBA_WITH_BIG_INTEGER |
7 | # define TEMPLATE_DECL(T) /* nothing */ |
8 | -# define INTEGER_IMPL(T) IntegerImpl |
9 | +# define INTEGER_IMPL(I) IntegerImpl |
10 | #else |
11 | -# define TEMPLATE_DECL(T) template<typename T> |
12 | -# define INTEGER_IMPL(T) IntegerImpl<T> |
13 | +# define TEMPLATE_DECL(T) template<typename T> /* spacer */ |
14 | +# define INTEGER_IMPL(I) IntegerImpl<I> /* spacer */ |
15 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
16 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) |
17 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) |
18 | @@ -229,8 +229,8 @@ |
19 | value_ = f.getNumber(); |
20 | } |
21 | |
22 | -TEMPLATE_DECL(T) |
23 | -Decimal::Decimal( INTEGER_IMPL(T) const &i ) : value_( i.itod() ) { |
24 | +TEMPLATE_DECL(I) |
25 | +Decimal::Decimal( INTEGER_IMPL(I) const &i ) : value_( i.itod() ) { |
26 | } |
27 | #ifndef ZORBA_WITH_BIG_INTEGER |
28 | template Decimal::Decimal( INTEGER_IMPL_LL const& ); |
29 | @@ -251,8 +251,8 @@ |
30 | return *this; |
31 | } |
32 | |
33 | -TEMPLATE_DECL(T) |
34 | -Decimal& Decimal::operator=( INTEGER_IMPL(T) const &i ) { |
35 | +TEMPLATE_DECL(I) |
36 | +Decimal& Decimal::operator=( INTEGER_IMPL(I) const &i ) { |
37 | value_ = i.itod(); |
38 | return *this; |
39 | } |
40 | @@ -286,8 +286,8 @@ |
41 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
42 | |
43 | #define ZORBA_DECIMAL_OP(OP) \ |
44 | - TEMPLATE_DECL(T) \ |
45 | - Decimal operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
46 | + TEMPLATE_DECL(I) \ |
47 | + Decimal operator OP( Decimal const &d, INTEGER_IMPL(I) const &i ) { \ |
48 | return d.value_ OP i.itod(); \ |
49 | } \ |
50 | ZORBA_INSTANTIATE(OP) |
51 | @@ -311,8 +311,8 @@ |
52 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
53 | |
54 | #define ZORBA_DECIMAL_OP(OP) \ |
55 | - TEMPLATE_DECL(T) \ |
56 | - bool operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
57 | + TEMPLATE_DECL(I) \ |
58 | + bool operator OP( Decimal const &d, INTEGER_IMPL(I) const &i ) { \ |
59 | return d.value_ OP i.itod(); \ |
60 | } \ |
61 | ZORBA_INSTANTIATE(OP) |
62 | @@ -332,8 +332,8 @@ |
63 | return round( INTEGER_IMPL_LL::zero() ); |
64 | } |
65 | |
66 | -TEMPLATE_DECL(T) |
67 | -Decimal Decimal::round( INTEGER_IMPL(T) const &precision ) const { |
68 | +TEMPLATE_DECL(I) |
69 | +Decimal Decimal::round( INTEGER_IMPL(I) const &precision ) const { |
70 | return round2( value_, precision.itod() ); |
71 | } |
72 | #ifndef ZORBA_WITH_BIG_INTEGER |
73 | @@ -351,8 +351,8 @@ |
74 | return result; |
75 | } |
76 | |
77 | -TEMPLATE_DECL(T) |
78 | -Decimal Decimal::roundHalfToEven( INTEGER_IMPL(T) const &precision ) const { |
79 | +TEMPLATE_DECL(I) |
80 | +Decimal Decimal::roundHalfToEven( INTEGER_IMPL(I) const &precision ) const { |
81 | return roundHalfToEven2( value_, precision.itod() ); |
82 | } |
83 | #ifndef ZORBA_WITH_BIG_INTEGER |
84 | |
85 | === modified file 'src/zorbatypes/decimal.h' |
86 | --- src/zorbatypes/decimal.h 2012-04-16 20:56:43 +0000 |
87 | +++ src/zorbatypes/decimal.h 2012-04-17 18:33:19 +0000 |
88 | @@ -34,8 +34,8 @@ |
89 | # define TEMPLATE_DECL(I) /* nothing */ |
90 | # define INTEGER_IMPL(I) IntegerImpl |
91 | #else |
92 | -# define TEMPLATE_DECL(I) template<typename I> |
93 | -# define INTEGER_IMPL(I) IntegerImpl<I> |
94 | +# define TEMPLATE_DECL(I) template<typename I> /* spacer */ |
95 | +# define INTEGER_IMPL(I) IntegerImpl<I> /* spacer */ |
96 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
97 | |
98 | namespace zorba { |
99 | @@ -106,19 +106,16 @@ |
100 | */ |
101 | Decimal& operator=( Decimal const &d ); |
102 | |
103 | - /** |
104 | - * For every built-in arithmetic type A, assign to this %Decimal. |
105 | - * |
106 | - * @tparam A The built-in arithmetic type. |
107 | - * @param n The arithmetic value to assign. |
108 | - * @return Returns \c *this. |
109 | - */ |
110 | - template<typename A> |
111 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,Decimal&>::type |
112 | - operator=( A n ); |
113 | - |
114 | - // These arithmetic types have to be special-cased. |
115 | + Decimal& operator=( signed char c ); |
116 | + Decimal& operator=( char c ); |
117 | + Decimal& operator=( short n ); |
118 | + Decimal& operator=( int n ); |
119 | + Decimal& operator=( long n ); |
120 | Decimal& operator=( long long n ); |
121 | + Decimal& operator=( unsigned char c ); |
122 | + Decimal& operator=( unsigned short n ); |
123 | + Decimal& operator=( unsigned int n ); |
124 | + Decimal& operator=( unsigned long n ); |
125 | Decimal& operator=( unsigned long long n ); |
126 | |
127 | Decimal& operator=( char const *s ); |
128 | @@ -222,6 +219,8 @@ |
129 | |
130 | private: |
131 | typedef MAPM value_type; |
132 | + typedef long int_cast_type; |
133 | + |
134 | value_type value_; |
135 | |
136 | Decimal( value_type const &v ) : value_( v ) { } |
137 | @@ -256,29 +255,18 @@ |
138 | |
139 | ////////// constructors /////////////////////////////////////////////////////// |
140 | |
141 | -inline Decimal::Decimal( char c ) : value_( static_cast<long>( c ) ) { |
142 | -} |
143 | - |
144 | -inline Decimal::Decimal( signed char c ) : value_( static_cast<long>( c ) ) { |
145 | -} |
146 | - |
147 | -inline Decimal::Decimal( short n ) : value_( static_cast<long>( n ) ) { |
148 | -} |
149 | - |
150 | -inline Decimal::Decimal( int n ) : value_( static_cast<long>( n ) ) { |
151 | -} |
152 | - |
153 | -inline Decimal::Decimal( long n ) : value_( n ) { |
154 | -} |
155 | - |
156 | -inline Decimal::Decimal( unsigned char c ) : value_( static_cast<long>( c ) ) { |
157 | -} |
158 | - |
159 | -inline Decimal::Decimal( unsigned short n ) : value_( static_cast<long>( n ) ) { |
160 | -} |
161 | - |
162 | -inline Decimal::Decimal( unsigned int n ) : value_( static_cast<long>( n ) ) { |
163 | -} |
164 | +#define ZORBA_DECIMAL_CTOR(T) \ |
165 | + inline Decimal::Decimal( T n ) : value_( static_cast<int_cast_type>( n ) ) { } |
166 | + |
167 | +ZORBA_DECIMAL_CTOR(char) |
168 | +ZORBA_DECIMAL_CTOR(signed char) |
169 | +ZORBA_DECIMAL_CTOR(short) |
170 | +ZORBA_DECIMAL_CTOR(int) |
171 | +ZORBA_DECIMAL_CTOR(long) |
172 | +ZORBA_DECIMAL_CTOR(unsigned char) |
173 | +ZORBA_DECIMAL_CTOR(unsigned short) |
174 | +ZORBA_DECIMAL_CTOR(unsigned int) |
175 | +#undef ZORBA_DECIMAL_CTOR |
176 | |
177 | inline Decimal::Decimal( char const *s ) { |
178 | parse( s, &value_ ); |
179 | @@ -296,12 +284,22 @@ |
180 | return *this; |
181 | } |
182 | |
183 | -template<typename A> inline |
184 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,Decimal&>::type |
185 | -Decimal::operator=( A n ) { |
186 | - value_ = static_cast<long>( n ); |
187 | - return *this; |
188 | -} |
189 | +#define ZORBA_DECIMAL_OP(T) \ |
190 | + inline Decimal& Decimal::operator=( T n ) { \ |
191 | + value_ = static_cast<int_cast_type>( n ); \ |
192 | + return *this; \ |
193 | + } |
194 | + |
195 | +ZORBA_DECIMAL_OP(signed char) |
196 | +ZORBA_DECIMAL_OP(char) |
197 | +ZORBA_DECIMAL_OP(short) |
198 | +ZORBA_DECIMAL_OP(int) |
199 | +ZORBA_DECIMAL_OP(long) |
200 | +ZORBA_DECIMAL_OP(unsigned char) |
201 | +ZORBA_DECIMAL_OP(unsigned short) |
202 | +ZORBA_DECIMAL_OP(unsigned int) |
203 | +ZORBA_DECIMAL_OP(unsigned long) |
204 | +#undef ZORBA_DECIMAL_OP |
205 | |
206 | inline Decimal& Decimal::operator=( char const *s ) { |
207 | parse( s, &value_ ); |
208 | |
209 | === modified file 'src/zorbatypes/floatimpl.cpp' |
210 | --- src/zorbatypes/floatimpl.cpp 2012-04-16 20:56:43 +0000 |
211 | +++ src/zorbatypes/floatimpl.cpp 2012-04-17 18:33:19 +0000 |
212 | @@ -32,10 +32,10 @@ |
213 | |
214 | #ifdef ZORBA_WITH_BIG_INTEGER |
215 | # define TEMPLATE_DECL(T) /* nothing */ |
216 | -# define INTEGER_IMPL(T) IntegerImpl |
217 | +# define INTEGER_IMPL(I) IntegerImpl |
218 | #else |
219 | -# define TEMPLATE_DECL(T) template<typename T> |
220 | -# define INTEGER_IMPL(T) IntegerImpl<T> |
221 | +# define TEMPLATE_DECL(T) template<typename T> /* spacer */ |
222 | +# define INTEGER_IMPL(I) IntegerImpl<I> /* spacer */ |
223 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
224 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) |
225 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) |
226 | |
227 | === modified file 'src/zorbatypes/floatimpl.h' |
228 | --- src/zorbatypes/floatimpl.h 2012-04-16 20:56:43 +0000 |
229 | +++ src/zorbatypes/floatimpl.h 2012-04-17 18:33:19 +0000 |
230 | @@ -33,8 +33,8 @@ |
231 | # define TEMPLATE_DECL(I) /* nothing */ |
232 | # define INTEGER_IMPL(I) IntegerImpl |
233 | #else |
234 | -# define TEMPLATE_DECL(I) template<typename I> |
235 | -# define INTEGER_IMPL(I) IntegerImpl<I> |
236 | +# define TEMPLATE_DECL(I) template<typename I> /* spacer */ |
237 | +# define INTEGER_IMPL(I) IntegerImpl<I> /* spacer */ |
238 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
239 | |
240 | namespace zorba { |
241 | @@ -109,17 +109,19 @@ |
242 | template<typename FloatType2> |
243 | FloatImpl& operator=( FloatImpl<FloatType2> const &f ); |
244 | |
245 | - /** |
246 | - * For every built-in arithmetic type A, assign to this %FloatImpl. |
247 | - * |
248 | - * @tparam A The built-in arithmetic type. |
249 | - * @param n The arithmetic value to assign. |
250 | - * @return Returns \c *this. |
251 | - */ |
252 | - template<typename A> |
253 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
254 | - FloatImpl&>::type |
255 | - operator=( A n ); |
256 | + FloatImpl& operator=( char c ); |
257 | + FloatImpl& operator=( signed char c ); |
258 | + FloatImpl& operator=( short n ); |
259 | + FloatImpl& operator=( int n ); |
260 | + FloatImpl& operator=( long n ); |
261 | + FloatImpl& operator=( long long n ); |
262 | + FloatImpl& operator=( unsigned char c ); |
263 | + FloatImpl& operator=( unsigned short n ); |
264 | + FloatImpl& operator=( unsigned int n ); |
265 | + FloatImpl& operator=( unsigned long n ); |
266 | + FloatImpl& operator=( unsigned long long n ); |
267 | + FloatImpl& operator=( float n ); |
268 | + FloatImpl& operator=( double n ); |
269 | |
270 | FloatImpl& operator=( char const *s ); |
271 | FloatImpl& operator=( Decimal const &d ); |
272 | @@ -129,17 +131,74 @@ |
273 | |
274 | ////////// arithmetic operators ///////////////////////////////////////////// |
275 | |
276 | -#define ZORBA_FLOAT_OP(OP) \ |
277 | - template<typename A> \ |
278 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
279 | - FloatImpl&>::type \ |
280 | - operator OP( A n ) |
281 | +#define ZORBA_FLOAT_OP(OP,T) \ |
282 | + FloatImpl& operator OP( T n ) |
283 | |
284 | - ZORBA_FLOAT_OP(+=); |
285 | - ZORBA_FLOAT_OP(-=); |
286 | - ZORBA_FLOAT_OP(*=); |
287 | - ZORBA_FLOAT_OP(/=); |
288 | - ZORBA_FLOAT_OP(%=); |
289 | + ZORBA_FLOAT_OP(+=,char); |
290 | + ZORBA_FLOAT_OP(-=,char); |
291 | + ZORBA_FLOAT_OP(*=,char); |
292 | + ZORBA_FLOAT_OP(/=,char); |
293 | + ZORBA_FLOAT_OP(%=,char); |
294 | + ZORBA_FLOAT_OP(+=,signed char); |
295 | + ZORBA_FLOAT_OP(-=,signed char); |
296 | + ZORBA_FLOAT_OP(*=,signed char); |
297 | + ZORBA_FLOAT_OP(/=,signed char); |
298 | + ZORBA_FLOAT_OP(%=,signed char); |
299 | + ZORBA_FLOAT_OP(+=,short); |
300 | + ZORBA_FLOAT_OP(-=,short); |
301 | + ZORBA_FLOAT_OP(*=,short); |
302 | + ZORBA_FLOAT_OP(/=,short); |
303 | + ZORBA_FLOAT_OP(%=,short); |
304 | + ZORBA_FLOAT_OP(+=,int); |
305 | + ZORBA_FLOAT_OP(-=,int); |
306 | + ZORBA_FLOAT_OP(*=,int); |
307 | + ZORBA_FLOAT_OP(/=,int); |
308 | + ZORBA_FLOAT_OP(%=,int); |
309 | + ZORBA_FLOAT_OP(+=,long); |
310 | + ZORBA_FLOAT_OP(-=,long); |
311 | + ZORBA_FLOAT_OP(*=,long); |
312 | + ZORBA_FLOAT_OP(/=,long); |
313 | + ZORBA_FLOAT_OP(%=,long); |
314 | + ZORBA_FLOAT_OP(+=,long long); |
315 | + ZORBA_FLOAT_OP(-=,long long); |
316 | + ZORBA_FLOAT_OP(*=,long long); |
317 | + ZORBA_FLOAT_OP(/=,long long); |
318 | + ZORBA_FLOAT_OP(%=,long long); |
319 | + ZORBA_FLOAT_OP(+=,unsigned char); |
320 | + ZORBA_FLOAT_OP(-=,unsigned char); |
321 | + ZORBA_FLOAT_OP(*=,unsigned char); |
322 | + ZORBA_FLOAT_OP(/=,unsigned char); |
323 | + ZORBA_FLOAT_OP(%=,unsigned char); |
324 | + ZORBA_FLOAT_OP(+=,unsigned short); |
325 | + ZORBA_FLOAT_OP(-=,unsigned short); |
326 | + ZORBA_FLOAT_OP(*=,unsigned short); |
327 | + ZORBA_FLOAT_OP(/=,unsigned short); |
328 | + ZORBA_FLOAT_OP(%=,unsigned short); |
329 | + ZORBA_FLOAT_OP(+=,unsigned int); |
330 | + ZORBA_FLOAT_OP(-=,unsigned int); |
331 | + ZORBA_FLOAT_OP(*=,unsigned int); |
332 | + ZORBA_FLOAT_OP(/=,unsigned int); |
333 | + ZORBA_FLOAT_OP(%=,unsigned int); |
334 | + ZORBA_FLOAT_OP(+=,unsigned long); |
335 | + ZORBA_FLOAT_OP(-=,unsigned long); |
336 | + ZORBA_FLOAT_OP(*=,unsigned long); |
337 | + ZORBA_FLOAT_OP(/=,unsigned long); |
338 | + ZORBA_FLOAT_OP(%=,unsigned long); |
339 | + ZORBA_FLOAT_OP(+=,unsigned long long); |
340 | + ZORBA_FLOAT_OP(-=,unsigned long long); |
341 | + ZORBA_FLOAT_OP(*=,unsigned long long); |
342 | + ZORBA_FLOAT_OP(/=,unsigned long long); |
343 | + ZORBA_FLOAT_OP(%=,unsigned long long); |
344 | + ZORBA_FLOAT_OP(+=,float); |
345 | + ZORBA_FLOAT_OP(-=,float); |
346 | + ZORBA_FLOAT_OP(*=,float); |
347 | + ZORBA_FLOAT_OP(/=,float); |
348 | + ZORBA_FLOAT_OP(%=,float); |
349 | + ZORBA_FLOAT_OP(+=,double); |
350 | + ZORBA_FLOAT_OP(-=,double); |
351 | + ZORBA_FLOAT_OP(*=,double); |
352 | + ZORBA_FLOAT_OP(/=,double); |
353 | + ZORBA_FLOAT_OP(%=,double); |
354 | #undef ZORBA_FLOAT_OP |
355 | |
356 | #define ZORBA_FLOAT_OP(OP) \ |
357 | @@ -371,14 +430,28 @@ |
358 | return *this; |
359 | } |
360 | |
361 | -template<typename F> template<typename A> inline |
362 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
363 | - FloatImpl<F>&>::type |
364 | -FloatImpl<F>::operator=( A n ) { |
365 | - value_ = static_cast<F>( n ); |
366 | - precision_ = max_precision(); |
367 | - return *this; |
368 | -} |
369 | +#define ZORBA_FLOAT_OP(T) \ |
370 | + template<typename F> \ |
371 | + inline FloatImpl<F>& FloatImpl<F>::operator=( T n ) { \ |
372 | + value_ = static_cast<F>( n ); \ |
373 | + precision_ = max_precision(); \ |
374 | + return *this; \ |
375 | + } |
376 | + |
377 | +ZORBA_FLOAT_OP(char) |
378 | +ZORBA_FLOAT_OP(signed char) |
379 | +ZORBA_FLOAT_OP(short) |
380 | +ZORBA_FLOAT_OP(int) |
381 | +ZORBA_FLOAT_OP(long) |
382 | +ZORBA_FLOAT_OP(long long) |
383 | +ZORBA_FLOAT_OP(unsigned char) |
384 | +ZORBA_FLOAT_OP(unsigned short) |
385 | +ZORBA_FLOAT_OP(unsigned int) |
386 | +ZORBA_FLOAT_OP(unsigned long) |
387 | +ZORBA_FLOAT_OP(unsigned long long) |
388 | +ZORBA_FLOAT_OP(float) |
389 | +ZORBA_FLOAT_OP(double) |
390 | +#undef ZORBA_FLOAT_OP |
391 | |
392 | template<typename F> |
393 | inline FloatImpl<F>& FloatImpl<F>::operator=( char const *s ) { |
394 | @@ -388,40 +461,96 @@ |
395 | |
396 | ////////// arithmetic operators /////////////////////////////////////////////// |
397 | |
398 | -#define ZORBA_FLOAT_OP(OP) \ |
399 | - template<typename F,typename A> inline \ |
400 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
401 | - FloatImpl<F> >::type \ |
402 | - operator OP( FloatImpl<F> const &f, A n ) { \ |
403 | +#define ZORBA_FLOAT_OP(OP,T) \ |
404 | + template<typename F> \ |
405 | + inline FloatImpl<F> operator OP( FloatImpl<F> const &f, T n ) { \ |
406 | return FloatImpl<F>( f.getNumber() OP static_cast<F>( n ) ); \ |
407 | } \ |
408 | \ |
409 | - template<typename F,typename A> inline \ |
410 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
411 | - FloatImpl<F> >::type \ |
412 | - operator OP( A n, FloatImpl<F> const &f ) { \ |
413 | + template<typename F> \ |
414 | + inline FloatImpl<F> operator OP( T n, FloatImpl<F> const &f ) { \ |
415 | return FloatImpl<F>( static_cast<F>( n ) OP f.getNumber() ); \ |
416 | } |
417 | |
418 | -ZORBA_FLOAT_OP(+) |
419 | -ZORBA_FLOAT_OP(-) |
420 | -ZORBA_FLOAT_OP(*) |
421 | -ZORBA_FLOAT_OP(/) |
422 | -#undef ZORBA_FLOAT_OP |
423 | - |
424 | -template<typename F,typename A> inline |
425 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
426 | - FloatImpl<F> >::type |
427 | -operator%( FloatImpl<F> const &f, A n ) { |
428 | - return FloatImpl<F>( std::fmod( f.getNumber(), static_cast<F>( n ) ) ); |
429 | -} |
430 | - |
431 | -template<typename F,typename A> inline |
432 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
433 | - FloatImpl<F> >::type |
434 | -operator%( A n, FloatImpl<F> const &f ) { |
435 | - return FloatImpl<F>( std::fmod( static_cast<F>( n ), f.getNumber() ) ); |
436 | -} |
437 | +ZORBA_FLOAT_OP(+,char) |
438 | +ZORBA_FLOAT_OP(-,char) |
439 | +ZORBA_FLOAT_OP(*,char) |
440 | +ZORBA_FLOAT_OP(/,char) |
441 | +ZORBA_FLOAT_OP(+,signed char) |
442 | +ZORBA_FLOAT_OP(-,signed char) |
443 | +ZORBA_FLOAT_OP(*,signed char) |
444 | +ZORBA_FLOAT_OP(/,signed char) |
445 | +ZORBA_FLOAT_OP(+,short) |
446 | +ZORBA_FLOAT_OP(-,short) |
447 | +ZORBA_FLOAT_OP(*,short) |
448 | +ZORBA_FLOAT_OP(/,short) |
449 | +ZORBA_FLOAT_OP(+,int) |
450 | +ZORBA_FLOAT_OP(-,int) |
451 | +ZORBA_FLOAT_OP(*,int) |
452 | +ZORBA_FLOAT_OP(/,int) |
453 | +ZORBA_FLOAT_OP(+,long) |
454 | +ZORBA_FLOAT_OP(-,long) |
455 | +ZORBA_FLOAT_OP(*,long) |
456 | +ZORBA_FLOAT_OP(/,long) |
457 | +ZORBA_FLOAT_OP(+,long long) |
458 | +ZORBA_FLOAT_OP(-,long long) |
459 | +ZORBA_FLOAT_OP(*,long long) |
460 | +ZORBA_FLOAT_OP(/,long long) |
461 | +ZORBA_FLOAT_OP(+,unsigned char) |
462 | +ZORBA_FLOAT_OP(-,unsigned char) |
463 | +ZORBA_FLOAT_OP(*,unsigned char) |
464 | +ZORBA_FLOAT_OP(/,unsigned char) |
465 | +ZORBA_FLOAT_OP(+,unsigned short) |
466 | +ZORBA_FLOAT_OP(-,unsigned short) |
467 | +ZORBA_FLOAT_OP(*,unsigned short) |
468 | +ZORBA_FLOAT_OP(/,unsigned short) |
469 | +ZORBA_FLOAT_OP(+,unsigned int) |
470 | +ZORBA_FLOAT_OP(-,unsigned int) |
471 | +ZORBA_FLOAT_OP(*,unsigned int) |
472 | +ZORBA_FLOAT_OP(/,unsigned int) |
473 | +ZORBA_FLOAT_OP(+,unsigned long) |
474 | +ZORBA_FLOAT_OP(-,unsigned long) |
475 | +ZORBA_FLOAT_OP(*,unsigned long) |
476 | +ZORBA_FLOAT_OP(/,unsigned long) |
477 | +ZORBA_FLOAT_OP(+,unsigned long long) |
478 | +ZORBA_FLOAT_OP(-,unsigned long long) |
479 | +ZORBA_FLOAT_OP(*,unsigned long long) |
480 | +ZORBA_FLOAT_OP(/,unsigned long long) |
481 | +ZORBA_FLOAT_OP(+,float) |
482 | +ZORBA_FLOAT_OP(-,float) |
483 | +ZORBA_FLOAT_OP(*,float) |
484 | +ZORBA_FLOAT_OP(/,float) |
485 | +ZORBA_FLOAT_OP(+,double) |
486 | +ZORBA_FLOAT_OP(-,double) |
487 | +ZORBA_FLOAT_OP(*,double) |
488 | +ZORBA_FLOAT_OP(/,double) |
489 | +#undef ZORBA_FLOAT_OP |
490 | + |
491 | +#define ZORBA_FLOAT_OP(T) \ |
492 | + template<typename F> \ |
493 | + inline FloatImpl<F> operator%( FloatImpl<F> const &f, T n ) { \ |
494 | + return FloatImpl<F>( std::fmod( f.getNumber(), static_cast<F>( n ) ) ); \ |
495 | + } \ |
496 | + \ |
497 | + template<typename F> \ |
498 | + inline FloatImpl<F> operator%( T n, FloatImpl<F> const &f ) { \ |
499 | + return FloatImpl<F>( std::fmod( static_cast<F>( n ), f.getNumber() ) ); \ |
500 | + } |
501 | + |
502 | +ZORBA_FLOAT_OP(signed char) |
503 | +ZORBA_FLOAT_OP(char) |
504 | +ZORBA_FLOAT_OP(short) |
505 | +ZORBA_FLOAT_OP(int) |
506 | +ZORBA_FLOAT_OP(long) |
507 | +ZORBA_FLOAT_OP(long long) |
508 | +ZORBA_FLOAT_OP(unsigned char) |
509 | +ZORBA_FLOAT_OP(unsigned short) |
510 | +ZORBA_FLOAT_OP(unsigned int) |
511 | +ZORBA_FLOAT_OP(unsigned long) |
512 | +ZORBA_FLOAT_OP(unsigned long long) |
513 | +ZORBA_FLOAT_OP(float) |
514 | +ZORBA_FLOAT_OP(double) |
515 | +#undef ZORBA_FLOAT_OP |
516 | |
517 | #define ZORBA_FLOAT_OP(OP) \ |
518 | template<typename F> inline \ |
519 | @@ -440,20 +569,87 @@ |
520 | return FloatImpl<F>( std::fmod( f.getNumber(), g.getNumber() ) ); |
521 | } |
522 | |
523 | -#define ZORBA_FLOAT_OP(OP) \ |
524 | - template<typename F> template<typename A> inline \ |
525 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
526 | - FloatImpl<F>&>::type \ |
527 | - FloatImpl<F>::operator OP( A n ) { \ |
528 | - value_ OP static_cast<F>( n ); \ |
529 | - return *this; \ |
530 | - } |
531 | - |
532 | -ZORBA_FLOAT_OP(+=) |
533 | -ZORBA_FLOAT_OP(-=) |
534 | -ZORBA_FLOAT_OP(*=) |
535 | -ZORBA_FLOAT_OP(/=) |
536 | -ZORBA_FLOAT_OP(%=) |
537 | +#define ZORBA_FLOAT_OP(OP,T) \ |
538 | + template<typename F> \ |
539 | + inline FloatImpl<F>& FloatImpl<F>::operator OP( T n ) { \ |
540 | + value_ OP static_cast<F>( n ); \ |
541 | + return *this; \ |
542 | + } |
543 | + |
544 | +ZORBA_FLOAT_OP(+=,char) |
545 | +ZORBA_FLOAT_OP(-=,char) |
546 | +ZORBA_FLOAT_OP(*=,char) |
547 | +ZORBA_FLOAT_OP(/=,char) |
548 | +ZORBA_FLOAT_OP(+=,signed char) |
549 | +ZORBA_FLOAT_OP(-=,signed char) |
550 | +ZORBA_FLOAT_OP(*=,signed char) |
551 | +ZORBA_FLOAT_OP(/=,signed char) |
552 | +ZORBA_FLOAT_OP(+=,short) |
553 | +ZORBA_FLOAT_OP(-=,short) |
554 | +ZORBA_FLOAT_OP(*=,short) |
555 | +ZORBA_FLOAT_OP(/=,short) |
556 | +ZORBA_FLOAT_OP(+=,int) |
557 | +ZORBA_FLOAT_OP(-=,int) |
558 | +ZORBA_FLOAT_OP(*=,int) |
559 | +ZORBA_FLOAT_OP(/=,int) |
560 | +ZORBA_FLOAT_OP(+=,long) |
561 | +ZORBA_FLOAT_OP(-=,long) |
562 | +ZORBA_FLOAT_OP(*=,long) |
563 | +ZORBA_FLOAT_OP(/=,long) |
564 | +ZORBA_FLOAT_OP(+=,long long) |
565 | +ZORBA_FLOAT_OP(-=,long long) |
566 | +ZORBA_FLOAT_OP(*=,long long) |
567 | +ZORBA_FLOAT_OP(/=,long long) |
568 | +ZORBA_FLOAT_OP(+=,unsigned char) |
569 | +ZORBA_FLOAT_OP(-=,unsigned char) |
570 | +ZORBA_FLOAT_OP(*=,unsigned char) |
571 | +ZORBA_FLOAT_OP(/=,unsigned char) |
572 | +ZORBA_FLOAT_OP(+=,unsigned short) |
573 | +ZORBA_FLOAT_OP(-=,unsigned short) |
574 | +ZORBA_FLOAT_OP(*=,unsigned short) |
575 | +ZORBA_FLOAT_OP(/=,unsigned short) |
576 | +ZORBA_FLOAT_OP(+=,unsigned int) |
577 | +ZORBA_FLOAT_OP(-=,unsigned int) |
578 | +ZORBA_FLOAT_OP(*=,unsigned int) |
579 | +ZORBA_FLOAT_OP(/=,unsigned int) |
580 | +ZORBA_FLOAT_OP(+=,unsigned long) |
581 | +ZORBA_FLOAT_OP(-=,unsigned long) |
582 | +ZORBA_FLOAT_OP(*=,unsigned long) |
583 | +ZORBA_FLOAT_OP(/=,unsigned long) |
584 | +ZORBA_FLOAT_OP(+=,unsigned long long) |
585 | +ZORBA_FLOAT_OP(-=,unsigned long long) |
586 | +ZORBA_FLOAT_OP(*=,unsigned long long) |
587 | +ZORBA_FLOAT_OP(/=,unsigned long long) |
588 | +ZORBA_FLOAT_OP(+=,float) |
589 | +ZORBA_FLOAT_OP(-=,float) |
590 | +ZORBA_FLOAT_OP(*=,float) |
591 | +ZORBA_FLOAT_OP(/=,float) |
592 | +ZORBA_FLOAT_OP(+=,double) |
593 | +ZORBA_FLOAT_OP(-=,double) |
594 | +ZORBA_FLOAT_OP(*=,double) |
595 | +ZORBA_FLOAT_OP(/=,double) |
596 | +#undef ZORBA_FLOAT_OP |
597 | + |
598 | +#define ZORBA_FLOAT_OP(T) \ |
599 | + template<typename F> \ |
600 | + inline FloatImpl<F>& FloatImpl<F>::operator%=( T n ) { \ |
601 | + value_ = std::fmod( getNumber(), static_cast<F>( n ) ); \ |
602 | + return *this; \ |
603 | + } |
604 | + |
605 | +ZORBA_FLOAT_OP(signed char) |
606 | +ZORBA_FLOAT_OP(char) |
607 | +ZORBA_FLOAT_OP(short) |
608 | +ZORBA_FLOAT_OP(int) |
609 | +ZORBA_FLOAT_OP(long) |
610 | +ZORBA_FLOAT_OP(long long) |
611 | +ZORBA_FLOAT_OP(unsigned char) |
612 | +ZORBA_FLOAT_OP(unsigned short) |
613 | +ZORBA_FLOAT_OP(unsigned int) |
614 | +ZORBA_FLOAT_OP(unsigned long) |
615 | +ZORBA_FLOAT_OP(unsigned long long) |
616 | +ZORBA_FLOAT_OP(float) |
617 | +ZORBA_FLOAT_OP(double) |
618 | #undef ZORBA_FLOAT_OP |
619 | |
620 | #define ZORBA_FLOAT_OP(OP) \ |
621 | |
622 | === modified file 'src/zorbatypes/integer.cpp' |
623 | --- src/zorbatypes/integer.cpp 2012-04-16 20:56:43 +0000 |
624 | +++ src/zorbatypes/integer.cpp 2012-04-17 18:33:19 +0000 |
625 | @@ -31,8 +31,8 @@ |
626 | # define TEMPLATE_DECL(T) /* nothing */ |
627 | # define INTEGER_IMPL(T) IntegerImpl |
628 | #else |
629 | -# define TEMPLATE_DECL(T) template<typename T> |
630 | -# define INTEGER_IMPL(T) IntegerImpl<T> |
631 | +# define TEMPLATE_DECL(T) template<typename T> /* spacer */ |
632 | +# define INTEGER_IMPL(T) IntegerImpl<T> /* spacer */ |
633 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
634 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) |
635 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) |
636 | @@ -55,13 +55,12 @@ |
637 | |
638 | /////////////////////////////////////////////////////////////////////////////// |
639 | |
640 | +TEMPLATE_DECL(I) |
641 | +void INTEGER_IMPL(I)::parse( char const *s ) { |
642 | #ifdef ZORBA_WITH_BIG_INTEGER |
643 | -void IntegerImpl::parse( char const *s ) { |
644 | Decimal::parse( s, &value_, Decimal::parse_integer ); |
645 | #else |
646 | -template<typename IntType> |
647 | -void IntegerImpl<IntType>::parse( char const *s ) { |
648 | - value_type const temp = ztd::aton<value_type>( s ); |
649 | + value_type const temp( ztd::aton<value_type>( s ) ); |
650 | if ( is_too_big( temp ) ) |
651 | throw std::invalid_argument( |
652 | BUILD_STRING( '"', temp, "\": unsigned integer too big" ) |
653 | @@ -177,6 +176,85 @@ |
654 | #undef ZORBA_INTEGER_OP |
655 | #undef ZORBA_INSTANTIATE |
656 | |
657 | +#ifdef ZORBA_WITH_BIG_INTEGER |
658 | + |
659 | +#define ZORBA_INTEGER_OP(OP,T) \ |
660 | + IntegerImpl operator OP( IntegerImpl const &i, T n ) { \ |
661 | + ztd::itoa_buf_type buf; \ |
662 | + return i.value_ OP IntegerImpl::value_type( ztd::itoa( n, buf ) ); \ |
663 | + } \ |
664 | + IntegerImpl operator OP( T n, IntegerImpl const &i ) { \ |
665 | + ztd::itoa_buf_type buf; \ |
666 | + return IntegerImpl::value_type( ztd::itoa( n, buf ) ) OP i.value_; \ |
667 | + } |
668 | + |
669 | +ZORBA_INTEGER_OP(+,long long) |
670 | +ZORBA_INTEGER_OP(-,long long) |
671 | +ZORBA_INTEGER_OP(*,long long) |
672 | +ZORBA_INTEGER_OP(%,long long) |
673 | +ZORBA_INTEGER_OP(+,unsigned long) |
674 | +ZORBA_INTEGER_OP(-,unsigned long) |
675 | +ZORBA_INTEGER_OP(*,unsigned long) |
676 | +ZORBA_INTEGER_OP(%,unsigned long) |
677 | +ZORBA_INTEGER_OP(+,unsigned long long) |
678 | +ZORBA_INTEGER_OP(-,unsigned long long) |
679 | +ZORBA_INTEGER_OP(*,unsigned long long) |
680 | +ZORBA_INTEGER_OP(%,unsigned long long) |
681 | +#undef ZORBA_INTEGER_OP |
682 | + |
683 | +#define ZORBA_INTEGER_OP(T) \ |
684 | + IntegerImpl operator/( IntegerImpl const &i, T n ) { \ |
685 | + ztd::itoa_buf_type buf; \ |
686 | + IntegerImpl::value_type const temp( ztd::itoa( n, buf ) ); \ |
687 | + return IntegerImpl::ftoi( i.value_ / temp ); \ |
688 | + } \ |
689 | + IntegerImpl operator/( T n, IntegerImpl const &i ) { \ |
690 | + ztd::itoa_buf_type buf; \ |
691 | + IntegerImpl::value_type const temp( ztd::itoa( n, buf ) ); \ |
692 | + return IntegerImpl::ftoi( temp / i.value_ ); \ |
693 | + } |
694 | + |
695 | +ZORBA_INTEGER_OP(long long) |
696 | +ZORBA_INTEGER_OP(unsigned long) |
697 | +ZORBA_INTEGER_OP(unsigned long long) |
698 | +#undef ZORBA_INTEGER_OP |
699 | + |
700 | +#define ZORBA_INTEGER_OP(OP,T) \ |
701 | + IntegerImpl& IntegerImpl::operator OP( T n ) { \ |
702 | + ztd::itoa_buf_type buf; \ |
703 | + value_type const temp( ztd::itoa( n, buf ) ); \ |
704 | + value_ OP temp; \ |
705 | + return *this; \ |
706 | + } |
707 | + |
708 | +ZORBA_INTEGER_OP(+=,long long) |
709 | +ZORBA_INTEGER_OP(-=,long long) |
710 | +ZORBA_INTEGER_OP(*=,long long) |
711 | +ZORBA_INTEGER_OP(%=,long long) |
712 | +ZORBA_INTEGER_OP(+=,unsigned long) |
713 | +ZORBA_INTEGER_OP(-=,unsigned long) |
714 | +ZORBA_INTEGER_OP(*=,unsigned long) |
715 | +ZORBA_INTEGER_OP(%=,unsigned long) |
716 | +ZORBA_INTEGER_OP(+=,unsigned long long) |
717 | +ZORBA_INTEGER_OP(-=,unsigned long long) |
718 | +ZORBA_INTEGER_OP(*=,unsigned long long) |
719 | +ZORBA_INTEGER_OP(%=,unsigned long long) |
720 | +#undef ZORBA_INTEGER_OP |
721 | + |
722 | +#define ZORBA_INTEGER_OP(T) \ |
723 | + IntegerImpl& IntegerImpl::operator/=( T n ) { \ |
724 | + ztd::itoa_buf_type buf; \ |
725 | + value_type const temp( ztd::itoa( n, buf ) ); \ |
726 | + value_ = ftoi( value_ / temp ); \ |
727 | + return *this; \ |
728 | + } |
729 | + |
730 | +ZORBA_INTEGER_OP(long long) |
731 | +ZORBA_INTEGER_OP(unsigned long) |
732 | +ZORBA_INTEGER_OP(unsigned long long) |
733 | +#undef ZORBA_INTEGER_OP |
734 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
735 | + |
736 | ////////// relational operators /////////////////////////////////////////////// |
737 | |
738 | TEMPLATE_DECL(T) |
739 | @@ -197,7 +275,40 @@ |
740 | ZORBA_INTEGER_OP(>=) |
741 | #undef ZORBA_INTEGER_OP |
742 | |
743 | -#ifndef ZORBA_WITH_BIG_INTEGER |
744 | +#ifdef ZORBA_WITH_BIG_INTEGER |
745 | + |
746 | +#define ZORBA_INTEGER_OP(OP,T) \ |
747 | + bool operator OP( IntegerImpl const &i, T n ) { \ |
748 | + ztd::itoa_buf_type buf; \ |
749 | + return i.value_ OP IntegerImpl::value_type( ztd::itoa( n, buf ) ); \ |
750 | + } \ |
751 | + \ |
752 | + bool operator OP( T n, IntegerImpl const &i ) { \ |
753 | + ztd::itoa_buf_type buf; \ |
754 | + return IntegerImpl::value_type( ztd::itoa( n, buf ) ) OP i.value_; \ |
755 | + } |
756 | + |
757 | +ZORBA_INTEGER_OP(==,long long) |
758 | +ZORBA_INTEGER_OP(!=,long long) |
759 | +ZORBA_INTEGER_OP(< ,long long) |
760 | +ZORBA_INTEGER_OP(<=,long long) |
761 | +ZORBA_INTEGER_OP(> ,long long) |
762 | +ZORBA_INTEGER_OP(>=,long long) |
763 | +ZORBA_INTEGER_OP(==,unsigned long) |
764 | +ZORBA_INTEGER_OP(!=,unsigned long) |
765 | +ZORBA_INTEGER_OP(< ,unsigned long) |
766 | +ZORBA_INTEGER_OP(<=,unsigned long) |
767 | +ZORBA_INTEGER_OP(> ,unsigned long) |
768 | +ZORBA_INTEGER_OP(>=,unsigned long) |
769 | +ZORBA_INTEGER_OP(==,unsigned long long) |
770 | +ZORBA_INTEGER_OP(!=,unsigned long long) |
771 | +ZORBA_INTEGER_OP(< ,unsigned long long) |
772 | +ZORBA_INTEGER_OP(<=,unsigned long long) |
773 | +ZORBA_INTEGER_OP(> ,unsigned long long) |
774 | +ZORBA_INTEGER_OP(>=,unsigned long long) |
775 | + |
776 | +#else /* ZORBA_WITH_BIG_INTEGER */ |
777 | + |
778 | #define ZORBA_INSTANTIATE(OP) \ |
779 | template bool operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \ |
780 | template bool operator OP( INTEGER_IMPL_ULL const&, Decimal const& ) |
781 | @@ -209,6 +320,7 @@ |
782 | ZORBA_INSTANTIATE(> ); |
783 | ZORBA_INSTANTIATE(>=); |
784 | #undef ZORBA_INSTANTIATE |
785 | + |
786 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
787 | |
788 | ////////// math functions ///////////////////////////////////////////////////// |
789 | |
790 | === modified file 'src/zorbatypes/integer.h' |
791 | --- src/zorbatypes/integer.h 2012-04-16 20:56:43 +0000 |
792 | +++ src/zorbatypes/integer.h 2012-04-17 18:33:19 +0000 |
793 | @@ -32,16 +32,14 @@ |
794 | #include "zstring.h" |
795 | |
796 | #ifdef ZORBA_WITH_BIG_INTEGER |
797 | -# define TEMPLATE_DECL(I) /* nothing */ |
798 | -# define TEMPLATE_DECL2(I,A) template<typename A> |
799 | -# define INTEGER_IMPL(I) IntegerImpl |
800 | +# define TEMPLATE_DECL(I) /* nothing */ |
801 | +# define INTEGER_IMPL(I) IntegerImpl |
802 | #else |
803 | -# define TEMPLATE_DECL(I) template<typename I> |
804 | -# define TEMPLATE_DECL2(I,A) template<typename I,typename A> |
805 | -# define INTEGER_IMPL(I) IntegerImpl<I> |
806 | +# define TEMPLATE_DECL(I) template<typename I> /* spacer */ |
807 | +# define INTEGER_IMPL(I) IntegerImpl<I> /* spacer */ |
808 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
809 | -#define INTEGER_IMPL_LL INTEGER_IMPL(long long) |
810 | -#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) |
811 | +#define INTEGER_IMPL_LL INTEGER_IMPL(long long) |
812 | +#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) |
813 | |
814 | namespace zorba { |
815 | |
816 | @@ -127,22 +125,19 @@ |
817 | TEMPLATE_DECL(IntType2) |
818 | IntegerImpl& operator=( INTEGER_IMPL(IntType2) const &i ); |
819 | |
820 | - /** |
821 | - * For every built-in arithmetic type A, assign to this %IntegerImpl. |
822 | - * |
823 | - * @tparam A The built-in arithmetic type. |
824 | - * @param n The arithmetic value to assign. |
825 | - * @return Returns \c *this. |
826 | - */ |
827 | - template<typename A> |
828 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
829 | - IntegerImpl&>::type |
830 | - operator=( A n ); |
831 | - |
832 | - // These arithmetic types have to be special-cased. |
833 | - IntegerImpl& operator=( long long ); |
834 | - IntegerImpl& operator=( unsigned long ); |
835 | - IntegerImpl& operator=( unsigned long long ); |
836 | + IntegerImpl& operator=( char c ); |
837 | + IntegerImpl& operator=( signed char c ); |
838 | + IntegerImpl& operator=( short n ); |
839 | + IntegerImpl& operator=( int n ); |
840 | + IntegerImpl& operator=( long n ); |
841 | + IntegerImpl& operator=( long long n ); |
842 | + IntegerImpl& operator=( unsigned char c ); |
843 | + IntegerImpl& operator=( unsigned short n ); |
844 | + IntegerImpl& operator=( unsigned int n ); |
845 | + IntegerImpl& operator=( unsigned long n ); |
846 | + IntegerImpl& operator=( unsigned long long n ); |
847 | + IntegerImpl& operator=( float n ); |
848 | + IntegerImpl& operator=( double n ); |
849 | |
850 | IntegerImpl& operator=( char const *s ); |
851 | IntegerImpl& operator=( Decimal const &d ); |
852 | @@ -169,22 +164,78 @@ |
853 | ZORBA_INTEGER_OP(%); |
854 | #undef ZORBA_INTEGER_OP |
855 | |
856 | -#define ZORBA_INTEGER_OP(OP) \ |
857 | - TEMPLATE_DECL2(I,A) friend \ |
858 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
859 | - INTEGER_IMPL(I)>::type \ |
860 | - operator OP( INTEGER_IMPL(I) const&, A ); \ |
861 | - \ |
862 | - TEMPLATE_DECL2(I,A) friend \ |
863 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
864 | - INTEGER_IMPL(I)>::type \ |
865 | - operator OP( A, INTEGER_IMPL(I) const& ) |
866 | +#define ZORBA_INTEGER_OP(OP,T) \ |
867 | + TEMPLATE_DECL(I) friend \ |
868 | + INTEGER_IMPL(I) operator OP( INTEGER_IMPL(I) const&, T ); \ |
869 | + \ |
870 | + TEMPLATE_DECL(I) friend \ |
871 | + INTEGER_IMPL(I) operator OP( T, INTEGER_IMPL(I) const& ) |
872 | |
873 | - ZORBA_INTEGER_OP(+); |
874 | - ZORBA_INTEGER_OP(-); |
875 | - ZORBA_INTEGER_OP(*); |
876 | - ZORBA_INTEGER_OP(/); |
877 | - ZORBA_INTEGER_OP(%); |
878 | + ZORBA_INTEGER_OP(+,char); |
879 | + ZORBA_INTEGER_OP(-,char); |
880 | + ZORBA_INTEGER_OP(*,char); |
881 | + ZORBA_INTEGER_OP(/,char); |
882 | + ZORBA_INTEGER_OP(%,char); |
883 | + ZORBA_INTEGER_OP(+,signed char); |
884 | + ZORBA_INTEGER_OP(-,signed char); |
885 | + ZORBA_INTEGER_OP(*,signed char); |
886 | + ZORBA_INTEGER_OP(/,signed char); |
887 | + ZORBA_INTEGER_OP(%,signed char); |
888 | + ZORBA_INTEGER_OP(+,short); |
889 | + ZORBA_INTEGER_OP(-,short); |
890 | + ZORBA_INTEGER_OP(*,short); |
891 | + ZORBA_INTEGER_OP(/,short); |
892 | + ZORBA_INTEGER_OP(%,short); |
893 | + ZORBA_INTEGER_OP(+,int); |
894 | + ZORBA_INTEGER_OP(-,int); |
895 | + ZORBA_INTEGER_OP(*,int); |
896 | + ZORBA_INTEGER_OP(/,int); |
897 | + ZORBA_INTEGER_OP(%,int); |
898 | + ZORBA_INTEGER_OP(+,long); |
899 | + ZORBA_INTEGER_OP(-,long); |
900 | + ZORBA_INTEGER_OP(*,long); |
901 | + ZORBA_INTEGER_OP(/,long); |
902 | + ZORBA_INTEGER_OP(%,long); |
903 | + ZORBA_INTEGER_OP(+,long long); |
904 | + ZORBA_INTEGER_OP(-,long long); |
905 | + ZORBA_INTEGER_OP(*,long long); |
906 | + ZORBA_INTEGER_OP(/,long long); |
907 | + ZORBA_INTEGER_OP(%,long long); |
908 | + ZORBA_INTEGER_OP(+,unsigned char); |
909 | + ZORBA_INTEGER_OP(-,unsigned char); |
910 | + ZORBA_INTEGER_OP(*,unsigned char); |
911 | + ZORBA_INTEGER_OP(/,unsigned char); |
912 | + ZORBA_INTEGER_OP(%,unsigned char); |
913 | + ZORBA_INTEGER_OP(+,unsigned short); |
914 | + ZORBA_INTEGER_OP(-,unsigned short); |
915 | + ZORBA_INTEGER_OP(*,unsigned short); |
916 | + ZORBA_INTEGER_OP(/,unsigned short); |
917 | + ZORBA_INTEGER_OP(%,unsigned short); |
918 | + ZORBA_INTEGER_OP(+,unsigned int); |
919 | + ZORBA_INTEGER_OP(-,unsigned int); |
920 | + ZORBA_INTEGER_OP(*,unsigned int); |
921 | + ZORBA_INTEGER_OP(/,unsigned int); |
922 | + ZORBA_INTEGER_OP(%,unsigned int); |
923 | + ZORBA_INTEGER_OP(+,unsigned long); |
924 | + ZORBA_INTEGER_OP(-,unsigned long); |
925 | + ZORBA_INTEGER_OP(*,unsigned long); |
926 | + ZORBA_INTEGER_OP(/,unsigned long); |
927 | + ZORBA_INTEGER_OP(%,unsigned long); |
928 | + ZORBA_INTEGER_OP(+,unsigned long long); |
929 | + ZORBA_INTEGER_OP(-,unsigned long long); |
930 | + ZORBA_INTEGER_OP(*,unsigned long long); |
931 | + ZORBA_INTEGER_OP(/,unsigned long long); |
932 | + ZORBA_INTEGER_OP(%,unsigned long long); |
933 | + ZORBA_INTEGER_OP(+,float); |
934 | + ZORBA_INTEGER_OP(-,float); |
935 | + ZORBA_INTEGER_OP(*,float); |
936 | + ZORBA_INTEGER_OP(/,float); |
937 | + ZORBA_INTEGER_OP(%,float); |
938 | + ZORBA_INTEGER_OP(+,double); |
939 | + ZORBA_INTEGER_OP(-,double); |
940 | + ZORBA_INTEGER_OP(*,double); |
941 | + ZORBA_INTEGER_OP(/,double); |
942 | + ZORBA_INTEGER_OP(%,double); |
943 | #undef ZORBA_INTEGER_OP |
944 | |
945 | #define ZORBA_INTEGER_OP(OP,TYPE) \ |
946 | @@ -197,17 +248,74 @@ |
947 | ZORBA_INTEGER_OP(%=,IntegerImpl const&); |
948 | #undef ZORBA_INTEGER_OP |
949 | |
950 | -#define ZORBA_INTEGER_OP(OP) \ |
951 | - template<typename A> \ |
952 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
953 | - IntegerImpl&>::type \ |
954 | - operator OP( A ) |
955 | +#define ZORBA_INTEGER_OP(OP,T) \ |
956 | + IntegerImpl& operator OP( T ) |
957 | |
958 | - ZORBA_INTEGER_OP(+=); |
959 | - ZORBA_INTEGER_OP(-=); |
960 | - ZORBA_INTEGER_OP(*=); |
961 | - ZORBA_INTEGER_OP(/=); |
962 | - ZORBA_INTEGER_OP(%=); |
963 | + ZORBA_INTEGER_OP(+=,char); |
964 | + ZORBA_INTEGER_OP(-=,char); |
965 | + ZORBA_INTEGER_OP(*=,char); |
966 | + ZORBA_INTEGER_OP(/=,char); |
967 | + ZORBA_INTEGER_OP(%=,char); |
968 | + ZORBA_INTEGER_OP(+=,signed char); |
969 | + ZORBA_INTEGER_OP(-=,signed char); |
970 | + ZORBA_INTEGER_OP(*=,signed char); |
971 | + ZORBA_INTEGER_OP(/=,signed char); |
972 | + ZORBA_INTEGER_OP(%=,signed char); |
973 | + ZORBA_INTEGER_OP(+=,short); |
974 | + ZORBA_INTEGER_OP(-=,short); |
975 | + ZORBA_INTEGER_OP(*=,short); |
976 | + ZORBA_INTEGER_OP(/=,short); |
977 | + ZORBA_INTEGER_OP(%=,short); |
978 | + ZORBA_INTEGER_OP(+=,int); |
979 | + ZORBA_INTEGER_OP(-=,int); |
980 | + ZORBA_INTEGER_OP(*=,int); |
981 | + ZORBA_INTEGER_OP(/=,int); |
982 | + ZORBA_INTEGER_OP(%=,int); |
983 | + ZORBA_INTEGER_OP(+=,long); |
984 | + ZORBA_INTEGER_OP(-=,long); |
985 | + ZORBA_INTEGER_OP(*=,long); |
986 | + ZORBA_INTEGER_OP(/=,long); |
987 | + ZORBA_INTEGER_OP(%=,long); |
988 | + ZORBA_INTEGER_OP(+=,long long); |
989 | + ZORBA_INTEGER_OP(-=,long long); |
990 | + ZORBA_INTEGER_OP(*=,long long); |
991 | + ZORBA_INTEGER_OP(/=,long long); |
992 | + ZORBA_INTEGER_OP(%=,long long); |
993 | + ZORBA_INTEGER_OP(+=,unsigned char); |
994 | + ZORBA_INTEGER_OP(-=,unsigned char); |
995 | + ZORBA_INTEGER_OP(*=,unsigned char); |
996 | + ZORBA_INTEGER_OP(/=,unsigned char); |
997 | + ZORBA_INTEGER_OP(%=,unsigned char); |
998 | + ZORBA_INTEGER_OP(+=,unsigned short); |
999 | + ZORBA_INTEGER_OP(-=,unsigned short); |
1000 | + ZORBA_INTEGER_OP(*=,unsigned short); |
1001 | + ZORBA_INTEGER_OP(/=,unsigned short); |
1002 | + ZORBA_INTEGER_OP(%=,unsigned short); |
1003 | + ZORBA_INTEGER_OP(+=,unsigned int); |
1004 | + ZORBA_INTEGER_OP(-=,unsigned int); |
1005 | + ZORBA_INTEGER_OP(*=,unsigned int); |
1006 | + ZORBA_INTEGER_OP(/=,unsigned int); |
1007 | + ZORBA_INTEGER_OP(%=,unsigned int); |
1008 | + ZORBA_INTEGER_OP(+=,unsigned long); |
1009 | + ZORBA_INTEGER_OP(-=,unsigned long); |
1010 | + ZORBA_INTEGER_OP(*=,unsigned long); |
1011 | + ZORBA_INTEGER_OP(/=,unsigned long); |
1012 | + ZORBA_INTEGER_OP(%=,unsigned long); |
1013 | + ZORBA_INTEGER_OP(+=,unsigned long long); |
1014 | + ZORBA_INTEGER_OP(-=,unsigned long long); |
1015 | + ZORBA_INTEGER_OP(*=,unsigned long long); |
1016 | + ZORBA_INTEGER_OP(/=,unsigned long long); |
1017 | + ZORBA_INTEGER_OP(%=,unsigned long long); |
1018 | + ZORBA_INTEGER_OP(+=,float); |
1019 | + ZORBA_INTEGER_OP(-=,float); |
1020 | + ZORBA_INTEGER_OP(*=,float); |
1021 | + ZORBA_INTEGER_OP(/=,float); |
1022 | + ZORBA_INTEGER_OP(%=,float); |
1023 | + ZORBA_INTEGER_OP(+=,double); |
1024 | + ZORBA_INTEGER_OP(-=,double); |
1025 | + ZORBA_INTEGER_OP(*=,double); |
1026 | + ZORBA_INTEGER_OP(/=,double); |
1027 | + ZORBA_INTEGER_OP(%=,double); |
1028 | #undef ZORBA_INTEGER_OP |
1029 | |
1030 | IntegerImpl operator-() const; |
1031 | @@ -237,21 +345,88 @@ |
1032 | ZORBA_INTEGER_OP(>=); |
1033 | #undef ZORBA_INTEGER_OP |
1034 | |
1035 | -#define ZORBA_INTEGER_OP(OP) \ |
1036 | - TEMPLATE_DECL2(I,A) friend \ |
1037 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,bool>::type \ |
1038 | - operator OP( INTEGER_IMPL(I) const&, A ); \ |
1039 | - \ |
1040 | - TEMPLATE_DECL2(I,A) friend \ |
1041 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,bool>::type \ |
1042 | - operator OP( A, INTEGER_IMPL(I) const& ) |
1043 | +#define ZORBA_INTEGER_OP(OP,T) \ |
1044 | + TEMPLATE_DECL(I) friend bool operator OP( INTEGER_IMPL(I) const&, T ); \ |
1045 | + TEMPLATE_DECL(I) friend bool operator OP( T, INTEGER_IMPL(I) const& ) |
1046 | |
1047 | - ZORBA_INTEGER_OP(==); |
1048 | - ZORBA_INTEGER_OP(!=); |
1049 | - ZORBA_INTEGER_OP(< ); |
1050 | - ZORBA_INTEGER_OP(<=); |
1051 | - ZORBA_INTEGER_OP(> ); |
1052 | - ZORBA_INTEGER_OP(>=); |
1053 | + ZORBA_INTEGER_OP(==,char); |
1054 | + ZORBA_INTEGER_OP(!=,char); |
1055 | + ZORBA_INTEGER_OP(< ,char); |
1056 | + ZORBA_INTEGER_OP(<=,char); |
1057 | + ZORBA_INTEGER_OP(> ,char); |
1058 | + ZORBA_INTEGER_OP(>=,char); |
1059 | + ZORBA_INTEGER_OP(==,signed char); |
1060 | + ZORBA_INTEGER_OP(!=,signed char); |
1061 | + ZORBA_INTEGER_OP(< ,signed char); |
1062 | + ZORBA_INTEGER_OP(<=,signed char); |
1063 | + ZORBA_INTEGER_OP(> ,signed char); |
1064 | + ZORBA_INTEGER_OP(>=,signed char); |
1065 | + ZORBA_INTEGER_OP(==,short); |
1066 | + ZORBA_INTEGER_OP(!=,short); |
1067 | + ZORBA_INTEGER_OP(< ,short); |
1068 | + ZORBA_INTEGER_OP(<=,short); |
1069 | + ZORBA_INTEGER_OP(> ,short); |
1070 | + ZORBA_INTEGER_OP(>=,short); |
1071 | + ZORBA_INTEGER_OP(==,int); |
1072 | + ZORBA_INTEGER_OP(!=,int); |
1073 | + ZORBA_INTEGER_OP(< ,int); |
1074 | + ZORBA_INTEGER_OP(<=,int); |
1075 | + ZORBA_INTEGER_OP(> ,int); |
1076 | + ZORBA_INTEGER_OP(>=,int); |
1077 | + ZORBA_INTEGER_OP(==,long); |
1078 | + ZORBA_INTEGER_OP(!=,long); |
1079 | + ZORBA_INTEGER_OP(< ,long); |
1080 | + ZORBA_INTEGER_OP(<=,long); |
1081 | + ZORBA_INTEGER_OP(> ,long); |
1082 | + ZORBA_INTEGER_OP(>=,long); |
1083 | + ZORBA_INTEGER_OP(==,long long); |
1084 | + ZORBA_INTEGER_OP(!=,long long); |
1085 | + ZORBA_INTEGER_OP(< ,long long); |
1086 | + ZORBA_INTEGER_OP(<=,long long); |
1087 | + ZORBA_INTEGER_OP(> ,long long); |
1088 | + ZORBA_INTEGER_OP(>=,long long); |
1089 | + ZORBA_INTEGER_OP(==,unsigned char); |
1090 | + ZORBA_INTEGER_OP(!=,unsigned char); |
1091 | + ZORBA_INTEGER_OP(< ,unsigned char); |
1092 | + ZORBA_INTEGER_OP(<=,unsigned char); |
1093 | + ZORBA_INTEGER_OP(> ,unsigned char); |
1094 | + ZORBA_INTEGER_OP(>=,unsigned char); |
1095 | + ZORBA_INTEGER_OP(==,unsigned short); |
1096 | + ZORBA_INTEGER_OP(!=,unsigned short); |
1097 | + ZORBA_INTEGER_OP(< ,unsigned short); |
1098 | + ZORBA_INTEGER_OP(<=,unsigned short); |
1099 | + ZORBA_INTEGER_OP(> ,unsigned short); |
1100 | + ZORBA_INTEGER_OP(>=,unsigned short); |
1101 | + ZORBA_INTEGER_OP(==,unsigned int); |
1102 | + ZORBA_INTEGER_OP(!=,unsigned int); |
1103 | + ZORBA_INTEGER_OP(< ,unsigned int); |
1104 | + ZORBA_INTEGER_OP(<=,unsigned int); |
1105 | + ZORBA_INTEGER_OP(> ,unsigned int); |
1106 | + ZORBA_INTEGER_OP(>=,unsigned int); |
1107 | + ZORBA_INTEGER_OP(==,unsigned long); |
1108 | + ZORBA_INTEGER_OP(!=,unsigned long); |
1109 | + ZORBA_INTEGER_OP(< ,unsigned long); |
1110 | + ZORBA_INTEGER_OP(<=,unsigned long); |
1111 | + ZORBA_INTEGER_OP(> ,unsigned long); |
1112 | + ZORBA_INTEGER_OP(>=,unsigned long); |
1113 | + ZORBA_INTEGER_OP(==,unsigned long long); |
1114 | + ZORBA_INTEGER_OP(!=,unsigned long long); |
1115 | + ZORBA_INTEGER_OP(< ,unsigned long long); |
1116 | + ZORBA_INTEGER_OP(<=,unsigned long long); |
1117 | + ZORBA_INTEGER_OP(> ,unsigned long long); |
1118 | + ZORBA_INTEGER_OP(>=,unsigned long long); |
1119 | + ZORBA_INTEGER_OP(==,float); |
1120 | + ZORBA_INTEGER_OP(!=,float); |
1121 | + ZORBA_INTEGER_OP(< ,float); |
1122 | + ZORBA_INTEGER_OP(<=,float); |
1123 | + ZORBA_INTEGER_OP(> ,float); |
1124 | + ZORBA_INTEGER_OP(>=,float); |
1125 | + ZORBA_INTEGER_OP(==,double); |
1126 | + ZORBA_INTEGER_OP(!=,double); |
1127 | + ZORBA_INTEGER_OP(< ,double); |
1128 | + ZORBA_INTEGER_OP(<=,double); |
1129 | + ZORBA_INTEGER_OP(> ,double); |
1130 | + ZORBA_INTEGER_OP(>=,double); |
1131 | #undef ZORBA_INTEGER_OP |
1132 | |
1133 | ////////// math functions /////////////////////////////////////////////////// |
1134 | @@ -274,8 +449,10 @@ |
1135 | private: |
1136 | #ifdef ZORBA_WITH_BIG_INTEGER |
1137 | typedef MAPM value_type; |
1138 | + typedef long int_cast_type; |
1139 | #else |
1140 | typedef IntType value_type; |
1141 | + typedef IntType int_cast_type; |
1142 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1143 | |
1144 | value_type value_; |
1145 | @@ -289,11 +466,6 @@ |
1146 | } |
1147 | |
1148 | #ifdef ZORBA_WITH_BIG_INTEGER |
1149 | - template<typename T> |
1150 | - static value_type cast( T n ) { |
1151 | - return value_type( static_cast<long>( n ) ); |
1152 | - } |
1153 | - |
1154 | static value_type ftoi( MAPM const &d ) { |
1155 | return d.sign() >= 0 ? d.floor() : d.ceil(); |
1156 | } |
1157 | @@ -301,12 +473,12 @@ |
1158 | MAPM const& itod() const { |
1159 | return value_; // intentional no-op |
1160 | } |
1161 | -#else |
1162 | + |
1163 | template<typename T> |
1164 | - static value_type cast( T n ) { |
1165 | - return static_cast<value_type>( n ); |
1166 | + static value_type make_value_type( T n ) { |
1167 | + return value_type( static_cast<int_cast_type>( n ) ); |
1168 | } |
1169 | - |
1170 | +#else /* ZORBA_WITH_BIG_INTEGER */ |
1171 | bool is_long() const; |
1172 | |
1173 | static value_type ftoi( value_type v ) { |
1174 | @@ -316,6 +488,11 @@ |
1175 | static value_type ftoi( MAPM const &d ); |
1176 | |
1177 | MAPM itod() const; |
1178 | + |
1179 | + template<typename T> |
1180 | + static value_type make_value_type( T n ) { |
1181 | + return static_cast<value_type>( n ); |
1182 | + } |
1183 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1184 | |
1185 | void parse( char const *s ); |
1186 | @@ -445,33 +622,29 @@ |
1187 | |
1188 | ////////// assignment operators /////////////////////////////////////////////// |
1189 | |
1190 | -TEMPLATE_DECL(I) template<typename A> inline |
1191 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
1192 | - INTEGER_IMPL(I)&>::type |
1193 | -INTEGER_IMPL(I)::operator=( A n ) { |
1194 | - value_ = static_cast<long>( n ); |
1195 | - return *this; |
1196 | -} |
1197 | +#define ZORBA_ASSIGN_OP(T) \ |
1198 | + TEMPLATE_DECL(I) inline \ |
1199 | + INTEGER_IMPL(I)& INTEGER_IMPL(I)::operator=( T n ) { \ |
1200 | + value_ = static_cast<int_cast_type>( n ); \ |
1201 | + return *this; \ |
1202 | + } |
1203 | |
1204 | +ZORBA_ASSIGN_OP(char) |
1205 | +ZORBA_ASSIGN_OP(signed char) |
1206 | +ZORBA_ASSIGN_OP(short) |
1207 | +ZORBA_ASSIGN_OP(int) |
1208 | +ZORBA_ASSIGN_OP(long) |
1209 | +ZORBA_ASSIGN_OP(unsigned char) |
1210 | +ZORBA_ASSIGN_OP(unsigned short) |
1211 | +ZORBA_ASSIGN_OP(unsigned int) |
1212 | +ZORBA_ASSIGN_OP(float) |
1213 | +ZORBA_ASSIGN_OP(double) |
1214 | #ifndef ZORBA_WITH_BIG_INTEGER |
1215 | -template<typename I> |
1216 | -inline IntegerImpl<I>& IntegerImpl<I>::operator=( long long n ) { |
1217 | - value_ = n; |
1218 | - return *this; |
1219 | -} |
1220 | - |
1221 | -template<typename I> |
1222 | -inline IntegerImpl<I>& IntegerImpl<I>::operator=( unsigned long n ) { |
1223 | - value_ = static_cast<long>( n ); |
1224 | - return *this; |
1225 | -} |
1226 | - |
1227 | -template<typename I> |
1228 | -inline IntegerImpl<I>& IntegerImpl<I>::operator=( unsigned long long n ) { |
1229 | - value_ = n; |
1230 | - return *this; |
1231 | -} |
1232 | +ZORBA_ASSIGN_OP(long long) |
1233 | +ZORBA_ASSIGN_OP(unsigned long) |
1234 | +ZORBA_ASSIGN_OP(unsigned long long) |
1235 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1236 | +#undef ZORBA_ASSIGN_OP |
1237 | |
1238 | TEMPLATE_DECL(I) |
1239 | inline INTEGER_IMPL(I)& INTEGER_IMPL(I)::operator=( char const *s ) { |
1240 | @@ -506,44 +679,100 @@ |
1241 | return INTEGER_IMPL(I)( INTEGER_IMPL(I)::ftoi( i.value_ / j.value_ ) ); |
1242 | } |
1243 | |
1244 | -#define ZORBA_INTEGER_OP(OP) \ |
1245 | - TEMPLATE_DECL2(I,A) inline \ |
1246 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
1247 | - INTEGER_IMPL(I)>::type \ |
1248 | - operator OP( INTEGER_IMPL(I) const& i, A n ) { \ |
1249 | - return INTEGER_IMPL(I)( i.value_ OP INTEGER_IMPL(I)::cast( n ) ); \ |
1250 | - } \ |
1251 | - \ |
1252 | - TEMPLATE_DECL2(I,A) inline \ |
1253 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
1254 | - INTEGER_IMPL(I)>::type \ |
1255 | - operator OP( A n, INTEGER_IMPL(I) const &i ) { \ |
1256 | - return INTEGER_IMPL(I)( INTEGER_IMPL(I)::cast( n ) OP i.value_ ); \ |
1257 | - } |
1258 | - |
1259 | -ZORBA_INTEGER_OP(+) |
1260 | -ZORBA_INTEGER_OP(-) |
1261 | -ZORBA_INTEGER_OP(*) |
1262 | -ZORBA_INTEGER_OP(%) |
1263 | -#undef ZORBA_INTEGER_OP |
1264 | - |
1265 | -TEMPLATE_DECL2(I,A) inline |
1266 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
1267 | - INTEGER_IMPL(I)>::type |
1268 | -operator/( INTEGER_IMPL(I) const &i, A n ) { |
1269 | - return INTEGER_IMPL(I)( |
1270 | - INTEGER_IMPL(I)::ftoi( i.value_ / INTEGER_IMPL(I)::cast( n ) ) |
1271 | - ); |
1272 | -} |
1273 | - |
1274 | -TEMPLATE_DECL2(I,A) inline |
1275 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
1276 | - INTEGER_IMPL(I)>::type |
1277 | -operator/( A n, INTEGER_IMPL(I) const &i ) { |
1278 | - return INTEGER_IMPL(I)( |
1279 | - INTEGER_IMPL(I)::ftoi( INTEGER_IMPL(I)::cast( n ) / i.value_ ) |
1280 | - ); |
1281 | -} |
1282 | +#define ZORBA_INTEGER_OP(OP,T) \ |
1283 | + TEMPLATE_DECL(I) inline \ |
1284 | + INTEGER_IMPL(I) operator OP( INTEGER_IMPL(I) const &i, T n ) { \ |
1285 | + return INTEGER_IMPL(I)( i.value_ OP INTEGER_IMPL(I)::make_value_type( n ) ); \ |
1286 | + } \ |
1287 | + \ |
1288 | + TEMPLATE_DECL(I) inline \ |
1289 | + INTEGER_IMPL(I) operator OP( T n, INTEGER_IMPL(I) const &i ) { \ |
1290 | + return INTEGER_IMPL(I)( INTEGER_IMPL(I)::make_value_type( n ) OP i.value_ ); \ |
1291 | + } |
1292 | + |
1293 | +ZORBA_INTEGER_OP(+,char) |
1294 | +ZORBA_INTEGER_OP(-,char) |
1295 | +ZORBA_INTEGER_OP(*,char) |
1296 | +ZORBA_INTEGER_OP(%,char) |
1297 | +ZORBA_INTEGER_OP(+,signed char) |
1298 | +ZORBA_INTEGER_OP(-,signed char) |
1299 | +ZORBA_INTEGER_OP(*,signed char) |
1300 | +ZORBA_INTEGER_OP(%,signed char) |
1301 | +ZORBA_INTEGER_OP(+,short) |
1302 | +ZORBA_INTEGER_OP(-,short) |
1303 | +ZORBA_INTEGER_OP(*,short) |
1304 | +ZORBA_INTEGER_OP(%,short) |
1305 | +ZORBA_INTEGER_OP(+,int) |
1306 | +ZORBA_INTEGER_OP(-,int) |
1307 | +ZORBA_INTEGER_OP(*,int) |
1308 | +ZORBA_INTEGER_OP(%,int) |
1309 | +ZORBA_INTEGER_OP(+,long) |
1310 | +ZORBA_INTEGER_OP(-,long) |
1311 | +ZORBA_INTEGER_OP(*,long) |
1312 | +ZORBA_INTEGER_OP(%,long) |
1313 | +ZORBA_INTEGER_OP(+,unsigned char) |
1314 | +ZORBA_INTEGER_OP(-,unsigned char) |
1315 | +ZORBA_INTEGER_OP(*,unsigned char) |
1316 | +ZORBA_INTEGER_OP(%,unsigned char) |
1317 | +ZORBA_INTEGER_OP(+,unsigned short) |
1318 | +ZORBA_INTEGER_OP(-,unsigned short) |
1319 | +ZORBA_INTEGER_OP(*,unsigned short) |
1320 | +ZORBA_INTEGER_OP(%,unsigned short) |
1321 | +ZORBA_INTEGER_OP(+,unsigned int) |
1322 | +ZORBA_INTEGER_OP(-,unsigned int) |
1323 | +ZORBA_INTEGER_OP(*,unsigned int) |
1324 | +ZORBA_INTEGER_OP(%,unsigned int) |
1325 | +ZORBA_INTEGER_OP(+,float) |
1326 | +ZORBA_INTEGER_OP(-,float) |
1327 | +ZORBA_INTEGER_OP(*,float) |
1328 | +ZORBA_INTEGER_OP(%,float) |
1329 | +ZORBA_INTEGER_OP(+,double) |
1330 | +ZORBA_INTEGER_OP(-,double) |
1331 | +ZORBA_INTEGER_OP(*,double) |
1332 | +ZORBA_INTEGER_OP(%,double) |
1333 | +#ifndef ZORBA_WITH_BIG_INTEGER |
1334 | +ZORBA_INTEGER_OP(+,long long) |
1335 | +ZORBA_INTEGER_OP(-,long long) |
1336 | +ZORBA_INTEGER_OP(*,long long) |
1337 | +ZORBA_INTEGER_OP(%,long long) |
1338 | +ZORBA_INTEGER_OP(+,unsigned long) |
1339 | +ZORBA_INTEGER_OP(-,unsigned long) |
1340 | +ZORBA_INTEGER_OP(*,unsigned long) |
1341 | +ZORBA_INTEGER_OP(%,unsigned long) |
1342 | +ZORBA_INTEGER_OP(+,unsigned long long) |
1343 | +ZORBA_INTEGER_OP(-,unsigned long long) |
1344 | +ZORBA_INTEGER_OP(*,unsigned long long) |
1345 | +ZORBA_INTEGER_OP(%,unsigned long long) |
1346 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
1347 | +#undef ZORBA_INTEGER_OP |
1348 | + |
1349 | +#define ZORBA_INTEGER_OP(T) \ |
1350 | + TEMPLATE_DECL(I) inline \ |
1351 | + INTEGER_IMPL(I) operator/( INTEGER_IMPL(I) const &i, T n ) { \ |
1352 | + return INTEGER_IMPL(I)( INTEGER_IMPL(I)::ftoi( i.value_ / INTEGER_IMPL(I)::make_value_type( n ) ) ); \ |
1353 | + } \ |
1354 | + \ |
1355 | + TEMPLATE_DECL(I) inline \ |
1356 | + INTEGER_IMPL(I) operator/( T n, INTEGER_IMPL(I) const &i ) { \ |
1357 | + return INTEGER_IMPL(I)( INTEGER_IMPL(I)::ftoi( INTEGER_IMPL(I)::make_value_type( n ) / i.value_ ) ); \ |
1358 | + } |
1359 | + |
1360 | +ZORBA_INTEGER_OP(signed char) |
1361 | +ZORBA_INTEGER_OP(char) |
1362 | +ZORBA_INTEGER_OP(short) |
1363 | +ZORBA_INTEGER_OP(int) |
1364 | +ZORBA_INTEGER_OP(long) |
1365 | +ZORBA_INTEGER_OP(unsigned char) |
1366 | +ZORBA_INTEGER_OP(unsigned short) |
1367 | +ZORBA_INTEGER_OP(unsigned int) |
1368 | +ZORBA_INTEGER_OP(float) |
1369 | +ZORBA_INTEGER_OP(double) |
1370 | +#ifndef ZORBA_WITH_BIG_INTEGER |
1371 | +ZORBA_INTEGER_OP(long long) |
1372 | +ZORBA_INTEGER_OP(unsigned long) |
1373 | +ZORBA_INTEGER_OP(unsigned long long) |
1374 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
1375 | +#undef ZORBA_INTEGER_OP |
1376 | |
1377 | #define ZORBA_INTEGER_OP(OP) \ |
1378 | TEMPLATE_DECL(I) inline \ |
1379 | @@ -564,28 +793,92 @@ |
1380 | return *this; |
1381 | } |
1382 | |
1383 | -#define ZORBA_INTEGER_OP(OP) \ |
1384 | - TEMPLATE_DECL(I) template<typename A> inline \ |
1385 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, \ |
1386 | - INTEGER_IMPL(I)&>::type \ |
1387 | - INTEGER_IMPL(I)::operator OP( A n ) { \ |
1388 | - value_ OP cast( n ); \ |
1389 | - return *this; \ |
1390 | - } |
1391 | - |
1392 | -ZORBA_INTEGER_OP(+=) |
1393 | -ZORBA_INTEGER_OP(-=) |
1394 | -ZORBA_INTEGER_OP(*=) |
1395 | -ZORBA_INTEGER_OP(%=) |
1396 | -#undef ZORBA_INTEGER_OP |
1397 | - |
1398 | -TEMPLATE_DECL(I) template<typename A> inline |
1399 | -typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value, |
1400 | - INTEGER_IMPL(I)&>::type |
1401 | -INTEGER_IMPL(I)::operator/=( A n ) { |
1402 | - value_ = ftoi( value_ / cast( n ) ); |
1403 | - return *this; |
1404 | -} |
1405 | +#define ZORBA_INTEGER_OP(OP,T) \ |
1406 | + TEMPLATE_DECL(I) inline \ |
1407 | + INTEGER_IMPL(I)& INTEGER_IMPL(I)::operator OP( T n ) { \ |
1408 | + value_ OP make_value_type( n ); \ |
1409 | + return *this; \ |
1410 | + } |
1411 | + |
1412 | +ZORBA_INTEGER_OP(+=,char) |
1413 | +ZORBA_INTEGER_OP(-=,char) |
1414 | +ZORBA_INTEGER_OP(*=,char) |
1415 | +ZORBA_INTEGER_OP(%=,char) |
1416 | +ZORBA_INTEGER_OP(+=,signed char) |
1417 | +ZORBA_INTEGER_OP(-=,signed char) |
1418 | +ZORBA_INTEGER_OP(*=,signed char) |
1419 | +ZORBA_INTEGER_OP(%=,signed char) |
1420 | +ZORBA_INTEGER_OP(+=,short) |
1421 | +ZORBA_INTEGER_OP(-=,short) |
1422 | +ZORBA_INTEGER_OP(*=,short) |
1423 | +ZORBA_INTEGER_OP(%=,short) |
1424 | +ZORBA_INTEGER_OP(+=,int) |
1425 | +ZORBA_INTEGER_OP(-=,int) |
1426 | +ZORBA_INTEGER_OP(*=,int) |
1427 | +ZORBA_INTEGER_OP(%=,int) |
1428 | +ZORBA_INTEGER_OP(+=,long) |
1429 | +ZORBA_INTEGER_OP(-=,long) |
1430 | +ZORBA_INTEGER_OP(*=,long) |
1431 | +ZORBA_INTEGER_OP(%=,long) |
1432 | +ZORBA_INTEGER_OP(+=,unsigned char) |
1433 | +ZORBA_INTEGER_OP(-=,unsigned char) |
1434 | +ZORBA_INTEGER_OP(*=,unsigned char) |
1435 | +ZORBA_INTEGER_OP(%=,unsigned char) |
1436 | +ZORBA_INTEGER_OP(+=,unsigned short) |
1437 | +ZORBA_INTEGER_OP(-=,unsigned short) |
1438 | +ZORBA_INTEGER_OP(*=,unsigned short) |
1439 | +ZORBA_INTEGER_OP(%=,unsigned short) |
1440 | +ZORBA_INTEGER_OP(+=,unsigned int) |
1441 | +ZORBA_INTEGER_OP(-=,unsigned int) |
1442 | +ZORBA_INTEGER_OP(*=,unsigned int) |
1443 | +ZORBA_INTEGER_OP(%=,unsigned int) |
1444 | +ZORBA_INTEGER_OP(+=,float) |
1445 | +ZORBA_INTEGER_OP(-=,float) |
1446 | +ZORBA_INTEGER_OP(*=,float) |
1447 | +ZORBA_INTEGER_OP(%=,float) |
1448 | +ZORBA_INTEGER_OP(+=,double) |
1449 | +ZORBA_INTEGER_OP(-=,double) |
1450 | +ZORBA_INTEGER_OP(*=,double) |
1451 | +ZORBA_INTEGER_OP(%=,double) |
1452 | +#ifndef ZORBA_WITH_BIG_INTEGER |
1453 | +ZORBA_INTEGER_OP(+=,long long) |
1454 | +ZORBA_INTEGER_OP(-=,long long) |
1455 | +ZORBA_INTEGER_OP(*=,long long) |
1456 | +ZORBA_INTEGER_OP(%=,long long) |
1457 | +ZORBA_INTEGER_OP(+=,unsigned long) |
1458 | +ZORBA_INTEGER_OP(-=,unsigned long) |
1459 | +ZORBA_INTEGER_OP(*=,unsigned long) |
1460 | +ZORBA_INTEGER_OP(%=,unsigned long) |
1461 | +ZORBA_INTEGER_OP(+=,unsigned long long) |
1462 | +ZORBA_INTEGER_OP(-=,unsigned long long) |
1463 | +ZORBA_INTEGER_OP(*=,unsigned long long) |
1464 | +ZORBA_INTEGER_OP(%=,unsigned long long) |
1465 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
1466 | +#undef ZORBA_INTEGER_OP |
1467 | + |
1468 | +#define ZORBA_INTEGER_OP(T) \ |
1469 | + TEMPLATE_DECL(I) inline \ |
1470 | + INTEGER_IMPL(I)& INTEGER_IMPL(I)::operator/=( T n ) { \ |
1471 | + value_ = ftoi( value_ / make_value_type( n ) ); \ |
1472 | + return *this; \ |
1473 | + } |
1474 | + |
1475 | +ZORBA_INTEGER_OP(char) |
1476 | +ZORBA_INTEGER_OP(signed char) |
1477 | +ZORBA_INTEGER_OP(short) |
1478 | +ZORBA_INTEGER_OP(int) |
1479 | +ZORBA_INTEGER_OP(long) |
1480 | +ZORBA_INTEGER_OP(unsigned char) |
1481 | +ZORBA_INTEGER_OP(unsigned short) |
1482 | +ZORBA_INTEGER_OP(unsigned int) |
1483 | +ZORBA_INTEGER_OP(float) |
1484 | +ZORBA_INTEGER_OP(double) |
1485 | +#ifndef ZORBA_WITH_BIG_INTEGER |
1486 | +ZORBA_INTEGER_OP(long long) |
1487 | +ZORBA_INTEGER_OP(unsigned long) |
1488 | +ZORBA_INTEGER_OP(unsigned long long) |
1489 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
1490 | +#undef ZORBA_INTEGER_OP |
1491 | |
1492 | TEMPLATE_DECL(I) |
1493 | inline INTEGER_IMPL(I) INTEGER_IMPL(I)::operator-() const { |
1494 | @@ -634,25 +927,97 @@ |
1495 | ZORBA_INTEGER_OP(>=) |
1496 | #undef ZORBA_INTEGER_OP |
1497 | |
1498 | -#define ZORBA_INTEGER_OP(OP) \ |
1499 | - TEMPLATE_DECL2(I,A) inline \ |
1500 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,bool>::type \ |
1501 | - operator OP( INTEGER_IMPL(I) const &i, A n ) { \ |
1502 | - return i.value_ OP INTEGER_IMPL(I)::cast( n ); \ |
1503 | - } \ |
1504 | - \ |
1505 | - TEMPLATE_DECL2(I,A) inline \ |
1506 | - typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<A>::value,bool>::type \ |
1507 | - operator OP( A n, INTEGER_IMPL(I) const &i ) { \ |
1508 | - return INTEGER_IMPL(I)::cast( n ) OP i.value_; \ |
1509 | - } \ |
1510 | +#define ZORBA_INTEGER_OP(OP,T) \ |
1511 | + TEMPLATE_DECL(I) inline \ |
1512 | + bool operator OP( INTEGER_IMPL(I) const &i, T n ) { \ |
1513 | + return i.value_ OP INTEGER_IMPL(I)::make_value_type( n ); \ |
1514 | + } \ |
1515 | + \ |
1516 | + TEMPLATE_DECL(I) inline \ |
1517 | + bool operator OP( T n, INTEGER_IMPL(I) const &i ) { \ |
1518 | + return INTEGER_IMPL(I)::make_value_type( n ) OP i.value_; \ |
1519 | + } |
1520 | |
1521 | - ZORBA_INTEGER_OP(==) |
1522 | - ZORBA_INTEGER_OP(!=) |
1523 | - ZORBA_INTEGER_OP(< ) |
1524 | - ZORBA_INTEGER_OP(<=) |
1525 | - ZORBA_INTEGER_OP(> ) |
1526 | - ZORBA_INTEGER_OP(>=) |
1527 | +ZORBA_INTEGER_OP(==,char) |
1528 | +ZORBA_INTEGER_OP(!=,char) |
1529 | +ZORBA_INTEGER_OP(< ,char) |
1530 | +ZORBA_INTEGER_OP(<=,char) |
1531 | +ZORBA_INTEGER_OP(> ,char) |
1532 | +ZORBA_INTEGER_OP(>=,char) |
1533 | +ZORBA_INTEGER_OP(==,signed char) |
1534 | +ZORBA_INTEGER_OP(!=,signed char) |
1535 | +ZORBA_INTEGER_OP(< ,signed char) |
1536 | +ZORBA_INTEGER_OP(<=,signed char) |
1537 | +ZORBA_INTEGER_OP(> ,signed char) |
1538 | +ZORBA_INTEGER_OP(>=,signed char) |
1539 | +ZORBA_INTEGER_OP(==,short) |
1540 | +ZORBA_INTEGER_OP(!=,short) |
1541 | +ZORBA_INTEGER_OP(< ,short) |
1542 | +ZORBA_INTEGER_OP(<=,short) |
1543 | +ZORBA_INTEGER_OP(> ,short) |
1544 | +ZORBA_INTEGER_OP(>=,short) |
1545 | +ZORBA_INTEGER_OP(==,int) |
1546 | +ZORBA_INTEGER_OP(!=,int) |
1547 | +ZORBA_INTEGER_OP(< ,int) |
1548 | +ZORBA_INTEGER_OP(<=,int) |
1549 | +ZORBA_INTEGER_OP(> ,int) |
1550 | +ZORBA_INTEGER_OP(>=,int) |
1551 | +ZORBA_INTEGER_OP(==,long) |
1552 | +ZORBA_INTEGER_OP(!=,long) |
1553 | +ZORBA_INTEGER_OP(< ,long) |
1554 | +ZORBA_INTEGER_OP(<=,long) |
1555 | +ZORBA_INTEGER_OP(> ,long) |
1556 | +ZORBA_INTEGER_OP(>=,long) |
1557 | +ZORBA_INTEGER_OP(==,unsigned char) |
1558 | +ZORBA_INTEGER_OP(!=,unsigned char) |
1559 | +ZORBA_INTEGER_OP(< ,unsigned char) |
1560 | +ZORBA_INTEGER_OP(<=,unsigned char) |
1561 | +ZORBA_INTEGER_OP(> ,unsigned char) |
1562 | +ZORBA_INTEGER_OP(>=,unsigned char) |
1563 | +ZORBA_INTEGER_OP(==,unsigned short) |
1564 | +ZORBA_INTEGER_OP(!=,unsigned short) |
1565 | +ZORBA_INTEGER_OP(< ,unsigned short) |
1566 | +ZORBA_INTEGER_OP(<=,unsigned short) |
1567 | +ZORBA_INTEGER_OP(> ,unsigned short) |
1568 | +ZORBA_INTEGER_OP(>=,unsigned short) |
1569 | +ZORBA_INTEGER_OP(==,unsigned int) |
1570 | +ZORBA_INTEGER_OP(!=,unsigned int) |
1571 | +ZORBA_INTEGER_OP(< ,unsigned int) |
1572 | +ZORBA_INTEGER_OP(<=,unsigned int) |
1573 | +ZORBA_INTEGER_OP(> ,unsigned int) |
1574 | +ZORBA_INTEGER_OP(>=,unsigned int) |
1575 | +ZORBA_INTEGER_OP(==,float) |
1576 | +ZORBA_INTEGER_OP(!=,float) |
1577 | +ZORBA_INTEGER_OP(< ,float) |
1578 | +ZORBA_INTEGER_OP(<=,float) |
1579 | +ZORBA_INTEGER_OP(> ,float) |
1580 | +ZORBA_INTEGER_OP(>=,float) |
1581 | +ZORBA_INTEGER_OP(==,double) |
1582 | +ZORBA_INTEGER_OP(!=,double) |
1583 | +ZORBA_INTEGER_OP(< ,double) |
1584 | +ZORBA_INTEGER_OP(<=,double) |
1585 | +ZORBA_INTEGER_OP(> ,double) |
1586 | +ZORBA_INTEGER_OP(>=,double) |
1587 | +#ifndef ZORBA_WITH_BIG_INTEGER |
1588 | +ZORBA_INTEGER_OP(==,long long) |
1589 | +ZORBA_INTEGER_OP(!=,long long) |
1590 | +ZORBA_INTEGER_OP(< ,long long) |
1591 | +ZORBA_INTEGER_OP(<=,long long) |
1592 | +ZORBA_INTEGER_OP(> ,long long) |
1593 | +ZORBA_INTEGER_OP(>=,long long) |
1594 | +ZORBA_INTEGER_OP(==,unsigned long) |
1595 | +ZORBA_INTEGER_OP(!=,unsigned long) |
1596 | +ZORBA_INTEGER_OP(< ,unsigned long) |
1597 | +ZORBA_INTEGER_OP(<=,unsigned long) |
1598 | +ZORBA_INTEGER_OP(> ,unsigned long) |
1599 | +ZORBA_INTEGER_OP(>=,unsigned long) |
1600 | +ZORBA_INTEGER_OP(==,unsigned long long) |
1601 | +ZORBA_INTEGER_OP(!=,unsigned long long) |
1602 | +ZORBA_INTEGER_OP(< ,unsigned long long) |
1603 | +ZORBA_INTEGER_OP(<=,unsigned long long) |
1604 | +ZORBA_INTEGER_OP(> ,unsigned long long) |
1605 | +ZORBA_INTEGER_OP(>=,unsigned long long) |
1606 | +#endif /* ZORBA_WITH_BIG_INTEGER */ |
1607 | #undef ZORBA_INTEGER_OP |
1608 | |
1609 | ////////// miscellaneous ////////////////////////////////////////////////////// |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug-983628- 2012-04- 17T18-44- 54.123Z/ log.html
Log at: http://