Merge lp:~zorba-coders/zorba/bug-867059 into lp:zorba
- bug-867059
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10516 |
Merged at revision: | 10689 |
Proposed branch: | lp:~zorba-coders/zorba/bug-867059 |
Merge into: | lp:zorba |
Diff against target: |
3551 lines (+1457/-679) 39 files modified
ChangeLog (+1/-0) doc/zorba/build.dox (+2/-1) doc/zorba/build_options.dox (+35/-0) src/api/itemfactoryimpl.cpp (+6/-6) src/common/shared_types.h (+10/-4) src/compiler/rewriter/rules/flwor_rules.cpp (+1/-1) src/compiler/rewriter/rules/fold_rules.cpp (+1/-1) src/compiler/translator/translator.cpp (+3/-3) src/runtime/booleans/BooleanImpl.cpp (+2/-2) src/runtime/core/flwor_iterator.cpp (+1/-1) src/runtime/core/gflwor/count_iterator.cpp (+1/-1) src/runtime/core/gflwor/for_iterator.cpp (+1/-1) src/runtime/numerics/NumericsImpl.cpp (+2/-1) src/store/api/item.h (+1/-1) src/store/api/item_factory.h (+2/-2) src/store/naive/atomic_items.cpp (+186/-27) src/store/naive/atomic_items.h (+111/-39) src/store/naive/item.cpp (+1/-1) src/store/naive/simple_item_factory.cpp (+6/-6) src/store/naive/simple_item_factory.h (+2/-2) src/types/casting.cpp (+257/-46) src/types/casting.h (+2/-2) src/types/schema/XercesParseUtils.cpp (+2/-2) src/util/stl_util.h (+31/-0) src/util/string_util.cpp (+13/-5) src/zorbaserialization/zorba_class_serializer.cpp (+12/-3) src/zorbaserialization/zorba_class_serializer.h (+11/-2) src/zorbatypes/decimal.cpp (+80/-47) src/zorbatypes/decimal.h (+68/-48) src/zorbatypes/floatimpl.cpp (+20/-1) src/zorbatypes/floatimpl.h (+19/-4) src/zorbatypes/integer.cpp (+144/-96) src/zorbatypes/integer.h (+369/-308) src/zorbatypes/numconversions.cpp (+8/-1) src/zorbatypes/numconversions.h (+4/-0) src/zorbatypes/schema_types.h (+5/-1) src/zorbatypes/zorbatypes_decl.h (+13/-1) test/rbkt/Queries/CMakeLists.txt (+13/-11) test/rbkt/Queries/w3c_known_failures.txt (+11/-1) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-867059 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Matthias Brantner | Approve | ||
Review via email: mp+83717@code.launchpad.net |
This proposal supersedes a proposal from 2011-10-31.
Commit message
Better implementation of ZORBA_WITH_
Description of the change
Better implementation of ZORBA_WITH_
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
The attempt to merge lp:~zorba-coders/zorba/bug-867059 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-867059-2011-10-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in test/rbkt/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-867059-2011-11-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 3 Pending.
Matthias Brantner (matthias-brantner) : | # |
Matthias Brantner (matthias-brantner) wrote : | # |
The change log should mention that the corresponding bug is fixed with this change.
Paul J. Lucas (paul-lucas) wrote : | # |
> The change log should mention that the corresponding bug is fixed with this
> change.
It does now.
- 10515. By Paul J. Lucas
-
Merge from trunk.
- 10516. By Paul J. Lucas
-
Merge from trunk.
Markos Zaharioudakis (markos-za) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-867059-2012-02-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-02-27 15:17:53 +0000 | |||
3 | +++ ChangeLog 2012-02-28 18:23:19 +0000 | |||
4 | @@ -11,6 +11,7 @@ | |||
5 | 11 | * Caching of results for recursive functions with atomic parameter and return types. | 11 | * Caching of results for recursive functions with atomic parameter and return types. |
6 | 12 | * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types. | 12 | * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types. |
7 | 13 | * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) | 13 | * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) |
8 | 14 | * Fixed bug 867509 (Can not handle largest xs:unsignedLong values) | ||
9 | 14 | * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) | 15 | * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) |
10 | 15 | * Optimization: change the implementation of the free-vars annotation and got rid | 16 | * Optimization: change the implementation of the free-vars annotation and got rid |
11 | 16 | of the annotations map in expressions. | 17 | of the annotations map in expressions. |
12 | 17 | 18 | ||
13 | === modified file 'doc/zorba/build.dox' | |||
14 | --- doc/zorba/build.dox 2012-01-26 10:08:12 +0000 | |||
15 | +++ doc/zorba/build.dox 2012-02-28 18:23:19 +0000 | |||
16 | @@ -116,7 +116,8 @@ | |||
17 | 116 | To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel), | 116 | To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel), |
18 | 117 | you can pass an additional parameter to CMake, e.g., | 117 | you can pass an additional parameter to CMake, e.g., |
19 | 118 | <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>. | 118 | <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>. |
21 | 119 | - Zorba has other options as well. | 119 | - Zorba has other build options as well |
22 | 120 | (see \ref build_options). | ||
23 | 120 | You can tweak the performance and library footprint | 121 | You can tweak the performance and library footprint |
24 | 121 | by enabling or disabling various features from Zorba. | 122 | by enabling or disabling various features from Zorba. |
25 | 122 | 123 | ||
26 | 123 | 124 | ||
27 | === added file 'doc/zorba/build_options.dox' | |||
28 | --- doc/zorba/build_options.dox 1970-01-01 00:00:00 +0000 | |||
29 | +++ doc/zorba/build_options.dox 2012-02-28 18:23:19 +0000 | |||
30 | @@ -0,0 +1,35 @@ | |||
31 | 1 | /** \page build_options Zorba Build Options | ||
32 | 2 | |||
33 | 3 | \section ZORBA_WITH_BIG_INTEGER Big Integer Support (ZORBA_WITH_BIG_INTEGER) | ||
34 | 4 | |||
35 | 5 | The Zorba XQuery processor | ||
36 | 6 | by default | ||
37 | 7 | has arbitrary precision | ||
38 | 8 | for the \c xs:integer type. | ||
39 | 9 | Compared to a C++ \c int, | ||
40 | 10 | however, | ||
41 | 11 | arbitrary precision integers | ||
42 | 12 | are orders of magnitude slower. | ||
43 | 13 | If arbitrary precision integers are not needed, | ||
44 | 14 | they can be disabled | ||
45 | 15 | by configuring Zorba | ||
46 | 16 | with the | ||
47 | 17 | \c ZORBA_WITH_BIG_INTEGER | ||
48 | 18 | option set to \c OFF. | ||
49 | 19 | |||
50 | 20 | When arbitrary precision integers are disabled, | ||
51 | 21 | Zorba uses a C++ <code>long long</code> | ||
52 | 22 | for \c xs:integer, | ||
53 | 23 | the precision for which | ||
54 | 24 | is dependent on your C++ implementation. | ||
55 | 25 | Typically, however, | ||
56 | 26 | the precision is at least 64 bits. | ||
57 | 27 | However, | ||
58 | 28 | in order to maintain the condition | ||
59 | 29 | that the value space for \c xs:nonNegativeInteger | ||
60 | 30 | is a subset of that of \c xs:integer, | ||
61 | 31 | one less bit is allowed | ||
62 | 32 | for \c xs:nonNegativeInteger. | ||
63 | 33 | |||
64 | 34 | */ | ||
65 | 35 | /* vim:set et sw=2 ts=2: */ | ||
66 | 0 | 36 | ||
67 | === modified file 'src/api/itemfactoryimpl.cpp' | |||
68 | --- src/api/itemfactoryimpl.cpp 2012-02-22 01:31:08 +0000 | |||
69 | +++ src/api/itemfactoryimpl.cpp 2012-02-28 18:23:19 +0000 | |||
70 | @@ -288,7 +288,7 @@ | |||
71 | 288 | ItemFactoryImpl::createInteger(long long aInteger) | 288 | ItemFactoryImpl::createInteger(long long aInteger) |
72 | 289 | { | 289 | { |
73 | 290 | store::Item_t lItem; | 290 | store::Item_t lItem; |
75 | 291 | Integer const lInteger(aInteger); | 291 | xs_integer const lInteger(aInteger); |
76 | 292 | theItemFactory->createInteger(lItem, lInteger); | 292 | theItemFactory->createInteger(lItem, lInteger); |
77 | 293 | return &*lItem; | 293 | return &*lItem; |
78 | 294 | } | 294 | } |
79 | @@ -300,7 +300,7 @@ | |||
80 | 300 | zstring const &lString = Unmarshaller::getInternalString( aInteger ); | 300 | zstring const &lString = Unmarshaller::getInternalString( aInteger ); |
81 | 301 | store::Item_t lItem; | 301 | store::Item_t lItem; |
82 | 302 | try { | 302 | try { |
84 | 303 | Integer const lInteger( lString.c_str() ); | 303 | xs_integer const lInteger( lString.c_str() ); |
85 | 304 | theItemFactory->createInteger(lItem, lInteger); | 304 | theItemFactory->createInteger(lItem, lInteger); |
86 | 305 | } | 305 | } |
87 | 306 | catch ( std::exception const& ) { | 306 | catch ( std::exception const& ) { |
88 | @@ -497,7 +497,7 @@ | |||
89 | 497 | { | 497 | { |
90 | 498 | store::Item_t lItem; | 498 | store::Item_t lItem; |
91 | 499 | if (aValue < 0) { | 499 | if (aValue < 0) { |
93 | 500 | Integer const lInteger(aValue); | 500 | xs_integer const lInteger(aValue); |
94 | 501 | theItemFactory->createNegativeInteger(lItem, lInteger); | 501 | theItemFactory->createNegativeInteger(lItem, lInteger); |
95 | 502 | } | 502 | } |
96 | 503 | return &*lItem; | 503 | return &*lItem; |
97 | @@ -507,7 +507,7 @@ | |||
98 | 507 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) | 507 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) |
99 | 508 | { | 508 | { |
100 | 509 | store::Item_t lItem; | 509 | store::Item_t lItem; |
102 | 510 | Integer lInteger(aValue); | 510 | xs_nonNegativeInteger lInteger(aValue); |
103 | 511 | theItemFactory->createNonNegativeInteger(lItem, lInteger); | 511 | theItemFactory->createNonNegativeInteger(lItem, lInteger); |
104 | 512 | return &*lItem; | 512 | return &*lItem; |
105 | 513 | } | 513 | } |
106 | @@ -517,7 +517,7 @@ | |||
107 | 517 | { | 517 | { |
108 | 518 | store::Item_t lItem; | 518 | store::Item_t lItem; |
109 | 519 | if (aValue < 0) { | 519 | if (aValue < 0) { |
111 | 520 | Integer const lInteger(aValue); | 520 | xs_integer const lInteger(aValue); |
112 | 521 | theItemFactory->createNonPositiveInteger(lItem, lInteger); | 521 | theItemFactory->createNonPositiveInteger(lItem, lInteger); |
113 | 522 | } | 522 | } |
114 | 523 | return &*lItem; | 523 | return &*lItem; |
115 | @@ -527,7 +527,7 @@ | |||
116 | 527 | Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue ) | 527 | Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue ) |
117 | 528 | { | 528 | { |
118 | 529 | store::Item_t lItem; | 529 | store::Item_t lItem; |
120 | 530 | Integer lInteger(aValue); | 530 | xs_nonNegativeInteger lInteger(aValue); |
121 | 531 | theItemFactory->createPositiveInteger(lItem, lInteger); | 531 | theItemFactory->createPositiveInteger(lItem, lInteger); |
122 | 532 | return &*lItem; | 532 | return &*lItem; |
123 | 533 | } | 533 | } |
124 | 534 | 534 | ||
125 | === modified file 'src/common/shared_types.h' | |||
126 | --- src/common/shared_types.h 2011-09-12 22:42:28 +0000 | |||
127 | +++ src/common/shared_types.h 2012-02-28 18:23:19 +0000 | |||
128 | @@ -140,12 +140,18 @@ | |||
129 | 140 | typedef rchandle<GMonth> GMonth_t; | 140 | typedef rchandle<GMonth> GMonth_t; |
130 | 141 | 141 | ||
131 | 142 | /* numerics */ | 142 | /* numerics */ |
136 | 143 | template <class Object> class FloatImpl; | 143 | template<typename FloatType> class FloatImpl; |
133 | 144 | class Integer; | ||
134 | 145 | |||
135 | 146 | /* numerics */ | ||
137 | 147 | typedef FloatImpl<double> Double; | 144 | typedef FloatImpl<double> Double; |
138 | 148 | typedef FloatImpl<float> Float; | 145 | typedef FloatImpl<float> Float; |
139 | 146 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
140 | 147 | class IntegerImpl; | ||
141 | 148 | typedef IntegerImpl Integer; | ||
142 | 149 | typedef IntegerImpl UInteger; | ||
143 | 150 | #else | ||
144 | 151 | template<typename IntType> class IntegerImpl; | ||
145 | 152 | typedef IntegerImpl<long long> Integer; | ||
146 | 153 | typedef IntegerImpl<unsigned long long> UInteger; | ||
147 | 154 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
148 | 149 | 155 | ||
149 | 150 | /* api */ | 156 | /* api */ |
150 | 151 | class serializer; | 157 | class serializer; |
151 | 152 | 158 | ||
152 | === modified file 'src/compiler/rewriter/rules/flwor_rules.cpp' | |||
153 | --- src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-16 12:48:17 +0000 | |||
154 | +++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-28 18:23:19 +0000 | |||
155 | @@ -953,7 +953,7 @@ | |||
156 | 953 | (a) op is eq or =, and | 953 | (a) op is eq or =, and |
157 | 954 | (b1) posExpr is an integer literal with value >= 1, or | 954 | (b1) posExpr is an integer literal with value >= 1, or |
158 | 955 | (b2) the flwor expr has no sequential clauses and posExpr is an expression | 955 | (b2) the flwor expr has no sequential clauses and posExpr is an expression |
160 | 956 | whose type is xs:Integer? and which does not reference the for var | 956 | whose type is xs:integer? and which does not reference the for var |
161 | 957 | associated with posVar nor any other vars that are defined after that | 957 | associated with posVar nor any other vars that are defined after that |
162 | 958 | for var. | 958 | for var. |
163 | 959 | 959 | ||
164 | 960 | 960 | ||
165 | === modified file 'src/compiler/rewriter/rules/fold_rules.cpp' | |||
166 | --- src/compiler/rewriter/rules/fold_rules.cpp 2012-02-16 12:48:17 +0000 | |||
167 | +++ src/compiler/rewriter/rules/fold_rules.cpp 2012-02-28 18:23:19 +0000 | |||
168 | @@ -753,7 +753,7 @@ | |||
169 | 753 | { | 753 | { |
170 | 754 | return new const_expr(fo->get_sctx(), | 754 | return new const_expr(fo->get_sctx(), |
171 | 755 | fo->get_loc(), | 755 | fo->get_loc(), |
173 | 756 | Integer(type_cnt)); | 756 | xs_integer(type_cnt)); |
174 | 757 | } | 757 | } |
175 | 758 | else if (fkind == FunctionConsts::FN_EMPTY_1) | 758 | else if (fkind == FunctionConsts::FN_EMPTY_1) |
176 | 759 | { | 759 | { |
177 | 760 | 760 | ||
178 | === modified file 'src/compiler/translator/translator.cpp' | |||
179 | --- src/compiler/translator/translator.cpp 2012-02-19 19:43:28 +0000 | |||
180 | +++ src/compiler/translator/translator.cpp 2012-02-28 18:23:19 +0000 | |||
181 | @@ -9738,8 +9738,8 @@ | |||
182 | 9738 | { | 9738 | { |
183 | 9739 | case FunctionConsts::FN_HEAD_1: | 9739 | case FunctionConsts::FN_HEAD_1: |
184 | 9740 | { | 9740 | { |
187 | 9741 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(1))); | 9741 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1))); |
188 | 9742 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(1))); | 9742 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1))); |
189 | 9743 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3); | 9743 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3); |
190 | 9744 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); | 9744 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); |
191 | 9745 | normalize_fo(foExpr); | 9745 | normalize_fo(foExpr); |
192 | @@ -9748,7 +9748,7 @@ | |||
193 | 9748 | } | 9748 | } |
194 | 9749 | case FunctionConsts::FN_TAIL_1: | 9749 | case FunctionConsts::FN_TAIL_1: |
195 | 9750 | { | 9750 | { |
197 | 9751 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(2))); | 9751 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(2))); |
198 | 9752 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2); | 9752 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2); |
199 | 9753 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); | 9753 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); |
200 | 9754 | normalize_fo(foExpr); | 9754 | normalize_fo(foExpr); |
201 | 9755 | 9755 | ||
202 | === modified file 'src/runtime/booleans/BooleanImpl.cpp' | |||
203 | --- src/runtime/booleans/BooleanImpl.cpp 2012-01-26 19:56:14 +0000 | |||
204 | +++ src/runtime/booleans/BooleanImpl.cpp 2012-02-28 18:23:19 +0000 | |||
205 | @@ -845,7 +845,7 @@ | |||
206 | 845 | { | 845 | { |
207 | 846 | // There are 2 cases when two types are comparable without one being a | 846 | // There are 2 cases when two types are comparable without one being a |
208 | 847 | // subtype of the other: (a) they belong to different branches under of | 847 | // subtype of the other: (a) they belong to different branches under of |
210 | 848 | // the type-inheritance subtree rooted at xs:Integer, (b) they belong to | 848 | // the type-inheritance subtree rooted at xs:integer, (b) they belong to |
211 | 849 | // different branches under of the type-inheritance subtree rooted at | 849 | // different branches under of the type-inheritance subtree rooted at |
212 | 850 | // xs::duration (i.e. one is xs:yearMonthDuration and the other is | 850 | // xs::duration (i.e. one is xs:yearMonthDuration and the other is |
213 | 851 | // xs:dayTimeDuration). | 851 | // xs:dayTimeDuration). |
214 | @@ -935,7 +935,7 @@ | |||
215 | 935 | { | 935 | { |
216 | 936 | // There is 1 case when two types are order-comparable without one being a | 936 | // There is 1 case when two types are order-comparable without one being a |
217 | 937 | // subtype of the other: they belong to different branches under of the | 937 | // subtype of the other: they belong to different branches under of the |
219 | 938 | // type-inheritance subtree rooted at xs:Integer. | 938 | // type-inheritance subtree rooted at xs:integer. |
220 | 939 | if (TypeOps::is_subtype(type0, store::XS_INTEGER) && | 939 | if (TypeOps::is_subtype(type0, store::XS_INTEGER) && |
221 | 940 | TypeOps::is_subtype(type1, store::XS_INTEGER)) | 940 | TypeOps::is_subtype(type1, store::XS_INTEGER)) |
222 | 941 | { | 941 | { |
223 | 942 | 942 | ||
224 | === modified file 'src/runtime/core/flwor_iterator.cpp' | |||
225 | --- src/runtime/core/flwor_iterator.cpp 2012-02-27 14:46:27 +0000 | |||
226 | +++ src/runtime/core/flwor_iterator.cpp 2012-02-28 18:23:19 +0000 | |||
227 | @@ -1216,7 +1216,7 @@ | |||
228 | 1216 | if (!flc.thePosVarRefs.empty()) | 1216 | if (!flc.thePosVarRefs.empty()) |
229 | 1217 | { | 1217 | { |
230 | 1218 | store::Item_t posItem; | 1218 | store::Item_t posItem; |
232 | 1219 | GENV_ITEMFACTORY->createInteger(posItem, Integer(bindingState)); | 1219 | GENV_ITEMFACTORY->createInteger(posItem, xs_integer(bindingState)); |
233 | 1220 | 1220 | ||
234 | 1221 | std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin(); | 1221 | std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin(); |
235 | 1222 | std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end(); | 1222 | std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end(); |
236 | 1223 | 1223 | ||
237 | === modified file 'src/runtime/core/gflwor/count_iterator.cpp' | |||
238 | --- src/runtime/core/gflwor/count_iterator.cpp 2011-06-14 17:26:33 +0000 | |||
239 | +++ src/runtime/core/gflwor/count_iterator.cpp 2012-02-28 18:23:19 +0000 | |||
240 | @@ -91,7 +91,7 @@ | |||
241 | 91 | { | 91 | { |
242 | 92 | { | 92 | { |
243 | 93 | store::Item_t lCountItem; | 93 | store::Item_t lCountItem; |
245 | 94 | GENV_ITEMFACTORY->createInteger(lCountItem, Integer(lState->incCount())); | 94 | GENV_ITEMFACTORY->createInteger(lCountItem, xs_integer(lState->incCount())); |
246 | 95 | bindVariables(lCountItem, theCountVars, aPlanState); | 95 | bindVariables(lCountItem, theCountVars, aPlanState); |
247 | 96 | } | 96 | } |
248 | 97 | STACK_PUSH(true, lState); | 97 | STACK_PUSH(true, lState); |
249 | 98 | 98 | ||
250 | === modified file 'src/runtime/core/gflwor/for_iterator.cpp' | |||
251 | --- src/runtime/core/gflwor/for_iterator.cpp 2011-06-22 14:42:38 +0000 | |||
252 | +++ src/runtime/core/gflwor/for_iterator.cpp 2012-02-28 18:23:19 +0000 | |||
253 | @@ -126,7 +126,7 @@ | |||
254 | 126 | { | 126 | { |
255 | 127 | store::Item_t lPosItem; | 127 | store::Item_t lPosItem; |
256 | 128 | GENV_ITEMFACTORY->createInteger(lPosItem, | 128 | GENV_ITEMFACTORY->createInteger(lPosItem, |
258 | 129 | Integer(lState->incReturnPosition())); | 129 | xs_integer(lState->incReturnPosition())); |
259 | 130 | bindVariables(lPosItem, thePosVarRefs, aPlanState); | 130 | bindVariables(lPosItem, thePosVarRefs, aPlanState); |
260 | 131 | } | 131 | } |
261 | 132 | STACK_PUSH(true, lState); | 132 | STACK_PUSH(true, lState); |
262 | 133 | 133 | ||
263 | === modified file 'src/runtime/numerics/NumericsImpl.cpp' | |||
264 | --- src/runtime/numerics/NumericsImpl.cpp 2012-01-30 16:59:01 +0000 | |||
265 | +++ src/runtime/numerics/NumericsImpl.cpp 2012-02-28 18:23:19 +0000 | |||
266 | @@ -442,10 +442,11 @@ | |||
267 | 442 | xs_integer ll0 = i0->getIntegerValue(); | 442 | xs_integer ll0 = i0->getIntegerValue(); |
268 | 443 | xs_integer ll1 = i1->getIntegerValue(); | 443 | xs_integer ll1 = i1->getIntegerValue(); |
269 | 444 | 444 | ||
271 | 445 | if ( ll1 == Integer::zero() ) | 445 | if ( ll1.sign() == 0 ) |
272 | 446 | { | 446 | { |
273 | 447 | throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) ); | 447 | throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) ); |
274 | 448 | } | 448 | } |
275 | 449 | |||
276 | 449 | return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1); | 450 | return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1); |
277 | 450 | } | 451 | } |
278 | 451 | 452 | ||
279 | 452 | 453 | ||
280 | === modified file 'src/store/api/item.h' | |||
281 | --- src/store/api/item.h 2012-02-22 04:03:16 +0000 | |||
282 | +++ src/store/api/item.h 2012-02-28 18:23:19 +0000 | |||
283 | @@ -311,7 +311,7 @@ | |||
284 | 311 | 311 | ||
285 | 312 | /** Accessor for xs:nonNegativeInteager, xs:positiveInteger | 312 | /** Accessor for xs:nonNegativeInteager, xs:positiveInteger |
286 | 313 | */ | 313 | */ |
288 | 314 | virtual xs_uinteger | 314 | virtual xs_nonNegativeInteger |
289 | 315 | getUnsignedIntegerValue() const; | 315 | getUnsignedIntegerValue() const; |
290 | 316 | 316 | ||
291 | 317 | /** Accessor for xs:long | 317 | /** Accessor for xs:long |
292 | 318 | 318 | ||
293 | === modified file 'src/store/api/item_factory.h' | |||
294 | --- src/store/api/item_factory.h 2012-02-22 01:31:08 +0000 | |||
295 | +++ src/store/api/item_factory.h 2012-02-28 18:23:19 +0000 | |||
296 | @@ -261,13 +261,13 @@ | |||
297 | 261 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger] | 261 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger] |
298 | 262 | * @param value | 262 | * @param value |
299 | 263 | */ | 263 | */ |
301 | 264 | virtual bool createNonNegativeInteger(Item_t& result, const xs_uinteger& value) = 0; | 264 | virtual bool createNonNegativeInteger(Item_t& result, const xs_nonNegativeInteger& value) = 0; |
302 | 265 | 265 | ||
303 | 266 | /** | 266 | /** |
304 | 267 | * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger] | 267 | * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger] |
305 | 268 | * @param value | 268 | * @param value |
306 | 269 | */ | 269 | */ |
308 | 270 | virtual bool createPositiveInteger(Item_t& result, const xs_uinteger& value) = 0; | 270 | virtual bool createPositiveInteger(Item_t& result, const xs_positiveInteger& value) = 0; |
309 | 271 | 271 | ||
310 | 272 | /** | 272 | /** |
311 | 273 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger] | 273 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger] |
312 | 274 | 274 | ||
313 | === modified file 'src/store/naive/atomic_items.cpp' | |||
314 | --- src/store/naive/atomic_items.cpp 2012-02-24 03:57:49 +0000 | |||
315 | +++ src/store/naive/atomic_items.cpp 2012-02-28 18:23:19 +0000 | |||
316 | @@ -137,7 +137,7 @@ | |||
317 | 137 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); | 137 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); |
318 | 138 | try | 138 | try |
319 | 139 | { | 139 | { |
321 | 140 | longValue = to_xs_long(item->theValue); | 140 | longValue = item->getLongValue(); |
322 | 141 | GET_FACTORY().createLong(result, longValue); | 141 | GET_FACTORY().createLong(result, longValue); |
323 | 142 | } | 142 | } |
324 | 143 | catch (std::range_error const&) | 143 | catch (std::range_error const&) |
325 | @@ -207,11 +207,11 @@ | |||
326 | 207 | { | 207 | { |
327 | 208 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); | 208 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); |
328 | 209 | 209 | ||
330 | 210 | doubleValue = item->theValue; | 210 | doubleValue = item->getIntegerValue(); |
331 | 211 | 211 | ||
332 | 212 | const xs_integer intValue(doubleValue); | 212 | const xs_integer intValue(doubleValue); |
333 | 213 | 213 | ||
335 | 214 | lossy = (intValue != item->theValue); | 214 | lossy = (intValue != item->getIntegerValue()); |
336 | 215 | break; | 215 | break; |
337 | 216 | } | 216 | } |
338 | 217 | 217 | ||
339 | @@ -2350,10 +2350,11 @@ | |||
340 | 2350 | 2350 | ||
341 | 2351 | 2351 | ||
342 | 2352 | /******************************************************************************* | 2352 | /******************************************************************************* |
344 | 2353 | class IntegerItem | 2353 | class IntegerItemImpl |
345 | 2354 | ********************************************************************************/ | 2354 | ********************************************************************************/ |
346 | 2355 | 2355 | ||
348 | 2356 | long IntegerItem::compare( Item const *other, long, const XQPCollator* ) const { | 2356 | long IntegerItemImpl::compare( Item const *other, long, |
349 | 2357 | const XQPCollator* ) const { | ||
350 | 2357 | try | 2358 | try |
351 | 2358 | { | 2359 | { |
352 | 2359 | return theValue.compare( other->getIntegerValue() ); | 2360 | return theValue.compare( other->getIntegerValue() ); |
353 | @@ -2364,8 +2365,8 @@ | |||
354 | 2364 | } | 2365 | } |
355 | 2365 | } | 2366 | } |
356 | 2366 | 2367 | ||
359 | 2367 | bool IntegerItem::equals( const store::Item* other, long, | 2368 | bool IntegerItemImpl::equals( const store::Item* other, long, |
360 | 2368 | const XQPCollator*) const | 2369 | const XQPCollator*) const |
361 | 2369 | { | 2370 | { |
362 | 2370 | try | 2371 | try |
363 | 2371 | { | 2372 | { |
364 | @@ -2377,13 +2378,13 @@ | |||
365 | 2377 | } | 2378 | } |
366 | 2378 | } | 2379 | } |
367 | 2379 | 2380 | ||
369 | 2380 | xs_decimal IntegerItem::getDecimalValue() const | 2381 | xs_decimal IntegerItemImpl::getDecimalValue() const |
370 | 2381 | { | 2382 | { |
371 | 2382 | return xs_decimal(theValue); | 2383 | return xs_decimal(theValue); |
372 | 2383 | } | 2384 | } |
373 | 2384 | 2385 | ||
374 | 2385 | 2386 | ||
376 | 2386 | xs_long IntegerItem::getLongValue() const | 2387 | xs_long IntegerItemImpl::getLongValue() const |
377 | 2387 | { | 2388 | { |
378 | 2388 | try | 2389 | try |
379 | 2389 | { | 2390 | { |
380 | @@ -2397,41 +2398,42 @@ | |||
381 | 2397 | } | 2398 | } |
382 | 2398 | 2399 | ||
383 | 2399 | 2400 | ||
385 | 2400 | store::Item* IntegerItem::getType() const | 2401 | store::Item* IntegerItemImpl::getType() const |
386 | 2401 | { | 2402 | { |
387 | 2402 | return GET_STORE().theSchemaTypeNames[store::XS_INTEGER]; | 2403 | return GET_STORE().theSchemaTypeNames[store::XS_INTEGER]; |
388 | 2403 | } | 2404 | } |
389 | 2404 | 2405 | ||
390 | 2405 | 2406 | ||
392 | 2406 | bool IntegerItem::getEBV() const | 2407 | bool IntegerItemImpl::getEBV() const |
393 | 2407 | { | 2408 | { |
395 | 2408 | return ( theValue != xs_integer::zero() ); | 2409 | return !!theValue.sign(); |
396 | 2409 | } | 2410 | } |
397 | 2410 | 2411 | ||
398 | 2411 | 2412 | ||
400 | 2412 | zstring IntegerItem::getStringValue() const | 2413 | zstring IntegerItemImpl::getStringValue() const |
401 | 2413 | { | 2414 | { |
402 | 2414 | return theValue.toString(); | 2415 | return theValue.toString(); |
403 | 2415 | } | 2416 | } |
404 | 2416 | 2417 | ||
405 | 2417 | 2418 | ||
407 | 2418 | void IntegerItem::getStringValue2(zstring& val) const | 2419 | void IntegerItemImpl::getStringValue2(zstring& val) const |
408 | 2419 | { | 2420 | { |
409 | 2420 | val = theValue.toString(); | 2421 | val = theValue.toString(); |
410 | 2421 | } | 2422 | } |
411 | 2422 | 2423 | ||
413 | 2423 | uint32_t IntegerItem::hash(long, const XQPCollator*) const | 2424 | uint32_t IntegerItemImpl::hash(long, const XQPCollator*) const |
414 | 2424 | { | 2425 | { |
415 | 2425 | return theValue.hash(); | 2426 | return theValue.hash(); |
416 | 2426 | } | 2427 | } |
417 | 2427 | 2428 | ||
419 | 2428 | void IntegerItem::appendStringValue(zstring& buf) const | 2429 | |
420 | 2430 | void IntegerItemImpl::appendStringValue(zstring& buf) const | ||
421 | 2429 | { | 2431 | { |
422 | 2430 | buf += theValue.toString(); | 2432 | buf += theValue.toString(); |
423 | 2431 | } | 2433 | } |
424 | 2432 | 2434 | ||
425 | 2433 | 2435 | ||
427 | 2434 | zstring IntegerItem::show() const | 2436 | zstring IntegerItemImpl::show() const |
428 | 2435 | { | 2437 | { |
429 | 2436 | zstring res("xs:integer("); | 2438 | zstring res("xs:integer("); |
430 | 2437 | appendStringValue(res); | 2439 | appendStringValue(res); |
431 | @@ -2443,11 +2445,88 @@ | |||
432 | 2443 | /******************************************************************************* | 2445 | /******************************************************************************* |
433 | 2444 | class NonPositiveIntegerItem | 2446 | class NonPositiveIntegerItem |
434 | 2445 | ********************************************************************************/ | 2447 | ********************************************************************************/ |
435 | 2448 | long NonPositiveIntegerItem::compare( Item const *other, long, | ||
436 | 2449 | const XQPCollator* ) const { | ||
437 | 2450 | try | ||
438 | 2451 | { | ||
439 | 2452 | return theValue.compare( other->getIntegerValue() ); | ||
440 | 2453 | } | ||
441 | 2454 | catch ( ZorbaException const& ) | ||
442 | 2455 | { | ||
443 | 2456 | return getDecimalValue().compare( other->getDecimalValue() ); | ||
444 | 2457 | } | ||
445 | 2458 | } | ||
446 | 2459 | |||
447 | 2460 | bool NonPositiveIntegerItem::equals( const store::Item* other, long, | ||
448 | 2461 | const XQPCollator* ) const | ||
449 | 2462 | { | ||
450 | 2463 | try | ||
451 | 2464 | { | ||
452 | 2465 | return theValue == other->getIntegerValue(); | ||
453 | 2466 | } | ||
454 | 2467 | catch (ZorbaException const&) | ||
455 | 2468 | { | ||
456 | 2469 | return getDecimalValue() == other->getDecimalValue(); | ||
457 | 2470 | } | ||
458 | 2471 | } | ||
459 | 2472 | |||
460 | 2446 | store::Item* NonPositiveIntegerItem::getType() const | 2473 | store::Item* NonPositiveIntegerItem::getType() const |
461 | 2447 | { | 2474 | { |
462 | 2448 | return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER]; | 2475 | return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER]; |
463 | 2449 | } | 2476 | } |
464 | 2450 | 2477 | ||
465 | 2478 | xs_decimal NonPositiveIntegerItem::getDecimalValue() const | ||
466 | 2479 | { | ||
467 | 2480 | return xs_decimal(theValue); | ||
468 | 2481 | } | ||
469 | 2482 | |||
470 | 2483 | xs_integer NonPositiveIntegerItem::getIntegerValue() const | ||
471 | 2484 | { | ||
472 | 2485 | return xs_integer(theValue); | ||
473 | 2486 | } | ||
474 | 2487 | |||
475 | 2488 | xs_long NonPositiveIntegerItem::getLongValue() const | ||
476 | 2489 | { | ||
477 | 2490 | try | ||
478 | 2491 | { | ||
479 | 2492 | return to_xs_long(theValue); | ||
480 | 2493 | } | ||
481 | 2494 | catch ( std::range_error const& ) | ||
482 | 2495 | { | ||
483 | 2496 | throw XQUERY_EXCEPTION( | ||
484 | 2497 | err::FORG0001, | ||
485 | 2498 | ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" ) | ||
486 | 2499 | ); | ||
487 | 2500 | } | ||
488 | 2501 | } | ||
489 | 2502 | |||
490 | 2503 | zstring NonPositiveIntegerItem::getStringValue() const | ||
491 | 2504 | { | ||
492 | 2505 | return theValue.toString(); | ||
493 | 2506 | } | ||
494 | 2507 | |||
495 | 2508 | |||
496 | 2509 | void NonPositiveIntegerItem::getStringValue2(zstring& val) const | ||
497 | 2510 | { | ||
498 | 2511 | val = theValue.toString(); | ||
499 | 2512 | } | ||
500 | 2513 | |||
501 | 2514 | uint32_t NonPositiveIntegerItem::hash(long, const XQPCollator*) const | ||
502 | 2515 | { | ||
503 | 2516 | return theValue.hash(); | ||
504 | 2517 | } | ||
505 | 2518 | |||
506 | 2519 | |||
507 | 2520 | void NonPositiveIntegerItem::appendStringValue(zstring& buf) const | ||
508 | 2521 | { | ||
509 | 2522 | buf += theValue.toString(); | ||
510 | 2523 | } | ||
511 | 2524 | |||
512 | 2525 | bool NonPositiveIntegerItem::getEBV() const | ||
513 | 2526 | { | ||
514 | 2527 | return !!theValue.sign(); | ||
515 | 2528 | } | ||
516 | 2529 | |||
517 | 2451 | zstring NonPositiveIntegerItem::show() const | 2530 | zstring NonPositiveIntegerItem::show() const |
518 | 2452 | { | 2531 | { |
519 | 2453 | zstring res("xs:nonPositiveInteger("); | 2532 | zstring res("xs:nonPositiveInteger("); |
520 | @@ -2476,14 +2555,91 @@ | |||
521 | 2476 | 2555 | ||
522 | 2477 | 2556 | ||
523 | 2478 | /******************************************************************************* | 2557 | /******************************************************************************* |
525 | 2479 | class NonNegativeINtegerItem | 2558 | class NonNegativeIntegerItem |
526 | 2480 | ********************************************************************************/ | 2559 | ********************************************************************************/ |
527 | 2560 | long NonNegativeIntegerItem::compare( Item const *other, long, | ||
528 | 2561 | const XQPCollator* ) const { | ||
529 | 2562 | try | ||
530 | 2563 | { | ||
531 | 2564 | return theValue.compare( other->getUnsignedIntegerValue() ); | ||
532 | 2565 | } | ||
533 | 2566 | catch ( ZorbaException const& ) | ||
534 | 2567 | { | ||
535 | 2568 | return getDecimalValue().compare( other->getDecimalValue() ); | ||
536 | 2569 | } | ||
537 | 2570 | } | ||
538 | 2571 | |||
539 | 2572 | bool NonNegativeIntegerItem::equals( const store::Item* other, long, | ||
540 | 2573 | const XQPCollator* ) const | ||
541 | 2574 | { | ||
542 | 2575 | try | ||
543 | 2576 | { | ||
544 | 2577 | return theValue == other->getUnsignedIntegerValue(); | ||
545 | 2578 | } | ||
546 | 2579 | catch (ZorbaException const&) | ||
547 | 2580 | { | ||
548 | 2581 | return getDecimalValue() == other->getDecimalValue(); | ||
549 | 2582 | } | ||
550 | 2583 | } | ||
551 | 2584 | |||
552 | 2481 | store::Item* NonNegativeIntegerItem::getType() const | 2585 | store::Item* NonNegativeIntegerItem::getType() const |
553 | 2482 | { | 2586 | { |
554 | 2483 | return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER]; | 2587 | return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER]; |
555 | 2484 | } | 2588 | } |
556 | 2485 | 2589 | ||
557 | 2486 | 2590 | ||
558 | 2591 | xs_decimal NonNegativeIntegerItem::getDecimalValue() const | ||
559 | 2592 | { | ||
560 | 2593 | return xs_decimal(theValue); | ||
561 | 2594 | } | ||
562 | 2595 | |||
563 | 2596 | xs_integer NonNegativeIntegerItem::getIntegerValue() const | ||
564 | 2597 | { | ||
565 | 2598 | return xs_integer(theValue); | ||
566 | 2599 | } | ||
567 | 2600 | |||
568 | 2601 | xs_long NonNegativeIntegerItem::getLongValue() const | ||
569 | 2602 | { | ||
570 | 2603 | try | ||
571 | 2604 | { | ||
572 | 2605 | return to_xs_long(theValue); | ||
573 | 2606 | } | ||
574 | 2607 | catch ( std::range_error const& ) | ||
575 | 2608 | { | ||
576 | 2609 | throw XQUERY_EXCEPTION( | ||
577 | 2610 | err::FORG0001, | ||
578 | 2611 | ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" ) | ||
579 | 2612 | ); | ||
580 | 2613 | } | ||
581 | 2614 | } | ||
582 | 2615 | |||
583 | 2616 | zstring NonNegativeIntegerItem::getStringValue() const | ||
584 | 2617 | { | ||
585 | 2618 | return theValue.toString(); | ||
586 | 2619 | } | ||
587 | 2620 | |||
588 | 2621 | |||
589 | 2622 | void NonNegativeIntegerItem::getStringValue2(zstring& val) const | ||
590 | 2623 | { | ||
591 | 2624 | val = theValue.toString(); | ||
592 | 2625 | } | ||
593 | 2626 | |||
594 | 2627 | uint32_t NonNegativeIntegerItem::hash(long, const XQPCollator*) const | ||
595 | 2628 | { | ||
596 | 2629 | return theValue.hash(); | ||
597 | 2630 | } | ||
598 | 2631 | |||
599 | 2632 | |||
600 | 2633 | void NonNegativeIntegerItem::appendStringValue(zstring& buf) const | ||
601 | 2634 | { | ||
602 | 2635 | buf += theValue.toString(); | ||
603 | 2636 | } | ||
604 | 2637 | |||
605 | 2638 | bool NonNegativeIntegerItem::getEBV() const | ||
606 | 2639 | { | ||
607 | 2640 | return !!theValue.sign(); | ||
608 | 2641 | } | ||
609 | 2642 | |||
610 | 2487 | zstring NonNegativeIntegerItem::show() const | 2643 | zstring NonNegativeIntegerItem::show() const |
611 | 2488 | { | 2644 | { |
612 | 2489 | zstring res("xs:nonNegativeInteger("); | 2645 | zstring res("xs:nonNegativeInteger("); |
613 | @@ -2525,6 +2681,9 @@ | |||
614 | 2525 | return xs_integer(theValue); | 2681 | return xs_integer(theValue); |
615 | 2526 | } | 2682 | } |
616 | 2527 | 2683 | ||
617 | 2684 | xs_nonNegativeInteger LongItem::getUnsignedIntegerValue() const { | ||
618 | 2685 | return theValue >= 0 ? theValue : -theValue; | ||
619 | 2686 | } | ||
620 | 2528 | 2687 | ||
621 | 2529 | store::Item* LongItem::getType() const | 2688 | store::Item* LongItem::getType() const |
622 | 2530 | { | 2689 | { |
623 | @@ -2758,9 +2917,9 @@ | |||
624 | 2758 | } | 2917 | } |
625 | 2759 | 2918 | ||
626 | 2760 | 2919 | ||
628 | 2761 | xs_uinteger UnsignedLongItem::getUnsignedIntegerValue() const | 2920 | xs_nonNegativeInteger UnsignedLongItem::getUnsignedIntegerValue() const |
629 | 2762 | { | 2921 | { |
631 | 2763 | return xs_uinteger(theValue); | 2922 | return xs_nonNegativeInteger(theValue); |
632 | 2764 | } | 2923 | } |
633 | 2765 | 2924 | ||
634 | 2766 | 2925 | ||
635 | @@ -2822,9 +2981,9 @@ | |||
636 | 2822 | } | 2981 | } |
637 | 2823 | 2982 | ||
638 | 2824 | 2983 | ||
640 | 2825 | xs_uinteger UnsignedIntItem::getUnsignedIntegerValue() const | 2984 | xs_nonNegativeInteger UnsignedIntItem::getUnsignedIntegerValue() const |
641 | 2826 | { | 2985 | { |
643 | 2827 | return Integer(theValue); | 2986 | return xs_nonNegativeInteger(theValue); |
644 | 2828 | } | 2987 | } |
645 | 2829 | 2988 | ||
646 | 2830 | 2989 | ||
647 | @@ -2886,9 +3045,9 @@ | |||
648 | 2886 | } | 3045 | } |
649 | 2887 | 3046 | ||
650 | 2888 | 3047 | ||
652 | 2889 | xs_uinteger UnsignedShortItem::getUnsignedIntegerValue() const | 3048 | xs_nonNegativeInteger UnsignedShortItem::getUnsignedIntegerValue() const |
653 | 2890 | { | 3049 | { |
655 | 2891 | return Integer(theValue); | 3050 | return xs_nonNegativeInteger(theValue); |
656 | 2892 | } | 3051 | } |
657 | 2893 | 3052 | ||
658 | 2894 | 3053 | ||
659 | @@ -2946,13 +3105,13 @@ | |||
660 | 2946 | 3105 | ||
661 | 2947 | xs_integer UnsignedByteItem::getIntegerValue() const | 3106 | xs_integer UnsignedByteItem::getIntegerValue() const |
662 | 2948 | { | 3107 | { |
664 | 2949 | return Integer((uint32_t)theValue); | 3108 | return xs_integer((uint32_t)theValue); |
665 | 2950 | } | 3109 | } |
666 | 2951 | 3110 | ||
667 | 2952 | 3111 | ||
669 | 2953 | xs_uinteger UnsignedByteItem::getUnsignedIntegerValue() const | 3112 | xs_nonNegativeInteger UnsignedByteItem::getUnsignedIntegerValue() const |
670 | 2954 | { | 3113 | { |
672 | 2955 | return Integer(theValue); | 3114 | return xs_nonNegativeInteger(theValue); |
673 | 2956 | } | 3115 | } |
674 | 2957 | 3116 | ||
675 | 2958 | 3117 | ||
676 | 2959 | 3118 | ||
677 | === modified file 'src/store/naive/atomic_items.h' | |||
678 | --- src/store/naive/atomic_items.h 2012-02-24 16:47:43 +0000 | |||
679 | +++ src/store/naive/atomic_items.h 2012-02-28 18:23:19 +0000 | |||
680 | @@ -171,7 +171,7 @@ | |||
681 | 171 | 171 | ||
682 | 172 | xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); } | 172 | xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); } |
683 | 173 | 173 | ||
685 | 174 | xs_uinteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); } | 174 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); } |
686 | 175 | 175 | ||
687 | 176 | xs_long getLongValue() const { return theBaseItem->getLongValue(); } | 176 | xs_long getLongValue() const { return theBaseItem->getLongValue(); } |
688 | 177 | 177 | ||
689 | @@ -1182,7 +1182,7 @@ | |||
690 | 1182 | return theValue.compare(other->getDoubleValue()); | 1182 | return theValue.compare(other->getDoubleValue()); |
691 | 1183 | } | 1183 | } |
692 | 1184 | 1184 | ||
694 | 1185 | bool getEBV( ) const; | 1185 | bool getEBV() const; |
695 | 1186 | 1186 | ||
696 | 1187 | zstring getStringValue() const; | 1187 | zstring getStringValue() const; |
697 | 1188 | 1188 | ||
698 | @@ -1339,6 +1339,31 @@ | |||
699 | 1339 | ********************************************************************************/ | 1339 | ********************************************************************************/ |
700 | 1340 | class IntegerItem : public AtomicItem | 1340 | class IntegerItem : public AtomicItem |
701 | 1341 | { | 1341 | { |
702 | 1342 | protected: | ||
703 | 1343 | IntegerItem() {} | ||
704 | 1344 | |||
705 | 1345 | public: | ||
706 | 1346 | virtual xs_decimal getDecimalValue() const = 0; | ||
707 | 1347 | virtual xs_integer getIntegerValue() const = 0; | ||
708 | 1348 | virtual xs_long getLongValue() const = 0; | ||
709 | 1349 | |||
710 | 1350 | virtual bool getEBV() const = 0; | ||
711 | 1351 | virtual store::Item* getType() const = 0; | ||
712 | 1352 | |||
713 | 1353 | virtual zstring getStringValue() const = 0; | ||
714 | 1354 | virtual void getStringValue2(zstring&) const = 0; | ||
715 | 1355 | virtual void appendStringValue(zstring& buf) const = 0; | ||
716 | 1356 | |||
717 | 1357 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const = 0; | ||
718 | 1358 | bool isNaN() const { return false; } | ||
719 | 1359 | }; | ||
720 | 1360 | |||
721 | 1361 | |||
722 | 1362 | /******************************************************************************* | ||
723 | 1363 | class IntegerItemImpl | ||
724 | 1364 | ********************************************************************************/ | ||
725 | 1365 | class IntegerItemImpl : public IntegerItem | ||
726 | 1366 | { | ||
727 | 1342 | friend class BasicItemFactory; | 1367 | friend class BasicItemFactory; |
728 | 1343 | friend class AtomicItem; | 1368 | friend class AtomicItem; |
729 | 1344 | 1369 | ||
730 | @@ -1346,40 +1371,37 @@ | |||
731 | 1346 | xs_integer theValue; | 1371 | xs_integer theValue; |
732 | 1347 | 1372 | ||
733 | 1348 | protected: | 1373 | protected: |
735 | 1349 | IntegerItem(const xs_integer& aValue) : theValue ( aValue ) {} | 1374 | IntegerItemImpl(const xs_integer& aValue) : theValue ( aValue ) {} |
736 | 1350 | 1375 | ||
738 | 1351 | IntegerItem() {} | 1376 | IntegerItemImpl() {} |
739 | 1352 | 1377 | ||
740 | 1353 | public: | 1378 | public: |
741 | 1354 | xs_decimal getDecimalValue() const; | 1379 | xs_decimal getDecimalValue() const; |
742 | 1355 | |||
743 | 1356 | xs_integer getIntegerValue() const { return theValue; } | 1380 | xs_integer getIntegerValue() const { return theValue; } |
744 | 1357 | 1381 | ||
746 | 1358 | xs_long getLongValue() const; | 1382 | xs_long getLongValue() const; |
747 | 1383 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } | ||
748 | 1384 | |||
749 | 1385 | zstring getStringValue() const; | ||
750 | 1386 | void getStringValue2(zstring&) const; | ||
751 | 1387 | void appendStringValue(zstring&) const; | ||
752 | 1359 | 1388 | ||
753 | 1360 | virtual store::SchemaTypeCode getTypeCode() const { return store::XS_INTEGER; } | 1389 | virtual store::SchemaTypeCode getTypeCode() const { return store::XS_INTEGER; } |
754 | 1361 | 1390 | ||
755 | 1362 | virtual store::Item* getType() const; | 1391 | virtual store::Item* getType() const; |
756 | 1363 | |||
757 | 1364 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | 1392 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; |
758 | 1365 | 1393 | ||
759 | 1394 | long compare( | ||
760 | 1395 | const Item* other, | ||
761 | 1396 | long timezone = 0, | ||
762 | 1397 | const XQPCollator* aCollation = 0) const; | ||
763 | 1398 | |||
764 | 1366 | bool equals( | 1399 | bool equals( |
765 | 1367 | const store::Item* other, | 1400 | const store::Item* other, |
766 | 1368 | long timezone = 0, | 1401 | long timezone = 0, |
767 | 1369 | const XQPCollator* aCollation = 0) const; | 1402 | const XQPCollator* aCollation = 0) const; |
768 | 1370 | 1403 | ||
781 | 1371 | long compare( | 1404 | bool getEBV() const; |
770 | 1372 | const Item* other, | ||
771 | 1373 | long timezone = 0, | ||
772 | 1374 | const XQPCollator* aCollation = 0) const; | ||
773 | 1375 | |||
774 | 1376 | bool getEBV( ) const; | ||
775 | 1377 | |||
776 | 1378 | zstring getStringValue() const; | ||
777 | 1379 | |||
778 | 1380 | void getStringValue2(zstring& val) const; | ||
779 | 1381 | |||
780 | 1382 | void appendStringValue(zstring& buf) const; | ||
782 | 1383 | 1405 | ||
783 | 1384 | bool isNaN() const { return false; } | 1406 | bool isNaN() const { return false; } |
784 | 1385 | 1407 | ||
785 | @@ -1395,28 +1417,53 @@ | |||
786 | 1395 | friend class BasicItemFactory; | 1417 | friend class BasicItemFactory; |
787 | 1396 | 1418 | ||
788 | 1397 | protected: | 1419 | protected: |
790 | 1398 | NonPositiveIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {} | 1420 | xs_nonPositiveInteger theValue; |
791 | 1421 | |||
792 | 1422 | NonPositiveIntegerItem(const xs_integer& aValue) : theValue(aValue) {} | ||
793 | 1399 | 1423 | ||
794 | 1400 | NonPositiveIntegerItem() {} | 1424 | NonPositiveIntegerItem() {} |
795 | 1401 | 1425 | ||
796 | 1402 | public: | 1426 | public: |
797 | 1427 | // inherited | ||
798 | 1428 | xs_decimal getDecimalValue() const; | ||
799 | 1429 | xs_integer getIntegerValue() const; | ||
800 | 1430 | xs_long getLongValue() const; | ||
801 | 1431 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } | ||
802 | 1432 | |||
803 | 1433 | zstring getStringValue() const; | ||
804 | 1434 | void getStringValue2(zstring& val) const; | ||
805 | 1435 | void appendStringValue(zstring&) const; | ||
806 | 1436 | |||
807 | 1437 | bool getEBV() const; | ||
808 | 1438 | |||
809 | 1403 | store::SchemaTypeCode getTypeCode() const { return store::XS_NON_POSITIVE_INTEGER; } | 1439 | store::SchemaTypeCode getTypeCode() const { return store::XS_NON_POSITIVE_INTEGER; } |
810 | 1404 | 1440 | ||
811 | 1405 | store::Item* getType() const; | 1441 | store::Item* getType() const; |
812 | 1442 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | ||
813 | 1406 | 1443 | ||
814 | 1407 | zstring show() const; | 1444 | zstring show() const; |
815 | 1445 | |||
816 | 1446 | long compare( | ||
817 | 1447 | const Item* other, | ||
818 | 1448 | long timezone = 0, | ||
819 | 1449 | const XQPCollator* aCollation = 0) const; | ||
820 | 1450 | |||
821 | 1451 | bool equals( | ||
822 | 1452 | const store::Item* other, | ||
823 | 1453 | long timezone = 0, | ||
824 | 1454 | const XQPCollator* aCollation = 0) const; | ||
825 | 1408 | }; | 1455 | }; |
826 | 1409 | 1456 | ||
827 | 1410 | 1457 | ||
828 | 1411 | /******************************************************************************* | 1458 | /******************************************************************************* |
829 | 1412 | class NegativeIntegerItem | 1459 | class NegativeIntegerItem |
830 | 1413 | ********************************************************************************/ | 1460 | ********************************************************************************/ |
832 | 1414 | class NegativeIntegerItem : public IntegerItem | 1461 | class NegativeIntegerItem : public NonPositiveIntegerItem |
833 | 1415 | { | 1462 | { |
834 | 1416 | friend class BasicItemFactory; | 1463 | friend class BasicItemFactory; |
835 | 1417 | 1464 | ||
836 | 1418 | protected: | 1465 | protected: |
838 | 1419 | NegativeIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {} | 1466 | NegativeIntegerItem(const xs_integer& aValue) : NonPositiveIntegerItem(aValue) {} |
839 | 1420 | 1467 | ||
840 | 1421 | NegativeIntegerItem() {} | 1468 | NegativeIntegerItem() {} |
841 | 1422 | 1469 | ||
842 | @@ -1431,38 +1478,61 @@ | |||
843 | 1431 | 1478 | ||
844 | 1432 | /******************************************************************************* | 1479 | /******************************************************************************* |
845 | 1433 | class NonNegativeIntegerItem | 1480 | class NonNegativeIntegerItem |
846 | 1434 | |||
847 | 1435 | Note: xs_uinteger is typedef of Integer | ||
848 | 1436 | ********************************************************************************/ | 1481 | ********************************************************************************/ |
849 | 1437 | class NonNegativeIntegerItem : public IntegerItem | 1482 | class NonNegativeIntegerItem : public IntegerItem |
850 | 1438 | { | 1483 | { |
851 | 1439 | friend class BasicItemFactory; | 1484 | friend class BasicItemFactory; |
852 | 1440 | 1485 | ||
853 | 1441 | protected: | 1486 | protected: |
855 | 1442 | NonNegativeIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) {} | 1487 | xs_nonNegativeInteger theValue; |
856 | 1488 | |||
857 | 1489 | NonNegativeIntegerItem(const xs_nonNegativeInteger& aValue) : theValue(aValue) {} | ||
858 | 1443 | 1490 | ||
859 | 1444 | NonNegativeIntegerItem() {} | 1491 | NonNegativeIntegerItem() {} |
860 | 1445 | 1492 | ||
861 | 1446 | public: | 1493 | public: |
863 | 1447 | xs_uinteger getUnsignedIntegerValue() const { return theValue; } | 1494 | // inherited |
864 | 1495 | xs_decimal getDecimalValue() const; | ||
865 | 1496 | xs_integer getIntegerValue() const; | ||
866 | 1497 | xs_long getLongValue() const; | ||
867 | 1498 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } | ||
868 | 1499 | |||
869 | 1500 | bool getEBV() const; | ||
870 | 1448 | 1501 | ||
871 | 1449 | store::SchemaTypeCode getTypeCode() const { return store::XS_NON_NEGATIVE_INTEGER; } | 1502 | store::SchemaTypeCode getTypeCode() const { return store::XS_NON_NEGATIVE_INTEGER; } |
872 | 1450 | 1503 | ||
873 | 1504 | |||
874 | 1451 | store::Item* getType() const; | 1505 | store::Item* getType() const; |
875 | 1452 | 1506 | ||
876 | 1507 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | ||
877 | 1508 | |||
878 | 1453 | zstring show() const; | 1509 | zstring show() const; |
879 | 1510 | |||
880 | 1511 | zstring getStringValue() const; | ||
881 | 1512 | void getStringValue2(zstring& val) const; | ||
882 | 1513 | void appendStringValue(zstring&) const; | ||
883 | 1514 | |||
884 | 1515 | long compare( | ||
885 | 1516 | const Item* other, | ||
886 | 1517 | long timezone = 0, | ||
887 | 1518 | const XQPCollator* aCollation = 0) const; | ||
888 | 1519 | |||
889 | 1520 | bool equals( | ||
890 | 1521 | const store::Item* other, | ||
891 | 1522 | long timezone = 0, | ||
892 | 1523 | const XQPCollator* aCollation = 0) const; | ||
893 | 1454 | }; | 1524 | }; |
894 | 1455 | 1525 | ||
895 | 1456 | 1526 | ||
896 | 1457 | /******************************************************************************* | 1527 | /******************************************************************************* |
897 | 1458 | class PositiveIntegerItem | 1528 | class PositiveIntegerItem |
898 | 1459 | ********************************************************************************/ | 1529 | ********************************************************************************/ |
900 | 1460 | class PositiveIntegerItem : public IntegerItem | 1530 | class PositiveIntegerItem : public NonNegativeIntegerItem |
901 | 1461 | { | 1531 | { |
902 | 1462 | friend class BasicItemFactory; | 1532 | friend class BasicItemFactory; |
903 | 1463 | 1533 | ||
904 | 1464 | protected: | 1534 | protected: |
906 | 1465 | PositiveIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) { } | 1535 | PositiveIntegerItem(const xs_positiveInteger& aValue) : NonNegativeIntegerItem(aValue) { } |
907 | 1466 | 1536 | ||
908 | 1467 | PositiveIntegerItem() {} | 1537 | PositiveIntegerItem() {} |
909 | 1468 | 1538 | ||
910 | @@ -1500,6 +1570,8 @@ | |||
911 | 1500 | 1570 | ||
912 | 1501 | xs_long getLongValue() const { return theValue; } | 1571 | xs_long getLongValue() const { return theValue; } |
913 | 1502 | 1572 | ||
914 | 1573 | xs_nonNegativeInteger getUnsignedIntegerValue() const; | ||
915 | 1574 | |||
916 | 1503 | store::SchemaTypeCode getTypeCode() const { return store::XS_LONG; } | 1575 | store::SchemaTypeCode getTypeCode() const { return store::XS_LONG; } |
917 | 1504 | 1576 | ||
918 | 1505 | store::Item* getType() const; | 1577 | store::Item* getType() const; |
919 | @@ -1541,7 +1613,7 @@ | |||
920 | 1541 | } | 1613 | } |
921 | 1542 | } | 1614 | } |
922 | 1543 | 1615 | ||
924 | 1544 | bool getEBV( ) const; | 1616 | bool getEBV() const; |
925 | 1545 | 1617 | ||
926 | 1546 | zstring getStringValue() const; | 1618 | zstring getStringValue() const; |
927 | 1547 | 1619 | ||
928 | @@ -1703,7 +1775,7 @@ | |||
929 | 1703 | } | 1775 | } |
930 | 1704 | } | 1776 | } |
931 | 1705 | 1777 | ||
933 | 1706 | bool getEBV( ) const; | 1778 | bool getEBV() const; |
934 | 1707 | 1779 | ||
935 | 1708 | zstring getStringValue() const; | 1780 | zstring getStringValue() const; |
936 | 1709 | 1781 | ||
937 | @@ -1787,7 +1859,7 @@ | |||
938 | 1787 | } | 1859 | } |
939 | 1788 | } | 1860 | } |
940 | 1789 | 1861 | ||
942 | 1790 | bool getEBV( ) const; | 1862 | bool getEBV() const; |
943 | 1791 | 1863 | ||
944 | 1792 | zstring getStringValue() const; | 1864 | zstring getStringValue() const; |
945 | 1793 | 1865 | ||
946 | @@ -1824,7 +1896,7 @@ | |||
947 | 1824 | 1896 | ||
948 | 1825 | xs_integer getIntegerValue() const; | 1897 | xs_integer getIntegerValue() const; |
949 | 1826 | 1898 | ||
951 | 1827 | xs_uinteger getUnsignedIntegerValue() const; | 1899 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
952 | 1828 | 1900 | ||
953 | 1829 | xs_unsignedLong getUnsignedLongValue() const { return theValue; } | 1901 | xs_unsignedLong getUnsignedLongValue() const { return theValue; } |
954 | 1830 | 1902 | ||
955 | @@ -1869,7 +1941,7 @@ | |||
956 | 1869 | } | 1941 | } |
957 | 1870 | } | 1942 | } |
958 | 1871 | 1943 | ||
960 | 1872 | bool getEBV( ) const; | 1944 | bool getEBV() const; |
961 | 1873 | 1945 | ||
962 | 1874 | zstring getStringValue() const; | 1946 | zstring getStringValue() const; |
963 | 1875 | 1947 | ||
964 | @@ -1904,7 +1976,7 @@ | |||
965 | 1904 | 1976 | ||
966 | 1905 | xs_integer getIntegerValue() const; | 1977 | xs_integer getIntegerValue() const; |
967 | 1906 | 1978 | ||
969 | 1907 | xs_uinteger getUnsignedIntegerValue() const; | 1979 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
970 | 1908 | 1980 | ||
971 | 1909 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 1981 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
972 | 1910 | 1982 | ||
973 | @@ -1960,7 +2032,7 @@ | |||
974 | 1960 | } | 2032 | } |
975 | 1961 | } | 2033 | } |
976 | 1962 | 2034 | ||
978 | 1963 | bool getEBV( ) const; | 2035 | bool getEBV() const; |
979 | 1964 | 2036 | ||
980 | 1965 | zstring getStringValue() const; | 2037 | zstring getStringValue() const; |
981 | 1966 | 2038 | ||
982 | @@ -1993,7 +2065,7 @@ | |||
983 | 1993 | 2065 | ||
984 | 1994 | xs_integer getIntegerValue() const; | 2066 | xs_integer getIntegerValue() const; |
985 | 1995 | 2067 | ||
987 | 1996 | xs_uinteger getUnsignedIntegerValue() const; | 2068 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
988 | 1997 | 2069 | ||
989 | 1998 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 2070 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
990 | 1999 | 2071 | ||
991 | @@ -2053,7 +2125,7 @@ | |||
992 | 2053 | } | 2125 | } |
993 | 2054 | } | 2126 | } |
994 | 2055 | 2127 | ||
996 | 2056 | bool getEBV( ) const; | 2128 | bool getEBV() const; |
997 | 2057 | 2129 | ||
998 | 2058 | zstring getStringValue() const; | 2130 | zstring getStringValue() const; |
999 | 2059 | 2131 | ||
1000 | @@ -2086,7 +2158,7 @@ | |||
1001 | 2086 | 2158 | ||
1002 | 2087 | xs_integer getIntegerValue() const; | 2159 | xs_integer getIntegerValue() const; |
1003 | 2088 | 2160 | ||
1005 | 2089 | xs_uinteger getUnsignedIntegerValue() const; | 2161 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
1006 | 2090 | 2162 | ||
1007 | 2091 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 2163 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
1008 | 2092 | 2164 | ||
1009 | @@ -2202,7 +2274,7 @@ | |||
1010 | 2202 | (theValue == false ? -1 : 1)); | 2274 | (theValue == false ? -1 : 1)); |
1011 | 2203 | } | 2275 | } |
1012 | 2204 | 2276 | ||
1014 | 2205 | bool getEBV( ) const; | 2277 | bool getEBV() const; |
1015 | 2206 | 2278 | ||
1016 | 2207 | zstring getStringValue() const; | 2279 | zstring getStringValue() const; |
1017 | 2208 | 2280 | ||
1018 | 2209 | 2281 | ||
1019 | === modified file 'src/store/naive/item.cpp' | |||
1020 | --- src/store/naive/item.cpp 2012-02-22 04:03:16 +0000 | |||
1021 | +++ src/store/naive/item.cpp 2012-02-28 18:23:19 +0000 | |||
1022 | @@ -570,7 +570,7 @@ | |||
1023 | 570 | * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort, | 570 | * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort, |
1024 | 571 | * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger | 571 | * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger |
1025 | 572 | */ | 572 | */ |
1027 | 573 | xs_uinteger Item::getUnsignedIntegerValue() const | 573 | xs_nonNegativeInteger Item::getUnsignedIntegerValue() const |
1028 | 574 | { | 574 | { |
1029 | 575 | throw ZORBA_EXCEPTION( | 575 | throw ZORBA_EXCEPTION( |
1030 | 576 | zerr::ZSTR0040_TYPE_ERROR, | 576 | zerr::ZSTR0040_TYPE_ERROR, |
1031 | 577 | 577 | ||
1032 | === modified file 'src/store/naive/simple_item_factory.cpp' | |||
1033 | --- src/store/naive/simple_item_factory.cpp 2012-02-22 01:31:08 +0000 | |||
1034 | +++ src/store/naive/simple_item_factory.cpp 2012-02-28 18:23:19 +0000 | |||
1035 | @@ -318,7 +318,7 @@ | |||
1036 | 318 | 318 | ||
1037 | 319 | bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value) | 319 | bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value) |
1038 | 320 | { | 320 | { |
1040 | 321 | result = new IntegerItem( value ); | 321 | result = new IntegerItemImpl( value ); |
1041 | 322 | return true; | 322 | return true; |
1042 | 323 | } | 323 | } |
1043 | 324 | 324 | ||
1044 | @@ -327,7 +327,7 @@ | |||
1045 | 327 | store::Item_t& result, | 327 | store::Item_t& result, |
1046 | 328 | const xs_integer& value) | 328 | const xs_integer& value) |
1047 | 329 | { | 329 | { |
1049 | 330 | ZORBA_ASSERT(value <= Integer::zero()); | 330 | ZORBA_ASSERT(value.sign() <= 0); |
1050 | 331 | result = new NonPositiveIntegerItem( value ); | 331 | result = new NonPositiveIntegerItem( value ); |
1051 | 332 | return true; | 332 | return true; |
1052 | 333 | } | 333 | } |
1053 | @@ -337,7 +337,7 @@ | |||
1054 | 337 | store::Item_t& result, | 337 | store::Item_t& result, |
1055 | 338 | const xs_integer& value) | 338 | const xs_integer& value) |
1056 | 339 | { | 339 | { |
1058 | 340 | ZORBA_ASSERT(value < xs_integer::zero()); | 340 | ZORBA_ASSERT(value.sign() < 0); |
1059 | 341 | result = new NegativeIntegerItem(value); | 341 | result = new NegativeIntegerItem(value); |
1060 | 342 | return true; | 342 | return true; |
1061 | 343 | } | 343 | } |
1062 | @@ -345,7 +345,7 @@ | |||
1063 | 345 | 345 | ||
1064 | 346 | bool BasicItemFactory::createNonNegativeInteger( | 346 | bool BasicItemFactory::createNonNegativeInteger( |
1065 | 347 | store::Item_t& result, | 347 | store::Item_t& result, |
1067 | 348 | const xs_uinteger& value ) | 348 | const xs_nonNegativeInteger& value ) |
1068 | 349 | { | 349 | { |
1069 | 350 | result = new NonNegativeIntegerItem( value ); | 350 | result = new NonNegativeIntegerItem( value ); |
1070 | 351 | return true; | 351 | return true; |
1071 | @@ -355,9 +355,9 @@ | |||
1072 | 355 | 355 | ||
1073 | 356 | bool BasicItemFactory::createPositiveInteger( | 356 | bool BasicItemFactory::createPositiveInteger( |
1074 | 357 | store::Item_t& result, | 357 | store::Item_t& result, |
1076 | 358 | const xs_uinteger& value) | 358 | const xs_positiveInteger& value) |
1077 | 359 | { | 359 | { |
1079 | 360 | ZORBA_ASSERT(value > Integer::zero()); | 360 | ZORBA_ASSERT(value.sign() > 0); |
1080 | 361 | result = new PositiveIntegerItem( value ); | 361 | result = new PositiveIntegerItem( value ); |
1081 | 362 | return true; | 362 | return true; |
1082 | 363 | } | 363 | } |
1083 | 364 | 364 | ||
1084 | === modified file 'src/store/naive/simple_item_factory.h' | |||
1085 | --- src/store/naive/simple_item_factory.h 2012-02-24 16:47:43 +0000 | |||
1086 | +++ src/store/naive/simple_item_factory.h 2012-02-28 18:23:19 +0000 | |||
1087 | @@ -131,9 +131,9 @@ | |||
1088 | 131 | 131 | ||
1089 | 132 | bool createInteger(store::Item_t& result, const xs_integer& value); | 132 | bool createInteger(store::Item_t& result, const xs_integer& value); |
1090 | 133 | 133 | ||
1092 | 134 | bool createNonNegativeInteger(store::Item_t& result, const xs_uinteger& value); | 134 | bool createNonNegativeInteger(store::Item_t& result, const xs_nonNegativeInteger& value); |
1093 | 135 | 135 | ||
1095 | 136 | bool createPositiveInteger(store::Item_t& result, const xs_uinteger& value ); | 136 | bool createPositiveInteger(store::Item_t& result, const xs_positiveInteger& value ); |
1096 | 137 | 137 | ||
1097 | 138 | bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value); | 138 | bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value); |
1098 | 139 | 139 | ||
1099 | 140 | 140 | ||
1100 | === modified file 'src/types/casting.cpp' | |||
1101 | --- src/types/casting.cpp 2012-02-22 04:03:16 +0000 | |||
1102 | +++ src/types/casting.cpp 2012-02-28 18:23:19 +0000 | |||
1103 | @@ -166,6 +166,7 @@ | |||
1104 | 166 | SAME_S_AND_T(aURI) | 166 | SAME_S_AND_T(aURI) |
1105 | 167 | SAME_S_AND_T(QN) | 167 | SAME_S_AND_T(QN) |
1106 | 168 | SAME_S_AND_T(NOT) | 168 | SAME_S_AND_T(NOT) |
1107 | 169 | SAME_S_AND_T(uint) | ||
1108 | 169 | 170 | ||
1109 | 170 | #undef SAME_S_AND_T | 171 | #undef SAME_S_AND_T |
1110 | 171 | 172 | ||
1111 | @@ -1344,6 +1345,153 @@ | |||
1112 | 1344 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); | 1345 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); |
1113 | 1345 | } | 1346 | } |
1114 | 1346 | 1347 | ||
1115 | 1348 | T1_TO_T2(uint, uA) | ||
1116 | 1349 | { | ||
1117 | 1350 | zstring strval2; | ||
1118 | 1351 | aItem->getStringValue2(strval2); | ||
1119 | 1352 | return str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo); | ||
1120 | 1353 | } | ||
1121 | 1354 | |||
1122 | 1355 | |||
1123 | 1356 | T1_TO_T2(uint, str) | ||
1124 | 1357 | { | ||
1125 | 1358 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); | ||
1126 | 1359 | } | ||
1127 | 1360 | |||
1128 | 1361 | |||
1129 | 1362 | T1_TO_T2(uint, flt) | ||
1130 | 1363 | { | ||
1131 | 1364 | return aFactory->createFloat( | ||
1132 | 1365 | result, xs_float(aItem->getUnsignedIntegerValue()) | ||
1133 | 1366 | ); | ||
1134 | 1367 | } | ||
1135 | 1368 | |||
1136 | 1369 | |||
1137 | 1370 | T1_TO_T2(uint, dbl) | ||
1138 | 1371 | { | ||
1139 | 1372 | return aFactory->createDouble( | ||
1140 | 1373 | result, xs_double(aItem->getUnsignedIntegerValue()) | ||
1141 | 1374 | ); | ||
1142 | 1375 | } | ||
1143 | 1376 | |||
1144 | 1377 | |||
1145 | 1378 | T1_TO_T2(uint, dec) | ||
1146 | 1379 | { | ||
1147 | 1380 | return aFactory->createDecimal( | ||
1148 | 1381 | result, xs_decimal(aItem->getUnsignedIntegerValue()) | ||
1149 | 1382 | ); | ||
1150 | 1383 | } | ||
1151 | 1384 | |||
1152 | 1385 | |||
1153 | 1386 | T1_TO_T2(uint, bool) | ||
1154 | 1387 | { | ||
1155 | 1388 | aFactory->createBoolean(result, aItem->getEBV()); | ||
1156 | 1389 | return true; | ||
1157 | 1390 | } | ||
1158 | 1391 | |||
1159 | 1392 | |||
1160 | 1393 | T1_TO_T2(uA, uint) | ||
1161 | 1394 | { | ||
1162 | 1395 | zstring strval2; | ||
1163 | 1396 | aItem->getStringValue2(strval2); | ||
1164 | 1397 | return str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo); | ||
1165 | 1398 | } | ||
1166 | 1399 | |||
1167 | 1400 | |||
1168 | 1401 | T1_TO_T2(flt, uint) | ||
1169 | 1402 | { | ||
1170 | 1403 | try | ||
1171 | 1404 | { | ||
1172 | 1405 | xs_nonNegativeInteger const n(aItem->getFloatValue()); | ||
1173 | 1406 | return aFactory->createNonNegativeInteger(result, n); | ||
1174 | 1407 | } | ||
1175 | 1408 | catch ( std::exception const& ) | ||
1176 | 1409 | { | ||
1177 | 1410 | throwTypeException( err::FOCA0002, aErrorInfo ); | ||
1178 | 1411 | return NULL; | ||
1179 | 1412 | } | ||
1180 | 1413 | } | ||
1181 | 1414 | |||
1182 | 1415 | |||
1183 | 1416 | T1_TO_T2(int, uint) | ||
1184 | 1417 | { | ||
1185 | 1418 | try | ||
1186 | 1419 | { | ||
1187 | 1420 | xs_nonNegativeInteger const n(aItem->getIntegerValue()); | ||
1188 | 1421 | return aFactory->createNonNegativeInteger(result, n); | ||
1189 | 1422 | } | ||
1190 | 1423 | catch ( std::exception const& ) | ||
1191 | 1424 | { | ||
1192 | 1425 | throwTypeException( err::FOCA0002, aErrorInfo ); | ||
1193 | 1426 | return NULL; | ||
1194 | 1427 | } | ||
1195 | 1428 | } | ||
1196 | 1429 | |||
1197 | 1430 | |||
1198 | 1431 | T1_TO_T2(uint, int) | ||
1199 | 1432 | { | ||
1200 | 1433 | try | ||
1201 | 1434 | { | ||
1202 | 1435 | xs_integer const n(aItem->getIntegerValue()); | ||
1203 | 1436 | return aFactory->createInteger(result, n); | ||
1204 | 1437 | } | ||
1205 | 1438 | catch ( std::exception const& ) | ||
1206 | 1439 | { | ||
1207 | 1440 | throwTypeException( err::FOCA0002, aErrorInfo ); | ||
1208 | 1441 | return NULL; | ||
1209 | 1442 | } | ||
1210 | 1443 | } | ||
1211 | 1444 | |||
1212 | 1445 | |||
1213 | 1446 | T1_TO_T2(dbl, uint) | ||
1214 | 1447 | { | ||
1215 | 1448 | try | ||
1216 | 1449 | { | ||
1217 | 1450 | xs_nonNegativeInteger const n(aItem->getDoubleValue()); | ||
1218 | 1451 | return aFactory->createInteger(result, n); | ||
1219 | 1452 | } | ||
1220 | 1453 | catch ( std::exception const& ) | ||
1221 | 1454 | { | ||
1222 | 1455 | throwTypeException( err::FOCA0002, aErrorInfo ); | ||
1223 | 1456 | return NULL; | ||
1224 | 1457 | } | ||
1225 | 1458 | } | ||
1226 | 1459 | |||
1227 | 1460 | |||
1228 | 1461 | T1_TO_T2(dec, uint) | ||
1229 | 1462 | { | ||
1230 | 1463 | xs_nonNegativeInteger const n(aItem->getDecimalValue()); | ||
1231 | 1464 | return aFactory->createNonNegativeInteger(result, n); | ||
1232 | 1465 | } | ||
1233 | 1466 | |||
1234 | 1467 | |||
1235 | 1468 | T1_TO_T2(bool, uint) | ||
1236 | 1469 | { | ||
1237 | 1470 | if (aItem->getBooleanValue()) | ||
1238 | 1471 | return aFactory->createNonNegativeInteger( | ||
1239 | 1472 | result, xs_nonNegativeInteger::one() | ||
1240 | 1473 | ); | ||
1241 | 1474 | else | ||
1242 | 1475 | return aFactory->createNonNegativeInteger( | ||
1243 | 1476 | result, xs_nonNegativeInteger::zero() | ||
1244 | 1477 | ); | ||
1245 | 1478 | } | ||
1246 | 1479 | |||
1247 | 1480 | |||
1248 | 1481 | T1_TO_T2(str, uint) | ||
1249 | 1482 | { | ||
1250 | 1483 | try { | ||
1251 | 1484 | xs_nonNegativeInteger const n(strval.c_str()); | ||
1252 | 1485 | return aFactory->createNonNegativeInteger(result, n); | ||
1253 | 1486 | } | ||
1254 | 1487 | catch ( std::invalid_argument const& ) { | ||
1255 | 1488 | throwTypeException( err::FORG0001, aErrorInfo ); | ||
1256 | 1489 | } | ||
1257 | 1490 | catch ( std::range_error const& ) { | ||
1258 | 1491 | throwTypeException( err::FOCA0002, aErrorInfo ); | ||
1259 | 1492 | } | ||
1260 | 1493 | return NULL; | ||
1261 | 1494 | } | ||
1262 | 1347 | 1495 | ||
1263 | 1348 | /******************************************************************************* | 1496 | /******************************************************************************* |
1264 | 1349 | 1497 | ||
1265 | @@ -1451,14 +1599,14 @@ | |||
1266 | 1451 | case store::XS_NON_POSITIVE_INTEGER: | 1599 | case store::XS_NON_POSITIVE_INTEGER: |
1267 | 1452 | { | 1600 | { |
1268 | 1453 | xs_integer const lInteger = aItem->getIntegerValue(); | 1601 | xs_integer const lInteger = aItem->getIntegerValue(); |
1270 | 1454 | if (lInteger <= xs_integer::zero()) | 1602 | if (lInteger.sign() <= 0) |
1271 | 1455 | return aFactory->createNonPositiveInteger(result, lInteger); | 1603 | return aFactory->createNonPositiveInteger(result, lInteger); |
1272 | 1456 | break; | 1604 | break; |
1273 | 1457 | } | 1605 | } |
1274 | 1458 | case store::XS_NEGATIVE_INTEGER: | 1606 | case store::XS_NEGATIVE_INTEGER: |
1275 | 1459 | { | 1607 | { |
1276 | 1460 | xs_integer const lInteger = aItem->getIntegerValue(); | 1608 | xs_integer const lInteger = aItem->getIntegerValue(); |
1278 | 1461 | if (lInteger < xs_integer::zero()) | 1609 | if (lInteger.sign() < 0) |
1279 | 1462 | return aFactory->createNegativeInteger(result, lInteger); | 1610 | return aFactory->createNegativeInteger(result, lInteger); |
1280 | 1463 | break; | 1611 | break; |
1281 | 1464 | } | 1612 | } |
1282 | @@ -1522,9 +1670,15 @@ | |||
1283 | 1522 | } | 1670 | } |
1284 | 1523 | case store::XS_NON_NEGATIVE_INTEGER: | 1671 | case store::XS_NON_NEGATIVE_INTEGER: |
1285 | 1524 | { | 1672 | { |
1289 | 1525 | xs_integer const lInteger = aItem->getIntegerValue(); | 1673 | xs_decimal const d = aItem->getDecimalValue(); |
1290 | 1526 | if (lInteger >= xs_integer::zero()) | 1674 | if (d.sign() >= 0) |
1291 | 1527 | return aFactory->createNonNegativeInteger(result, lInteger); | 1675 | try { |
1292 | 1676 | xs_nonNegativeInteger const i(d); | ||
1293 | 1677 | return aFactory->createNonNegativeInteger(result, i); | ||
1294 | 1678 | } | ||
1295 | 1679 | catch ( std::exception const& ) { | ||
1296 | 1680 | // ignore | ||
1297 | 1681 | } | ||
1298 | 1528 | break; | 1682 | break; |
1299 | 1529 | } | 1683 | } |
1300 | 1530 | case store::XS_UNSIGNED_LONG: | 1684 | case store::XS_UNSIGNED_LONG: |
1301 | @@ -1587,9 +1741,9 @@ | |||
1302 | 1587 | } | 1741 | } |
1303 | 1588 | case store::XS_POSITIVE_INTEGER: | 1742 | case store::XS_POSITIVE_INTEGER: |
1304 | 1589 | { | 1743 | { |
1308 | 1590 | xs_integer lInteger = aItem->getIntegerValue(); | 1744 | xs_positiveInteger const i = aItem->getUnsignedIntegerValue(); |
1309 | 1591 | if (lInteger > xs_integer::zero()) | 1745 | if (i.sign() > 0) |
1310 | 1592 | return aFactory->createPositiveInteger(result, lInteger); | 1746 | return aFactory->createPositiveInteger(result, i); |
1311 | 1593 | break; | 1747 | break; |
1312 | 1594 | } | 1748 | } |
1313 | 1595 | default: | 1749 | default: |
1314 | @@ -1634,12 +1788,12 @@ | |||
1315 | 1634 | 5, // 25 XS_INT | 1788 | 5, // 25 XS_INT |
1316 | 1635 | 5, // 26 XS_SHORT | 1789 | 5, // 26 XS_SHORT |
1317 | 1636 | 5, // 27 XS_BYTE | 1790 | 5, // 27 XS_BYTE |
1324 | 1637 | 5, // 28 XS_NON_NEGATIVE_INTEGER | 1791 | 23, // 28 XS_NON_NEGATIVE_INTEGER |
1325 | 1638 | 5, // 29 XS_UNSIGNED_LONG | 1792 | 23, // 29 XS_UNSIGNED_LONG |
1326 | 1639 | 5, // 30 XS_UNSIGNED_INT | 1793 | 23, // 30 XS_UNSIGNED_INT |
1327 | 1640 | 5, // 31 XS_UNSIGNED_SHORT | 1794 | 23, // 31 XS_UNSIGNED_SHORT |
1328 | 1641 | 5, // 32 XS_UNSIGNED_BYTE | 1795 | 23, // 32 XS_UNSIGNED_BYTE |
1329 | 1642 | 5, // 33 XS_POSITIVE_INTEGER | 1796 | 23, // 33 XS_POSITIVE_INTEGER |
1330 | 1643 | 12, // 34 XS_GYEAR_MONTH | 1797 | 12, // 34 XS_GYEAR_MONTH |
1331 | 1644 | 13, // 35 XS_GYEAR | 1798 | 13, // 35 XS_GYEAR |
1332 | 1645 | 14, // 36 XS_GMONTH_DAY | 1799 | 14, // 36 XS_GMONTH_DAY |
1333 | @@ -1657,98 +1811,155 @@ | |||
1334 | 1657 | /******************************************************************************* | 1811 | /******************************************************************************* |
1335 | 1658 | 1812 | ||
1336 | 1659 | ********************************************************************************/ | 1813 | ********************************************************************************/ |
1338 | 1660 | const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[23] = | 1814 | const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[24] = |
1339 | 1661 | { | 1815 | { |
1343 | 1662 | /*uA*/ 0, /*str*/ str_down, /*flt*/ 0, /*dbl*/ 0, /*dec*/ 0, /*int*/ int_down, /*dur*/ 0, | 1816 | /*uA*/ 0, |
1344 | 1663 | /*yMD*/ 0, /*dTD*/ 0, /*dT*/ 0, /*tim*/ 0, /*dat*/ 0, /*gYM*/ 0, /*gYr*/ 0, /*gMD*/ 0, | 1817 | /*str*/ str_down, |
1345 | 1664 | /*gDay*/0, /*gMon*/0, /*bool*/0, /*b64*/ 0, /*hxB*/ 0, /*aURI*/0, /*QN*/ 0, /*NOT*/ 0 | 1818 | /*flt*/ 0, |
1346 | 1819 | /*dbl*/ 0, | ||
1347 | 1820 | /*dec*/ 0, | ||
1348 | 1821 | /*int*/ int_down, | ||
1349 | 1822 | /*dur*/ 0, | ||
1350 | 1823 | /*yMD*/ 0, | ||
1351 | 1824 | /*dTD*/ 0, | ||
1352 | 1825 | /*dT*/ 0, | ||
1353 | 1826 | /*tim*/ 0, | ||
1354 | 1827 | /*dat*/ 0, | ||
1355 | 1828 | /*gYM*/ 0, | ||
1356 | 1829 | /*gYr*/ 0, | ||
1357 | 1830 | /*gMD*/ 0, | ||
1358 | 1831 | /*gDay*/ 0, | ||
1359 | 1832 | /*gMon*/ 0, | ||
1360 | 1833 | /*bool*/ 0, | ||
1361 | 1834 | /*b64*/ 0, | ||
1362 | 1835 | /*hxB*/ 0, | ||
1363 | 1836 | /*aURI*/ 0, | ||
1364 | 1837 | /*QN*/ 0, | ||
1365 | 1838 | /*NOT*/ 0, | ||
1366 | 1839 | /*uint*/ int_down, | ||
1367 | 1665 | }; | 1840 | }; |
1368 | 1666 | 1841 | ||
1369 | 1667 | 1842 | ||
1370 | 1668 | /******************************************************************************* | 1843 | /******************************************************************************* |
1371 | 1669 | 1844 | ||
1372 | 1670 | ********************************************************************************/ | 1845 | ********************************************************************************/ |
1374 | 1671 | const GenericCast::CastFunc GenericCast::theCastMatrix[23][23] = | 1846 | const GenericCast::CastFunc GenericCast::theCastMatrix[24][24] = |
1375 | 1672 | { | 1847 | { |
1376 | 1673 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | 1848 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ |
1377 | 1674 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | 1849 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ |
1379 | 1675 | /*aURI*/ /*QN*/ /*NOT*/ | 1850 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ |
1380 | 1851 | |||
1381 | 1676 | /*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT, | 1852 | /*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT, |
1382 | 1677 | &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, | 1853 | &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, |
1384 | 1678 | &uA_aURI, 0, 0}, | 1854 | &uA_aURI, 0, 0, &uA_uint}, |
1385 | 1679 | 1855 | ||
1386 | 1680 | /*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT, | 1856 | /*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT, |
1387 | 1681 | &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB, | 1857 | &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB, |
1389 | 1682 | &str_aURI, &str_QN, &str_NOT}, | 1858 | &str_aURI, &str_QN, &str_NOT, &str_uint}, |
1390 | 1683 | 1859 | ||
1391 | 1684 | /*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0, | 1860 | /*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0, |
1392 | 1685 | 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0, | 1861 | 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0, |
1394 | 1686 | 0, 0, 0}, | 1862 | 0, 0, 0, &flt_uint}, |
1395 | 1687 | 1863 | ||
1396 | 1688 | /*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0, | 1864 | /*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0, |
1397 | 1689 | 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0, | 1865 | 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0, |
1399 | 1690 | 0, 0, 0}, | 1866 | 0, 0, 0, &dbl_uint}, |
1400 | 1691 | 1867 | ||
1401 | 1692 | /*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0, | 1868 | /*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0, |
1402 | 1693 | 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0, | 1869 | 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0, |
1404 | 1694 | 0, 0, 0}, | 1870 | 0, 0, 0, &dec_uint}, |
1405 | 1871 | |||
1406 | 1872 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1407 | 1873 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1408 | 1874 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1409 | 1875 | |||
1410 | 1695 | /*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0, | 1876 | /*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0, |
1411 | 1696 | 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0, | 1877 | 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0, |
1413 | 1697 | 0, 0, 0}, | 1878 | 0, 0, 0, &int_uint}, |
1414 | 1879 | |||
1415 | 1698 | /*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0, | 1880 | /*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0, |
1416 | 1699 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1881 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1418 | 1700 | 0, 0, 0}, | 1882 | 0, 0, 0, 0}, |
1419 | 1883 | |||
1420 | 1701 | /*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0, | 1884 | /*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0, |
1421 | 1702 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1885 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1423 | 1703 | 0, 0, 0}, | 1886 | 0, 0, 0, 0}, |
1424 | 1887 | |||
1425 | 1704 | /*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0, | 1888 | /*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0, |
1426 | 1705 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1889 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1431 | 1706 | 0, 0, 0}, | 1890 | 0, 0, 0, 0}, |
1432 | 1707 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | 1891 | |
1429 | 1708 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1430 | 1709 | /*aURI*/ /*QN*/ /*NOT*/ | ||
1433 | 1710 | /*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT, | 1892 | /*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT, |
1434 | 1711 | &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0, | 1893 | &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0, |
1436 | 1712 | 0, 0, 0}, | 1894 | 0, 0, 0, 0}, |
1437 | 1895 | |||
1438 | 1896 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1439 | 1897 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1440 | 1898 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1441 | 1899 | |||
1442 | 1713 | /*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1900 | /*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1443 | 1714 | &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1901 | &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1445 | 1715 | 0, 0, 0}, | 1902 | 0, 0, 0, 0}, |
1446 | 1903 | |||
1447 | 1716 | /*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT, | 1904 | /*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT, |
1448 | 1717 | 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0, | 1905 | 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0, |
1450 | 1718 | 0, 0, 0}, | 1906 | 0, 0, 0, 0}, |
1451 | 1907 | |||
1452 | 1719 | /*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1908 | /*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1453 | 1720 | 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0, | 1909 | 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0, |
1455 | 1721 | 0, 0, 0}, | 1910 | 0, 0, 0, 0}, |
1456 | 1911 | |||
1457 | 1722 | /*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1912 | /*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1458 | 1723 | 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0, | 1913 | 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0, |
1460 | 1724 | 0, 0, 0}, | 1914 | 0, 0, 0, 0}, |
1461 | 1915 | |||
1462 | 1725 | /*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1916 | /*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1463 | 1726 | 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0, | 1917 | 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0, |
1465 | 1727 | 0, 0, 0}, | 1918 | 0, 0, 0, 0}, |
1466 | 1919 | |||
1467 | 1920 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1468 | 1921 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1469 | 1922 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1470 | 1923 | |||
1471 | 1728 | /*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1924 | /*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1472 | 1729 | 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0, | 1925 | 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0, |
1474 | 1730 | 0, 0, 0}, | 1926 | 0, 0, 0, 0}, |
1475 | 1927 | |||
1476 | 1731 | /*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1928 | /*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1477 | 1732 | 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0, | 1929 | 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0, |
1479 | 1733 | 0, 0, 0}, | 1930 | 0, 0, 0, 0}, |
1480 | 1931 | |||
1481 | 1734 | /*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0, | 1932 | /*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0, |
1482 | 1735 | 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0, | 1933 | 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0, |
1484 | 1736 | 0, 0, 0}, | 1934 | 0, 0, 0, &bool_uint}, |
1485 | 1935 | |||
1486 | 1737 | /*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1936 | /*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1487 | 1738 | 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB, | 1937 | 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB, |
1489 | 1739 | 0, 0, 0}, | 1938 | 0, 0, 0, 0}, |
1490 | 1939 | |||
1491 | 1740 | /*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1940 | /*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1492 | 1741 | 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB, | 1941 | 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB, |
1494 | 1742 | 0, 0, 0}, | 1942 | 0, 0, 0, 0}, |
1495 | 1943 | |||
1496 | 1944 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1497 | 1945 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1498 | 1946 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1499 | 1947 | |||
1500 | 1743 | /*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1948 | /*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1501 | 1744 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1949 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1503 | 1745 | &aURI_aURI,0, 0}, | 1950 | &aURI_aURI,0, 0, 0}, |
1504 | 1951 | |||
1505 | 1746 | /*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1952 | /*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1506 | 1747 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1953 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1508 | 1748 | 0, &QN_QN, 0}, | 1954 | 0, &QN_QN, 0, 0}, |
1509 | 1955 | |||
1510 | 1749 | /*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1956 | /*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1511 | 1750 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1957 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1513 | 1751 | 0, 0, &NOT_NOT} | 1958 | 0, 0, &NOT_NOT, 0}, |
1514 | 1959 | |||
1515 | 1960 | /*uint*/ {&uint_uA, &uint_str, &uint_flt, &uint_dbl, &uint_dec, &uint_int, 0, 0, 0, 0, | ||
1516 | 1961 | 0, 0, 0, 0, 0, 0, 0, &uint_bool,0, 0, | ||
1517 | 1962 | 0, 0, 0, &uint_uint}, | ||
1518 | 1752 | }; | 1963 | }; |
1519 | 1753 | 1964 | ||
1520 | 1754 | 1965 | ||
1521 | 1755 | 1966 | ||
1522 | === modified file 'src/types/casting.h' | |||
1523 | --- src/types/casting.h 2012-01-24 11:24:56 +0000 | |||
1524 | +++ src/types/casting.h 2012-02-28 18:23:19 +0000 | |||
1525 | @@ -51,8 +51,8 @@ | |||
1526 | 51 | 51 | ||
1527 | 52 | private: | 52 | private: |
1528 | 53 | static const int theMapping[store::XS_LAST]; | 53 | static const int theMapping[store::XS_LAST]; |
1531 | 54 | static const CastFunc theCastMatrix[23][23]; | 54 | static const CastFunc theCastMatrix[24][24]; |
1532 | 55 | static const DownCastFunc theDownCastMatrix[23]; | 55 | static const DownCastFunc theDownCastMatrix[24]; |
1533 | 56 | 56 | ||
1534 | 57 | GenericCast() {} | 57 | GenericCast() {} |
1535 | 58 | 58 | ||
1536 | 59 | 59 | ||
1537 | === modified file 'src/types/schema/XercesParseUtils.cpp' | |||
1538 | --- src/types/schema/XercesParseUtils.cpp 2011-06-30 05:16:55 +0000 | |||
1539 | +++ src/types/schema/XercesParseUtils.cpp 2012-02-28 18:23:19 +0000 | |||
1540 | @@ -118,7 +118,7 @@ | |||
1541 | 118 | { | 118 | { |
1542 | 119 | long value = xsval->fData.fValue.f_long; | 119 | long value = xsval->fData.fValue.f_long; |
1543 | 120 | 120 | ||
1545 | 121 | xs_integer tvalue(value); | 121 | xs_positiveInteger tvalue(value); |
1546 | 122 | 122 | ||
1547 | 123 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 123 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
1548 | 124 | return factory->createPositiveInteger(result, tvalue); | 124 | return factory->createPositiveInteger(result, tvalue); |
1549 | @@ -207,7 +207,7 @@ | |||
1550 | 207 | { | 207 | { |
1551 | 208 | long value = xsval->fData.fValue.f_long; | 208 | long value = xsval->fData.fValue.f_long; |
1552 | 209 | 209 | ||
1554 | 210 | xs_integer tvalue(value); | 210 | xs_nonNegativeInteger tvalue(value); |
1555 | 211 | 211 | ||
1556 | 212 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 212 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
1557 | 213 | return factory->createNonNegativeInteger(result, tvalue); | 213 | return factory->createNonNegativeInteger(result, tvalue); |
1558 | 214 | 214 | ||
1559 | === modified file 'src/util/stl_util.h' | |||
1560 | --- src/util/stl_util.h 2012-02-16 14:11:02 +0000 | |||
1561 | +++ src/util/stl_util.h 2012-02-28 18:23:19 +0000 | |||
1562 | @@ -248,6 +248,13 @@ | |||
1563 | 248 | /////////////////////////////////////////////////////////////////////////////// | 248 | /////////////////////////////////////////////////////////////////////////////// |
1564 | 249 | 249 | ||
1565 | 250 | template<typename NumericType> inline | 250 | template<typename NumericType> inline |
1566 | 251 | typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<NumericType>::value, | ||
1567 | 252 | bool>::type | ||
1568 | 253 | gt0( NumericType n ) { // for completeness | ||
1569 | 254 | return n > 0; | ||
1570 | 255 | } | ||
1571 | 256 | |||
1572 | 257 | template<typename NumericType> inline | ||
1573 | 251 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | 258 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type |
1574 | 252 | ge0( NumericType n ) { | 259 | ge0( NumericType n ) { |
1575 | 253 | return n >= 0; | 260 | return n >= 0; |
1576 | @@ -259,6 +266,30 @@ | |||
1577 | 259 | return true; | 266 | return true; |
1578 | 260 | } | 267 | } |
1579 | 261 | 268 | ||
1580 | 269 | template<typename NumericType> inline | ||
1581 | 270 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | ||
1582 | 271 | lt0( NumericType n ) { | ||
1583 | 272 | return n < 0; | ||
1584 | 273 | } | ||
1585 | 274 | |||
1586 | 275 | template<typename IntType> inline | ||
1587 | 276 | typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type | ||
1588 | 277 | lt0( IntType ) { | ||
1589 | 278 | return false; | ||
1590 | 279 | } | ||
1591 | 280 | |||
1592 | 281 | template<typename NumericType> inline | ||
1593 | 282 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | ||
1594 | 283 | le0( NumericType n ) { | ||
1595 | 284 | return n <= 0; | ||
1596 | 285 | } | ||
1597 | 286 | |||
1598 | 287 | template<typename IntType> inline | ||
1599 | 288 | typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type | ||
1600 | 289 | le0( IntType n ) { | ||
1601 | 290 | return n == 0; | ||
1602 | 291 | } | ||
1603 | 292 | |||
1604 | 262 | /////////////////////////////////////////////////////////////////////////////// | 293 | /////////////////////////////////////////////////////////////////////////////// |
1605 | 263 | 294 | ||
1606 | 264 | template<typename T> class stack_generator { | 295 | template<typename T> class stack_generator { |
1607 | 265 | 296 | ||
1608 | === modified file 'src/util/string_util.cpp' | |||
1609 | --- src/util/string_util.cpp 2011-07-07 18:48:27 +0000 | |||
1610 | +++ src/util/string_util.cpp 2012-02-28 18:23:19 +0000 | |||
1611 | @@ -110,14 +110,22 @@ | |||
1612 | 110 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). | 110 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). |
1613 | 111 | // | 111 | // |
1614 | 112 | s = ascii::trim_start_whitespace( s ); | 112 | s = ascii::trim_start_whitespace( s ); |
1616 | 113 | if ( *s == '-' ) | 113 | bool const minus = *s == '-'; |
1617 | 114 | |||
1618 | 115 | char *end; | ||
1619 | 116 | errno = 0; | ||
1620 | 117 | unsigned long long const result = std::strtoull( s, &end, 10 ); | ||
1621 | 118 | check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) ); | ||
1622 | 119 | |||
1623 | 120 | if ( minus && result ) { | ||
1624 | 121 | // | ||
1625 | 122 | // Throw an exception only if there was a '-' and the result is non-zero. | ||
1626 | 123 | // Hence, this allows "-0" and treats it as "0". | ||
1627 | 124 | // | ||
1628 | 114 | throw std::invalid_argument( | 125 | throw std::invalid_argument( |
1629 | 115 | "\"-\": invalid character for unsigned integer" | 126 | "\"-\": invalid character for unsigned integer" |
1630 | 116 | ); | 127 | ); |
1635 | 117 | char *end; | 128 | } |
1632 | 118 | errno = 0; | ||
1633 | 119 | unsigned long long const result = std::strtoull( s, &end, 10 ); | ||
1634 | 120 | check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) ); | ||
1636 | 121 | return result; | 129 | return result; |
1637 | 122 | } | 130 | } |
1638 | 123 | 131 | ||
1639 | 124 | 132 | ||
1640 | === modified file 'src/zorbaserialization/zorba_class_serializer.cpp' | |||
1641 | --- src/zorbaserialization/zorba_class_serializer.cpp 2012-02-22 04:03:16 +0000 | |||
1642 | +++ src/zorbaserialization/zorba_class_serializer.cpp 2012-02-28 18:23:19 +0000 | |||
1643 | @@ -205,10 +205,19 @@ | |||
1644 | 205 | } | 205 | } |
1645 | 206 | } | 206 | } |
1646 | 207 | 207 | ||
1648 | 208 | void operator&(serialization::Archiver &ar, Integer &obj) | 208 | #ifdef ZORBA_WITH_BIG_INTEGER |
1649 | 209 | void operator&(serialization::Archiver &ar, IntegerImpl &obj) | ||
1650 | 210 | #else | ||
1651 | 211 | template<typename IntType> | ||
1652 | 212 | void operator&(serialization::Archiver &ar, IntegerImpl<IntType> &obj) | ||
1653 | 213 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1654 | 209 | { | 214 | { |
1655 | 210 | ar & obj.value_; | 215 | ar & obj.value_; |
1656 | 211 | } | 216 | } |
1657 | 217 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1658 | 218 | template void operator&(serialization::Archiver&, IntegerImpl<long long>&); | ||
1659 | 219 | template void operator&(serialization::Archiver&, IntegerImpl<unsigned long long>&); | ||
1660 | 220 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1661 | 212 | 221 | ||
1662 | 213 | void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items) | 222 | void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items) |
1663 | 214 | { | 223 | { |
1664 | @@ -590,7 +599,7 @@ | |||
1665 | 590 | } | 599 | } |
1666 | 591 | else if(name_of_type == "nonNegativeInteger") | 600 | else if(name_of_type == "nonNegativeInteger") |
1667 | 592 | { | 601 | { |
1669 | 593 | SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue()); | 602 | SERIALIZE_FIELD(xs_nonNegativeInteger, value, getUnsignedIntegerValue()); |
1670 | 594 | FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value)); | 603 | FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value)); |
1671 | 595 | } | 604 | } |
1672 | 596 | else if(name_of_type == "negativeInteger") | 605 | else if(name_of_type == "negativeInteger") |
1673 | @@ -600,7 +609,7 @@ | |||
1674 | 600 | } | 609 | } |
1675 | 601 | else if(name_of_type == "positiveInteger") | 610 | else if(name_of_type == "positiveInteger") |
1676 | 602 | { | 611 | { |
1678 | 603 | SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue()); | 612 | SERIALIZE_FIELD(xs_positiveInteger, value, getUnsignedIntegerValue()); |
1679 | 604 | FINALIZE_SERIALIZE(createPositiveInteger, (result, value)); | 613 | FINALIZE_SERIALIZE(createPositiveInteger, (result, value)); |
1680 | 605 | } | 614 | } |
1681 | 606 | 615 | ||
1682 | 607 | 616 | ||
1683 | === modified file 'src/zorbaserialization/zorba_class_serializer.h' | |||
1684 | --- src/zorbaserialization/zorba_class_serializer.h 2012-02-02 09:56:52 +0000 | |||
1685 | +++ src/zorbaserialization/zorba_class_serializer.h 2012-02-28 18:23:19 +0000 | |||
1686 | @@ -38,13 +38,22 @@ | |||
1687 | 38 | class function; | 38 | class function; |
1688 | 39 | class Diagnostic; | 39 | class Diagnostic; |
1689 | 40 | class ZorbaException; | 40 | class ZorbaException; |
1691 | 41 | class Integer; | 41 | #ifdef ZORBA_WITH_BIG_INTEGER |
1692 | 42 | class IntegerImpl; | ||
1693 | 43 | #else | ||
1694 | 44 | template<typename IntType> class IntegerImpl; | ||
1695 | 45 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1696 | 42 | 46 | ||
1697 | 43 | namespace serialization{ | 47 | namespace serialization{ |
1698 | 44 | //void operator&(Archiver &ar, XQType *&obj); | 48 | //void operator&(Archiver &ar, XQType *&obj); |
1699 | 45 | void operator&(Archiver &ar, const XQType *&obj); | 49 | void operator&(Archiver &ar, const XQType *&obj); |
1700 | 46 | void operator&(Archiver &ar, MAPM &obj); | 50 | void operator&(Archiver &ar, MAPM &obj); |
1702 | 47 | void operator&(Archiver &ar, Integer &obj); | 51 | #ifdef ZORBA_WITH_BIG_INTEGER |
1703 | 52 | void operator&(Archiver &ar, IntegerImpl &obj); | ||
1704 | 53 | #else | ||
1705 | 54 | template<typename IntType> | ||
1706 | 55 | void operator&(Archiver &ar, IntegerImpl<IntType> &obj); | ||
1707 | 56 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1708 | 48 | 57 | ||
1709 | 49 | void operator&(Archiver &ar, XQPCollator *&obj); | 58 | void operator&(Archiver &ar, XQPCollator *&obj); |
1710 | 50 | void operator&(Archiver &ar, store::Item* &obj); | 59 | void operator&(Archiver &ar, store::Item* &obj); |
1711 | 51 | 60 | ||
1712 | === modified file 'src/zorbatypes/decimal.cpp' | |||
1713 | --- src/zorbatypes/decimal.cpp 2011-07-06 19:59:26 +0000 | |||
1714 | +++ src/zorbatypes/decimal.cpp 2012-02-28 18:23:19 +0000 | |||
1715 | @@ -28,6 +28,16 @@ | |||
1716 | 28 | #include "integer.h" | 28 | #include "integer.h" |
1717 | 29 | #include "numconversions.h" | 29 | #include "numconversions.h" |
1718 | 30 | 30 | ||
1719 | 31 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
1720 | 32 | # define TEMPLATE_DECL(T) /* nothing */ | ||
1721 | 33 | # define INTEGER_IMPL(T) IntegerImpl | ||
1722 | 34 | #else | ||
1723 | 35 | # define TEMPLATE_DECL(T) template<typename T> | ||
1724 | 36 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
1725 | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1726 | 38 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
1727 | 39 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
1728 | 40 | |||
1729 | 31 | namespace zorba { | 41 | namespace zorba { |
1730 | 32 | 42 | ||
1731 | 33 | SERIALIZABLE_CLASS_VERSIONS(Decimal) | 43 | SERIALIZABLE_CLASS_VERSIONS(Decimal) |
1732 | @@ -218,8 +228,13 @@ | |||
1733 | 218 | value_ = f.getNumber(); | 228 | value_ = f.getNumber(); |
1734 | 219 | } | 229 | } |
1735 | 220 | 230 | ||
1737 | 221 | Decimal::Decimal( Integer const &i ) : value_( i.itod() ) { | 231 | TEMPLATE_DECL(T) |
1738 | 232 | Decimal::Decimal( INTEGER_IMPL(T) const &i ) : value_( i.itod() ) { | ||
1739 | 222 | } | 233 | } |
1740 | 234 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1741 | 235 | template Decimal::Decimal( INTEGER_IMPL_LL const& ); | ||
1742 | 236 | template Decimal::Decimal( INTEGER_IMPL_ULL const& ); | ||
1743 | 237 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1744 | 223 | 238 | ||
1745 | 224 | ////////// assignment operators /////////////////////////////////////////////// | 239 | ////////// assignment operators /////////////////////////////////////////////// |
1746 | 225 | 240 | ||
1747 | @@ -235,10 +250,15 @@ | |||
1748 | 235 | return *this; | 250 | return *this; |
1749 | 236 | } | 251 | } |
1750 | 237 | 252 | ||
1752 | 238 | Decimal& Decimal::operator=( Integer const &i ) { | 253 | TEMPLATE_DECL(T) |
1753 | 254 | Decimal& Decimal::operator=( INTEGER_IMPL(T) const &i ) { | ||
1754 | 239 | value_ = i.itod(); | 255 | value_ = i.itod(); |
1755 | 240 | return *this; | 256 | return *this; |
1756 | 241 | } | 257 | } |
1757 | 258 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1758 | 259 | template Decimal& Decimal::operator=( INTEGER_IMPL_LL const& ); | ||
1759 | 260 | template Decimal& Decimal::operator=( INTEGER_IMPL_ULL const& ); | ||
1760 | 261 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1761 | 242 | 262 | ||
1762 | 243 | Decimal& Decimal::operator=( Double const &d ) { | 263 | Decimal& Decimal::operator=( Double const &d ) { |
1763 | 244 | if ( !d.isFinite() ) | 264 | if ( !d.isFinite() ) |
1764 | @@ -256,61 +276,69 @@ | |||
1765 | 256 | 276 | ||
1766 | 257 | ////////// arithmetic operators /////////////////////////////////////////////// | 277 | ////////// arithmetic operators /////////////////////////////////////////////// |
1767 | 258 | 278 | ||
1787 | 259 | Decimal operator+( Decimal const &d, Integer const &i ) { | 279 | #ifdef ZORBA_WITH_BIG_INTEGER |
1788 | 260 | return d.value_ + i.itod(); | 280 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
1789 | 261 | } | 281 | #else |
1790 | 262 | 282 | # define ZORBA_INSTANTIATE(OP) \ | |
1791 | 263 | Decimal operator-( Decimal const &d, Integer const &i ) { | 283 | template Decimal operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \ |
1792 | 264 | return d.value_ - i.itod(); | 284 | template Decimal operator OP( Decimal const&, INTEGER_IMPL_ULL const& ) |
1793 | 265 | } | 285 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1794 | 266 | 286 | ||
1795 | 267 | Decimal operator*( Decimal const &d, Integer const &i ) { | 287 | #define ZORBA_DECIMAL_OP(OP) \ |
1796 | 268 | return d.value_ * i.itod(); | 288 | TEMPLATE_DECL(T) \ |
1797 | 269 | } | 289 | Decimal operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
1798 | 270 | 290 | return d.value_ OP i.itod(); \ | |
1799 | 271 | Decimal operator/( Decimal const &d, Integer const &i ) { | 291 | } \ |
1800 | 272 | return d.value_ / i.itod(); | 292 | ZORBA_INSTANTIATE(OP) |
1801 | 273 | } | 293 | |
1802 | 274 | 294 | ZORBA_DECIMAL_OP(+); | |
1803 | 275 | Decimal operator%( Decimal const &d, Integer const &i ) { | 295 | ZORBA_DECIMAL_OP(-); |
1804 | 276 | return d.value_ % i.itod(); | 296 | ZORBA_DECIMAL_OP(*); |
1805 | 277 | } | 297 | ZORBA_DECIMAL_OP(/); |
1806 | 298 | ZORBA_DECIMAL_OP(%); | ||
1807 | 299 | #undef ZORBA_DECIMAL_OP | ||
1808 | 300 | #undef ZORBA_INSTANTIATE | ||
1809 | 278 | 301 | ||
1810 | 279 | ////////// relational operators /////////////////////////////////////////////// | 302 | ////////// relational operators /////////////////////////////////////////////// |
1811 | 280 | 303 | ||
1835 | 281 | bool operator==( Decimal const &d, Integer const &i ) { | 304 | #ifdef ZORBA_WITH_BIG_INTEGER |
1836 | 282 | return d.value_ == i.itod(); | 305 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
1837 | 283 | } | 306 | #else |
1838 | 284 | 307 | # define ZORBA_INSTANTIATE(OP) \ | |
1839 | 285 | bool operator!=( Decimal const &d, Integer const &i ) { | 308 | template bool operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \ |
1840 | 286 | return d.value_ != i.itod(); | 309 | template bool operator OP( Decimal const&, INTEGER_IMPL_ULL const& ) |
1841 | 287 | } | 310 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1842 | 288 | 311 | ||
1843 | 289 | bool operator<( Decimal const &d, Integer const &i ) { | 312 | #define ZORBA_DECIMAL_OP(OP) \ |
1844 | 290 | return d.value_ < i.itod(); | 313 | TEMPLATE_DECL(T) \ |
1845 | 291 | } | 314 | bool operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
1846 | 292 | 315 | return d.value_ OP i.itod(); \ | |
1847 | 293 | bool operator<=( Decimal const &d, Integer const &i ) { | 316 | } \ |
1848 | 294 | return d.value_ <= i.itod(); | 317 | ZORBA_INSTANTIATE(OP) |
1849 | 295 | } | 318 | |
1850 | 296 | 319 | ZORBA_DECIMAL_OP(==); | |
1851 | 297 | bool operator>( Decimal const &d, Integer const &i ) { | 320 | ZORBA_DECIMAL_OP(!=); |
1852 | 298 | return d.value_ > i.itod(); | 321 | ZORBA_DECIMAL_OP(< ); |
1853 | 299 | } | 322 | ZORBA_DECIMAL_OP(<=); |
1854 | 300 | 323 | ZORBA_DECIMAL_OP(> ); | |
1855 | 301 | bool operator>=( Decimal const &d, Integer const &i ) { | 324 | ZORBA_DECIMAL_OP(>=); |
1856 | 302 | return d.value_ >= i.itod(); | 325 | #undef ZORBA_DECIMAL_OP |
1857 | 303 | } | 326 | #undef ZORBA_INSTANTIATE |
1858 | 304 | 327 | ||
1859 | 305 | ////////// math functions ///////////////////////////////////////////////////// | 328 | ////////// math functions ///////////////////////////////////////////////////// |
1860 | 306 | 329 | ||
1861 | 307 | Decimal Decimal::round() const { | 330 | Decimal Decimal::round() const { |
1863 | 308 | return round( Integer::zero() ); | 331 | return round( INTEGER_IMPL_LL::zero() ); |
1864 | 309 | } | 332 | } |
1865 | 310 | 333 | ||
1867 | 311 | Decimal Decimal::round( Integer const &precision ) const { | 334 | TEMPLATE_DECL(T) |
1868 | 335 | Decimal Decimal::round( INTEGER_IMPL(T) const &precision ) const { | ||
1869 | 312 | return round( value_, precision.itod() ); | 336 | return round( value_, precision.itod() ); |
1870 | 313 | } | 337 | } |
1871 | 338 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1872 | 339 | template Decimal Decimal::round( INTEGER_IMPL_LL const& ) const; | ||
1873 | 340 | template Decimal Decimal::round( INTEGER_IMPL_ULL const& ) const; | ||
1874 | 341 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1875 | 314 | 342 | ||
1876 | 315 | Decimal::value_type Decimal::round( value_type const &v, | 343 | Decimal::value_type Decimal::round( value_type const &v, |
1877 | 316 | value_type const &precision ) { | 344 | value_type const &precision ) { |
1878 | @@ -322,9 +350,14 @@ | |||
1879 | 322 | return result; | 350 | return result; |
1880 | 323 | } | 351 | } |
1881 | 324 | 352 | ||
1883 | 325 | Decimal Decimal::roundHalfToEven( Integer const &precision ) const { | 353 | TEMPLATE_DECL(T) |
1884 | 354 | Decimal Decimal::roundHalfToEven( INTEGER_IMPL(T) const &precision ) const { | ||
1885 | 326 | return roundHalfToEven( value_, precision.itod() ); | 355 | return roundHalfToEven( value_, precision.itod() ); |
1886 | 327 | } | 356 | } |
1887 | 357 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1888 | 358 | template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_LL const& ) const; | ||
1889 | 359 | template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_ULL const& ) const; | ||
1890 | 360 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1891 | 328 | 361 | ||
1892 | 329 | Decimal::value_type Decimal::roundHalfToEven( value_type const &v, | 362 | Decimal::value_type Decimal::roundHalfToEven( value_type const &v, |
1893 | 330 | value_type const &precision ) { | 363 | value_type const &precision ) { |
1894 | 331 | 364 | ||
1895 | === modified file 'src/zorbatypes/decimal.h' | |||
1896 | --- src/zorbatypes/decimal.h 2011-06-24 18:27:08 +0000 | |||
1897 | +++ src/zorbatypes/decimal.h 2012-02-28 18:23:19 +0000 | |||
1898 | @@ -29,6 +29,14 @@ | |||
1899 | 29 | #include "zorbatypes_decl.h" | 29 | #include "zorbatypes_decl.h" |
1900 | 30 | #include "zstring.h" | 30 | #include "zstring.h" |
1901 | 31 | 31 | ||
1902 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
1903 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
1904 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
1905 | 35 | #else | ||
1906 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
1907 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
1908 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1909 | 39 | |||
1910 | 32 | namespace zorba { | 40 | namespace zorba { |
1911 | 33 | 41 | ||
1912 | 34 | /////////////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////////////// |
1913 | @@ -52,7 +60,9 @@ | |||
1914 | 52 | Decimal( float n ); | 60 | Decimal( float n ); |
1915 | 53 | Decimal( double n ); | 61 | Decimal( double n ); |
1916 | 54 | Decimal( Decimal const &d ); | 62 | Decimal( Decimal const &d ); |
1918 | 55 | Decimal( Integer const &i ); | 63 | |
1919 | 64 | TEMPLATE_DECL(T) | ||
1920 | 65 | Decimal( INTEGER_IMPL(T) const &i ); | ||
1921 | 56 | 66 | ||
1922 | 57 | /** | 67 | /** |
1923 | 58 | * Constructs a %Decimal from a C string. | 68 | * Constructs a %Decimal from a C string. |
1924 | @@ -98,27 +108,30 @@ | |||
1925 | 98 | Decimal& operator=( Decimal const &d ); | 108 | Decimal& operator=( Decimal const &d ); |
1926 | 99 | Decimal& operator=( Double const &d ); | 109 | Decimal& operator=( Double const &d ); |
1927 | 100 | Decimal& operator=( Float const &f ); | 110 | Decimal& operator=( Float const &f ); |
1929 | 101 | Decimal& operator=( Integer const &i ); | 111 | |
1930 | 112 | TEMPLATE_DECL(T) | ||
1931 | 113 | Decimal& operator=( INTEGER_IMPL(T) const &i ); | ||
1932 | 102 | 114 | ||
1933 | 103 | ////////// arithmetic operators ///////////////////////////////////////////// | 115 | ////////// arithmetic operators ///////////////////////////////////////////// |
1934 | 104 | 116 | ||
1952 | 105 | friend Decimal operator+( Decimal const &d1, Decimal const &d2 ); | 117 | friend Decimal operator+( Decimal const&, Decimal const& ); |
1953 | 106 | friend Decimal operator-( Decimal const &d1, Decimal const &d2 ); | 118 | friend Decimal operator-( Decimal const&, Decimal const& ); |
1954 | 107 | friend Decimal operator*( Decimal const &d1, Decimal const &d2 ); | 119 | friend Decimal operator*( Decimal const&, Decimal const& ); |
1955 | 108 | friend Decimal operator/( Decimal const &d1, Decimal const &d2 ); | 120 | friend Decimal operator/( Decimal const&, Decimal const& ); |
1956 | 109 | friend Decimal operator%( Decimal const &d1, Decimal const &d2 ); | 121 | friend Decimal operator%( Decimal const&, Decimal const& ); |
1957 | 110 | 122 | ||
1958 | 111 | friend Decimal operator+( Decimal const &d, Integer const &i ); | 123 | #define ZORBA_DECIMAL_OP(OP) \ |
1959 | 112 | friend Decimal operator-( Decimal const &d, Integer const &i ); | 124 | TEMPLATE_DECL(T) \ |
1960 | 113 | friend Decimal operator*( Decimal const &d, Integer const &i ); | 125 | friend Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \ |
1961 | 114 | friend Decimal operator/( Decimal const &d, Integer const &i ); | 126 | TEMPLATE_DECL(T) \ |
1962 | 115 | friend Decimal operator%( Decimal const &d, Integer const &i ); | 127 | friend Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& ) |
1963 | 116 | 128 | ||
1964 | 117 | friend Decimal operator+( Integer const &i, Decimal const &d ); | 129 | ZORBA_DECIMAL_OP(+); |
1965 | 118 | friend Decimal operator-( Integer const &i, Decimal const &d ); | 130 | ZORBA_DECIMAL_OP(-); |
1966 | 119 | friend Decimal operator*( Integer const &i, Decimal const &d ); | 131 | ZORBA_DECIMAL_OP(*); |
1967 | 120 | friend Decimal operator/( Integer const &i, Decimal const &d ); | 132 | ZORBA_DECIMAL_OP(/); |
1968 | 121 | friend Decimal operator%( Integer const &i, Decimal const &d ); | 133 | ZORBA_DECIMAL_OP(%); |
1969 | 134 | #undef ZORBA_DECIMAL_OP | ||
1970 | 122 | 135 | ||
1971 | 123 | Decimal& operator+=( Decimal const& ); | 136 | Decimal& operator+=( Decimal const& ); |
1972 | 124 | Decimal& operator-=( Decimal const& ); | 137 | Decimal& operator-=( Decimal const& ); |
1973 | @@ -126,46 +139,49 @@ | |||
1974 | 126 | Decimal& operator/=( Decimal const& ); | 139 | Decimal& operator/=( Decimal const& ); |
1975 | 127 | Decimal& operator%=( Decimal const& ); | 140 | Decimal& operator%=( Decimal const& ); |
1976 | 128 | 141 | ||
1982 | 129 | Decimal& operator+=( Integer const& ); | 142 | #define ZORBA_DECIMAL_OP(OP) \ |
1983 | 130 | Decimal& operator-=( Integer const& ); | 143 | TEMPLATE_DECL(T) Decimal& operator OP( INTEGER_IMPL(T) const& ) |
1984 | 131 | Decimal& operator*=( Integer const& ); | 144 | |
1985 | 132 | Decimal& operator/=( Integer const& ); | 145 | ZORBA_DECIMAL_OP(+=); |
1986 | 133 | Decimal& operator%=( Integer const& ); | 146 | ZORBA_DECIMAL_OP(-=); |
1987 | 147 | ZORBA_DECIMAL_OP(*=); | ||
1988 | 148 | ZORBA_DECIMAL_OP(/=); | ||
1989 | 149 | ZORBA_DECIMAL_OP(%=); | ||
1990 | 150 | #undef ZORBA_DECIMAL_OP | ||
1991 | 134 | 151 | ||
1992 | 135 | Decimal operator-() const; | 152 | Decimal operator-() const; |
1993 | 136 | 153 | ||
1994 | 137 | ////////// relational operators ///////////////////////////////////////////// | 154 | ////////// relational operators ///////////////////////////////////////////// |
1995 | 138 | 155 | ||
2016 | 139 | friend bool operator==( Decimal const &d1, Decimal const &d2 ); | 156 | #define ZORBA_DECIMAL_OP(OP) \ |
2017 | 140 | friend bool operator!=( Decimal const &d1, Decimal const &d2 ); | 157 | friend bool operator OP( Decimal const&, Decimal const& ); \ |
2018 | 141 | friend bool operator< ( Decimal const &d1, Decimal const &d2 ); | 158 | TEMPLATE_DECL(T) \ |
2019 | 142 | friend bool operator<=( Decimal const &d1, Decimal const &d2 ); | 159 | friend bool operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \ |
2020 | 143 | friend bool operator> ( Decimal const &d1, Decimal const &d2 ); | 160 | TEMPLATE_DECL(T) \ |
2021 | 144 | friend bool operator>=( Decimal const &d1, Decimal const &d2 ); | 161 | friend bool operator OP( INTEGER_IMPL(T) const&, Decimal const& ) |
2022 | 145 | 162 | ||
2023 | 146 | friend bool operator==( Decimal const &d, Integer const &i ); | 163 | ZORBA_DECIMAL_OP(==); |
2024 | 147 | friend bool operator!=( Decimal const &d, Integer const &i ); | 164 | ZORBA_DECIMAL_OP(!=); |
2025 | 148 | friend bool operator< ( Decimal const &d, Integer const &i ); | 165 | ZORBA_DECIMAL_OP(< ); |
2026 | 149 | friend bool operator<=( Decimal const &d, Integer const &i ); | 166 | ZORBA_DECIMAL_OP(<=); |
2027 | 150 | friend bool operator> ( Decimal const &d, Integer const &i ); | 167 | ZORBA_DECIMAL_OP(> ); |
2028 | 151 | friend bool operator>=( Decimal const &d, Integer const &i ); | 168 | ZORBA_DECIMAL_OP(>=); |
2029 | 152 | 169 | #undef ZORBA_DECIMAL_OP | |
2010 | 153 | friend bool operator==( Integer const &i, Decimal const &d ); | ||
2011 | 154 | friend bool operator!=( Integer const &i, Decimal const &d ); | ||
2012 | 155 | friend bool operator< ( Integer const &i, Decimal const &d ); | ||
2013 | 156 | friend bool operator<=( Integer const &i, Decimal const &d ); | ||
2014 | 157 | friend bool operator> ( Integer const &i, Decimal const &d ); | ||
2015 | 158 | friend bool operator>=( Integer const &i, Decimal const &d ); | ||
2030 | 159 | 170 | ||
2031 | 160 | ////////// math functions /////////////////////////////////////////////////// | 171 | ////////// math functions /////////////////////////////////////////////////// |
2032 | 161 | 172 | ||
2034 | 162 | int compare( Decimal const &d ) const; | 173 | int compare( Decimal const& ) const; |
2035 | 163 | 174 | ||
2036 | 164 | Decimal ceil() const; | 175 | Decimal ceil() const; |
2037 | 165 | Decimal floor() const; | 176 | Decimal floor() const; |
2038 | 166 | Decimal round() const; | 177 | Decimal round() const; |
2041 | 167 | Decimal round( Integer const &precision ) const; | 178 | |
2042 | 168 | Decimal roundHalfToEven( Integer const &precision ) const; | 179 | TEMPLATE_DECL(T) |
2043 | 180 | Decimal round( INTEGER_IMPL(T) const &precision ) const; | ||
2044 | 181 | |||
2045 | 182 | TEMPLATE_DECL(T) | ||
2046 | 183 | Decimal roundHalfToEven( INTEGER_IMPL(T) const &precision ) const; | ||
2047 | 184 | |||
2048 | 169 | Decimal sqrt() const; | 185 | Decimal sqrt() const; |
2049 | 170 | 186 | ||
2050 | 171 | ////////// miscellaneous //////////////////////////////////////////////////// | 187 | ////////// miscellaneous //////////////////////////////////////////////////// |
2051 | @@ -215,7 +231,7 @@ | |||
2052 | 215 | static zstring toString( value_type const&, | 231 | static zstring toString( value_type const&, |
2053 | 216 | int precision = ZORBA_FLOAT_POINT_PRECISION ); | 232 | int precision = ZORBA_FLOAT_POINT_PRECISION ); |
2054 | 217 | 233 | ||
2056 | 218 | friend class Integer; | 234 | TEMPLATE_DECL(T) friend class IntegerImpl; |
2057 | 219 | template<typename T> friend class FloatImpl; | 235 | template<typename T> friend class FloatImpl; |
2058 | 220 | 236 | ||
2059 | 221 | friend xs_long to_xs_long( Decimal const& ); | 237 | friend xs_long to_xs_long( Decimal const& ); |
2060 | @@ -443,6 +459,10 @@ | |||
2061 | 443 | /////////////////////////////////////////////////////////////////////////////// | 459 | /////////////////////////////////////////////////////////////////////////////// |
2062 | 444 | 460 | ||
2063 | 445 | } // namespace zorba | 461 | } // namespace zorba |
2064 | 462 | |||
2065 | 463 | #undef TEMPLATE_DECL | ||
2066 | 464 | #undef INTEGER_IMPL | ||
2067 | 465 | |||
2068 | 446 | #endif /* ZORBA_DECIMAL_H */ | 466 | #endif /* ZORBA_DECIMAL_H */ |
2069 | 447 | /* | 467 | /* |
2070 | 448 | * Local variables: | 468 | * Local variables: |
2071 | 449 | 469 | ||
2072 | === modified file 'src/zorbatypes/floatimpl.cpp' | |||
2073 | --- src/zorbatypes/floatimpl.cpp 2011-07-07 12:05:43 +0000 | |||
2074 | +++ src/zorbatypes/floatimpl.cpp 2012-02-28 18:23:19 +0000 | |||
2075 | @@ -29,6 +29,16 @@ | |||
2076 | 29 | 29 | ||
2077 | 30 | #include "zorbaserialization/serialization_engine.h" | 30 | #include "zorbaserialization/serialization_engine.h" |
2078 | 31 | 31 | ||
2079 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2080 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2081 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
2082 | 35 | #else | ||
2083 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
2084 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2085 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2086 | 39 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2087 | 40 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2088 | 41 | |||
2089 | 32 | /////////////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////////////// |
2090 | 33 | 43 | ||
2091 | 34 | namespace zorba { | 44 | namespace zorba { |
2092 | @@ -144,11 +154,20 @@ | |||
2093 | 144 | } | 154 | } |
2094 | 145 | 155 | ||
2095 | 146 | template<typename FloatType> | 156 | template<typename FloatType> |
2097 | 147 | FloatImpl<FloatType>::FloatImpl( Integer const &i ) { | 157 | TEMPLATE_DECL(IntType) |
2098 | 158 | FloatImpl<FloatType>::FloatImpl( INTEGER_IMPL(IntType) const &i ) { | ||
2099 | 148 | zstring const temp( i.toString() ); | 159 | zstring const temp( i.toString() ); |
2100 | 149 | parse( temp.c_str() ); | 160 | parse( temp.c_str() ); |
2101 | 150 | } | 161 | } |
2102 | 151 | 162 | ||
2103 | 163 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2104 | 164 | template FloatImpl<float>::FloatImpl( INTEGER_IMPL_LL const& ); | ||
2105 | 165 | template FloatImpl<float>::FloatImpl( INTEGER_IMPL_ULL const& ); | ||
2106 | 166 | |||
2107 | 167 | template FloatImpl<double>::FloatImpl( INTEGER_IMPL_LL const& ); | ||
2108 | 168 | template FloatImpl<double>::FloatImpl( INTEGER_IMPL_ULL const& ); | ||
2109 | 169 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2110 | 170 | |||
2111 | 152 | ////////// math functions ///////////////////////////////////////////////////// | 171 | ////////// math functions ///////////////////////////////////////////////////// |
2112 | 153 | 172 | ||
2113 | 154 | template<typename FloatType> | 173 | template<typename FloatType> |
2114 | 155 | 174 | ||
2115 | === modified file 'src/zorbatypes/floatimpl.h' | |||
2116 | --- src/zorbatypes/floatimpl.h 2011-10-03 09:18:49 +0000 | |||
2117 | +++ src/zorbatypes/floatimpl.h 2012-02-28 18:23:19 +0000 | |||
2118 | @@ -29,13 +29,22 @@ | |||
2119 | 29 | #include "schema_types.h" | 29 | #include "schema_types.h" |
2120 | 30 | #include "zorbatypes_decl.h" | 30 | #include "zorbatypes_decl.h" |
2121 | 31 | 31 | ||
2122 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2123 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2124 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
2125 | 35 | #else | ||
2126 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
2127 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2128 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2129 | 39 | |||
2130 | 32 | namespace zorba { | 40 | namespace zorba { |
2131 | 33 | 41 | ||
2132 | 34 | template<typename FloatType> | 42 | template<typename FloatType> |
2133 | 35 | class FloatImpl; | 43 | class FloatImpl; |
2135 | 36 | namespace serialization{ | 44 | |
2136 | 45 | namespace serialization { | ||
2137 | 37 | template<typename FloatType> | 46 | template<typename FloatType> |
2139 | 38 | void operator&(Archiver &ar, FloatImpl<FloatType> &obj); | 47 | void operator&( Archiver&, FloatImpl<FloatType>& ); |
2140 | 39 | } | 48 | } |
2141 | 40 | 49 | ||
2142 | 41 | /////////////////////////////////////////////////////////////////////////////// | 50 | /////////////////////////////////////////////////////////////////////////////// |
2143 | @@ -61,7 +70,9 @@ | |||
2144 | 61 | FloatImpl( float n ); | 70 | FloatImpl( float n ); |
2145 | 62 | FloatImpl( double n ); | 71 | FloatImpl( double n ); |
2146 | 63 | FloatImpl( Decimal const &d ); | 72 | FloatImpl( Decimal const &d ); |
2148 | 64 | FloatImpl( Integer const &i ); | 73 | |
2149 | 74 | TEMPLATE_DECL(T) | ||
2150 | 75 | FloatImpl( INTEGER_IMPL(T) const &i ); | ||
2151 | 65 | 76 | ||
2152 | 66 | /** | 77 | /** |
2153 | 67 | * Constructs a %FloatImpl from a C string. | 78 | * Constructs a %FloatImpl from a C string. |
2154 | @@ -220,7 +231,7 @@ | |||
2155 | 220 | void parse( char const* ); | 231 | void parse( char const* ); |
2156 | 221 | bool parse_etc( char const* ); | 232 | bool parse_etc( char const* ); |
2157 | 222 | 233 | ||
2159 | 223 | friend class Integer; | 234 | TEMPLATE_DECL(T) friend class IntegerImpl; |
2160 | 224 | friend class Decimal; | 235 | friend class Decimal; |
2161 | 225 | 236 | ||
2162 | 226 | friend class FloatImpl<float>; | 237 | friend class FloatImpl<float>; |
2163 | @@ -772,6 +783,10 @@ | |||
2164 | 772 | /////////////////////////////////////////////////////////////////////////////// | 783 | /////////////////////////////////////////////////////////////////////////////// |
2165 | 773 | 784 | ||
2166 | 774 | } // namespace zorba | 785 | } // namespace zorba |
2167 | 786 | |||
2168 | 787 | #undef TEMPLATE_DECL | ||
2169 | 788 | #undef INTEGER_IMPL | ||
2170 | 789 | |||
2171 | 775 | #endif // ZORBA_FLOATIMPL_H | 790 | #endif // ZORBA_FLOATIMPL_H |
2172 | 776 | /* | 791 | /* |
2173 | 777 | * Local variables: | 792 | * Local variables: |
2174 | 778 | 793 | ||
2175 | === modified file 'src/zorbatypes/integer.cpp' | |||
2176 | --- src/zorbatypes/integer.cpp 2011-07-06 20:13:28 +0000 | |||
2177 | +++ src/zorbatypes/integer.cpp 2012-02-28 18:23:19 +0000 | |||
2178 | @@ -27,62 +27,82 @@ | |||
2179 | 27 | #include "floatimpl.h" | 27 | #include "floatimpl.h" |
2180 | 28 | #include "numconversions.h" | 28 | #include "numconversions.h" |
2181 | 29 | 29 | ||
2182 | 30 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2183 | 31 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2184 | 32 | # define INTEGER_IMPL(T) IntegerImpl | ||
2185 | 33 | #else | ||
2186 | 34 | # define TEMPLATE_DECL(T) template<typename T> | ||
2187 | 35 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2188 | 36 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2189 | 37 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2190 | 38 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2191 | 39 | |||
2192 | 30 | using namespace std; | 40 | using namespace std; |
2193 | 31 | 41 | ||
2205 | 32 | #ifdef WIN32 | 42 | #ifndef ZORBA_WITH_BIG_INTEGER |
2206 | 33 | namespace std { | 43 | unsigned long long MaxUIntegerValue = ~0ull >> 1; |
2207 | 34 | inline long long strtoll( char const *s, char **end, int base ) { | 44 | |
2208 | 35 | return ::_strtoi64( s, end, base ); | 45 | inline bool is_too_big( long long ) { |
2209 | 36 | } | 46 | return false; |
2210 | 37 | 47 | } | |
2211 | 38 | inline long long strtoull( char const *s, char **end, int base ) { | 48 | |
2212 | 39 | return ::_strtoui64( s, end, base ); | 49 | inline bool is_too_big( unsigned long long n ) { |
2213 | 40 | } | 50 | return n > MaxUIntegerValue; |
2214 | 41 | } | 51 | } |
2215 | 42 | #endif /* WIN32 */ | 52 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2216 | 43 | 53 | ||
2217 | 44 | namespace zorba { | 54 | namespace zorba { |
2218 | 45 | 55 | ||
2219 | 46 | /////////////////////////////////////////////////////////////////////////////// | 56 | /////////////////////////////////////////////////////////////////////////////// |
2220 | 47 | 57 | ||
2221 | 48 | void Integer::parse( char const *s ) { | ||
2222 | 49 | #ifdef ZORBA_WITH_BIG_INTEGER | 58 | #ifdef ZORBA_WITH_BIG_INTEGER |
2223 | 59 | void IntegerImpl::parse( char const *s ) { | ||
2224 | 50 | Decimal::parse( s, &value_, Decimal::parse_integer ); | 60 | Decimal::parse( s, &value_, Decimal::parse_integer ); |
2225 | 51 | #else | 61 | #else |
2227 | 52 | value_ = ztd::aton<value_type>( s ); | 62 | template<typename IntType> |
2228 | 63 | void IntegerImpl<IntType>::parse( char const *s ) { | ||
2229 | 64 | value_type const temp = ztd::aton<value_type>( s ); | ||
2230 | 65 | if ( is_too_big( temp ) ) | ||
2231 | 66 | throw std::invalid_argument( | ||
2232 | 67 | BUILD_STRING( '"', temp, "\": unsigned integer too big" ) | ||
2233 | 68 | ); | ||
2234 | 69 | value_ = temp; | ||
2235 | 53 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 70 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2236 | 54 | } | 71 | } |
2237 | 55 | 72 | ||
2238 | 56 | ////////// constructors /////////////////////////////////////////////////////// | 73 | ////////// constructors /////////////////////////////////////////////////////// |
2239 | 57 | 74 | ||
2240 | 58 | #ifdef ZORBA_WITH_BIG_INTEGER | 75 | #ifdef ZORBA_WITH_BIG_INTEGER |
2252 | 59 | Integer::Integer( long long n ) { | 76 | IntegerImpl::IntegerImpl( long long n ) { |
2253 | 60 | ztd::itoa_buf_type buf; | 77 | ztd::itoa_buf_type buf; |
2254 | 61 | value_ = ztd::itoa( n, buf ); | 78 | value_ = ztd::itoa( n, buf ); |
2255 | 62 | } | 79 | } |
2256 | 63 | 80 | ||
2257 | 64 | Integer::Integer( unsigned long n ) { | 81 | IntegerImpl::IntegerImpl( unsigned long n ) { |
2258 | 65 | ztd::itoa_buf_type buf; | 82 | ztd::itoa_buf_type buf; |
2259 | 66 | value_ = ztd::itoa( n, buf ); | 83 | value_ = ztd::itoa( n, buf ); |
2260 | 67 | } | 84 | } |
2261 | 68 | 85 | ||
2262 | 69 | Integer::Integer( unsigned long long n ) { | 86 | IntegerImpl::IntegerImpl( unsigned long long n ) { |
2263 | 70 | ztd::itoa_buf_type buf; | 87 | ztd::itoa_buf_type buf; |
2264 | 71 | value_ = ztd::itoa( n, buf ); | 88 | value_ = ztd::itoa( n, buf ); |
2265 | 72 | } | 89 | } |
2266 | 73 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 90 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2267 | 74 | 91 | ||
2269 | 75 | Integer::Integer( Decimal const &d ) { | 92 | TEMPLATE_DECL(T) |
2270 | 93 | INTEGER_IMPL(T)::IntegerImpl( Decimal const &d ) { | ||
2271 | 76 | value_ = ftoi( d.value_ ); | 94 | value_ = ftoi( d.value_ ); |
2272 | 77 | } | 95 | } |
2273 | 78 | 96 | ||
2275 | 79 | Integer::Integer( Double const &d ) { | 97 | TEMPLATE_DECL(T) |
2276 | 98 | INTEGER_IMPL(T)::IntegerImpl( Double const &d ) { | ||
2277 | 80 | if ( !d.isFinite() ) | 99 | if ( !d.isFinite() ) |
2278 | 81 | throw std::invalid_argument( "not finite" ); | 100 | throw std::invalid_argument( "not finite" ); |
2279 | 82 | value_ = ftoi( d.getNumber() ); | 101 | value_ = ftoi( d.getNumber() ); |
2280 | 83 | } | 102 | } |
2281 | 84 | 103 | ||
2283 | 85 | Integer::Integer( Float const &f ) { | 104 | TEMPLATE_DECL(T) |
2284 | 105 | INTEGER_IMPL(T)::IntegerImpl( Float const &f ) { | ||
2285 | 86 | if ( !f.isFinite() ) | 106 | if ( !f.isFinite() ) |
2286 | 87 | throw std::invalid_argument( "not finite" ); | 107 | throw std::invalid_argument( "not finite" ); |
2287 | 88 | value_ = ftoi( f.getNumber() ); | 108 | value_ = ftoi( f.getNumber() ); |
2288 | @@ -91,38 +111,41 @@ | |||
2289 | 91 | ////////// assignment operators /////////////////////////////////////////////// | 111 | ////////// assignment operators /////////////////////////////////////////////// |
2290 | 92 | 112 | ||
2291 | 93 | #ifdef ZORBA_WITH_BIG_INTEGER | 113 | #ifdef ZORBA_WITH_BIG_INTEGER |
2305 | 94 | Integer& Integer::operator=( long long n ) { | 114 | IntegerImpl& IntegerImpl::operator=( long long n ) { |
2306 | 95 | ztd::itoa_buf_type buf; | 115 | ztd::itoa_buf_type buf; |
2307 | 96 | value_ = ztd::itoa( n, buf ); | 116 | value_ = ztd::itoa( n, buf ); |
2308 | 97 | return *this; | 117 | return *this; |
2309 | 98 | } | 118 | } |
2310 | 99 | 119 | ||
2311 | 100 | Integer& Integer::operator=( unsigned long n ) { | 120 | IntegerImpl& IntegerImpl::operator=( unsigned long n ) { |
2312 | 101 | ztd::itoa_buf_type buf; | 121 | ztd::itoa_buf_type buf; |
2313 | 102 | value_ = ztd::itoa( n, buf ); | 122 | value_ = ztd::itoa( n, buf ); |
2314 | 103 | return *this; | 123 | return *this; |
2315 | 104 | } | 124 | } |
2316 | 105 | 125 | ||
2317 | 106 | Integer& Integer::operator=( unsigned long long n ) { | 126 | IntegerImpl& IntegerImpl::operator=( unsigned long long n ) { |
2318 | 107 | ztd::itoa_buf_type buf; | 127 | ztd::itoa_buf_type buf; |
2319 | 108 | value_ = ztd::itoa( n, buf ); | 128 | value_ = ztd::itoa( n, buf ); |
2320 | 109 | return *this; | 129 | return *this; |
2321 | 110 | } | 130 | } |
2322 | 111 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 131 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2323 | 112 | 132 | ||
2325 | 113 | Integer& Integer::operator=( Decimal const &d ) { | 133 | TEMPLATE_DECL(T) |
2326 | 134 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Decimal const &d ) { | ||
2327 | 114 | value_ = ftoi( d.value_ ); | 135 | value_ = ftoi( d.value_ ); |
2328 | 115 | return *this; | 136 | return *this; |
2329 | 116 | } | 137 | } |
2330 | 117 | 138 | ||
2332 | 118 | Integer& Integer::operator=( Double const &d ) { | 139 | TEMPLATE_DECL(T) |
2333 | 140 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Double const &d ) { | ||
2334 | 119 | if ( !d.isFinite() ) | 141 | if ( !d.isFinite() ) |
2335 | 120 | throw std::invalid_argument( "not finite" ); | 142 | throw std::invalid_argument( "not finite" ); |
2336 | 121 | value_ = ftoi( d.getNumber() ); | 143 | value_ = ftoi( d.getNumber() ); |
2337 | 122 | return *this; | 144 | return *this; |
2338 | 123 | } | 145 | } |
2339 | 124 | 146 | ||
2341 | 125 | Integer& Integer::operator=( Float const &f ) { | 147 | TEMPLATE_DECL(T) |
2342 | 148 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Float const &f ) { | ||
2343 | 126 | if ( !f.isFinite() ) | 149 | if ( !f.isFinite() ) |
2344 | 127 | throw std::invalid_argument( "not finite" ); | 150 | throw std::invalid_argument( "not finite" ); |
2345 | 128 | value_ = ftoi( f.getNumber() ); | 151 | value_ = ftoi( f.getNumber() ); |
2346 | @@ -131,55 +154,67 @@ | |||
2347 | 131 | 154 | ||
2348 | 132 | ////////// arithmetic operators /////////////////////////////////////////////// | 155 | ////////// arithmetic operators /////////////////////////////////////////////// |
2349 | 133 | 156 | ||
2369 | 134 | Decimal operator+( Integer const &i, Decimal const &d ) { | 157 | #ifdef ZORBA_WITH_BIG_INTEGER |
2370 | 135 | return i.itod() + d.value_; | 158 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
2371 | 136 | } | 159 | #else |
2372 | 137 | 160 | # define ZORBA_INSTANTIATE(OP) \ | |
2373 | 138 | Decimal operator-( Integer const &i, Decimal const &d ) { | 161 | template Decimal operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \ |
2374 | 139 | return i.itod() - d.value_; | 162 | template Decimal operator OP( INTEGER_IMPL_ULL const&, Decimal const& ); |
2375 | 140 | } | 163 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2376 | 141 | 164 | ||
2377 | 142 | Decimal operator*( Integer const &i, Decimal const &d ) { | 165 | #define ZORBA_INTEGER_OP(OP) \ |
2378 | 143 | return i.itod() * d.value_; | 166 | TEMPLATE_DECL(T) \ |
2379 | 144 | } | 167 | Decimal operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \ |
2380 | 145 | 168 | return i.itod() OP d.value_; \ | |
2381 | 146 | Decimal operator/( Integer const &i, Decimal const &d ) { | 169 | } \ |
2382 | 147 | return i.itod() / d.value_; | 170 | ZORBA_INSTANTIATE(OP) |
2383 | 148 | } | 171 | |
2384 | 149 | 172 | ZORBA_INTEGER_OP(+) | |
2385 | 150 | Decimal operator%( Integer const &i, Decimal const &d ) { | 173 | ZORBA_INTEGER_OP(-) |
2386 | 151 | return i.itod() % d.value_; | 174 | ZORBA_INTEGER_OP(*) |
2387 | 152 | } | 175 | ZORBA_INTEGER_OP(/) |
2388 | 176 | ZORBA_INTEGER_OP(%) | ||
2389 | 177 | #undef ZORBA_INTEGER_OP | ||
2390 | 178 | #undef ZORBA_INSTANTIATE | ||
2391 | 153 | 179 | ||
2392 | 154 | ////////// relational operators /////////////////////////////////////////////// | 180 | ////////// relational operators /////////////////////////////////////////////// |
2393 | 155 | 181 | ||
2395 | 156 | bool operator==( Integer const &i, Decimal const &d ) { | 182 | TEMPLATE_DECL(T) |
2396 | 183 | bool operator==( INTEGER_IMPL(T) const &i, Decimal const &d ) { | ||
2397 | 157 | return d.is_integer() && i.itod() == d.value_; | 184 | return d.is_integer() && i.itod() == d.value_; |
2398 | 158 | } | 185 | } |
2399 | 159 | 186 | ||
2419 | 160 | bool operator!=( Integer const &i, Decimal const &d ) { | 187 | #define ZORBA_INTEGER_OP(OP) \ |
2420 | 161 | return i.itod() != d.value_; | 188 | TEMPLATE_DECL(T) \ |
2421 | 162 | } | 189 | bool operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \ |
2422 | 163 | 190 | return i.itod() OP d.value_; \ | |
2423 | 164 | bool operator<( Integer const &i, Decimal const &d ) { | 191 | } |
2424 | 165 | return i.itod() < d.value_; | 192 | |
2425 | 166 | } | 193 | ZORBA_INTEGER_OP(!=) |
2426 | 167 | 194 | ZORBA_INTEGER_OP(< ) | |
2427 | 168 | bool operator<=( Integer const &i, Decimal const &d ) { | 195 | ZORBA_INTEGER_OP(<=) |
2428 | 169 | return i.itod() <= d.value_; | 196 | ZORBA_INTEGER_OP(> ) |
2429 | 170 | } | 197 | ZORBA_INTEGER_OP(>=) |
2430 | 171 | 198 | #undef ZORBA_INTEGER_OP | |
2431 | 172 | bool operator>( Integer const &i, Decimal const &d ) { | 199 | |
2432 | 173 | return i.itod() > d.value_; | 200 | #ifndef ZORBA_WITH_BIG_INTEGER |
2433 | 174 | } | 201 | #define ZORBA_INSTANTIATE(OP) \ |
2434 | 175 | 202 | template bool operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \ | |
2435 | 176 | bool operator>=( Integer const &i, Decimal const &d ) { | 203 | template bool operator OP( INTEGER_IMPL_ULL const&, Decimal const& ) |
2436 | 177 | return i.itod() >= d.value_; | 204 | |
2437 | 178 | } | 205 | ZORBA_INSTANTIATE(==); |
2438 | 206 | ZORBA_INSTANTIATE(!=); | ||
2439 | 207 | ZORBA_INSTANTIATE(< ); | ||
2440 | 208 | ZORBA_INSTANTIATE(<=); | ||
2441 | 209 | ZORBA_INSTANTIATE(> ); | ||
2442 | 210 | ZORBA_INSTANTIATE(>=); | ||
2443 | 211 | #undef ZORBA_INSTANTIATE | ||
2444 | 212 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2445 | 179 | 213 | ||
2446 | 180 | ////////// math functions ///////////////////////////////////////////////////// | 214 | ////////// math functions ///////////////////////////////////////////////////// |
2447 | 181 | 215 | ||
2449 | 182 | Double Integer::pow( Integer const &power ) const { | 216 | TEMPLATE_DECL(T) |
2450 | 217 | Double INTEGER_IMPL(T)::pow( INTEGER_IMPL(T) const &power ) const { | ||
2451 | 183 | #ifdef ZORBA_WITH_BIG_INTEGER | 218 | #ifdef ZORBA_WITH_BIG_INTEGER |
2452 | 184 | value_type const result( value_.pow( power.value_, 15 ) ); | 219 | value_type const result( value_.pow( power.value_, 15 ) ); |
2453 | 185 | char buf[300]; | 220 | char buf[300]; |
2454 | @@ -193,27 +228,32 @@ | |||
2455 | 193 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 228 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2456 | 194 | } | 229 | } |
2457 | 195 | 230 | ||
2460 | 196 | Integer Integer::round( Integer const &precision ) const { | 231 | TEMPLATE_DECL(T) |
2461 | 197 | return Integer( Decimal::round( itod(), precision.itod() ) ); | 232 | INTEGER_IMPL(T) INTEGER_IMPL(T)::round( IntegerImpl const &precision ) const { |
2462 | 233 | return IntegerImpl( Decimal::round( itod(), precision.itod() ) ); | ||
2463 | 198 | } | 234 | } |
2464 | 199 | 235 | ||
2467 | 200 | Integer Integer::roundHalfToEven( Integer const &precision ) const { | 236 | TEMPLATE_DECL(T) |
2468 | 201 | return Integer( Decimal::roundHalfToEven( itod(), precision.itod() ) ); | 237 | INTEGER_IMPL(T) |
2469 | 238 | INTEGER_IMPL(T)::roundHalfToEven( IntegerImpl const &precision ) const { | ||
2470 | 239 | return IntegerImpl( Decimal::roundHalfToEven( itod(), precision.itod() ) ); | ||
2471 | 202 | } | 240 | } |
2472 | 203 | 241 | ||
2473 | 204 | ////////// miscellaneous ////////////////////////////////////////////////////// | 242 | ////////// miscellaneous ////////////////////////////////////////////////////// |
2474 | 205 | 243 | ||
2475 | 206 | #ifndef ZORBA_WITH_BIG_INTEGER | 244 | #ifndef ZORBA_WITH_BIG_INTEGER |
2477 | 207 | Integer::value_type Integer::ftoi( MAPM const &d ) { | 245 | TEMPLATE_DECL(T) |
2478 | 246 | typename INTEGER_IMPL(T)::value_type INTEGER_IMPL(T)::ftoi( MAPM const &d ) { | ||
2479 | 208 | MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() ); | 247 | MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() ); |
2480 | 209 | char *const buf = new char[ temp.exponent() + 3 ]; | 248 | char *const buf = new char[ temp.exponent() + 3 ]; |
2481 | 210 | temp.toIntegerString( buf ); | 249 | temp.toIntegerString( buf ); |
2483 | 211 | value_type const result( std::strtoll( buf, nullptr, 10 ) ); | 250 | value_type const result( ztd::aton<value_type>( buf ) ); |
2484 | 212 | delete[] buf; | 251 | delete[] buf; |
2485 | 213 | return result; | 252 | return result; |
2486 | 214 | } | 253 | } |
2487 | 215 | 254 | ||
2489 | 216 | MAPM Integer::itod() const { | 255 | TEMPLATE_DECL(T) |
2490 | 256 | MAPM INTEGER_IMPL(T)::itod() const { | ||
2491 | 217 | if ( is_long() ) | 257 | if ( is_long() ) |
2492 | 218 | return static_cast<long>( value_ ); | 258 | return static_cast<long>( value_ ); |
2493 | 219 | ztd::itoa_buf_type buf; | 259 | ztd::itoa_buf_type buf; |
2494 | @@ -222,17 +262,19 @@ | |||
2495 | 222 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 262 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2496 | 223 | 263 | ||
2497 | 224 | #ifdef ZORBA_WITH_BIG_INTEGER | 264 | #ifdef ZORBA_WITH_BIG_INTEGER |
2499 | 225 | uint32_t Integer::hash() const { | 265 | uint32_t IntegerImpl::hash() const { |
2500 | 226 | return Decimal::hash( value_ ); | 266 | return Decimal::hash( value_ ); |
2501 | 227 | } | 267 | } |
2502 | 228 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 268 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2503 | 229 | 269 | ||
2506 | 230 | Integer const& Integer::one() { | 270 | TEMPLATE_DECL(T) |
2507 | 231 | static Integer const i(1); | 271 | INTEGER_IMPL(T) const& INTEGER_IMPL(T)::one() { |
2508 | 272 | static INTEGER_IMPL(T) const i(1); | ||
2509 | 232 | return i; | 273 | return i; |
2510 | 233 | } | 274 | } |
2511 | 234 | 275 | ||
2513 | 235 | zstring Integer::toString() const { | 276 | TEMPLATE_DECL(T) |
2514 | 277 | zstring INTEGER_IMPL(T)::toString() const { | ||
2515 | 236 | #ifdef ZORBA_WITH_BIG_INTEGER | 278 | #ifdef ZORBA_WITH_BIG_INTEGER |
2516 | 237 | char *const buf = new char[ value_.exponent() + 3 ]; | 279 | char *const buf = new char[ value_.exponent() + 3 ]; |
2517 | 238 | value_.toIntegerString( buf ); | 280 | value_.toIntegerString( buf ); |
2518 | @@ -245,12 +287,18 @@ | |||
2519 | 245 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 287 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2520 | 246 | } | 288 | } |
2521 | 247 | 289 | ||
2524 | 248 | Integer const& Integer::zero() { | 290 | TEMPLATE_DECL(T) |
2525 | 249 | static Integer const i(0); | 291 | INTEGER_IMPL(T) const& INTEGER_IMPL(T)::zero() { |
2526 | 292 | static INTEGER_IMPL(T) const i(0); | ||
2527 | 250 | return i; | 293 | return i; |
2528 | 251 | } | 294 | } |
2529 | 252 | 295 | ||
2530 | 253 | /////////////////////////////////////////////////////////////////////////////// | 296 | /////////////////////////////////////////////////////////////////////////////// |
2531 | 254 | 297 | ||
2532 | 298 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2533 | 299 | template class IntegerImpl<long long>; | ||
2534 | 300 | template class IntegerImpl<unsigned long long>; | ||
2535 | 301 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2536 | 302 | |||
2537 | 255 | } // namespace zorba | 303 | } // namespace zorba |
2538 | 256 | /* vim:set et sw=2 ts=2: */ | 304 | /* vim:set et sw=2 ts=2: */ |
2539 | 257 | 305 | ||
2540 | === modified file 'src/zorbatypes/integer.h' | |||
2541 | --- src/zorbatypes/integer.h 2011-06-29 20:31:44 +0000 | |||
2542 | +++ src/zorbatypes/integer.h 2012-02-28 18:23:19 +0000 | |||
2543 | @@ -24,6 +24,7 @@ | |||
2544 | 24 | #include <zorba/config.h> | 24 | #include <zorba/config.h> |
2545 | 25 | #include "common/common.h" | 25 | #include "common/common.h" |
2546 | 26 | 26 | ||
2547 | 27 | #include "util/stl_util.h" | ||
2548 | 27 | #include "zorbaserialization/archiver.h" | 28 | #include "zorbaserialization/archiver.h" |
2549 | 28 | #include "zorbaserialization/zorba_class_serializer.h" | 29 | #include "zorbaserialization/zorba_class_serializer.h" |
2550 | 29 | 30 | ||
2551 | @@ -32,39 +33,53 @@ | |||
2552 | 32 | #include "zorbatypes_decl.h" | 33 | #include "zorbatypes_decl.h" |
2553 | 33 | #include "zstring.h" | 34 | #include "zstring.h" |
2554 | 34 | 35 | ||
2555 | 36 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2556 | 37 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2557 | 38 | # define INTEGER_IMPL(T) IntegerImpl | ||
2558 | 39 | #else | ||
2559 | 40 | # define TEMPLATE_DECL(T) template<typename T> | ||
2560 | 41 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2561 | 42 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2562 | 43 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2563 | 44 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2564 | 45 | |||
2565 | 35 | namespace zorba { | 46 | namespace zorba { |
2566 | 36 | 47 | ||
2568 | 37 | class Integer; | 48 | TEMPLATE_DECL(T) |
2569 | 49 | class IntegerImpl; | ||
2570 | 50 | |||
2571 | 38 | namespace serialization { | 51 | namespace serialization { |
2573 | 39 | void operator&(serialization::Archiver&, zorba::Integer&); | 52 | TEMPLATE_DECL(T) void operator&( Archiver&, INTEGER_IMPL(T)& ); |
2574 | 40 | } | 53 | } |
2575 | 41 | 54 | ||
2576 | 42 | /////////////////////////////////////////////////////////////////////////////// | 55 | /////////////////////////////////////////////////////////////////////////////// |
2577 | 43 | 56 | ||
2580 | 44 | // exported for testing only | 57 | TEMPLATE_DECL(IntType) |
2581 | 45 | class ZORBA_DLL_PUBLIC Integer { | 58 | class IntegerImpl { |
2582 | 46 | public: | 59 | public: |
2583 | 47 | 60 | ||
2584 | 48 | ////////// constructors ///////////////////////////////////////////////////// | 61 | ////////// constructors ///////////////////////////////////////////////////// |
2585 | 49 | 62 | ||
2601 | 50 | Integer( char c ); | 63 | IntegerImpl( char c ); |
2602 | 51 | Integer( signed char c ); | 64 | IntegerImpl( signed char c ); |
2603 | 52 | Integer( short n ); | 65 | IntegerImpl( short n ); |
2604 | 53 | Integer( int n = 0 ); | 66 | IntegerImpl( int n = 0 ); |
2605 | 54 | Integer( long n ); | 67 | IntegerImpl( long n ); |
2606 | 55 | Integer( long long n ); | 68 | IntegerImpl( long long n ); |
2607 | 56 | Integer( unsigned char c ); | 69 | IntegerImpl( unsigned char c ); |
2608 | 57 | Integer( unsigned short n ); | 70 | IntegerImpl( unsigned short n ); |
2609 | 58 | Integer( unsigned int n ); | 71 | IntegerImpl( unsigned int n ); |
2610 | 59 | Integer( unsigned long n ); | 72 | IntegerImpl( unsigned long n ); |
2611 | 60 | Integer( unsigned long long n ); | 73 | IntegerImpl( unsigned long long n ); |
2612 | 61 | Integer( float n ); | 74 | IntegerImpl( float n ); |
2613 | 62 | Integer( double n ); | 75 | IntegerImpl( double n ); |
2614 | 63 | Integer( Decimal const &d ); | 76 | IntegerImpl( Decimal const &d ); |
2615 | 64 | Integer( Integer const &i ); | 77 | |
2616 | 78 | TEMPLATE_DECL(U) | ||
2617 | 79 | IntegerImpl( INTEGER_IMPL(U) const &i ); | ||
2618 | 65 | 80 | ||
2619 | 66 | /** | 81 | /** |
2621 | 67 | * Constructs an %Integer from a C string. | 82 | * Constructs an %IntegerImpl from a C string. |
2622 | 68 | * | 83 | * |
2623 | 69 | * @param s The null-terminated C string to parse. Leading and trailing | 84 | * @param s The null-terminated C string to parse. Leading and trailing |
2624 | 70 | * whitespace is ignored. | 85 | * whitespace is ignored. |
2625 | @@ -73,115 +88,110 @@ | |||
2626 | 73 | * or overflows the smallest or largest representable integer (only when not | 88 | * or overflows the smallest or largest representable integer (only when not |
2627 | 74 | * compiled with ZORBA_WITH_BIG_INTEGER). | 89 | * compiled with ZORBA_WITH_BIG_INTEGER). |
2628 | 75 | */ | 90 | */ |
2630 | 76 | Integer( char const *s ); | 91 | IntegerImpl( char const *s ); |
2631 | 77 | 92 | ||
2632 | 78 | /** | 93 | /** |
2634 | 79 | * Constructs an %Integer from a Double. | 94 | * Constructs an %IntegerImpl from a Double. |
2635 | 80 | * | 95 | * |
2636 | 81 | * @param d The Double. | 96 | * @param d The Double. |
2637 | 82 | * @throw std::invalid_argument if \a d is not finite. | 97 | * @throw std::invalid_argument if \a d is not finite. |
2638 | 83 | */ | 98 | */ |
2640 | 84 | Integer( Double const &d ); | 99 | IntegerImpl( Double const &d ); |
2641 | 85 | 100 | ||
2642 | 86 | /** | 101 | /** |
2644 | 87 | * Constructs an %Integer from a Float. | 102 | * Constructs an %IntegerImpl from a Float. |
2645 | 88 | * | 103 | * |
2646 | 89 | * @param f The Float. | 104 | * @param f The Float. |
2647 | 90 | * @throw std::invalid_argument if \a f is not finite. | 105 | * @throw std::invalid_argument if \a f is not finite. |
2648 | 91 | */ | 106 | */ |
2650 | 92 | Integer( Float const &f ); | 107 | IntegerImpl( Float const &f ); |
2651 | 93 | 108 | ||
2652 | 94 | ////////// assignment operators ///////////////////////////////////////////// | 109 | ////////// assignment operators ///////////////////////////////////////////// |
2653 | 95 | 110 | ||
2672 | 96 | Integer& operator=( char c ); | 111 | IntegerImpl& operator=( char c ); |
2673 | 97 | Integer& operator=( signed char c ); | 112 | IntegerImpl& operator=( signed char c ); |
2674 | 98 | Integer& operator=( short n ); | 113 | IntegerImpl& operator=( short n ); |
2675 | 99 | Integer& operator=( int n ); | 114 | IntegerImpl& operator=( int n ); |
2676 | 100 | Integer& operator=( long n ); | 115 | IntegerImpl& operator=( long n ); |
2677 | 101 | Integer& operator=( long long n ); | 116 | IntegerImpl& operator=( long long n ); |
2678 | 102 | Integer& operator=( unsigned char c ); | 117 | IntegerImpl& operator=( unsigned char c ); |
2679 | 103 | Integer& operator=( unsigned short n ); | 118 | IntegerImpl& operator=( unsigned short n ); |
2680 | 104 | Integer& operator=( unsigned int n ); | 119 | IntegerImpl& operator=( unsigned int n ); |
2681 | 105 | Integer& operator=( unsigned long n ); | 120 | IntegerImpl& operator=( unsigned long n ); |
2682 | 106 | Integer& operator=( unsigned long long n ); | 121 | IntegerImpl& operator=( unsigned long long n ); |
2683 | 107 | Integer& operator=( float n ); | 122 | IntegerImpl& operator=( float n ); |
2684 | 108 | Integer& operator=( double n ); | 123 | IntegerImpl& operator=( double n ); |
2685 | 109 | Integer& operator=( char const *s ); | 124 | IntegerImpl& operator=( char const *s ); |
2686 | 110 | Integer& operator=( Decimal const &d ); | 125 | IntegerImpl& operator=( Decimal const &d ); |
2687 | 111 | Integer& operator=( Double const &d ); | 126 | IntegerImpl& operator=( Double const &d ); |
2688 | 112 | Integer& operator=( Float const &f ); | 127 | IntegerImpl& operator=( Float const &f ); |
2689 | 113 | Integer& operator=( Integer const &i ); | 128 | |
2690 | 129 | TEMPLATE_DECL(U) | ||
2691 | 130 | IntegerImpl& operator=( INTEGER_IMPL(U) const &i ); | ||
2692 | 114 | 131 | ||
2693 | 115 | ////////// arithmetic operators ///////////////////////////////////////////// | 132 | ////////// arithmetic operators ///////////////////////////////////////////// |
2694 | 116 | 133 | ||
2725 | 117 | friend Integer operator+( Integer const &i, Integer const &j ); | 134 | #define ZORBA_INTEGER_OP(OP) \ |
2726 | 118 | friend Integer operator-( Integer const &i, Integer const &j ); | 135 | TEMPLATE_DECL(T) friend \ |
2727 | 119 | friend Integer operator*( Integer const &i, Integer const &j ); | 136 | INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const&, \ |
2728 | 120 | friend Integer operator/( Integer const &i, Integer const &j ); | 137 | INTEGER_IMPL(T) const& ); \ |
2729 | 121 | friend Integer operator%( Integer const &i, Integer const &j ); | 138 | TEMPLATE_DECL(T) friend \ |
2730 | 122 | 139 | Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \ | |
2731 | 123 | friend Decimal operator+( Integer const &i, Decimal const &d ); | 140 | TEMPLATE_DECL(T) friend \ |
2732 | 124 | friend Decimal operator-( Integer const &i, Decimal const &d ); | 141 | Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& ) |
2733 | 125 | friend Decimal operator*( Integer const &i, Decimal const &d ); | 142 | |
2734 | 126 | friend Decimal operator/( Integer const &i, Decimal const &d ); | 143 | ZORBA_INTEGER_OP(+); |
2735 | 127 | friend Decimal operator%( Integer const &i, Decimal const &d ); | 144 | ZORBA_INTEGER_OP(-); |
2736 | 128 | 145 | ZORBA_INTEGER_OP(*); | |
2737 | 129 | friend Decimal operator+( Decimal const &d, Integer const &i ); | 146 | ZORBA_INTEGER_OP(/); |
2738 | 130 | friend Decimal operator-( Decimal const &d, Integer const &i ); | 147 | ZORBA_INTEGER_OP(%); |
2739 | 131 | friend Decimal operator*( Decimal const &d, Integer const &i ); | 148 | #undef ZORBA_INTEGER_OP |
2740 | 132 | friend Decimal operator/( Decimal const &d, Integer const &i ); | 149 | |
2741 | 133 | friend Decimal operator%( Decimal const &d, Integer const &i ); | 150 | IntegerImpl& operator+=( IntegerImpl const& ); |
2742 | 134 | 151 | IntegerImpl& operator-=( IntegerImpl const& ); | |
2743 | 135 | Integer& operator+=( Integer const &i ); | 152 | IntegerImpl& operator*=( IntegerImpl const& ); |
2744 | 136 | Integer& operator-=( Integer const &i ); | 153 | IntegerImpl& operator/=( IntegerImpl const& ); |
2745 | 137 | Integer& operator*=( Integer const &i ); | 154 | IntegerImpl& operator%=( IntegerImpl const& ); |
2746 | 138 | Integer& operator/=( Integer const &i ); | 155 | |
2747 | 139 | Integer& operator%=( Integer const &i ); | 156 | IntegerImpl operator-() const; |
2748 | 140 | 157 | ||
2749 | 141 | Integer operator-() const; | 158 | IntegerImpl& operator++(); |
2750 | 142 | 159 | IntegerImpl operator++(int); | |
2751 | 143 | Integer& operator++(); | 160 | IntegerImpl& operator--(); |
2752 | 144 | Integer operator++(int); | 161 | IntegerImpl operator--(int); |
2723 | 145 | Integer& operator--(); | ||
2724 | 146 | Integer operator--(int); | ||
2753 | 147 | 162 | ||
2754 | 148 | ////////// relational operators ///////////////////////////////////////////// | 163 | ////////// relational operators ///////////////////////////////////////////// |
2755 | 149 | 164 | ||
2776 | 150 | friend bool operator==( Integer const &i, Integer const &j ); | 165 | #define ZORBA_INTEGER_OP(OP) \ |
2777 | 151 | friend bool operator!=( Integer const &i, Integer const &j ); | 166 | TEMPLATE_DECL(T) friend \ |
2778 | 152 | friend bool operator< ( Integer const &i, Integer const &j ); | 167 | bool operator OP( INTEGER_IMPL(T) const&, INTEGER_IMPL(T) const& ); \ |
2779 | 153 | friend bool operator<=( Integer const &i, Integer const &j ); | 168 | TEMPLATE_DECL(T) friend \ |
2780 | 154 | friend bool operator> ( Integer const &i, Integer const &j ); | 169 | bool operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \ |
2781 | 155 | friend bool operator>=( Integer const &i, Integer const &j ); | 170 | TEMPLATE_DECL(T) friend \ |
2782 | 156 | 171 | bool operator OP( Decimal const&, INTEGER_IMPL(T) const& ) | |
2783 | 157 | friend bool operator==( Integer const &i, Decimal const &d ); | 172 | |
2784 | 158 | friend bool operator!=( Integer const &i, Decimal const &d ); | 173 | ZORBA_INTEGER_OP(==); |
2785 | 159 | friend bool operator< ( Integer const &i, Decimal const &d ); | 174 | ZORBA_INTEGER_OP(!=); |
2786 | 160 | friend bool operator<=( Integer const &i, Decimal const &d ); | 175 | ZORBA_INTEGER_OP(< ); |
2787 | 161 | friend bool operator> ( Integer const &i, Decimal const &d ); | 176 | ZORBA_INTEGER_OP(<=); |
2788 | 162 | friend bool operator>=( Integer const &i, Decimal const &d ); | 177 | ZORBA_INTEGER_OP(> ); |
2789 | 163 | 178 | ZORBA_INTEGER_OP(>=); | |
2790 | 164 | friend bool operator==( Decimal const &d, Integer const &i ); | 179 | #undef ZORBA_INTEGER_OP |
2771 | 165 | friend bool operator!=( Decimal const &d, Integer const &i ); | ||
2772 | 166 | friend bool operator< ( Decimal const &d, Integer const &i ); | ||
2773 | 167 | friend bool operator<=( Decimal const &d, Integer const &i ); | ||
2774 | 168 | friend bool operator> ( Decimal const &d, Integer const &i ); | ||
2775 | 169 | friend bool operator>=( Decimal const &d, Integer const &i ); | ||
2791 | 170 | 180 | ||
2792 | 171 | ////////// math functions /////////////////////////////////////////////////// | 181 | ////////// math functions /////////////////////////////////////////////////// |
2793 | 172 | 182 | ||
2797 | 173 | Double pow( Integer const &power ) const; | 183 | Double pow( IntegerImpl const &power ) const; |
2798 | 174 | Integer round( Integer const &precision ) const; | 184 | IntegerImpl round( IntegerImpl const &precision ) const; |
2799 | 175 | Integer roundHalfToEven( Integer const &precision ) const; | 185 | IntegerImpl roundHalfToEven( IntegerImpl const &precision ) const; |
2800 | 176 | 186 | ||
2801 | 177 | ////////// miscellaneous //////////////////////////////////////////////////// | 187 | ////////// miscellaneous //////////////////////////////////////////////////// |
2802 | 178 | 188 | ||
2804 | 179 | int compare( Integer const &i ) const; | 189 | int compare( IntegerImpl const& ) const; |
2805 | 180 | uint32_t hash() const; | 190 | uint32_t hash() const; |
2806 | 181 | int sign() const; | 191 | int sign() const; |
2807 | 182 | zstring toString() const; | 192 | zstring toString() const; |
2810 | 183 | static Integer const& one(); | 193 | static IntegerImpl const& one(); |
2811 | 184 | static Integer const& zero(); | 194 | static IntegerImpl const& zero(); |
2812 | 185 | 195 | ||
2813 | 186 | ///////////////////////////////////////////////////////////////////////////// | 196 | ///////////////////////////////////////////////////////////////////////////// |
2814 | 187 | 197 | ||
2815 | @@ -189,13 +199,13 @@ | |||
2816 | 189 | #ifdef ZORBA_WITH_BIG_INTEGER | 199 | #ifdef ZORBA_WITH_BIG_INTEGER |
2817 | 190 | typedef MAPM value_type; | 200 | typedef MAPM value_type; |
2818 | 191 | #else | 201 | #else |
2820 | 192 | typedef long long value_type; | 202 | typedef IntType value_type; |
2821 | 193 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 203 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2822 | 194 | 204 | ||
2823 | 195 | value_type value_; | 205 | value_type value_; |
2824 | 196 | 206 | ||
2825 | 197 | #ifdef ZORBA_WITH_BIG_INTEGER | 207 | #ifdef ZORBA_WITH_BIG_INTEGER |
2827 | 198 | Integer( value_type const &v ) : value_( v ) { } | 208 | IntegerImpl( value_type const &v ) : value_( v ) { } |
2828 | 199 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 209 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2829 | 200 | 210 | ||
2830 | 201 | static value_type ftoi( double d ) { | 211 | static value_type ftoi( double d ) { |
2831 | @@ -227,58 +237,96 @@ | |||
2832 | 227 | friend class Decimal; | 237 | friend class Decimal; |
2833 | 228 | template<typename T> friend class FloatImpl; | 238 | template<typename T> friend class FloatImpl; |
2834 | 229 | 239 | ||
2841 | 230 | friend xs_int to_xs_int( Integer const& ); | 240 | #ifndef ZORBA_WITH_BIG_INTEGER |
2842 | 231 | friend xs_long to_xs_long( Integer const& ); | 241 | template<typename U> friend class IntegerImpl; |
2843 | 232 | friend xs_unsignedInt to_xs_unsignedInt( Integer const& ); | 242 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2844 | 233 | friend xs_unsignedLong to_xs_unsignedLong( Integer const& ); | 243 | |
2845 | 234 | 244 | friend xs_int to_xs_int( INTEGER_IMPL_LL const& ); | |
2846 | 235 | friend void serialization::operator&(serialization::Archiver&, Integer&); | 245 | friend xs_long to_xs_long( INTEGER_IMPL_LL const& ); |
2847 | 246 | friend xs_unsignedInt to_xs_unsignedInt( INTEGER_IMPL_LL const& ); | ||
2848 | 247 | friend xs_unsignedLong to_xs_unsignedLong( INTEGER_IMPL_LL const& ); | ||
2849 | 248 | |||
2850 | 249 | TEMPLATE_DECL(T) friend | ||
2851 | 250 | void serialization::operator&( serialization::Archiver&, INTEGER_IMPL(T)& ); | ||
2852 | 236 | }; | 251 | }; |
2853 | 237 | 252 | ||
2854 | 253 | typedef INTEGER_IMPL_LL Integer; | ||
2855 | 254 | typedef INTEGER_IMPL_ULL UInteger; | ||
2856 | 255 | |||
2857 | 238 | ////////// constructors /////////////////////////////////////////////////////// | 256 | ////////// constructors /////////////////////////////////////////////////////// |
2858 | 239 | 257 | ||
2901 | 240 | inline Integer::Integer( char c ) : value_( static_cast<long>( c ) ) { | 258 | TEMPLATE_DECL(T) |
2902 | 241 | } | 259 | inline INTEGER_IMPL(T)::IntegerImpl( char c ) : |
2903 | 242 | 260 | value_( static_cast<long>( c ) ) | |
2904 | 243 | inline Integer::Integer( signed char c ) : value_( static_cast<long>( c ) ) { | 261 | { |
2905 | 244 | } | 262 | } |
2906 | 245 | 263 | ||
2907 | 246 | inline Integer::Integer( short n ) : value_( static_cast<long>( n ) ) { | 264 | TEMPLATE_DECL(T) |
2908 | 247 | } | 265 | inline INTEGER_IMPL(T)::IntegerImpl( signed char c ) : |
2909 | 248 | 266 | value_( static_cast<long>( c ) ) | |
2910 | 249 | inline Integer::Integer( int n ) : value_( static_cast<long>( n ) ) { | 267 | { |
2911 | 250 | } | 268 | } |
2912 | 251 | 269 | ||
2913 | 252 | inline Integer::Integer( long n ) : value_( n ) { | 270 | TEMPLATE_DECL(T) |
2914 | 253 | } | 271 | inline INTEGER_IMPL(T)::IntegerImpl( short n ) : |
2915 | 254 | 272 | value_( static_cast<long>( n ) ) | |
2916 | 255 | #ifndef ZORBA_WITH_BIG_INTEGER | 273 | { |
2917 | 256 | inline Integer::Integer( long long n ) : value_( n ) { | 274 | } |
2918 | 257 | } | 275 | |
2919 | 258 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 276 | TEMPLATE_DECL(T) |
2920 | 259 | 277 | inline INTEGER_IMPL(T)::IntegerImpl( int n ) : | |
2921 | 260 | inline Integer::Integer( unsigned char c ) : value_( static_cast<long>( c ) ) { | 278 | value_( static_cast<long>( n ) ) |
2922 | 261 | } | 279 | { |
2923 | 262 | 280 | } | |
2924 | 263 | inline Integer::Integer( unsigned short n ) : value_( static_cast<long>( n ) ) { | 281 | |
2925 | 264 | } | 282 | TEMPLATE_DECL(T) |
2926 | 265 | 283 | inline INTEGER_IMPL(T)::IntegerImpl( long n ) : | |
2927 | 266 | inline Integer::Integer( unsigned int n ) : value_( static_cast<long>( n ) ) { | 284 | value_( n ) |
2928 | 267 | } | 285 | { |
2929 | 268 | 286 | } | |
2930 | 269 | #ifndef ZORBA_WITH_BIG_INTEGER | 287 | |
2931 | 270 | inline Integer::Integer( unsigned long n ) : | 288 | #ifndef ZORBA_WITH_BIG_INTEGER |
2932 | 271 | value_( static_cast<value_type>( n ) ) | 289 | TEMPLATE_DECL(T) |
2933 | 272 | { | 290 | inline INTEGER_IMPL(T)::IntegerImpl( long long n ) : |
2934 | 273 | } | 291 | value_( n ) |
2935 | 274 | 292 | { | |
2936 | 275 | inline Integer::Integer( unsigned long long n ) : | 293 | } |
2937 | 276 | value_( static_cast<value_type>( n ) ) | 294 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2938 | 277 | { | 295 | |
2939 | 278 | } | 296 | TEMPLATE_DECL(T) |
2940 | 279 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 297 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned char c ) : |
2941 | 280 | 298 | value_( static_cast<long>( c ) ) | |
2942 | 281 | inline Integer::Integer( float n ) : | 299 | { |
2943 | 300 | } | ||
2944 | 301 | |||
2945 | 302 | TEMPLATE_DECL(T) | ||
2946 | 303 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned short n ) : | ||
2947 | 304 | value_( static_cast<long>( n ) ) | ||
2948 | 305 | { | ||
2949 | 306 | } | ||
2950 | 307 | |||
2951 | 308 | TEMPLATE_DECL(T) | ||
2952 | 309 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned int n ) : | ||
2953 | 310 | value_( static_cast<long>( n ) ) | ||
2954 | 311 | { | ||
2955 | 312 | } | ||
2956 | 313 | |||
2957 | 314 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2958 | 315 | TEMPLATE_DECL(T) | ||
2959 | 316 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned long n ) : | ||
2960 | 317 | value_( static_cast<value_type>( n ) ) | ||
2961 | 318 | { | ||
2962 | 319 | } | ||
2963 | 320 | |||
2964 | 321 | TEMPLATE_DECL(T) | ||
2965 | 322 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned long long n ) : | ||
2966 | 323 | value_( static_cast<value_type>( n ) ) | ||
2967 | 324 | { | ||
2968 | 325 | } | ||
2969 | 326 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2970 | 327 | |||
2971 | 328 | TEMPLATE_DECL(T) | ||
2972 | 329 | inline INTEGER_IMPL(T)::IntegerImpl( float n ) : | ||
2973 | 282 | #ifdef ZORBA_WITH_BIG_INTEGER | 330 | #ifdef ZORBA_WITH_BIG_INTEGER |
2974 | 283 | value_( static_cast<double>( n ) ) | 331 | value_( static_cast<double>( n ) ) |
2975 | 284 | #else | 332 | #else |
2976 | @@ -287,7 +335,8 @@ | |||
2977 | 287 | { | 335 | { |
2978 | 288 | } | 336 | } |
2979 | 289 | 337 | ||
2981 | 290 | inline Integer::Integer( double n ) : | 338 | TEMPLATE_DECL(T) |
2982 | 339 | inline INTEGER_IMPL(T)::IntegerImpl( double n ) : | ||
2983 | 291 | #ifdef ZORBA_WITH_BIG_INTEGER | 340 | #ifdef ZORBA_WITH_BIG_INTEGER |
2984 | 292 | value_( n ) | 341 | value_( n ) |
2985 | 293 | #else | 342 | #else |
2986 | @@ -296,240 +345,252 @@ | |||
2987 | 296 | { | 345 | { |
2988 | 297 | } | 346 | } |
2989 | 298 | 347 | ||
2991 | 299 | inline Integer::Integer( char const *s ) { | 348 | TEMPLATE_DECL(T) |
2992 | 349 | inline INTEGER_IMPL(T)::IntegerImpl( char const *s ) { | ||
2993 | 300 | parse( s ); | 350 | parse( s ); |
2994 | 301 | } | 351 | } |
2995 | 302 | 352 | ||
2997 | 303 | inline Integer::Integer( Integer const &i ) : | 353 | TEMPLATE_DECL(T) |
2998 | 354 | TEMPLATE_DECL(U) | ||
2999 | 355 | inline INTEGER_IMPL(T)::IntegerImpl( INTEGER_IMPL(U) const &i ) : | ||
3000 | 304 | value_( i.value_ ) | 356 | value_( i.value_ ) |
3001 | 305 | { | 357 | { |
3002 | 306 | } | 358 | } |
3003 | 307 | 359 | ||
3004 | 308 | ////////// assignment operators /////////////////////////////////////////////// | 360 | ////////// assignment operators /////////////////////////////////////////////// |
3005 | 309 | 361 | ||
3076 | 310 | inline Integer& Integer::operator=( char c ) { | 362 | TEMPLATE_DECL(T) |
3077 | 311 | value_ = static_cast<long>( c ); | 363 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char c ) { |
3078 | 312 | return *this; | 364 | value_ = static_cast<long>( c ); |
3079 | 313 | } | 365 | return *this; |
3080 | 314 | 366 | } | |
3081 | 315 | inline Integer& Integer::operator=( signed char c ) { | 367 | |
3082 | 316 | value_ = static_cast<long>( c ); | 368 | TEMPLATE_DECL(T) |
3083 | 317 | return *this; | 369 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( signed char c ) { |
3084 | 318 | } | 370 | value_ = static_cast<long>( c ); |
3085 | 319 | 371 | return *this; | |
3086 | 320 | inline Integer& Integer::operator=( short n ) { | 372 | } |
3087 | 321 | value_ = static_cast<long>( n ); | 373 | |
3088 | 322 | return *this; | 374 | TEMPLATE_DECL(T) |
3089 | 323 | } | 375 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( short n ) { |
3090 | 324 | 376 | value_ = static_cast<long>( n ); | |
3091 | 325 | inline Integer& Integer::operator=( int n ) { | 377 | return *this; |
3092 | 326 | value_ = static_cast<long>( n ); | 378 | } |
3093 | 327 | return *this; | 379 | |
3094 | 328 | } | 380 | TEMPLATE_DECL(T) |
3095 | 329 | 381 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( int n ) { | |
3096 | 330 | inline Integer& Integer::operator=( long n ) { | 382 | value_ = static_cast<long>( n ); |
3097 | 331 | value_ = n; | 383 | return *this; |
3098 | 332 | return *this; | 384 | } |
3099 | 333 | } | 385 | |
3100 | 334 | 386 | TEMPLATE_DECL(T) | |
3101 | 335 | #ifndef ZORBA_WITH_BIG_INTEGER | 387 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long n ) { |
3102 | 336 | inline Integer& Integer::operator=( long long n ) { | 388 | value_ = n; |
3103 | 337 | value_ = n; | 389 | return *this; |
3104 | 338 | return *this; | 390 | } |
3105 | 339 | } | 391 | |
3106 | 340 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 392 | #ifndef ZORBA_WITH_BIG_INTEGER |
3107 | 341 | 393 | TEMPLATE_DECL(T) | |
3108 | 342 | inline Integer& Integer::operator=( unsigned char c ) { | 394 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long long n ) { |
3109 | 343 | value_ = static_cast<long>( c ); | 395 | value_ = n; |
3110 | 344 | return *this; | 396 | return *this; |
3111 | 345 | } | 397 | } |
3112 | 346 | 398 | #endif /* ZORBA_WITH_BIG_INTEGER */ | |
3113 | 347 | inline Integer& Integer::operator=( unsigned short n ) { | 399 | |
3114 | 348 | value_ = static_cast<long>( n ); | 400 | TEMPLATE_DECL(T) |
3115 | 349 | return *this; | 401 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned char c ) { |
3116 | 350 | } | 402 | value_ = static_cast<long>( c ); |
3117 | 351 | 403 | return *this; | |
3118 | 352 | inline Integer& Integer::operator=( unsigned int n ) { | 404 | } |
3119 | 353 | value_ = static_cast<long>( n ); | 405 | |
3120 | 354 | return *this; | 406 | TEMPLATE_DECL(T) |
3121 | 355 | } | 407 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned short n ) { |
3122 | 356 | 408 | value_ = static_cast<long>( n ); | |
3123 | 357 | #ifndef ZORBA_WITH_BIG_INTEGER | 409 | return *this; |
3124 | 358 | inline Integer& Integer::operator=( unsigned long n ) { | 410 | } |
3125 | 359 | value_ = static_cast<long>( n ); | 411 | |
3126 | 360 | return *this; | 412 | TEMPLATE_DECL(T) |
3127 | 361 | } | 413 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned int n ) { |
3128 | 362 | 414 | value_ = static_cast<long>( n ); | |
3129 | 363 | inline Integer& Integer::operator=( unsigned long long n ) { | 415 | return *this; |
3130 | 364 | value_ = n; | 416 | } |
3131 | 365 | return *this; | 417 | |
3132 | 366 | } | 418 | #ifndef ZORBA_WITH_BIG_INTEGER |
3133 | 367 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 419 | TEMPLATE_DECL(T) |
3134 | 368 | 420 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long n ) { | |
3135 | 369 | inline Integer& Integer::operator=( float n ) { | 421 | value_ = static_cast<long>( n ); |
3136 | 370 | value_ = static_cast<long>( n ); | 422 | return *this; |
3137 | 371 | return *this; | 423 | } |
3138 | 372 | } | 424 | |
3139 | 373 | 425 | TEMPLATE_DECL(T) | |
3140 | 374 | inline Integer& Integer::operator=( double n ) { | 426 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long long n ) { |
3141 | 375 | value_ = static_cast<long>( n ); | 427 | value_ = n; |
3142 | 376 | return *this; | 428 | return *this; |
3143 | 377 | } | 429 | } |
3144 | 378 | 430 | #endif /* ZORBA_WITH_BIG_INTEGER */ | |
3145 | 379 | inline Integer& Integer::operator=( char const *s ) { | 431 | |
3146 | 432 | TEMPLATE_DECL(T) | ||
3147 | 433 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( float n ) { | ||
3148 | 434 | value_ = static_cast<long>( n ); | ||
3149 | 435 | return *this; | ||
3150 | 436 | } | ||
3151 | 437 | |||
3152 | 438 | TEMPLATE_DECL(T) | ||
3153 | 439 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( double n ) { | ||
3154 | 440 | value_ = static_cast<long>( n ); | ||
3155 | 441 | return *this; | ||
3156 | 442 | } | ||
3157 | 443 | |||
3158 | 444 | TEMPLATE_DECL(T) | ||
3159 | 445 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char const *s ) { | ||
3160 | 380 | parse( s ); | 446 | parse( s ); |
3161 | 381 | return *this; | 447 | return *this; |
3162 | 382 | } | 448 | } |
3163 | 383 | 449 | ||
3165 | 384 | inline Integer& Integer::operator=( Integer const &i ) { | 450 | TEMPLATE_DECL(T) |
3166 | 451 | TEMPLATE_DECL(U) | ||
3167 | 452 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( INTEGER_IMPL(U) const &i ) { | ||
3168 | 385 | value_ = i.value_; | 453 | value_ = i.value_; |
3169 | 386 | return *this; | 454 | return *this; |
3170 | 387 | } | 455 | } |
3171 | 388 | 456 | ||
3172 | 389 | ////////// arithmetic operators /////////////////////////////////////////////// | 457 | ////////// arithmetic operators /////////////////////////////////////////////// |
3173 | 390 | 458 | ||
3210 | 391 | inline Integer operator+( Integer const &i, Integer const &j ) { | 459 | #define ZORBA_INTEGER_OP(OP) \ |
3211 | 392 | return i.value_ + j.value_; | 460 | TEMPLATE_DECL(T) inline \ |
3212 | 393 | } | 461 | INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const &i, \ |
3213 | 394 | 462 | INTEGER_IMPL(T) const &j ) { \ | |
3214 | 395 | inline Integer operator-( Integer const &i, Integer const &j ) { | 463 | return i.value_ OP j.value_; \ |
3215 | 396 | return i.value_ - j.value_; | 464 | } |
3216 | 397 | } | 465 | |
3217 | 398 | 466 | ZORBA_INTEGER_OP(+) | |
3218 | 399 | inline Integer operator*( Integer const &i, Integer const &j ) { | 467 | ZORBA_INTEGER_OP(-) |
3219 | 400 | return i.value_ * j.value_; | 468 | ZORBA_INTEGER_OP(*) |
3220 | 401 | } | 469 | ZORBA_INTEGER_OP(%) |
3221 | 402 | 470 | #undef ZORBA_INTEGER_OP | |
3222 | 403 | inline Integer operator/( Integer const &i, Integer const &j ) { | 471 | |
3223 | 404 | return Integer::ftoi( i.value_ / j.value_ ); | 472 | TEMPLATE_DECL(T) inline |
3224 | 405 | } | 473 | INTEGER_IMPL(T) operator/( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) { |
3225 | 406 | 474 | return INTEGER_IMPL(T)::ftoi( i.value_ / j.value_ ); | |
3226 | 407 | inline Integer operator%( Integer const &i, Integer const &j ) { | 475 | } |
3227 | 408 | return i.value_ % j.value_; | 476 | |
3228 | 409 | } | 477 | #define ZORBA_INTEGER_OP(OP) \ |
3229 | 410 | 478 | TEMPLATE_DECL(T) inline \ | |
3230 | 411 | inline Integer& Integer::operator+=( Integer const &i ) { | 479 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator OP( IntegerImpl const &i ) { \ |
3231 | 412 | value_ += i.value_; | 480 | value_ OP i.value_; \ |
3232 | 413 | return *this; | 481 | return *this; \ |
3233 | 414 | } | 482 | } |
3234 | 415 | 483 | ||
3235 | 416 | inline Integer& Integer::operator-=( Integer const &i ) { | 484 | ZORBA_INTEGER_OP(+=) |
3236 | 417 | value_ -= i.value_; | 485 | ZORBA_INTEGER_OP(-=) |
3237 | 418 | return *this; | 486 | ZORBA_INTEGER_OP(*=) |
3238 | 419 | } | 487 | ZORBA_INTEGER_OP(%=) |
3239 | 420 | 488 | #undef ZORBA_INTEGER_OP | |
3240 | 421 | inline Integer& Integer::operator*=( Integer const &i ) { | 489 | |
3241 | 422 | value_ *= i.value_; | 490 | TEMPLATE_DECL(T) |
3242 | 423 | return *this; | 491 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator/=( IntegerImpl const &i ) { |
3207 | 424 | } | ||
3208 | 425 | |||
3209 | 426 | inline Integer& Integer::operator/=( Integer const &i ) { | ||
3243 | 427 | value_ = ftoi( value_ / i.value_ ); | 492 | value_ = ftoi( value_ / i.value_ ); |
3244 | 428 | return *this; | 493 | return *this; |
3245 | 429 | } | 494 | } |
3246 | 430 | 495 | ||
3253 | 431 | inline Integer& Integer::operator%=( Integer const &i ) { | 496 | TEMPLATE_DECL(T) |
3254 | 432 | value_ %= i.value_; | 497 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator-() const { |
3249 | 433 | return *this; | ||
3250 | 434 | } | ||
3251 | 435 | |||
3252 | 436 | inline Integer Integer::operator-() const { | ||
3255 | 437 | return -value_; | 498 | return -value_; |
3256 | 438 | } | 499 | } |
3257 | 439 | 500 | ||
3259 | 440 | inline Integer& Integer::operator++() { | 501 | TEMPLATE_DECL(T) |
3260 | 502 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator++() { | ||
3261 | 441 | ++value_; | 503 | ++value_; |
3262 | 442 | return *this; | 504 | return *this; |
3263 | 443 | } | 505 | } |
3264 | 444 | 506 | ||
3267 | 445 | inline Integer Integer::operator++(int) { | 507 | TEMPLATE_DECL(T) |
3268 | 446 | Integer const result( *this ); | 508 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator++(int) { |
3269 | 509 | INTEGER_IMPL(T) const result( *this ); | ||
3270 | 447 | ++value_; | 510 | ++value_; |
3271 | 448 | return result; | 511 | return result; |
3272 | 449 | } | 512 | } |
3273 | 450 | 513 | ||
3275 | 451 | inline Integer& Integer::operator--() { | 514 | TEMPLATE_DECL(T) |
3276 | 515 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator--() { | ||
3277 | 452 | --value_; | 516 | --value_; |
3278 | 453 | return *this; | 517 | return *this; |
3279 | 454 | } | 518 | } |
3280 | 455 | 519 | ||
3283 | 456 | inline Integer Integer::operator--(int) { | 520 | TEMPLATE_DECL(T) |
3284 | 457 | Integer const result( *this ); | 521 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator--(int) { |
3285 | 522 | INTEGER_IMPL(T) const result( *this ); | ||
3286 | 458 | --value_; | 523 | --value_; |
3287 | 459 | return result; | 524 | return result; |
3288 | 460 | } | 525 | } |
3289 | 461 | 526 | ||
3290 | 462 | ////////// relational operators /////////////////////////////////////////////// | 527 | ////////// relational operators /////////////////////////////////////////////// |
3291 | 463 | 528 | ||
3315 | 464 | inline bool operator==( Integer const &i, Integer const &j ) { | 529 | #define ZORBA_INTEGER_OP(OP) \ |
3316 | 465 | return i.value_ == j.value_; | 530 | TEMPLATE_DECL(T) inline \ |
3317 | 466 | } | 531 | bool operator OP( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) { \ |
3318 | 467 | 532 | return i.value_ OP j.value_; \ | |
3319 | 468 | inline bool operator!=( Integer const &i, Integer const &j ) { | 533 | } |
3320 | 469 | return i.value_ != j.value_; | 534 | |
3321 | 470 | } | 535 | ZORBA_INTEGER_OP(==) |
3322 | 471 | 536 | ZORBA_INTEGER_OP(!=) | |
3323 | 472 | inline bool operator<( Integer const &i, Integer const &j ) { | 537 | ZORBA_INTEGER_OP(< ) |
3324 | 473 | return i.value_ < j.value_; | 538 | ZORBA_INTEGER_OP(<=) |
3325 | 474 | } | 539 | ZORBA_INTEGER_OP(> ) |
3326 | 475 | 540 | ZORBA_INTEGER_OP(>=) | |
3327 | 476 | inline bool operator<=( Integer const &i, Integer const &j ) { | 541 | #undef ZORBA_INTEGER_OP |
3305 | 477 | return i.value_ <= j.value_; | ||
3306 | 478 | } | ||
3307 | 479 | |||
3308 | 480 | inline bool operator>( Integer const &i, Integer const &j ) { | ||
3309 | 481 | return i.value_ > j.value_; | ||
3310 | 482 | } | ||
3311 | 483 | |||
3312 | 484 | inline bool operator>=( Integer const &i, Integer const &j ) { | ||
3313 | 485 | return i.value_ >= j.value_; | ||
3314 | 486 | } | ||
3328 | 487 | 542 | ||
3329 | 488 | ////////// miscellaneous ////////////////////////////////////////////////////// | 543 | ////////// miscellaneous ////////////////////////////////////////////////////// |
3330 | 489 | 544 | ||
3331 | 490 | #ifdef ZORBA_WITH_BIG_INTEGER | 545 | #ifdef ZORBA_WITH_BIG_INTEGER |
3332 | 491 | 546 | ||
3334 | 492 | inline int Integer::compare( Integer const &i ) const { | 547 | inline int IntegerImpl::compare( IntegerImpl const &i ) const { |
3335 | 493 | return value_.compare( i.value_ ); | 548 | return value_.compare( i.value_ ); |
3336 | 494 | } | 549 | } |
3337 | 495 | 550 | ||
3339 | 496 | inline int Integer::sign() const { | 551 | inline int IntegerImpl::sign() const { |
3340 | 497 | return value_.sign(); | 552 | return value_.sign(); |
3341 | 498 | } | 553 | } |
3342 | 499 | 554 | ||
3343 | 500 | #else | 555 | #else |
3344 | 501 | 556 | ||
3352 | 502 | inline int Integer::compare( Integer const &i ) const { | 557 | template<typename IntType> |
3353 | 503 | // | 558 | inline int IntegerImpl<IntType>::compare( IntegerImpl const &i ) const { |
3354 | 504 | // Note that we can't return the difference directly since it will be | 559 | return value_ < i.value_ ? -1 : value_ > i.value_ ? 1 : 0; |
3348 | 505 | // truncated if it's ether > max(int) or < min(int) yielding a wrong result. | ||
3349 | 506 | // | ||
3350 | 507 | value_type const temp = value_ - i.value_; | ||
3351 | 508 | return temp < 0 ? -1 : temp > 0 ? 1 : 0; | ||
3355 | 509 | } | 560 | } |
3356 | 510 | 561 | ||
3358 | 511 | inline uint32_t Integer::hash() const { | 562 | template<typename IntType> |
3359 | 563 | inline uint32_t IntegerImpl<IntType>::hash() const { | ||
3360 | 512 | return static_cast<uint32_t>( value_ ); | 564 | return static_cast<uint32_t>( value_ ); |
3361 | 513 | } | 565 | } |
3362 | 514 | 566 | ||
3364 | 515 | inline bool Integer::is_long() const { | 567 | template<typename IntType> |
3365 | 568 | inline bool IntegerImpl<IntType>::is_long() const { | ||
3366 | 516 | return value_ >= std::numeric_limits<long>::min() && | 569 | return value_ >= std::numeric_limits<long>::min() && |
3367 | 517 | value_ <= std::numeric_limits<long>::max(); | 570 | value_ <= std::numeric_limits<long>::max(); |
3368 | 518 | } | 571 | } |
3369 | 519 | 572 | ||
3372 | 520 | inline int Integer::sign() const { | 573 | template<typename IntType> |
3373 | 521 | return value_ < 0 ? -1 : value_ > 0 ? 1 : 0; | 574 | inline int IntegerImpl<IntType>::sign() const { |
3374 | 575 | return ztd::lt0( value_ ) ? -1 : value_ > 0 ? 1 : 0; | ||
3375 | 522 | } | 576 | } |
3376 | 523 | 577 | ||
3377 | 524 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 578 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3378 | 525 | 579 | ||
3380 | 526 | inline std::ostream& operator<<( std::ostream &os, Integer const &i ) { | 580 | TEMPLATE_DECL(T) |
3381 | 581 | inline std::ostream& operator<<( std::ostream &os, INTEGER_IMPL(T) const &i ) { | ||
3382 | 527 | return os << i.toString(); | 582 | return os << i.toString(); |
3383 | 528 | } | 583 | } |
3384 | 529 | 584 | ||
3385 | 530 | /////////////////////////////////////////////////////////////////////////////// | 585 | /////////////////////////////////////////////////////////////////////////////// |
3386 | 531 | 586 | ||
3387 | 532 | } // namespace zorba | 587 | } // namespace zorba |
3388 | 588 | |||
3389 | 589 | #undef TEMPLATE_DECL | ||
3390 | 590 | #undef INTEGER_IMPL | ||
3391 | 591 | #undef INTEGER_IMPL_LL | ||
3392 | 592 | #undef INTEGER_IMPL_ULL | ||
3393 | 593 | |||
3394 | 533 | #endif // ZORBA_INTEGER_H | 594 | #endif // ZORBA_INTEGER_H |
3395 | 534 | /* | 595 | /* |
3396 | 535 | * Local variables: | 596 | * Local variables: |
3397 | 536 | 597 | ||
3398 | === modified file 'src/zorbatypes/numconversions.cpp' | |||
3399 | --- src/zorbatypes/numconversions.cpp 2011-06-29 20:31:44 +0000 | |||
3400 | +++ src/zorbatypes/numconversions.cpp 2012-02-28 18:23:19 +0000 | |||
3401 | @@ -33,7 +33,7 @@ | |||
3402 | 33 | zstring const temp( i.toString() ); | 33 | zstring const temp( i.toString() ); |
3403 | 34 | return ztd::aton<xs_int>( temp.c_str() ); | 34 | return ztd::aton<xs_int>( temp.c_str() ); |
3404 | 35 | #else | 35 | #else |
3406 | 36 | return static_cast<xs_int>(i.value_); | 36 | return static_cast<xs_int>( i.value_ ); |
3407 | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3408 | 38 | } | 38 | } |
3409 | 39 | 39 | ||
3410 | @@ -56,6 +56,13 @@ | |||
3411 | 56 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 56 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3412 | 57 | } | 57 | } |
3413 | 58 | 58 | ||
3414 | 59 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
3415 | 60 | xs_long to_xs_long( xs_nonNegativeInteger const &i ) { | ||
3416 | 61 | zstring const temp( i.toString() ); | ||
3417 | 62 | return ztd::aton<xs_long>( temp.c_str() ); | ||
3418 | 63 | } | ||
3419 | 64 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3420 | 65 | |||
3421 | 59 | xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) { | 66 | xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) { |
3422 | 60 | #ifdef ZORBA_WITH_BIG_INTEGER | 67 | #ifdef ZORBA_WITH_BIG_INTEGER |
3423 | 61 | zstring const temp( i.toString() ); | 68 | zstring const temp( i.toString() ); |
3424 | 62 | 69 | ||
3425 | === modified file 'src/zorbatypes/numconversions.h' | |||
3426 | --- src/zorbatypes/numconversions.h 2011-06-29 20:31:44 +0000 | |||
3427 | +++ src/zorbatypes/numconversions.h 2012-02-28 18:23:19 +0000 | |||
3428 | @@ -64,6 +64,10 @@ | |||
3429 | 64 | */ | 64 | */ |
3430 | 65 | xs_long to_xs_long( xs_integer const &i ); | 65 | xs_long to_xs_long( xs_integer const &i ); |
3431 | 66 | 66 | ||
3432 | 67 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
3433 | 68 | xs_long to_xs_long( xs_nonNegativeInteger const &i ); | ||
3434 | 69 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3435 | 70 | |||
3436 | 67 | /** | 71 | /** |
3437 | 68 | * Converts an \c xs:integer value to an \c xs:unsignedInt. | 72 | * Converts an \c xs:integer value to an \c xs:unsignedInt. |
3438 | 69 | * | 73 | * |
3439 | 70 | 74 | ||
3440 | === modified file 'src/zorbatypes/schema_types.h' | |||
3441 | --- src/zorbatypes/schema_types.h 2011-06-24 13:38:42 +0000 | |||
3442 | +++ src/zorbatypes/schema_types.h 2012-02-28 18:23:19 +0000 | |||
3443 | @@ -46,8 +46,12 @@ | |||
3444 | 46 | typedef DateTime xs_gYearMonth; | 46 | typedef DateTime xs_gYearMonth; |
3445 | 47 | typedef Base16 xs_hexBinary; | 47 | typedef Base16 xs_hexBinary; |
3446 | 48 | typedef Integer xs_integer; | 48 | typedef Integer xs_integer; |
3447 | 49 | typedef Integer xs_negativeInteger; // this isn't quite right | ||
3448 | 50 | typedef UInteger xs_nonNegativeInteger; // i.e., "unsigned" | ||
3449 | 51 | typedef Integer xs_nonPositiveInteger; // this isn't quite right either | ||
3450 | 52 | typedef UInteger xs_positiveInteger; | ||
3451 | 49 | typedef DateTime xs_time; | 53 | typedef DateTime xs_time; |
3453 | 50 | typedef Integer xs_uinteger; | 54 | typedef UInteger xs_uinteger; // old, deprecated name |
3454 | 51 | typedef Duration xs_yearMonthDuration; | 55 | typedef Duration xs_yearMonthDuration; |
3455 | 52 | 56 | ||
3456 | 53 | /////////////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////////////// |
3457 | 54 | 58 | ||
3458 | === modified file 'src/zorbatypes/zorbatypes_decl.h' | |||
3459 | --- src/zorbatypes/zorbatypes_decl.h 2011-06-14 17:26:33 +0000 | |||
3460 | +++ src/zorbatypes/zorbatypes_decl.h 2012-02-28 18:23:19 +0000 | |||
3461 | @@ -18,11 +18,23 @@ | |||
3462 | 18 | #ifndef ZORBA_ZORBATYPES_DECL_H | 18 | #ifndef ZORBA_ZORBATYPES_DECL_H |
3463 | 19 | #define ZORBA_ZORBATYPES_DECL_H | 19 | #define ZORBA_ZORBATYPES_DECL_H |
3464 | 20 | 20 | ||
3465 | 21 | #include <zorba/config.h> | ||
3466 | 22 | |||
3467 | 21 | namespace zorba | 23 | namespace zorba |
3468 | 22 | { | 24 | { |
3469 | 23 | /* numerics */ | 25 | /* numerics */ |
3470 | 24 | class Decimal; | 26 | class Decimal; |
3472 | 25 | class Integer; | 27 | |
3473 | 28 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
3474 | 29 | class IntegerImpl; | ||
3475 | 30 | typedef IntegerImpl Integer; | ||
3476 | 31 | typedef IntegerImpl UInteger; | ||
3477 | 32 | #else | ||
3478 | 33 | template<typename T> class IntegerImpl; | ||
3479 | 34 | typedef IntegerImpl<long long> Integer; | ||
3480 | 35 | typedef IntegerImpl<unsigned long long> UInteger; | ||
3481 | 36 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3482 | 37 | |||
3483 | 26 | template<typename T> class FloatImpl; | 38 | template<typename T> class FloatImpl; |
3484 | 27 | typedef FloatImpl<double> Double; | 39 | typedef FloatImpl<double> Double; |
3485 | 28 | typedef FloatImpl<float> Float; | 40 | typedef FloatImpl<float> Float; |
3486 | 29 | 41 | ||
3487 | === modified file 'test/rbkt/Queries/CMakeLists.txt' | |||
3488 | --- test/rbkt/Queries/CMakeLists.txt 2012-02-22 02:41:05 +0000 | |||
3489 | +++ test/rbkt/Queries/CMakeLists.txt 2012-02-28 18:23:19 +0000 | |||
3490 | @@ -235,15 +235,7 @@ | |||
3491 | 235 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) | 235 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) |
3492 | 236 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732) | 236 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732) |
3493 | 237 | 237 | ||
3503 | 238 | IF(NOT ZORBA_WITH_BIG_INTEGER) | 238 | IF (ZORBA_TEST_XQUERYX) |
3495 | 239 | # These tests fail due to integer overflow. | ||
3496 | 240 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 3323548) | ||
3497 | 241 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 3323548) | ||
3498 | 242 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 3323548) | ||
3499 | 243 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 3323548) | ||
3500 | 244 | ENDIF(NOT ZORBA_WITH_BIG_INTEGER) | ||
3501 | 245 | |||
3502 | 246 | IF(ZORBA_TEST_XQUERYX) | ||
3504 | 247 | 239 | ||
3505 | 248 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQueryX/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) | 240 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQueryX/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) |
3506 | 249 | 241 | ||
3507 | @@ -263,12 +255,22 @@ | |||
3508 | 263 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019) | 255 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019) |
3509 | 264 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019) | 256 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019) |
3510 | 265 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019) | 257 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019) |
3513 | 266 | ENDIF(ZORBA_TEST_XQUERYX) | 258 | ENDIF (ZORBA_TEST_XQUERYX) |
3514 | 267 | 259 | ||
3515 | 268 | #this is marked as expected failure because the RQ uses XQTS_1_0_3. In that version the expected result is err:FODC0004 instead of err:FODC0002. | 260 | #this is marked as expected failure because the RQ uses XQTS_1_0_3. In that version the expected result is err:FODC0004 instead of err:FODC0002. |
3516 | 269 | #W3C has changed the expected result for this test in the meantime: please see http://www.w3.org/Bugs/Public/show_bug.cgi?id=12542 | 261 | #W3C has changed the expected result for this test in the meantime: please see http://www.w3.org/Bugs/Public/show_bug.cgi?id=12542 |
3517 | 270 | #EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002) | 262 | #EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002) |
3518 | 271 | 263 | ||
3519 | 264 | IF (NOT ZORBA_WITH_BIG_INTEGER) | ||
3520 | 265 | # These test will never pass without big integers beause the integers used | ||
3521 | 266 | # in the queries exceed a 63-bit signed integer. | ||
3522 | 267 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 867059) | ||
3523 | 268 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 867059) | ||
3524 | 269 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 867059) | ||
3525 | 270 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 867059) | ||
3526 | 271 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 867059) | ||
3527 | 272 | ENDIF (NOT ZORBA_WITH_BIG_INTEGER) | ||
3528 | 273 | |||
3529 | 272 | ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS) | 274 | ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS) |
3530 | 273 | 275 | ||
3531 | 274 | 276 | ||
3532 | 275 | 277 | ||
3533 | === modified file 'test/rbkt/Queries/w3c_known_failures.txt' | |||
3534 | --- test/rbkt/Queries/w3c_known_failures.txt 2012-02-02 09:56:52 +0000 | |||
3535 | +++ test/rbkt/Queries/w3c_known_failures.txt 2012-02-28 18:23:19 +0000 | |||
3536 | @@ -77,4 +77,14 @@ | |||
3537 | 77 | test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch10 | 77 | test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch10 |
3538 | 78 | test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch11 | 78 | test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch11 |
3539 | 79 | test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-22 | 79 | test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-22 |
3541 | 80 | 80 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-02 | |
3542 | 81 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-WhereExpr001 | ||
3543 | 82 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/statictyping-24 | ||
3544 | 83 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01 | ||
3545 | 84 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001 | ||
3546 | 85 | test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context | ||
3547 | 86 | test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 | ||
3548 | 87 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 | ||
3549 | 88 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 | ||
3550 | 89 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 | ||
3551 | 90 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug-867059- 2011-10- 31T23-16- 07.098Z/ log.html
Log at: http://