Merge lp:~zorba-coders/zorba/bug-867059 into lp:zorba

Proposed by Paul J. Lucas
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
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_BIG_INTEGER=OFF: now limited to 63 bits (for a 64-bit implementation of a long long). Also added build_options.dox.

Description of the change

Better implementation of ZORBA_WITH_BIG_INTEGER=OFF: now limited to 63 bits (for a 64-bit implementation of a long long). Also added build_options.dox.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
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/zo/testing/zorbatest/tester/TarmacLander.cmake:272 (message):
  Validation queue job bug-867059-2011-10-31T23-16-07.098Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
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/Queries/CMakeLists.txt

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-867059-2011-11-29T00-45-15.245Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 3 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

The change log should mention that the corresponding bug is fixed with this change.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

> The change log should mention that the corresponding bug is fixed with this
> change.

It does now.

lp:~zorba-coders/zorba/bug-867059 updated
10515. By Paul J. Lucas

Merge from trunk.

10516. By Paul J. Lucas

Merge from trunk.

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-867059-2012-02-29T16-42-56.599Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-02-27 15:17:53 +0000
+++ ChangeLog 2012-02-28 18:23:19 +0000
@@ -11,6 +11,7 @@
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.
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.
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)
14 * Fixed bug 867509 (Can not handle largest xs:unsignedLong values)
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)
15 * Optimization: change the implementation of the free-vars annotation and got rid16 * Optimization: change the implementation of the free-vars annotation and got rid
16 of the annotations map in expressions.17 of the annotations map in expressions.
1718
=== modified file 'doc/zorba/build.dox'
--- doc/zorba/build.dox 2012-01-26 10:08:12 +0000
+++ doc/zorba/build.dox 2012-02-28 18:23:19 +0000
@@ -116,7 +116,8 @@
116 To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel),116 To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel),
117 you can pass an additional parameter to CMake, e.g.,117 you can pass an additional parameter to CMake, e.g.,
118 <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>.118 <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>.
119- Zorba has other options as well.119- Zorba has other build options as well
120 (see \ref build_options).
120 You can tweak the performance and library footprint121 You can tweak the performance and library footprint
121 by enabling or disabling various features from Zorba.122 by enabling or disabling various features from Zorba.
122123
123124
=== added file 'doc/zorba/build_options.dox'
--- doc/zorba/build_options.dox 1970-01-01 00:00:00 +0000
+++ doc/zorba/build_options.dox 2012-02-28 18:23:19 +0000
@@ -0,0 +1,35 @@
1/** \page build_options Zorba Build Options
2
3\section ZORBA_WITH_BIG_INTEGER Big Integer Support (ZORBA_WITH_BIG_INTEGER)
4
5The Zorba XQuery processor
6by default
7has arbitrary precision
8for the \c xs:integer type.
9Compared to a C++ \c int,
10however,
11arbitrary precision integers
12are orders of magnitude slower.
13If arbitrary precision integers are not needed,
14they can be disabled
15by configuring Zorba
16with the
17\c ZORBA_WITH_BIG_INTEGER
18option set to \c OFF.
19
20When arbitrary precision integers are disabled,
21Zorba uses a C++ <code>long long</code>
22for \c xs:integer,
23the precision for which
24is dependent on your C++ implementation.
25Typically, however,
26the precision is at least 64 bits.
27However,
28in order to maintain the condition
29that the value space for \c xs:nonNegativeInteger
30is a subset of that of \c xs:integer,
31one less bit is allowed
32for \c xs:nonNegativeInteger.
33
34*/
35/* vim:set et sw=2 ts=2: */
036
=== modified file 'src/api/itemfactoryimpl.cpp'
--- src/api/itemfactoryimpl.cpp 2012-02-22 01:31:08 +0000
+++ src/api/itemfactoryimpl.cpp 2012-02-28 18:23:19 +0000
@@ -288,7 +288,7 @@
288ItemFactoryImpl::createInteger(long long aInteger)288ItemFactoryImpl::createInteger(long long aInteger)
289{289{
290 store::Item_t lItem;290 store::Item_t lItem;
291 Integer const lInteger(aInteger);291 xs_integer const lInteger(aInteger);
292 theItemFactory->createInteger(lItem, lInteger);292 theItemFactory->createInteger(lItem, lInteger);
293 return &*lItem;293 return &*lItem;
294}294}
@@ -300,7 +300,7 @@
300 zstring const &lString = Unmarshaller::getInternalString( aInteger );300 zstring const &lString = Unmarshaller::getInternalString( aInteger );
301 store::Item_t lItem;301 store::Item_t lItem;
302 try {302 try {
303 Integer const lInteger( lString.c_str() );303 xs_integer const lInteger( lString.c_str() );
304 theItemFactory->createInteger(lItem, lInteger);304 theItemFactory->createInteger(lItem, lInteger);
305 }305 }
306 catch ( std::exception const& ) {306 catch ( std::exception const& ) {
@@ -497,7 +497,7 @@
497{497{
498 store::Item_t lItem;498 store::Item_t lItem;
499 if (aValue < 0) {499 if (aValue < 0) {
500 Integer const lInteger(aValue);500 xs_integer const lInteger(aValue);
501 theItemFactory->createNegativeInteger(lItem, lInteger);501 theItemFactory->createNegativeInteger(lItem, lInteger);
502 }502 }
503 return &*lItem;503 return &*lItem;
@@ -507,7 +507,7 @@
507Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue )507Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue )
508{508{
509 store::Item_t lItem;509 store::Item_t lItem;
510 Integer lInteger(aValue);510 xs_nonNegativeInteger lInteger(aValue);
511 theItemFactory->createNonNegativeInteger(lItem, lInteger);511 theItemFactory->createNonNegativeInteger(lItem, lInteger);
512 return &*lItem;512 return &*lItem;
513}513}
@@ -517,7 +517,7 @@
517{517{
518 store::Item_t lItem;518 store::Item_t lItem;
519 if (aValue < 0) {519 if (aValue < 0) {
520 Integer const lInteger(aValue);520 xs_integer const lInteger(aValue);
521 theItemFactory->createNonPositiveInteger(lItem, lInteger);521 theItemFactory->createNonPositiveInteger(lItem, lInteger);
522 }522 }
523 return &*lItem;523 return &*lItem;
@@ -527,7 +527,7 @@
527Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue )527Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue )
528{528{
529 store::Item_t lItem;529 store::Item_t lItem;
530 Integer lInteger(aValue);530 xs_nonNegativeInteger lInteger(aValue);
531 theItemFactory->createPositiveInteger(lItem, lInteger);531 theItemFactory->createPositiveInteger(lItem, lInteger);
532 return &*lItem;532 return &*lItem;
533}533}
534534
=== modified file 'src/common/shared_types.h'
--- src/common/shared_types.h 2011-09-12 22:42:28 +0000
+++ src/common/shared_types.h 2012-02-28 18:23:19 +0000
@@ -140,12 +140,18 @@
140typedef rchandle<GMonth> GMonth_t;140typedef rchandle<GMonth> GMonth_t;
141141
142/* numerics */142/* numerics */
143template <class Object> class FloatImpl;143template<typename FloatType> class FloatImpl;
144class Integer;
145
146/* numerics */
147typedef FloatImpl<double> Double;144typedef FloatImpl<double> Double;
148typedef FloatImpl<float> Float;145typedef FloatImpl<float> Float;
146#ifdef ZORBA_WITH_BIG_INTEGER
147class IntegerImpl;
148typedef IntegerImpl Integer;
149typedef IntegerImpl UInteger;
150#else
151template<typename IntType> class IntegerImpl;
152typedef IntegerImpl<long long> Integer;
153typedef IntegerImpl<unsigned long long> UInteger;
154#endif /* ZORBA_WITH_BIG_INTEGER */
149155
150/* api */156/* api */
151class serializer;157class serializer;
152158
=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-16 12:48:17 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-02-28 18:23:19 +0000
@@ -953,7 +953,7 @@
953 (a) op is eq or =, and953 (a) op is eq or =, and
954 (b1) posExpr is an integer literal with value >= 1, or954 (b1) posExpr is an integer literal with value >= 1, or
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
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
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
958 for var.958 for var.
959959
960960
=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
--- src/compiler/rewriter/rules/fold_rules.cpp 2012-02-16 12:48:17 +0000
+++ src/compiler/rewriter/rules/fold_rules.cpp 2012-02-28 18:23:19 +0000
@@ -753,7 +753,7 @@
753 {753 {
754 return new const_expr(fo->get_sctx(),754 return new const_expr(fo->get_sctx(),
755 fo->get_loc(),755 fo->get_loc(),
756 Integer(type_cnt));756 xs_integer(type_cnt));
757 }757 }
758 else if (fkind == FunctionConsts::FN_EMPTY_1)758 else if (fkind == FunctionConsts::FN_EMPTY_1)
759 {759 {
760760
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-02-19 19:43:28 +0000
+++ src/compiler/translator/translator.cpp 2012-02-28 18:23:19 +0000
@@ -9738,8 +9738,8 @@
9738 {9738 {
9739 case FunctionConsts::FN_HEAD_1:9739 case FunctionConsts::FN_HEAD_1:
9740 {9740 {
9741 arguments.push_back(new const_expr(theRootSctx, loc, Integer(1)));9741 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1)));
9742 arguments.push_back(new const_expr(theRootSctx, loc, Integer(1)));9742 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1)));
9743 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);9743 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);
9744 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);9744 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);
9745 normalize_fo(foExpr);9745 normalize_fo(foExpr);
@@ -9748,7 +9748,7 @@
9748 }9748 }
9749 case FunctionConsts::FN_TAIL_1:9749 case FunctionConsts::FN_TAIL_1:
9750 {9750 {
9751 arguments.push_back(new const_expr(theRootSctx, loc, Integer(2)));9751 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(2)));
9752 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);9752 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);
9753 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);9753 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);
9754 normalize_fo(foExpr);9754 normalize_fo(foExpr);
97559755
=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp 2012-01-26 19:56:14 +0000
+++ src/runtime/booleans/BooleanImpl.cpp 2012-02-28 18:23:19 +0000
@@ -845,7 +845,7 @@
845 {845 {
846 // There are 2 cases when two types are comparable without one being a846 // There are 2 cases when two types are comparable without one being a
847 // subtype of the other: (a) they belong to different branches under of847 // subtype of the other: (a) they belong to different branches under of
848 // the type-inheritance subtree rooted at xs:Integer, (b) they belong to848 // the type-inheritance subtree rooted at xs:integer, (b) they belong to
849 // different branches under of the type-inheritance subtree rooted at849 // different branches under of the type-inheritance subtree rooted at
850 // xs::duration (i.e. one is xs:yearMonthDuration and the other is850 // xs::duration (i.e. one is xs:yearMonthDuration and the other is
851 // xs:dayTimeDuration).851 // xs:dayTimeDuration).
@@ -935,7 +935,7 @@
935 {935 {
936 // There is 1 case when two types are order-comparable without one being a936 // There is 1 case when two types are order-comparable without one being a
937 // subtype of the other: they belong to different branches under of the937 // subtype of the other: they belong to different branches under of the
938 // type-inheritance subtree rooted at xs:Integer.938 // type-inheritance subtree rooted at xs:integer.
939 if (TypeOps::is_subtype(type0, store::XS_INTEGER) &&939 if (TypeOps::is_subtype(type0, store::XS_INTEGER) &&
940 TypeOps::is_subtype(type1, store::XS_INTEGER))940 TypeOps::is_subtype(type1, store::XS_INTEGER))
941 {941 {
942942
=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp 2012-02-27 14:46:27 +0000
+++ src/runtime/core/flwor_iterator.cpp 2012-02-28 18:23:19 +0000
@@ -1216,7 +1216,7 @@
1216 if (!flc.thePosVarRefs.empty())1216 if (!flc.thePosVarRefs.empty())
1217 {1217 {
1218 store::Item_t posItem;1218 store::Item_t posItem;
1219 GENV_ITEMFACTORY->createInteger(posItem, Integer(bindingState));1219 GENV_ITEMFACTORY->createInteger(posItem, xs_integer(bindingState));
12201220
1221 std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin();1221 std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin();
1222 std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end();1222 std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end();
12231223
=== modified file 'src/runtime/core/gflwor/count_iterator.cpp'
--- src/runtime/core/gflwor/count_iterator.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/core/gflwor/count_iterator.cpp 2012-02-28 18:23:19 +0000
@@ -91,7 +91,7 @@
91 {91 {
92 {92 {
93 store::Item_t lCountItem;93 store::Item_t lCountItem;
94 GENV_ITEMFACTORY->createInteger(lCountItem, Integer(lState->incCount()));94 GENV_ITEMFACTORY->createInteger(lCountItem, xs_integer(lState->incCount()));
95 bindVariables(lCountItem, theCountVars, aPlanState);95 bindVariables(lCountItem, theCountVars, aPlanState);
96 }96 }
97 STACK_PUSH(true, lState);97 STACK_PUSH(true, lState);
9898
=== modified file 'src/runtime/core/gflwor/for_iterator.cpp'
--- src/runtime/core/gflwor/for_iterator.cpp 2011-06-22 14:42:38 +0000
+++ src/runtime/core/gflwor/for_iterator.cpp 2012-02-28 18:23:19 +0000
@@ -126,7 +126,7 @@
126 {126 {
127 store::Item_t lPosItem;127 store::Item_t lPosItem;
128 GENV_ITEMFACTORY->createInteger(lPosItem,128 GENV_ITEMFACTORY->createInteger(lPosItem,
129 Integer(lState->incReturnPosition()));129 xs_integer(lState->incReturnPosition()));
130 bindVariables(lPosItem, thePosVarRefs, aPlanState);130 bindVariables(lPosItem, thePosVarRefs, aPlanState);
131 }131 }
132 STACK_PUSH(true, lState);132 STACK_PUSH(true, lState);
133133
=== modified file 'src/runtime/numerics/NumericsImpl.cpp'
--- src/runtime/numerics/NumericsImpl.cpp 2012-01-30 16:59:01 +0000
+++ src/runtime/numerics/NumericsImpl.cpp 2012-02-28 18:23:19 +0000
@@ -442,10 +442,11 @@
442 xs_integer ll0 = i0->getIntegerValue();442 xs_integer ll0 = i0->getIntegerValue();
443 xs_integer ll1 = i1->getIntegerValue();443 xs_integer ll1 = i1->getIntegerValue();
444444
445 if ( ll1 == Integer::zero() )445 if ( ll1.sign() == 0 )
446 {446 {
447 throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) );447 throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) );
448 }448 }
449
449 return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1);450 return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1);
450}451}
451452
452453
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2012-02-22 04:03:16 +0000
+++ src/store/api/item.h 2012-02-28 18:23:19 +0000
@@ -311,7 +311,7 @@
311311
312 /** Accessor for xs:nonNegativeInteager, xs:positiveInteger312 /** Accessor for xs:nonNegativeInteager, xs:positiveInteger
313 */313 */
314 virtual xs_uinteger314 virtual xs_nonNegativeInteger
315 getUnsignedIntegerValue() const;315 getUnsignedIntegerValue() const;
316316
317 /** Accessor for xs:long317 /** Accessor for xs:long
318318
=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h 2012-02-22 01:31:08 +0000
+++ src/store/api/item_factory.h 2012-02-28 18:23:19 +0000
@@ -261,13 +261,13 @@
261 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]261 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
262 * @param value262 * @param value
263 */263 */
264 virtual bool createNonNegativeInteger(Item_t& result, const xs_uinteger& value) = 0;264 virtual bool createNonNegativeInteger(Item_t& result, const xs_nonNegativeInteger& value) = 0;
265265
266 /**266 /**
267 * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger]267 * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
268 * @param value268 * @param value
269 */269 */
270 virtual bool createPositiveInteger(Item_t& result, const xs_uinteger& value) = 0;270 virtual bool createPositiveInteger(Item_t& result, const xs_positiveInteger& value) = 0;
271271
272 /**272 /**
273 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]273 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
274274
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2012-02-24 03:57:49 +0000
+++ src/store/naive/atomic_items.cpp 2012-02-28 18:23:19 +0000
@@ -137,7 +137,7 @@
137 const IntegerItem* item = static_cast<const IntegerItem*>(item1);137 const IntegerItem* item = static_cast<const IntegerItem*>(item1);
138 try138 try
139 {139 {
140 longValue = to_xs_long(item->theValue);140 longValue = item->getLongValue();
141 GET_FACTORY().createLong(result, longValue);141 GET_FACTORY().createLong(result, longValue);
142 }142 }
143 catch (std::range_error const&)143 catch (std::range_error const&)
@@ -207,11 +207,11 @@
207 {207 {
208 const IntegerItem* item = static_cast<const IntegerItem*>(item1);208 const IntegerItem* item = static_cast<const IntegerItem*>(item1);
209209
210 doubleValue = item->theValue;210 doubleValue = item->getIntegerValue();
211211
212 const xs_integer intValue(doubleValue);212 const xs_integer intValue(doubleValue);
213213
214 lossy = (intValue != item->theValue);214 lossy = (intValue != item->getIntegerValue());
215 break;215 break;
216 }216 }
217217
@@ -2350,10 +2350,11 @@
23502350
23512351
2352/*******************************************************************************2352/*******************************************************************************
2353 class IntegerItem2353 class IntegerItemImpl
2354********************************************************************************/2354********************************************************************************/
23552355
2356long IntegerItem::compare( Item const *other, long, const XQPCollator* ) const {2356long IntegerItemImpl::compare( Item const *other, long,
2357 const XQPCollator* ) const {
2357 try2358 try
2358 {2359 {
2359 return theValue.compare( other->getIntegerValue() );2360 return theValue.compare( other->getIntegerValue() );
@@ -2364,8 +2365,8 @@
2364 }2365 }
2365}2366}
23662367
2367bool IntegerItem::equals( const store::Item* other, long,2368bool IntegerItemImpl::equals( const store::Item* other, long,
2368 const XQPCollator*) const2369 const XQPCollator*) const
2369{2370{
2370 try2371 try
2371 {2372 {
@@ -2377,13 +2378,13 @@
2377 }2378 }
2378}2379}
23792380
2380xs_decimal IntegerItem::getDecimalValue() const2381xs_decimal IntegerItemImpl::getDecimalValue() const
2381{2382{
2382 return xs_decimal(theValue);2383 return xs_decimal(theValue);
2383}2384}
23842385
23852386
2386xs_long IntegerItem::getLongValue() const2387xs_long IntegerItemImpl::getLongValue() const
2387{2388{
2388 try2389 try
2389 {2390 {
@@ -2397,41 +2398,42 @@
2397}2398}
23982399
23992400
2400store::Item* IntegerItem::getType() const2401store::Item* IntegerItemImpl::getType() const
2401{2402{
2402 return GET_STORE().theSchemaTypeNames[store::XS_INTEGER];2403 return GET_STORE().theSchemaTypeNames[store::XS_INTEGER];
2403}2404}
24042405
24052406
2406bool IntegerItem::getEBV() const2407bool IntegerItemImpl::getEBV() const
2407{2408{
2408 return ( theValue != xs_integer::zero() );2409 return !!theValue.sign();
2409}2410}
24102411
24112412
2412zstring IntegerItem::getStringValue() const2413zstring IntegerItemImpl::getStringValue() const
2413{2414{
2414 return theValue.toString();2415 return theValue.toString();
2415}2416}
24162417
24172418
2418void IntegerItem::getStringValue2(zstring& val) const2419void IntegerItemImpl::getStringValue2(zstring& val) const
2419{2420{
2420 val = theValue.toString();2421 val = theValue.toString();
2421}2422}
24222423
2423uint32_t IntegerItem::hash(long, const XQPCollator*) const2424uint32_t IntegerItemImpl::hash(long, const XQPCollator*) const
2424{2425{
2425 return theValue.hash();2426 return theValue.hash();
2426}2427}
24272428
2428void IntegerItem::appendStringValue(zstring& buf) const2429
2430void IntegerItemImpl::appendStringValue(zstring& buf) const
2429{2431{
2430 buf += theValue.toString();2432 buf += theValue.toString();
2431}2433}
24322434
24332435
2434zstring IntegerItem::show() const2436zstring IntegerItemImpl::show() const
2435{2437{
2436 zstring res("xs:integer(");2438 zstring res("xs:integer(");
2437 appendStringValue(res);2439 appendStringValue(res);
@@ -2443,11 +2445,88 @@
2443/*******************************************************************************2445/*******************************************************************************
2444 class NonPositiveIntegerItem2446 class NonPositiveIntegerItem
2445********************************************************************************/2447********************************************************************************/
2448long NonPositiveIntegerItem::compare( Item const *other, long,
2449 const XQPCollator* ) const {
2450 try
2451 {
2452 return theValue.compare( other->getIntegerValue() );
2453 }
2454 catch ( ZorbaException const& )
2455 {
2456 return getDecimalValue().compare( other->getDecimalValue() );
2457 }
2458}
2459
2460bool NonPositiveIntegerItem::equals( const store::Item* other, long,
2461 const XQPCollator* ) const
2462{
2463 try
2464 {
2465 return theValue == other->getIntegerValue();
2466 }
2467 catch (ZorbaException const&)
2468 {
2469 return getDecimalValue() == other->getDecimalValue();
2470 }
2471}
2472
2446store::Item* NonPositiveIntegerItem::getType() const2473store::Item* NonPositiveIntegerItem::getType() const
2447{2474{
2448 return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER];2475 return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER];
2449}2476}
24502477
2478xs_decimal NonPositiveIntegerItem::getDecimalValue() const
2479{
2480 return xs_decimal(theValue);
2481}
2482
2483xs_integer NonPositiveIntegerItem::getIntegerValue() const
2484{
2485 return xs_integer(theValue);
2486}
2487
2488xs_long NonPositiveIntegerItem::getLongValue() const
2489{
2490 try
2491 {
2492 return to_xs_long(theValue);
2493 }
2494 catch ( std::range_error const& )
2495 {
2496 throw XQUERY_EXCEPTION(
2497 err::FORG0001,
2498 ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
2499 );
2500 }
2501}
2502
2503zstring NonPositiveIntegerItem::getStringValue() const
2504{
2505 return theValue.toString();
2506}
2507
2508
2509void NonPositiveIntegerItem::getStringValue2(zstring& val) const
2510{
2511 val = theValue.toString();
2512}
2513
2514uint32_t NonPositiveIntegerItem::hash(long, const XQPCollator*) const
2515{
2516 return theValue.hash();
2517}
2518
2519
2520void NonPositiveIntegerItem::appendStringValue(zstring& buf) const
2521{
2522 buf += theValue.toString();
2523}
2524
2525bool NonPositiveIntegerItem::getEBV() const
2526{
2527 return !!theValue.sign();
2528}
2529
2451zstring NonPositiveIntegerItem::show() const2530zstring NonPositiveIntegerItem::show() const
2452{2531{
2453 zstring res("xs:nonPositiveInteger(");2532 zstring res("xs:nonPositiveInteger(");
@@ -2476,14 +2555,91 @@
24762555
24772556
2478/*******************************************************************************2557/*******************************************************************************
2479 class NonNegativeINtegerItem2558 class NonNegativeIntegerItem
2480********************************************************************************/2559********************************************************************************/
2560long NonNegativeIntegerItem::compare( Item const *other, long,
2561 const XQPCollator* ) const {
2562 try
2563 {
2564 return theValue.compare( other->getUnsignedIntegerValue() );
2565 }
2566 catch ( ZorbaException const& )
2567 {
2568 return getDecimalValue().compare( other->getDecimalValue() );
2569 }
2570}
2571
2572bool NonNegativeIntegerItem::equals( const store::Item* other, long,
2573 const XQPCollator* ) const
2574{
2575 try
2576 {
2577 return theValue == other->getUnsignedIntegerValue();
2578 }
2579 catch (ZorbaException const&)
2580 {
2581 return getDecimalValue() == other->getDecimalValue();
2582 }
2583}
2584
2481store::Item* NonNegativeIntegerItem::getType() const2585store::Item* NonNegativeIntegerItem::getType() const
2482{2586{
2483 return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER];2587 return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER];
2484}2588}
24852589
24862590
2591xs_decimal NonNegativeIntegerItem::getDecimalValue() const
2592{
2593 return xs_decimal(theValue);
2594}
2595
2596xs_integer NonNegativeIntegerItem::getIntegerValue() const
2597{
2598 return xs_integer(theValue);
2599}
2600
2601xs_long NonNegativeIntegerItem::getLongValue() const
2602{
2603 try
2604 {
2605 return to_xs_long(theValue);
2606 }
2607 catch ( std::range_error const& )
2608 {
2609 throw XQUERY_EXCEPTION(
2610 err::FORG0001,
2611 ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
2612 );
2613 }
2614}
2615
2616zstring NonNegativeIntegerItem::getStringValue() const
2617{
2618 return theValue.toString();
2619}
2620
2621
2622void NonNegativeIntegerItem::getStringValue2(zstring& val) const
2623{
2624 val = theValue.toString();
2625}
2626
2627uint32_t NonNegativeIntegerItem::hash(long, const XQPCollator*) const
2628{
2629 return theValue.hash();
2630}
2631
2632
2633void NonNegativeIntegerItem::appendStringValue(zstring& buf) const
2634{
2635 buf += theValue.toString();
2636}
2637
2638bool NonNegativeIntegerItem::getEBV() const
2639{
2640 return !!theValue.sign();
2641}
2642
2487zstring NonNegativeIntegerItem::show() const2643zstring NonNegativeIntegerItem::show() const
2488{2644{
2489 zstring res("xs:nonNegativeInteger(");2645 zstring res("xs:nonNegativeInteger(");
@@ -2525,6 +2681,9 @@
2525 return xs_integer(theValue);2681 return xs_integer(theValue);
2526}2682}
25272683
2684xs_nonNegativeInteger LongItem::getUnsignedIntegerValue() const {
2685 return theValue >= 0 ? theValue : -theValue;
2686}
25282687
2529store::Item* LongItem::getType() const2688store::Item* LongItem::getType() const
2530{2689{
@@ -2758,9 +2917,9 @@
2758}2917}
27592918
27602919
2761xs_uinteger UnsignedLongItem::getUnsignedIntegerValue() const2920xs_nonNegativeInteger UnsignedLongItem::getUnsignedIntegerValue() const
2762{2921{
2763 return xs_uinteger(theValue);2922 return xs_nonNegativeInteger(theValue);
2764}2923}
27652924
27662925
@@ -2822,9 +2981,9 @@
2822}2981}
28232982
28242983
2825xs_uinteger UnsignedIntItem::getUnsignedIntegerValue() const2984xs_nonNegativeInteger UnsignedIntItem::getUnsignedIntegerValue() const
2826{2985{
2827 return Integer(theValue);2986 return xs_nonNegativeInteger(theValue);
2828}2987}
28292988
28302989
@@ -2886,9 +3045,9 @@
2886}3045}
28873046
28883047
2889xs_uinteger UnsignedShortItem::getUnsignedIntegerValue() const3048xs_nonNegativeInteger UnsignedShortItem::getUnsignedIntegerValue() const
2890{3049{
2891 return Integer(theValue);3050 return xs_nonNegativeInteger(theValue);
2892}3051}
28933052
28943053
@@ -2946,13 +3105,13 @@
29463105
2947xs_integer UnsignedByteItem::getIntegerValue() const3106xs_integer UnsignedByteItem::getIntegerValue() const
2948{3107{
2949 return Integer((uint32_t)theValue);3108 return xs_integer((uint32_t)theValue);
2950}3109}
29513110
29523111
2953xs_uinteger UnsignedByteItem::getUnsignedIntegerValue() const3112xs_nonNegativeInteger UnsignedByteItem::getUnsignedIntegerValue() const
2954{3113{
2955 return Integer(theValue);3114 return xs_nonNegativeInteger(theValue);
2956}3115}
29573116
29583117
29593118
=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h 2012-02-24 16:47:43 +0000
+++ src/store/naive/atomic_items.h 2012-02-28 18:23:19 +0000
@@ -171,7 +171,7 @@
171171
172 xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); }172 xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); }
173173
174 xs_uinteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); }174 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); }
175175
176 xs_long getLongValue() const { return theBaseItem->getLongValue(); }176 xs_long getLongValue() const { return theBaseItem->getLongValue(); }
177177
@@ -1182,7 +1182,7 @@
1182 return theValue.compare(other->getDoubleValue());1182 return theValue.compare(other->getDoubleValue());
1183 }1183 }
11841184
1185 bool getEBV( ) const;1185 bool getEBV() const;
11861186
1187 zstring getStringValue() const;1187 zstring getStringValue() const;
11881188
@@ -1339,6 +1339,31 @@
1339********************************************************************************/1339********************************************************************************/
1340class IntegerItem : public AtomicItem1340class IntegerItem : public AtomicItem
1341{1341{
1342protected:
1343 IntegerItem() {}
1344
1345public:
1346 virtual xs_decimal getDecimalValue() const = 0;
1347 virtual xs_integer getIntegerValue() const = 0;
1348 virtual xs_long getLongValue() const = 0;
1349
1350 virtual bool getEBV() const = 0;
1351 virtual store::Item* getType() const = 0;
1352
1353 virtual zstring getStringValue() const = 0;
1354 virtual void getStringValue2(zstring&) const = 0;
1355 virtual void appendStringValue(zstring& buf) const = 0;
1356
1357 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const = 0;
1358 bool isNaN() const { return false; }
1359};
1360
1361
1362/*******************************************************************************
1363 class IntegerItemImpl
1364********************************************************************************/
1365class IntegerItemImpl : public IntegerItem
1366{
1342 friend class BasicItemFactory;1367 friend class BasicItemFactory;
1343 friend class AtomicItem;1368 friend class AtomicItem;
13441369
@@ -1346,40 +1371,37 @@
1346 xs_integer theValue;1371 xs_integer theValue;
13471372
1348protected:1373protected:
1349 IntegerItem(const xs_integer& aValue) : theValue ( aValue ) {}1374 IntegerItemImpl(const xs_integer& aValue) : theValue ( aValue ) {}
13501375
1351 IntegerItem() {}1376 IntegerItemImpl() {}
13521377
1353public:1378public:
1354 xs_decimal getDecimalValue() const;1379 xs_decimal getDecimalValue() const;
1355
1356 xs_integer getIntegerValue() const { return theValue; }1380 xs_integer getIntegerValue() const { return theValue; }
13571381
1358 xs_long getLongValue() const;1382 xs_long getLongValue() const;
1383 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
1384
1385 zstring getStringValue() const;
1386 void getStringValue2(zstring&) const;
1387 void appendStringValue(zstring&) const;
13591388
1360 virtual store::SchemaTypeCode getTypeCode() const { return store::XS_INTEGER; }1389 virtual store::SchemaTypeCode getTypeCode() const { return store::XS_INTEGER; }
13611390
1362 virtual store::Item* getType() const;1391 virtual store::Item* getType() const;
1363
1364 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;1392 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
13651393
1394 long compare(
1395 const Item* other,
1396 long timezone = 0,
1397 const XQPCollator* aCollation = 0) const;
1398
1366 bool equals(1399 bool equals(
1367 const store::Item* other,1400 const store::Item* other,
1368 long timezone = 0,1401 long timezone = 0,
1369 const XQPCollator* aCollation = 0) const;1402 const XQPCollator* aCollation = 0) const;
13701403
1371 long compare(1404 bool getEBV() const;
1372 const Item* other,
1373 long timezone = 0,
1374 const XQPCollator* aCollation = 0) const;
1375
1376 bool getEBV( ) const;
1377
1378 zstring getStringValue() const;
1379
1380 void getStringValue2(zstring& val) const;
1381
1382 void appendStringValue(zstring& buf) const;
13831405
1384 bool isNaN() const { return false; }1406 bool isNaN() const { return false; }
13851407
@@ -1395,28 +1417,53 @@
1395 friend class BasicItemFactory;1417 friend class BasicItemFactory;
13961418
1397protected:1419protected:
1398 NonPositiveIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {}1420 xs_nonPositiveInteger theValue;
1421
1422 NonPositiveIntegerItem(const xs_integer& aValue) : theValue(aValue) {}
13991423
1400 NonPositiveIntegerItem() {}1424 NonPositiveIntegerItem() {}
14011425
1402public:1426public:
1427 // inherited
1428 xs_decimal getDecimalValue() const;
1429 xs_integer getIntegerValue() const;
1430 xs_long getLongValue() const;
1431 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
1432
1433 zstring getStringValue() const;
1434 void getStringValue2(zstring& val) const;
1435 void appendStringValue(zstring&) const;
1436
1437 bool getEBV() const;
1438
1403 store::SchemaTypeCode getTypeCode() const { return store::XS_NON_POSITIVE_INTEGER; }1439 store::SchemaTypeCode getTypeCode() const { return store::XS_NON_POSITIVE_INTEGER; }
14041440
1405 store::Item* getType() const;1441 store::Item* getType() const;
1442 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
14061443
1407 zstring show() const;1444 zstring show() const;
1445
1446 long compare(
1447 const Item* other,
1448 long timezone = 0,
1449 const XQPCollator* aCollation = 0) const;
1450
1451 bool equals(
1452 const store::Item* other,
1453 long timezone = 0,
1454 const XQPCollator* aCollation = 0) const;
1408};1455};
14091456
14101457
1411/*******************************************************************************1458/*******************************************************************************
1412 class NegativeIntegerItem1459 class NegativeIntegerItem
1413********************************************************************************/1460********************************************************************************/
1414class NegativeIntegerItem : public IntegerItem1461class NegativeIntegerItem : public NonPositiveIntegerItem
1415{1462{
1416 friend class BasicItemFactory;1463 friend class BasicItemFactory;
14171464
1418protected:1465protected:
1419 NegativeIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {}1466 NegativeIntegerItem(const xs_integer& aValue) : NonPositiveIntegerItem(aValue) {}
14201467
1421 NegativeIntegerItem() {}1468 NegativeIntegerItem() {}
14221469
@@ -1431,38 +1478,61 @@
14311478
1432/*******************************************************************************1479/*******************************************************************************
1433 class NonNegativeIntegerItem1480 class NonNegativeIntegerItem
1434
1435 Note: xs_uinteger is typedef of Integer
1436********************************************************************************/1481********************************************************************************/
1437class NonNegativeIntegerItem : public IntegerItem1482class NonNegativeIntegerItem : public IntegerItem
1438{1483{
1439 friend class BasicItemFactory;1484 friend class BasicItemFactory;
14401485
1441protected:1486protected:
1442 NonNegativeIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) {}1487 xs_nonNegativeInteger theValue;
1488
1489 NonNegativeIntegerItem(const xs_nonNegativeInteger& aValue) : theValue(aValue) {}
14431490
1444 NonNegativeIntegerItem() {}1491 NonNegativeIntegerItem() {}
14451492
1446public:1493public:
1447 xs_uinteger getUnsignedIntegerValue() const { return theValue; }1494 // inherited
1495 xs_decimal getDecimalValue() const;
1496 xs_integer getIntegerValue() const;
1497 xs_long getLongValue() const;
1498 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
1499
1500 bool getEBV() const;
14481501
1449 store::SchemaTypeCode getTypeCode() const { return store::XS_NON_NEGATIVE_INTEGER; }1502 store::SchemaTypeCode getTypeCode() const { return store::XS_NON_NEGATIVE_INTEGER; }
14501503
1504
1451 store::Item* getType() const;1505 store::Item* getType() const;
14521506
1507 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
1508
1453 zstring show() const;1509 zstring show() const;
1510
1511 zstring getStringValue() const;
1512 void getStringValue2(zstring& val) const;
1513 void appendStringValue(zstring&) const;
1514
1515 long compare(
1516 const Item* other,
1517 long timezone = 0,
1518 const XQPCollator* aCollation = 0) const;
1519
1520 bool equals(
1521 const store::Item* other,
1522 long timezone = 0,
1523 const XQPCollator* aCollation = 0) const;
1454};1524};
14551525
14561526
1457/*******************************************************************************1527/*******************************************************************************
1458 class PositiveIntegerItem1528 class PositiveIntegerItem
1459********************************************************************************/1529********************************************************************************/
1460class PositiveIntegerItem : public IntegerItem1530class PositiveIntegerItem : public NonNegativeIntegerItem
1461{1531{
1462 friend class BasicItemFactory;1532 friend class BasicItemFactory;
14631533
1464protected:1534protected:
1465 PositiveIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) { }1535 PositiveIntegerItem(const xs_positiveInteger& aValue) : NonNegativeIntegerItem(aValue) { }
14661536
1467 PositiveIntegerItem() {}1537 PositiveIntegerItem() {}
14681538
@@ -1500,6 +1570,8 @@
15001570
1501 xs_long getLongValue() const { return theValue; }1571 xs_long getLongValue() const { return theValue; }
15021572
1573 xs_nonNegativeInteger getUnsignedIntegerValue() const;
1574
1503 store::SchemaTypeCode getTypeCode() const { return store::XS_LONG; }1575 store::SchemaTypeCode getTypeCode() const { return store::XS_LONG; }
15041576
1505 store::Item* getType() const;1577 store::Item* getType() const;
@@ -1541,7 +1613,7 @@
1541 }1613 }
1542 }1614 }
15431615
1544 bool getEBV( ) const;1616 bool getEBV() const;
15451617
1546 zstring getStringValue() const;1618 zstring getStringValue() const;
15471619
@@ -1703,7 +1775,7 @@
1703 }1775 }
1704 }1776 }
17051777
1706 bool getEBV( ) const;1778 bool getEBV() const;
17071779
1708 zstring getStringValue() const;1780 zstring getStringValue() const;
17091781
@@ -1787,7 +1859,7 @@
1787 }1859 }
1788 }1860 }
17891861
1790 bool getEBV( ) const;1862 bool getEBV() const;
17911863
1792 zstring getStringValue() const;1864 zstring getStringValue() const;
17931865
@@ -1824,7 +1896,7 @@
18241896
1825 xs_integer getIntegerValue() const;1897 xs_integer getIntegerValue() const;
18261898
1827 xs_uinteger getUnsignedIntegerValue() const;1899 xs_nonNegativeInteger getUnsignedIntegerValue() const;
18281900
1829 xs_unsignedLong getUnsignedLongValue() const { return theValue; }1901 xs_unsignedLong getUnsignedLongValue() const { return theValue; }
18301902
@@ -1869,7 +1941,7 @@
1869 }1941 }
1870 }1942 }
18711943
1872 bool getEBV( ) const;1944 bool getEBV() const;
18731945
1874 zstring getStringValue() const;1946 zstring getStringValue() const;
18751947
@@ -1904,7 +1976,7 @@
19041976
1905 xs_integer getIntegerValue() const;1977 xs_integer getIntegerValue() const;
19061978
1907 xs_uinteger getUnsignedIntegerValue() const;1979 xs_nonNegativeInteger getUnsignedIntegerValue() const;
19081980
1909 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }1981 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
19101982
@@ -1960,7 +2032,7 @@
1960 }2032 }
1961 }2033 }
19622034
1963 bool getEBV( ) const;2035 bool getEBV() const;
19642036
1965 zstring getStringValue() const;2037 zstring getStringValue() const;
19662038
@@ -1993,7 +2065,7 @@
19932065
1994 xs_integer getIntegerValue() const;2066 xs_integer getIntegerValue() const;
19952067
1996 xs_uinteger getUnsignedIntegerValue() const;2068 xs_nonNegativeInteger getUnsignedIntegerValue() const;
19972069
1998 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }2070 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
19992071
@@ -2053,7 +2125,7 @@
2053 }2125 }
2054 }2126 }
20552127
2056 bool getEBV( ) const;2128 bool getEBV() const;
20572129
2058 zstring getStringValue() const;2130 zstring getStringValue() const;
20592131
@@ -2086,7 +2158,7 @@
20862158
2087 xs_integer getIntegerValue() const;2159 xs_integer getIntegerValue() const;
20882160
2089 xs_uinteger getUnsignedIntegerValue() const;2161 xs_nonNegativeInteger getUnsignedIntegerValue() const;
20902162
2091 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }2163 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
20922164
@@ -2202,7 +2274,7 @@
2202 (theValue == false ? -1 : 1));2274 (theValue == false ? -1 : 1));
2203 }2275 }
22042276
2205 bool getEBV( ) const;2277 bool getEBV() const;
22062278
2207 zstring getStringValue() const;2279 zstring getStringValue() const;
22082280
22092281
=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp 2012-02-22 04:03:16 +0000
+++ src/store/naive/item.cpp 2012-02-28 18:23:19 +0000
@@ -570,7 +570,7 @@
570 * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort,570 * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort,
571 * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger571 * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger
572 */572 */
573xs_uinteger Item::getUnsignedIntegerValue() const573xs_nonNegativeInteger Item::getUnsignedIntegerValue() const
574{574{
575 throw ZORBA_EXCEPTION(575 throw ZORBA_EXCEPTION(
576 zerr::ZSTR0040_TYPE_ERROR,576 zerr::ZSTR0040_TYPE_ERROR,
577577
=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp 2012-02-22 01:31:08 +0000
+++ src/store/naive/simple_item_factory.cpp 2012-02-28 18:23:19 +0000
@@ -318,7 +318,7 @@
318318
319bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value)319bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value)
320{320{
321 result = new IntegerItem( value );321 result = new IntegerItemImpl( value );
322 return true;322 return true;
323}323}
324324
@@ -327,7 +327,7 @@
327 store::Item_t& result,327 store::Item_t& result,
328 const xs_integer& value)328 const xs_integer& value)
329{329{
330 ZORBA_ASSERT(value <= Integer::zero());330 ZORBA_ASSERT(value.sign() <= 0);
331 result = new NonPositiveIntegerItem( value );331 result = new NonPositiveIntegerItem( value );
332 return true;332 return true;
333}333}
@@ -337,7 +337,7 @@
337 store::Item_t& result,337 store::Item_t& result,
338 const xs_integer& value)338 const xs_integer& value)
339{339{
340 ZORBA_ASSERT(value < xs_integer::zero());340 ZORBA_ASSERT(value.sign() < 0);
341 result = new NegativeIntegerItem(value);341 result = new NegativeIntegerItem(value);
342 return true;342 return true;
343}343}
@@ -345,7 +345,7 @@
345345
346bool BasicItemFactory::createNonNegativeInteger(346bool BasicItemFactory::createNonNegativeInteger(
347 store::Item_t& result,347 store::Item_t& result,
348 const xs_uinteger& value )348 const xs_nonNegativeInteger& value )
349{349{
350 result = new NonNegativeIntegerItem( value );350 result = new NonNegativeIntegerItem( value );
351 return true;351 return true;
@@ -355,9 +355,9 @@
355355
356bool BasicItemFactory::createPositiveInteger(356bool BasicItemFactory::createPositiveInteger(
357 store::Item_t& result,357 store::Item_t& result,
358 const xs_uinteger& value)358 const xs_positiveInteger& value)
359{359{
360 ZORBA_ASSERT(value > Integer::zero());360 ZORBA_ASSERT(value.sign() > 0);
361 result = new PositiveIntegerItem( value );361 result = new PositiveIntegerItem( value );
362 return true;362 return true;
363}363}
364364
=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h 2012-02-24 16:47:43 +0000
+++ src/store/naive/simple_item_factory.h 2012-02-28 18:23:19 +0000
@@ -131,9 +131,9 @@
131131
132 bool createInteger(store::Item_t& result, const xs_integer& value);132 bool createInteger(store::Item_t& result, const xs_integer& value);
133133
134 bool createNonNegativeInteger(store::Item_t& result, const xs_uinteger& value);134 bool createNonNegativeInteger(store::Item_t& result, const xs_nonNegativeInteger& value);
135135
136 bool createPositiveInteger(store::Item_t& result, const xs_uinteger& value );136 bool createPositiveInteger(store::Item_t& result, const xs_positiveInteger& value );
137137
138 bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value);138 bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value);
139139
140140
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2012-02-22 04:03:16 +0000
+++ src/types/casting.cpp 2012-02-28 18:23:19 +0000
@@ -166,6 +166,7 @@
166SAME_S_AND_T(aURI)166SAME_S_AND_T(aURI)
167SAME_S_AND_T(QN)167SAME_S_AND_T(QN)
168SAME_S_AND_T(NOT)168SAME_S_AND_T(NOT)
169SAME_S_AND_T(uint)
169170
170#undef SAME_S_AND_T171#undef SAME_S_AND_T
171172
@@ -1344,6 +1345,153 @@
1344 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);1345 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
1345}1346}
13461347
1348T1_TO_T2(uint, uA)
1349{
1350 zstring strval2;
1351 aItem->getStringValue2(strval2);
1352 return str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
1353}
1354
1355
1356T1_TO_T2(uint, str)
1357{
1358 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
1359}
1360
1361
1362T1_TO_T2(uint, flt)
1363{
1364 return aFactory->createFloat(
1365 result, xs_float(aItem->getUnsignedIntegerValue())
1366 );
1367}
1368
1369
1370T1_TO_T2(uint, dbl)
1371{
1372 return aFactory->createDouble(
1373 result, xs_double(aItem->getUnsignedIntegerValue())
1374 );
1375}
1376
1377
1378T1_TO_T2(uint, dec)
1379{
1380 return aFactory->createDecimal(
1381 result, xs_decimal(aItem->getUnsignedIntegerValue())
1382 );
1383}
1384
1385
1386T1_TO_T2(uint, bool)
1387{
1388 aFactory->createBoolean(result, aItem->getEBV());
1389 return true;
1390}
1391
1392
1393T1_TO_T2(uA, uint)
1394{
1395 zstring strval2;
1396 aItem->getStringValue2(strval2);
1397 return str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
1398}
1399
1400
1401T1_TO_T2(flt, uint)
1402{
1403 try
1404 {
1405 xs_nonNegativeInteger const n(aItem->getFloatValue());
1406 return aFactory->createNonNegativeInteger(result, n);
1407 }
1408 catch ( std::exception const& )
1409 {
1410 throwTypeException( err::FOCA0002, aErrorInfo );
1411 return NULL;
1412 }
1413}
1414
1415
1416T1_TO_T2(int, uint)
1417{
1418 try
1419 {
1420 xs_nonNegativeInteger const n(aItem->getIntegerValue());
1421 return aFactory->createNonNegativeInteger(result, n);
1422 }
1423 catch ( std::exception const& )
1424 {
1425 throwTypeException( err::FOCA0002, aErrorInfo );
1426 return NULL;
1427 }
1428}
1429
1430
1431T1_TO_T2(uint, int)
1432{
1433 try
1434 {
1435 xs_integer const n(aItem->getIntegerValue());
1436 return aFactory->createInteger(result, n);
1437 }
1438 catch ( std::exception const& )
1439 {
1440 throwTypeException( err::FOCA0002, aErrorInfo );
1441 return NULL;
1442 }
1443}
1444
1445
1446T1_TO_T2(dbl, uint)
1447{
1448 try
1449 {
1450 xs_nonNegativeInteger const n(aItem->getDoubleValue());
1451 return aFactory->createInteger(result, n);
1452 }
1453 catch ( std::exception const& )
1454 {
1455 throwTypeException( err::FOCA0002, aErrorInfo );
1456 return NULL;
1457 }
1458}
1459
1460
1461T1_TO_T2(dec, uint)
1462{
1463 xs_nonNegativeInteger const n(aItem->getDecimalValue());
1464 return aFactory->createNonNegativeInteger(result, n);
1465}
1466
1467
1468T1_TO_T2(bool, uint)
1469{
1470 if (aItem->getBooleanValue())
1471 return aFactory->createNonNegativeInteger(
1472 result, xs_nonNegativeInteger::one()
1473 );
1474 else
1475 return aFactory->createNonNegativeInteger(
1476 result, xs_nonNegativeInteger::zero()
1477 );
1478}
1479
1480
1481T1_TO_T2(str, uint)
1482{
1483 try {
1484 xs_nonNegativeInteger const n(strval.c_str());
1485 return aFactory->createNonNegativeInteger(result, n);
1486 }
1487 catch ( std::invalid_argument const& ) {
1488 throwTypeException( err::FORG0001, aErrorInfo );
1489 }
1490 catch ( std::range_error const& ) {
1491 throwTypeException( err::FOCA0002, aErrorInfo );
1492 }
1493 return NULL;
1494}
13471495
1348/*******************************************************************************1496/*******************************************************************************
13491497
@@ -1451,14 +1599,14 @@
1451 case store::XS_NON_POSITIVE_INTEGER:1599 case store::XS_NON_POSITIVE_INTEGER:
1452 {1600 {
1453 xs_integer const lInteger = aItem->getIntegerValue();1601 xs_integer const lInteger = aItem->getIntegerValue();
1454 if (lInteger <= xs_integer::zero())1602 if (lInteger.sign() <= 0)
1455 return aFactory->createNonPositiveInteger(result, lInteger);1603 return aFactory->createNonPositiveInteger(result, lInteger);
1456 break;1604 break;
1457 }1605 }
1458 case store::XS_NEGATIVE_INTEGER:1606 case store::XS_NEGATIVE_INTEGER:
1459 {1607 {
1460 xs_integer const lInteger = aItem->getIntegerValue();1608 xs_integer const lInteger = aItem->getIntegerValue();
1461 if (lInteger < xs_integer::zero())1609 if (lInteger.sign() < 0)
1462 return aFactory->createNegativeInteger(result, lInteger);1610 return aFactory->createNegativeInteger(result, lInteger);
1463 break;1611 break;
1464 }1612 }
@@ -1522,9 +1670,15 @@
1522 }1670 }
1523 case store::XS_NON_NEGATIVE_INTEGER:1671 case store::XS_NON_NEGATIVE_INTEGER:
1524 {1672 {
1525 xs_integer const lInteger = aItem->getIntegerValue();1673 xs_decimal const d = aItem->getDecimalValue();
1526 if (lInteger >= xs_integer::zero())1674 if (d.sign() >= 0)
1527 return aFactory->createNonNegativeInteger(result, lInteger);1675 try {
1676 xs_nonNegativeInteger const i(d);
1677 return aFactory->createNonNegativeInteger(result, i);
1678 }
1679 catch ( std::exception const& ) {
1680 // ignore
1681 }
1528 break;1682 break;
1529 }1683 }
1530 case store::XS_UNSIGNED_LONG:1684 case store::XS_UNSIGNED_LONG:
@@ -1587,9 +1741,9 @@
1587 }1741 }
1588 case store::XS_POSITIVE_INTEGER:1742 case store::XS_POSITIVE_INTEGER:
1589 {1743 {
1590 xs_integer lInteger = aItem->getIntegerValue();1744 xs_positiveInteger const i = aItem->getUnsignedIntegerValue();
1591 if (lInteger > xs_integer::zero())1745 if (i.sign() > 0)
1592 return aFactory->createPositiveInteger(result, lInteger);1746 return aFactory->createPositiveInteger(result, i);
1593 break;1747 break;
1594 }1748 }
1595 default:1749 default:
@@ -1634,12 +1788,12 @@
1634 5, // 25 XS_INT1788 5, // 25 XS_INT
1635 5, // 26 XS_SHORT1789 5, // 26 XS_SHORT
1636 5, // 27 XS_BYTE1790 5, // 27 XS_BYTE
1637 5, // 28 XS_NON_NEGATIVE_INTEGER1791 23, // 28 XS_NON_NEGATIVE_INTEGER
1638 5, // 29 XS_UNSIGNED_LONG1792 23, // 29 XS_UNSIGNED_LONG
1639 5, // 30 XS_UNSIGNED_INT1793 23, // 30 XS_UNSIGNED_INT
1640 5, // 31 XS_UNSIGNED_SHORT1794 23, // 31 XS_UNSIGNED_SHORT
1641 5, // 32 XS_UNSIGNED_BYTE1795 23, // 32 XS_UNSIGNED_BYTE
1642 5, // 33 XS_POSITIVE_INTEGER1796 23, // 33 XS_POSITIVE_INTEGER
1643 12, // 34 XS_GYEAR_MONTH1797 12, // 34 XS_GYEAR_MONTH
1644 13, // 35 XS_GYEAR1798 13, // 35 XS_GYEAR
1645 14, // 36 XS_GMONTH_DAY1799 14, // 36 XS_GMONTH_DAY
@@ -1657,98 +1811,155 @@
1657/*******************************************************************************1811/*******************************************************************************
16581812
1659********************************************************************************/1813********************************************************************************/
1660const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[23] =1814const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[24] =
1661{1815{
1662/*uA*/ 0, /*str*/ str_down, /*flt*/ 0, /*dbl*/ 0, /*dec*/ 0, /*int*/ int_down, /*dur*/ 0,1816/*uA*/ 0,
1663/*yMD*/ 0, /*dTD*/ 0, /*dT*/ 0, /*tim*/ 0, /*dat*/ 0, /*gYM*/ 0, /*gYr*/ 0, /*gMD*/ 0,1817/*str*/ str_down,
1664/*gDay*/0, /*gMon*/0, /*bool*/0, /*b64*/ 0, /*hxB*/ 0, /*aURI*/0, /*QN*/ 0, /*NOT*/ 01818/*flt*/ 0,
1819/*dbl*/ 0,
1820/*dec*/ 0,
1821/*int*/ int_down,
1822/*dur*/ 0,
1823/*yMD*/ 0,
1824/*dTD*/ 0,
1825/*dT*/ 0,
1826/*tim*/ 0,
1827/*dat*/ 0,
1828/*gYM*/ 0,
1829/*gYr*/ 0,
1830/*gMD*/ 0,
1831/*gDay*/ 0,
1832/*gMon*/ 0,
1833/*bool*/ 0,
1834/*b64*/ 0,
1835/*hxB*/ 0,
1836/*aURI*/ 0,
1837/*QN*/ 0,
1838/*NOT*/ 0,
1839/*uint*/ int_down,
1665};1840};
16661841
16671842
1668/*******************************************************************************1843/*******************************************************************************
16691844
1670********************************************************************************/1845********************************************************************************/
1671const GenericCast::CastFunc GenericCast::theCastMatrix[23][23] =1846const GenericCast::CastFunc GenericCast::theCastMatrix[24][24] =
1672{1847{
1673 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/1848 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1674 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/1849 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1675 /*aURI*/ /*QN*/ /*NOT*/1850 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1851
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,
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,
1678 &uA_aURI, 0, 0},1854 &uA_aURI, 0, 0, &uA_uint},
16791855
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,
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,
1682 &str_aURI, &str_QN, &str_NOT},1858 &str_aURI, &str_QN, &str_NOT, &str_uint},
16831859
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,
1685 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0,1861 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0,
1686 0, 0, 0},1862 0, 0, 0, &flt_uint},
16871863
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,
1689 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0,1865 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0,
1690 0, 0, 0},1866 0, 0, 0, &dbl_uint},
16911867
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,
1693 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0,1869 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0,
1694 0, 0, 0},1870 0, 0, 0, &dec_uint},
1871
1872 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1873 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1874 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1875
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,
1696 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0,1877 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0,
1697 0, 0, 0},1878 0, 0, 0, &int_uint},
1879
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,
1699 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1881 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1700 0, 0, 0},1882 0, 0, 0, 0},
1883
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,
1702 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1885 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1703 0, 0, 0},1886 0, 0, 0, 0},
1887
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,
1705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1889 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1706 0, 0, 0},1890 0, 0, 0, 0},
1707 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/1891
1708 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1709 /*aURI*/ /*QN*/ /*NOT*/
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,
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,
1712 0, 0, 0},1894 0, 0, 0, 0},
1895
1896 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1897 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1898 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1899
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,
1714 &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0,1901 &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1715 0, 0, 0},1902 0, 0, 0, 0},
1903
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,
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,
1718 0, 0, 0},1906 0, 0, 0, 0},
1907
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,
1720 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0,1909 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0,
1721 0, 0, 0},1910 0, 0, 0, 0},
1911
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,
1723 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0,1913 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0,
1724 0, 0, 0},1914 0, 0, 0, 0},
1915
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,
1726 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0,1917 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0,
1727 0, 0, 0},1918 0, 0, 0, 0},
1919
1920 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1921 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1922 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1923
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,
1729 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0,1925 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0,
1730 0, 0, 0},1926 0, 0, 0, 0},
1927
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,
1732 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0,1929 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0,
1733 0, 0, 0},1930 0, 0, 0, 0},
1931
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,
1735 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0,1933 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0,
1736 0, 0, 0},1934 0, 0, 0, &bool_uint},
1935
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,
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,
1739 0, 0, 0},1938 0, 0, 0, 0},
1939
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,
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,
1742 0, 0, 0},1942 0, 0, 0, 0},
1943
1944 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1945 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1946 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1947
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,
1744 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1949 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1745 &aURI_aURI,0, 0},1950 &aURI_aURI,0, 0, 0},
1951
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,
1747 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1953 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1748 0, &QN_QN, 0},1954 0, &QN_QN, 0, 0},
1955
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,
1750 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1957 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1751 0, 0, &NOT_NOT}1958 0, 0, &NOT_NOT, 0},
1959
1960/*uint*/ {&uint_uA, &uint_str, &uint_flt, &uint_dbl, &uint_dec, &uint_int, 0, 0, 0, 0,
1961 0, 0, 0, 0, 0, 0, 0, &uint_bool,0, 0,
1962 0, 0, 0, &uint_uint},
1752};1963};
17531964
17541965
17551966
=== modified file 'src/types/casting.h'
--- src/types/casting.h 2012-01-24 11:24:56 +0000
+++ src/types/casting.h 2012-02-28 18:23:19 +0000
@@ -51,8 +51,8 @@
51 51
52private:52private:
53 static const int theMapping[store::XS_LAST];53 static const int theMapping[store::XS_LAST];
54 static const CastFunc theCastMatrix[23][23];54 static const CastFunc theCastMatrix[24][24];
55 static const DownCastFunc theDownCastMatrix[23];55 static const DownCastFunc theDownCastMatrix[24];
5656
57 GenericCast() {}57 GenericCast() {}
58 58
5959
=== modified file 'src/types/schema/XercesParseUtils.cpp'
--- src/types/schema/XercesParseUtils.cpp 2011-06-30 05:16:55 +0000
+++ src/types/schema/XercesParseUtils.cpp 2012-02-28 18:23:19 +0000
@@ -118,7 +118,7 @@
118 {118 {
119 long value = xsval->fData.fValue.f_long;119 long value = xsval->fData.fValue.f_long;
120120
121 xs_integer tvalue(value);121 xs_positiveInteger tvalue(value);
122122
123 store::ItemFactory* factory = GENV_ITEMFACTORY;123 store::ItemFactory* factory = GENV_ITEMFACTORY;
124 return factory->createPositiveInteger(result, tvalue);124 return factory->createPositiveInteger(result, tvalue);
@@ -207,7 +207,7 @@
207 {207 {
208 long value = xsval->fData.fValue.f_long;208 long value = xsval->fData.fValue.f_long;
209209
210 xs_integer tvalue(value);210 xs_nonNegativeInteger tvalue(value);
211211
212 store::ItemFactory* factory = GENV_ITEMFACTORY;212 store::ItemFactory* factory = GENV_ITEMFACTORY;
213 return factory->createNonNegativeInteger(result, tvalue);213 return factory->createNonNegativeInteger(result, tvalue);
214214
=== modified file 'src/util/stl_util.h'
--- src/util/stl_util.h 2012-02-16 14:11:02 +0000
+++ src/util/stl_util.h 2012-02-28 18:23:19 +0000
@@ -248,6 +248,13 @@
248///////////////////////////////////////////////////////////////////////////////248///////////////////////////////////////////////////////////////////////////////
249249
250template<typename NumericType> inline250template<typename NumericType> inline
251typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<NumericType>::value,
252 bool>::type
253gt0( NumericType n ) { // for completeness
254 return n > 0;
255}
256
257template<typename NumericType> inline
251typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type258typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
252ge0( NumericType n ) {259ge0( NumericType n ) {
253 return n >= 0;260 return n >= 0;
@@ -259,6 +266,30 @@
259 return true;266 return true;
260}267}
261268
269template<typename NumericType> inline
270typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
271lt0( NumericType n ) {
272 return n < 0;
273}
274
275template<typename IntType> inline
276typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type
277lt0( IntType ) {
278 return false;
279}
280
281template<typename NumericType> inline
282typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
283le0( NumericType n ) {
284 return n <= 0;
285}
286
287template<typename IntType> inline
288typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type
289le0( IntType n ) {
290 return n == 0;
291}
292
262///////////////////////////////////////////////////////////////////////////////293///////////////////////////////////////////////////////////////////////////////
263294
264template<typename T> class stack_generator {295template<typename T> class stack_generator {
265296
=== modified file 'src/util/string_util.cpp'
--- src/util/string_util.cpp 2011-07-07 18:48:27 +0000
+++ src/util/string_util.cpp 2012-02-28 18:23:19 +0000
@@ -110,14 +110,22 @@
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).
111 //111 //
112 s = ascii::trim_start_whitespace( s );112 s = ascii::trim_start_whitespace( s );
113 if ( *s == '-' )113 bool const minus = *s == '-';
114
115 char *end;
116 errno = 0;
117 unsigned long long const result = std::strtoull( s, &end, 10 );
118 check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) );
119
120 if ( minus && result ) {
121 //
122 // Throw an exception only if there was a '-' and the result is non-zero.
123 // Hence, this allows "-0" and treats it as "0".
124 //
114 throw std::invalid_argument(125 throw std::invalid_argument(
115 "\"-\": invalid character for unsigned integer"126 "\"-\": invalid character for unsigned integer"
116 );127 );
117 char *end;128 }
118 errno = 0;
119 unsigned long long const result = std::strtoull( s, &end, 10 );
120 check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) );
121 return result;129 return result;
122}130}
123131
124132
=== modified file 'src/zorbaserialization/zorba_class_serializer.cpp'
--- src/zorbaserialization/zorba_class_serializer.cpp 2012-02-22 04:03:16 +0000
+++ src/zorbaserialization/zorba_class_serializer.cpp 2012-02-28 18:23:19 +0000
@@ -205,10 +205,19 @@
205 }205 }
206}206}
207207
208void operator&(serialization::Archiver &ar, Integer &obj)208#ifdef ZORBA_WITH_BIG_INTEGER
209void operator&(serialization::Archiver &ar, IntegerImpl &obj)
210#else
211template<typename IntType>
212void operator&(serialization::Archiver &ar, IntegerImpl<IntType> &obj)
213#endif /* ZORBA_WITH_BIG_INTEGER */
209{214{
210 ar & obj.value_;215 ar & obj.value_;
211}216}
217#ifndef ZORBA_WITH_BIG_INTEGER
218template void operator&(serialization::Archiver&, IntegerImpl<long long>&);
219template void operator&(serialization::Archiver&, IntegerImpl<unsigned long long>&);
220#endif /* ZORBA_WITH_BIG_INTEGER */
212221
213void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items)222void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items)
214{223{
@@ -590,7 +599,7 @@
590 }599 }
591 else if(name_of_type == "nonNegativeInteger")600 else if(name_of_type == "nonNegativeInteger")
592 {601 {
593 SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue());602 SERIALIZE_FIELD(xs_nonNegativeInteger, value, getUnsignedIntegerValue());
594 FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value));603 FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value));
595 }604 }
596 else if(name_of_type == "negativeInteger")605 else if(name_of_type == "negativeInteger")
@@ -600,7 +609,7 @@
600 }609 }
601 else if(name_of_type == "positiveInteger")610 else if(name_of_type == "positiveInteger")
602 {611 {
603 SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue());612 SERIALIZE_FIELD(xs_positiveInteger, value, getUnsignedIntegerValue());
604 FINALIZE_SERIALIZE(createPositiveInteger, (result, value));613 FINALIZE_SERIALIZE(createPositiveInteger, (result, value));
605 }614 }
606 615
607616
=== modified file 'src/zorbaserialization/zorba_class_serializer.h'
--- src/zorbaserialization/zorba_class_serializer.h 2012-02-02 09:56:52 +0000
+++ src/zorbaserialization/zorba_class_serializer.h 2012-02-28 18:23:19 +0000
@@ -38,13 +38,22 @@
38 class function;38 class function;
39 class Diagnostic;39 class Diagnostic;
40 class ZorbaException;40 class ZorbaException;
41 class Integer;41#ifdef ZORBA_WITH_BIG_INTEGER
42 class IntegerImpl;
43#else
44 template<typename IntType> class IntegerImpl;
45#endif /* ZORBA_WITH_BIG_INTEGER */
4246
43 namespace serialization{47 namespace serialization{
44//void operator&(Archiver &ar, XQType *&obj);48//void operator&(Archiver &ar, XQType *&obj);
45void operator&(Archiver &ar, const XQType *&obj);49void operator&(Archiver &ar, const XQType *&obj);
46void operator&(Archiver &ar, MAPM &obj);50void operator&(Archiver &ar, MAPM &obj);
47void operator&(Archiver &ar, Integer &obj);51#ifdef ZORBA_WITH_BIG_INTEGER
52void operator&(Archiver &ar, IntegerImpl &obj);
53#else
54template<typename IntType>
55void operator&(Archiver &ar, IntegerImpl<IntType> &obj);
56#endif /* ZORBA_WITH_BIG_INTEGER */
4857
49void operator&(Archiver &ar, XQPCollator *&obj);58void operator&(Archiver &ar, XQPCollator *&obj);
50void operator&(Archiver &ar, store::Item* &obj);59void operator&(Archiver &ar, store::Item* &obj);
5160
=== modified file 'src/zorbatypes/decimal.cpp'
--- src/zorbatypes/decimal.cpp 2011-07-06 19:59:26 +0000
+++ src/zorbatypes/decimal.cpp 2012-02-28 18:23:19 +0000
@@ -28,6 +28,16 @@
28#include "integer.h"28#include "integer.h"
29#include "numconversions.h"29#include "numconversions.h"
3030
31#ifdef ZORBA_WITH_BIG_INTEGER
32# define TEMPLATE_DECL(T) /* nothing */
33# define INTEGER_IMPL(T) IntegerImpl
34#else
35# define TEMPLATE_DECL(T) template<typename T>
36# define INTEGER_IMPL(T) IntegerImpl<T>
37#endif /* ZORBA_WITH_BIG_INTEGER */
38#define INTEGER_IMPL_LL INTEGER_IMPL(long long)
39#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long)
40
31namespace zorba {41namespace zorba {
3242
33SERIALIZABLE_CLASS_VERSIONS(Decimal)43SERIALIZABLE_CLASS_VERSIONS(Decimal)
@@ -218,8 +228,13 @@
218 value_ = f.getNumber();228 value_ = f.getNumber();
219}229}
220230
221Decimal::Decimal( Integer const &i ) : value_( i.itod() ) {231TEMPLATE_DECL(T)
232Decimal::Decimal( INTEGER_IMPL(T) const &i ) : value_( i.itod() ) {
222}233}
234#ifndef ZORBA_WITH_BIG_INTEGER
235template Decimal::Decimal( INTEGER_IMPL_LL const& );
236template Decimal::Decimal( INTEGER_IMPL_ULL const& );
237#endif /* ZORBA_WITH_BIG_INTEGER */
223238
224////////// assignment operators ///////////////////////////////////////////////239////////// assignment operators ///////////////////////////////////////////////
225240
@@ -235,10 +250,15 @@
235 return *this;250 return *this;
236}251}
237252
238Decimal& Decimal::operator=( Integer const &i ) {253TEMPLATE_DECL(T)
254Decimal& Decimal::operator=( INTEGER_IMPL(T) const &i ) {
239 value_ = i.itod();255 value_ = i.itod();
240 return *this;256 return *this;
241}257}
258#ifndef ZORBA_WITH_BIG_INTEGER
259template Decimal& Decimal::operator=( INTEGER_IMPL_LL const& );
260template Decimal& Decimal::operator=( INTEGER_IMPL_ULL const& );
261#endif /* ZORBA_WITH_BIG_INTEGER */
242262
243Decimal& Decimal::operator=( Double const &d ) {263Decimal& Decimal::operator=( Double const &d ) {
244 if ( !d.isFinite() )264 if ( !d.isFinite() )
@@ -256,61 +276,69 @@
256276
257////////// arithmetic operators ///////////////////////////////////////////////277////////// arithmetic operators ///////////////////////////////////////////////
258278
259Decimal operator+( Decimal const &d, Integer const &i ) {279#ifdef ZORBA_WITH_BIG_INTEGER
260 return d.value_ + i.itod();280# define ZORBA_INSTANTIATE(OP) /* nothing */
261}281#else
262282# define ZORBA_INSTANTIATE(OP) \
263Decimal operator-( Decimal const &d, Integer const &i ) {283 template Decimal operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \
264 return d.value_ - i.itod();284 template Decimal operator OP( Decimal const&, INTEGER_IMPL_ULL const& )
265}285#endif /* ZORBA_WITH_BIG_INTEGER */
266286
267Decimal operator*( Decimal const &d, Integer const &i ) {287#define ZORBA_DECIMAL_OP(OP) \
268 return d.value_ * i.itod();288 TEMPLATE_DECL(T) \
269}289 Decimal operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \
270290 return d.value_ OP i.itod(); \
271Decimal operator/( Decimal const &d, Integer const &i ) {291 } \
272 return d.value_ / i.itod();292 ZORBA_INSTANTIATE(OP)
273}293
274294ZORBA_DECIMAL_OP(+);
275Decimal operator%( Decimal const &d, Integer const &i ) {295ZORBA_DECIMAL_OP(-);
276 return d.value_ % i.itod();296ZORBA_DECIMAL_OP(*);
277}297ZORBA_DECIMAL_OP(/);
298ZORBA_DECIMAL_OP(%);
299#undef ZORBA_DECIMAL_OP
300#undef ZORBA_INSTANTIATE
278301
279////////// relational operators ///////////////////////////////////////////////302////////// relational operators ///////////////////////////////////////////////
280303
281bool operator==( Decimal const &d, Integer const &i ) {304#ifdef ZORBA_WITH_BIG_INTEGER
282 return d.value_ == i.itod();305# define ZORBA_INSTANTIATE(OP) /* nothing */
283}306#else
284307# define ZORBA_INSTANTIATE(OP) \
285bool operator!=( Decimal const &d, Integer const &i ) {308 template bool operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \
286 return d.value_ != i.itod();309 template bool operator OP( Decimal const&, INTEGER_IMPL_ULL const& )
287}310#endif /* ZORBA_WITH_BIG_INTEGER */
288311
289bool operator<( Decimal const &d, Integer const &i ) {312#define ZORBA_DECIMAL_OP(OP) \
290 return d.value_ < i.itod();313 TEMPLATE_DECL(T) \
291}314 bool operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \
292315 return d.value_ OP i.itod(); \
293bool operator<=( Decimal const &d, Integer const &i ) {316 } \
294 return d.value_ <= i.itod();317 ZORBA_INSTANTIATE(OP)
295}318
296319ZORBA_DECIMAL_OP(==);
297bool operator>( Decimal const &d, Integer const &i ) {320ZORBA_DECIMAL_OP(!=);
298 return d.value_ > i.itod();321ZORBA_DECIMAL_OP(< );
299}322ZORBA_DECIMAL_OP(<=);
300323ZORBA_DECIMAL_OP(> );
301bool operator>=( Decimal const &d, Integer const &i ) {324ZORBA_DECIMAL_OP(>=);
302 return d.value_ >= i.itod();325#undef ZORBA_DECIMAL_OP
303}326#undef ZORBA_INSTANTIATE
304327
305////////// math functions /////////////////////////////////////////////////////328////////// math functions /////////////////////////////////////////////////////
306329
307Decimal Decimal::round() const {330Decimal Decimal::round() const {
308 return round( Integer::zero() );331 return round( INTEGER_IMPL_LL::zero() );
309}332}
310333
311Decimal Decimal::round( Integer const &precision ) const {334TEMPLATE_DECL(T)
335Decimal Decimal::round( INTEGER_IMPL(T) const &precision ) const {
312 return round( value_, precision.itod() );336 return round( value_, precision.itod() );
313}337}
338#ifndef ZORBA_WITH_BIG_INTEGER
339template Decimal Decimal::round( INTEGER_IMPL_LL const& ) const;
340template Decimal Decimal::round( INTEGER_IMPL_ULL const& ) const;
341#endif /* ZORBA_WITH_BIG_INTEGER */
314342
315Decimal::value_type Decimal::round( value_type const &v,343Decimal::value_type Decimal::round( value_type const &v,
316 value_type const &precision ) {344 value_type const &precision ) {
@@ -322,9 +350,14 @@
322 return result;350 return result;
323}351}
324352
325Decimal Decimal::roundHalfToEven( Integer const &precision ) const {353TEMPLATE_DECL(T)
354Decimal Decimal::roundHalfToEven( INTEGER_IMPL(T) const &precision ) const {
326 return roundHalfToEven( value_, precision.itod() );355 return roundHalfToEven( value_, precision.itod() );
327}356}
357#ifndef ZORBA_WITH_BIG_INTEGER
358template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_LL const& ) const;
359template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_ULL const& ) const;
360#endif /* ZORBA_WITH_BIG_INTEGER */
328361
329Decimal::value_type Decimal::roundHalfToEven( value_type const &v,362Decimal::value_type Decimal::roundHalfToEven( value_type const &v,
330 value_type const &precision ) {363 value_type const &precision ) {
331364
=== modified file 'src/zorbatypes/decimal.h'
--- src/zorbatypes/decimal.h 2011-06-24 18:27:08 +0000
+++ src/zorbatypes/decimal.h 2012-02-28 18:23:19 +0000
@@ -29,6 +29,14 @@
29#include "zorbatypes_decl.h"29#include "zorbatypes_decl.h"
30#include "zstring.h"30#include "zstring.h"
3131
32#ifdef ZORBA_WITH_BIG_INTEGER
33# define TEMPLATE_DECL(T) /* nothing */
34# define INTEGER_IMPL(T) IntegerImpl
35#else
36# define TEMPLATE_DECL(T) template<typename T>
37# define INTEGER_IMPL(T) IntegerImpl<T>
38#endif /* ZORBA_WITH_BIG_INTEGER */
39
32namespace zorba {40namespace zorba {
3341
34///////////////////////////////////////////////////////////////////////////////42///////////////////////////////////////////////////////////////////////////////
@@ -52,7 +60,9 @@
52 Decimal( float n );60 Decimal( float n );
53 Decimal( double n );61 Decimal( double n );
54 Decimal( Decimal const &d );62 Decimal( Decimal const &d );
55 Decimal( Integer const &i );63
64 TEMPLATE_DECL(T)
65 Decimal( INTEGER_IMPL(T) const &i );
5666
57 /**67 /**
58 * Constructs a %Decimal from a C string.68 * Constructs a %Decimal from a C string.
@@ -98,27 +108,30 @@
98 Decimal& operator=( Decimal const &d );108 Decimal& operator=( Decimal const &d );
99 Decimal& operator=( Double const &d );109 Decimal& operator=( Double const &d );
100 Decimal& operator=( Float const &f );110 Decimal& operator=( Float const &f );
101 Decimal& operator=( Integer const &i );111
112 TEMPLATE_DECL(T)
113 Decimal& operator=( INTEGER_IMPL(T) const &i );
102114
103 ////////// arithmetic operators /////////////////////////////////////////////115 ////////// arithmetic operators /////////////////////////////////////////////
104116
105 friend Decimal operator+( Decimal const &d1, Decimal const &d2 );117 friend Decimal operator+( Decimal const&, Decimal const& );
106 friend Decimal operator-( Decimal const &d1, Decimal const &d2 );118 friend Decimal operator-( Decimal const&, Decimal const& );
107 friend Decimal operator*( Decimal const &d1, Decimal const &d2 );119 friend Decimal operator*( Decimal const&, Decimal const& );
108 friend Decimal operator/( Decimal const &d1, Decimal const &d2 );120 friend Decimal operator/( Decimal const&, Decimal const& );
109 friend Decimal operator%( Decimal const &d1, Decimal const &d2 );121 friend Decimal operator%( Decimal const&, Decimal const& );
110122
111 friend Decimal operator+( Decimal const &d, Integer const &i );123#define ZORBA_DECIMAL_OP(OP) \
112 friend Decimal operator-( Decimal const &d, Integer const &i );124 TEMPLATE_DECL(T) \
113 friend Decimal operator*( Decimal const &d, Integer const &i );125 friend Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \
114 friend Decimal operator/( Decimal const &d, Integer const &i );126 TEMPLATE_DECL(T) \
115 friend Decimal operator%( Decimal const &d, Integer const &i );127 friend Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& )
116128
117 friend Decimal operator+( Integer const &i, Decimal const &d );129 ZORBA_DECIMAL_OP(+);
118 friend Decimal operator-( Integer const &i, Decimal const &d );130 ZORBA_DECIMAL_OP(-);
119 friend Decimal operator*( Integer const &i, Decimal const &d );131 ZORBA_DECIMAL_OP(*);
120 friend Decimal operator/( Integer const &i, Decimal const &d );132 ZORBA_DECIMAL_OP(/);
121 friend Decimal operator%( Integer const &i, Decimal const &d );133 ZORBA_DECIMAL_OP(%);
134#undef ZORBA_DECIMAL_OP
122135
123 Decimal& operator+=( Decimal const& );136 Decimal& operator+=( Decimal const& );
124 Decimal& operator-=( Decimal const& );137 Decimal& operator-=( Decimal const& );
@@ -126,46 +139,49 @@
126 Decimal& operator/=( Decimal const& );139 Decimal& operator/=( Decimal const& );
127 Decimal& operator%=( Decimal const& );140 Decimal& operator%=( Decimal const& );
128141
129 Decimal& operator+=( Integer const& );142#define ZORBA_DECIMAL_OP(OP) \
130 Decimal& operator-=( Integer const& );143 TEMPLATE_DECL(T) Decimal& operator OP( INTEGER_IMPL(T) const& )
131 Decimal& operator*=( Integer const& );144
132 Decimal& operator/=( Integer const& );145 ZORBA_DECIMAL_OP(+=);
133 Decimal& operator%=( Integer const& );146 ZORBA_DECIMAL_OP(-=);
147 ZORBA_DECIMAL_OP(*=);
148 ZORBA_DECIMAL_OP(/=);
149 ZORBA_DECIMAL_OP(%=);
150#undef ZORBA_DECIMAL_OP
134151
135 Decimal operator-() const;152 Decimal operator-() const;
136153
137 ////////// relational operators /////////////////////////////////////////////154 ////////// relational operators /////////////////////////////////////////////
138155
139 friend bool operator==( Decimal const &d1, Decimal const &d2 );156#define ZORBA_DECIMAL_OP(OP) \
140 friend bool operator!=( Decimal const &d1, Decimal const &d2 );157 friend bool operator OP( Decimal const&, Decimal const& ); \
141 friend bool operator< ( Decimal const &d1, Decimal const &d2 );158 TEMPLATE_DECL(T) \
142 friend bool operator<=( Decimal const &d1, Decimal const &d2 );159 friend bool operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \
143 friend bool operator> ( Decimal const &d1, Decimal const &d2 );160 TEMPLATE_DECL(T) \
144 friend bool operator>=( Decimal const &d1, Decimal const &d2 );161 friend bool operator OP( INTEGER_IMPL(T) const&, Decimal const& )
145162
146 friend bool operator==( Decimal const &d, Integer const &i );163 ZORBA_DECIMAL_OP(==);
147 friend bool operator!=( Decimal const &d, Integer const &i );164 ZORBA_DECIMAL_OP(!=);
148 friend bool operator< ( Decimal const &d, Integer const &i );165 ZORBA_DECIMAL_OP(< );
149 friend bool operator<=( Decimal const &d, Integer const &i );166 ZORBA_DECIMAL_OP(<=);
150 friend bool operator> ( Decimal const &d, Integer const &i );167 ZORBA_DECIMAL_OP(> );
151 friend bool operator>=( Decimal const &d, Integer const &i );168 ZORBA_DECIMAL_OP(>=);
152169#undef ZORBA_DECIMAL_OP
153 friend bool operator==( Integer const &i, Decimal const &d );
154 friend bool operator!=( Integer const &i, Decimal const &d );
155 friend bool operator< ( Integer const &i, Decimal const &d );
156 friend bool operator<=( Integer const &i, Decimal const &d );
157 friend bool operator> ( Integer const &i, Decimal const &d );
158 friend bool operator>=( Integer const &i, Decimal const &d );
159170
160 ////////// math functions ///////////////////////////////////////////////////171 ////////// math functions ///////////////////////////////////////////////////
161172
162 int compare( Decimal const &d ) const;173 int compare( Decimal const& ) const;
163174
164 Decimal ceil() const;175 Decimal ceil() const;
165 Decimal floor() const;176 Decimal floor() const;
166 Decimal round() const;177 Decimal round() const;
167 Decimal round( Integer const &precision ) const;178
168 Decimal roundHalfToEven( Integer const &precision ) const;179 TEMPLATE_DECL(T)
180 Decimal round( INTEGER_IMPL(T) const &precision ) const;
181
182 TEMPLATE_DECL(T)
183 Decimal roundHalfToEven( INTEGER_IMPL(T) const &precision ) const;
184
169 Decimal sqrt() const;185 Decimal sqrt() const;
170186
171 ////////// miscellaneous ////////////////////////////////////////////////////187 ////////// miscellaneous ////////////////////////////////////////////////////
@@ -215,7 +231,7 @@
215 static zstring toString( value_type const&,231 static zstring toString( value_type const&,
216 int precision = ZORBA_FLOAT_POINT_PRECISION );232 int precision = ZORBA_FLOAT_POINT_PRECISION );
217233
218 friend class Integer;234 TEMPLATE_DECL(T) friend class IntegerImpl;
219 template<typename T> friend class FloatImpl;235 template<typename T> friend class FloatImpl;
220236
221 friend xs_long to_xs_long( Decimal const& );237 friend xs_long to_xs_long( Decimal const& );
@@ -443,6 +459,10 @@
443///////////////////////////////////////////////////////////////////////////////459///////////////////////////////////////////////////////////////////////////////
444460
445} // namespace zorba461} // namespace zorba
462
463#undef TEMPLATE_DECL
464#undef INTEGER_IMPL
465
446#endif /* ZORBA_DECIMAL_H */466#endif /* ZORBA_DECIMAL_H */
447/*467/*
448 * Local variables:468 * Local variables:
449469
=== modified file 'src/zorbatypes/floatimpl.cpp'
--- src/zorbatypes/floatimpl.cpp 2011-07-07 12:05:43 +0000
+++ src/zorbatypes/floatimpl.cpp 2012-02-28 18:23:19 +0000
@@ -29,6 +29,16 @@
2929
30#include "zorbaserialization/serialization_engine.h"30#include "zorbaserialization/serialization_engine.h"
3131
32#ifdef ZORBA_WITH_BIG_INTEGER
33# define TEMPLATE_DECL(T) /* nothing */
34# define INTEGER_IMPL(T) IntegerImpl
35#else
36# define TEMPLATE_DECL(T) template<typename T>
37# define INTEGER_IMPL(T) IntegerImpl<T>
38#endif /* ZORBA_WITH_BIG_INTEGER */
39#define INTEGER_IMPL_LL INTEGER_IMPL(long long)
40#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long)
41
32///////////////////////////////////////////////////////////////////////////////42///////////////////////////////////////////////////////////////////////////////
3343
34namespace zorba {44namespace zorba {
@@ -144,11 +154,20 @@
144}154}
145155
146template<typename FloatType>156template<typename FloatType>
147FloatImpl<FloatType>::FloatImpl( Integer const &i ) {157TEMPLATE_DECL(IntType)
158FloatImpl<FloatType>::FloatImpl( INTEGER_IMPL(IntType) const &i ) {
148 zstring const temp( i.toString() );159 zstring const temp( i.toString() );
149 parse( temp.c_str() );160 parse( temp.c_str() );
150}161}
151162
163#ifndef ZORBA_WITH_BIG_INTEGER
164template FloatImpl<float>::FloatImpl( INTEGER_IMPL_LL const& );
165template FloatImpl<float>::FloatImpl( INTEGER_IMPL_ULL const& );
166
167template FloatImpl<double>::FloatImpl( INTEGER_IMPL_LL const& );
168template FloatImpl<double>::FloatImpl( INTEGER_IMPL_ULL const& );
169#endif /* ZORBA_WITH_BIG_INTEGER */
170
152////////// math functions /////////////////////////////////////////////////////171////////// math functions /////////////////////////////////////////////////////
153172
154template<typename FloatType>173template<typename FloatType>
155174
=== modified file 'src/zorbatypes/floatimpl.h'
--- src/zorbatypes/floatimpl.h 2011-10-03 09:18:49 +0000
+++ src/zorbatypes/floatimpl.h 2012-02-28 18:23:19 +0000
@@ -29,13 +29,22 @@
29#include "schema_types.h"29#include "schema_types.h"
30#include "zorbatypes_decl.h"30#include "zorbatypes_decl.h"
3131
32#ifdef ZORBA_WITH_BIG_INTEGER
33# define TEMPLATE_DECL(T) /* nothing */
34# define INTEGER_IMPL(T) IntegerImpl
35#else
36# define TEMPLATE_DECL(T) template<typename T>
37# define INTEGER_IMPL(T) IntegerImpl<T>
38#endif /* ZORBA_WITH_BIG_INTEGER */
39
32namespace zorba {40namespace zorba {
3341
34template<typename FloatType>42template<typename FloatType>
35class FloatImpl;43class FloatImpl;
36namespace serialization{44
45namespace serialization {
37 template<typename FloatType>46 template<typename FloatType>
38 void operator&(Archiver &ar, FloatImpl<FloatType> &obj);47 void operator&( Archiver&, FloatImpl<FloatType>& );
39}48}
4049
41///////////////////////////////////////////////////////////////////////////////50///////////////////////////////////////////////////////////////////////////////
@@ -61,7 +70,9 @@
61 FloatImpl( float n );70 FloatImpl( float n );
62 FloatImpl( double n );71 FloatImpl( double n );
63 FloatImpl( Decimal const &d );72 FloatImpl( Decimal const &d );
64 FloatImpl( Integer const &i );73
74 TEMPLATE_DECL(T)
75 FloatImpl( INTEGER_IMPL(T) const &i );
6576
66 /**77 /**
67 * Constructs a %FloatImpl from a C string.78 * Constructs a %FloatImpl from a C string.
@@ -220,7 +231,7 @@
220 void parse( char const* );231 void parse( char const* );
221 bool parse_etc( char const* );232 bool parse_etc( char const* );
222233
223 friend class Integer;234 TEMPLATE_DECL(T) friend class IntegerImpl;
224 friend class Decimal;235 friend class Decimal;
225236
226 friend class FloatImpl<float>;237 friend class FloatImpl<float>;
@@ -772,6 +783,10 @@
772///////////////////////////////////////////////////////////////////////////////783///////////////////////////////////////////////////////////////////////////////
773784
774} // namespace zorba785} // namespace zorba
786
787#undef TEMPLATE_DECL
788#undef INTEGER_IMPL
789
775#endif // ZORBA_FLOATIMPL_H790#endif // ZORBA_FLOATIMPL_H
776/*791/*
777 * Local variables:792 * Local variables:
778793
=== modified file 'src/zorbatypes/integer.cpp'
--- src/zorbatypes/integer.cpp 2011-07-06 20:13:28 +0000
+++ src/zorbatypes/integer.cpp 2012-02-28 18:23:19 +0000
@@ -27,62 +27,82 @@
27#include "floatimpl.h"27#include "floatimpl.h"
28#include "numconversions.h"28#include "numconversions.h"
2929
30#ifdef ZORBA_WITH_BIG_INTEGER
31# define TEMPLATE_DECL(T) /* nothing */
32# define INTEGER_IMPL(T) IntegerImpl
33#else
34# define TEMPLATE_DECL(T) template<typename T>
35# define INTEGER_IMPL(T) IntegerImpl<T>
36#endif /* ZORBA_WITH_BIG_INTEGER */
37#define INTEGER_IMPL_LL INTEGER_IMPL(long long)
38#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long)
39
30using namespace std;40using namespace std;
3141
32#ifdef WIN3242#ifndef ZORBA_WITH_BIG_INTEGER
33namespace std {43unsigned long long MaxUIntegerValue = ~0ull >> 1;
34 inline long long strtoll( char const *s, char **end, int base ) {44
35 return ::_strtoi64( s, end, base );45inline bool is_too_big( long long ) {
36 }46 return false;
3747}
38 inline long long strtoull( char const *s, char **end, int base ) {48
39 return ::_strtoui64( s, end, base );49inline bool is_too_big( unsigned long long n ) {
40 }50 return n > MaxUIntegerValue;
41}51}
42#endif /* WIN32 */52#endif /* ZORBA_WITH_BIG_INTEGER */
4353
44namespace zorba {54namespace zorba {
4555
46///////////////////////////////////////////////////////////////////////////////56///////////////////////////////////////////////////////////////////////////////
4757
48void Integer::parse( char const *s ) {
49#ifdef ZORBA_WITH_BIG_INTEGER58#ifdef ZORBA_WITH_BIG_INTEGER
59void IntegerImpl::parse( char const *s ) {
50 Decimal::parse( s, &value_, Decimal::parse_integer );60 Decimal::parse( s, &value_, Decimal::parse_integer );
51#else61#else
52 value_ = ztd::aton<value_type>( s );62template<typename IntType>
63void IntegerImpl<IntType>::parse( char const *s ) {
64 value_type const temp = ztd::aton<value_type>( s );
65 if ( is_too_big( temp ) )
66 throw std::invalid_argument(
67 BUILD_STRING( '"', temp, "\": unsigned integer too big" )
68 );
69 value_ = temp;
53#endif /* ZORBA_WITH_BIG_INTEGER */70#endif /* ZORBA_WITH_BIG_INTEGER */
54}71}
5572
56////////// constructors ///////////////////////////////////////////////////////73////////// constructors ///////////////////////////////////////////////////////
5774
58#ifdef ZORBA_WITH_BIG_INTEGER75#ifdef ZORBA_WITH_BIG_INTEGER
59Integer::Integer( long long n ) {76IntegerImpl::IntegerImpl( long long n ) {
60 ztd::itoa_buf_type buf;77 ztd::itoa_buf_type buf;
61 value_ = ztd::itoa( n, buf );78 value_ = ztd::itoa( n, buf );
62}79}
6380
64Integer::Integer( unsigned long n ) {81IntegerImpl::IntegerImpl( unsigned long n ) {
65 ztd::itoa_buf_type buf;82 ztd::itoa_buf_type buf;
66 value_ = ztd::itoa( n, buf );83 value_ = ztd::itoa( n, buf );
67}84}
6885
69Integer::Integer( unsigned long long n ) {86IntegerImpl::IntegerImpl( unsigned long long n ) {
70 ztd::itoa_buf_type buf;87 ztd::itoa_buf_type buf;
71 value_ = ztd::itoa( n, buf );88 value_ = ztd::itoa( n, buf );
72}89}
73#endif /* ZORBA_WITH_BIG_INTEGER */90#endif /* ZORBA_WITH_BIG_INTEGER */
7491
75Integer::Integer( Decimal const &d ) {92TEMPLATE_DECL(T)
93INTEGER_IMPL(T)::IntegerImpl( Decimal const &d ) {
76 value_ = ftoi( d.value_ );94 value_ = ftoi( d.value_ );
77}95}
7896
79Integer::Integer( Double const &d ) {97TEMPLATE_DECL(T)
98INTEGER_IMPL(T)::IntegerImpl( Double const &d ) {
80 if ( !d.isFinite() )99 if ( !d.isFinite() )
81 throw std::invalid_argument( "not finite" );100 throw std::invalid_argument( "not finite" );
82 value_ = ftoi( d.getNumber() );101 value_ = ftoi( d.getNumber() );
83}102}
84103
85Integer::Integer( Float const &f ) {104TEMPLATE_DECL(T)
105INTEGER_IMPL(T)::IntegerImpl( Float const &f ) {
86 if ( !f.isFinite() )106 if ( !f.isFinite() )
87 throw std::invalid_argument( "not finite" );107 throw std::invalid_argument( "not finite" );
88 value_ = ftoi( f.getNumber() );108 value_ = ftoi( f.getNumber() );
@@ -91,38 +111,41 @@
91////////// assignment operators ///////////////////////////////////////////////111////////// assignment operators ///////////////////////////////////////////////
92112
93#ifdef ZORBA_WITH_BIG_INTEGER113#ifdef ZORBA_WITH_BIG_INTEGER
94Integer& Integer::operator=( long long n ) {114IntegerImpl& IntegerImpl::operator=( long long n ) {
95 ztd::itoa_buf_type buf;115 ztd::itoa_buf_type buf;
96 value_ = ztd::itoa( n, buf );116 value_ = ztd::itoa( n, buf );
97 return *this;117 return *this;
98}118}
99119
100Integer& Integer::operator=( unsigned long n ) {120IntegerImpl& IntegerImpl::operator=( unsigned long n ) {
101 ztd::itoa_buf_type buf;121 ztd::itoa_buf_type buf;
102 value_ = ztd::itoa( n, buf );122 value_ = ztd::itoa( n, buf );
103 return *this;123 return *this;
104}124}
105125
106Integer& Integer::operator=( unsigned long long n ) {126IntegerImpl& IntegerImpl::operator=( unsigned long long n ) {
107 ztd::itoa_buf_type buf;127 ztd::itoa_buf_type buf;
108 value_ = ztd::itoa( n, buf );128 value_ = ztd::itoa( n, buf );
109 return *this;129 return *this;
110}130}
111#endif /* ZORBA_WITH_BIG_INTEGER */131#endif /* ZORBA_WITH_BIG_INTEGER */
112132
113Integer& Integer::operator=( Decimal const &d ) {133TEMPLATE_DECL(T)
134INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Decimal const &d ) {
114 value_ = ftoi( d.value_ );135 value_ = ftoi( d.value_ );
115 return *this;136 return *this;
116}137}
117138
118Integer& Integer::operator=( Double const &d ) {139TEMPLATE_DECL(T)
140INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Double const &d ) {
119 if ( !d.isFinite() )141 if ( !d.isFinite() )
120 throw std::invalid_argument( "not finite" );142 throw std::invalid_argument( "not finite" );
121 value_ = ftoi( d.getNumber() );143 value_ = ftoi( d.getNumber() );
122 return *this;144 return *this;
123}145}
124146
125Integer& Integer::operator=( Float const &f ) {147TEMPLATE_DECL(T)
148INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Float const &f ) {
126 if ( !f.isFinite() )149 if ( !f.isFinite() )
127 throw std::invalid_argument( "not finite" );150 throw std::invalid_argument( "not finite" );
128 value_ = ftoi( f.getNumber() );151 value_ = ftoi( f.getNumber() );
@@ -131,55 +154,67 @@
131154
132////////// arithmetic operators ///////////////////////////////////////////////155////////// arithmetic operators ///////////////////////////////////////////////
133156
134Decimal operator+( Integer const &i, Decimal const &d ) {157#ifdef ZORBA_WITH_BIG_INTEGER
135 return i.itod() + d.value_;158# define ZORBA_INSTANTIATE(OP) /* nothing */
136}159#else
137160# define ZORBA_INSTANTIATE(OP) \
138Decimal operator-( Integer const &i, Decimal const &d ) {161 template Decimal operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \
139 return i.itod() - d.value_;162 template Decimal operator OP( INTEGER_IMPL_ULL const&, Decimal const& );
140}163#endif /* ZORBA_WITH_BIG_INTEGER */
141164
142Decimal operator*( Integer const &i, Decimal const &d ) {165#define ZORBA_INTEGER_OP(OP) \
143 return i.itod() * d.value_;166 TEMPLATE_DECL(T) \
144}167 Decimal operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \
145168 return i.itod() OP d.value_; \
146Decimal operator/( Integer const &i, Decimal const &d ) {169 } \
147 return i.itod() / d.value_;170 ZORBA_INSTANTIATE(OP)
148}171
149172ZORBA_INTEGER_OP(+)
150Decimal operator%( Integer const &i, Decimal const &d ) {173ZORBA_INTEGER_OP(-)
151 return i.itod() % d.value_;174ZORBA_INTEGER_OP(*)
152}175ZORBA_INTEGER_OP(/)
176ZORBA_INTEGER_OP(%)
177#undef ZORBA_INTEGER_OP
178#undef ZORBA_INSTANTIATE
153179
154////////// relational operators ///////////////////////////////////////////////180////////// relational operators ///////////////////////////////////////////////
155181
156bool operator==( Integer const &i, Decimal const &d ) {182TEMPLATE_DECL(T)
183bool operator==( INTEGER_IMPL(T) const &i, Decimal const &d ) {
157 return d.is_integer() && i.itod() == d.value_;184 return d.is_integer() && i.itod() == d.value_;
158}185}
159186
160bool operator!=( Integer const &i, Decimal const &d ) {187#define ZORBA_INTEGER_OP(OP) \
161 return i.itod() != d.value_;188 TEMPLATE_DECL(T) \
162}189 bool operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \
163190 return i.itod() OP d.value_; \
164bool operator<( Integer const &i, Decimal const &d ) {191 }
165 return i.itod() < d.value_;192
166}193ZORBA_INTEGER_OP(!=)
167194ZORBA_INTEGER_OP(< )
168bool operator<=( Integer const &i, Decimal const &d ) {195ZORBA_INTEGER_OP(<=)
169 return i.itod() <= d.value_;196ZORBA_INTEGER_OP(> )
170}197ZORBA_INTEGER_OP(>=)
171198#undef ZORBA_INTEGER_OP
172bool operator>( Integer const &i, Decimal const &d ) {199
173 return i.itod() > d.value_;200#ifndef ZORBA_WITH_BIG_INTEGER
174}201#define ZORBA_INSTANTIATE(OP) \
175202 template bool operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \
176bool operator>=( Integer const &i, Decimal const &d ) {203 template bool operator OP( INTEGER_IMPL_ULL const&, Decimal const& )
177 return i.itod() >= d.value_;204
178}205ZORBA_INSTANTIATE(==);
206ZORBA_INSTANTIATE(!=);
207ZORBA_INSTANTIATE(< );
208ZORBA_INSTANTIATE(<=);
209ZORBA_INSTANTIATE(> );
210ZORBA_INSTANTIATE(>=);
211#undef ZORBA_INSTANTIATE
212#endif /* ZORBA_WITH_BIG_INTEGER */
179213
180////////// math functions /////////////////////////////////////////////////////214////////// math functions /////////////////////////////////////////////////////
181215
182Double Integer::pow( Integer const &power ) const {216TEMPLATE_DECL(T)
217Double INTEGER_IMPL(T)::pow( INTEGER_IMPL(T) const &power ) const {
183#ifdef ZORBA_WITH_BIG_INTEGER218#ifdef ZORBA_WITH_BIG_INTEGER
184 value_type const result( value_.pow( power.value_, 15 ) );219 value_type const result( value_.pow( power.value_, 15 ) );
185 char buf[300];220 char buf[300];
@@ -193,27 +228,32 @@
193#endif /* ZORBA_WITH_BIG_INTEGER */228#endif /* ZORBA_WITH_BIG_INTEGER */
194}229}
195230
196Integer Integer::round( Integer const &precision ) const {231TEMPLATE_DECL(T)
197 return Integer( Decimal::round( itod(), precision.itod() ) );232INTEGER_IMPL(T) INTEGER_IMPL(T)::round( IntegerImpl const &precision ) const {
233 return IntegerImpl( Decimal::round( itod(), precision.itod() ) );
198}234}
199235
200Integer Integer::roundHalfToEven( Integer const &precision ) const {236TEMPLATE_DECL(T)
201 return Integer( Decimal::roundHalfToEven( itod(), precision.itod() ) );237INTEGER_IMPL(T)
238INTEGER_IMPL(T)::roundHalfToEven( IntegerImpl const &precision ) const {
239 return IntegerImpl( Decimal::roundHalfToEven( itod(), precision.itod() ) );
202}240}
203241
204////////// miscellaneous //////////////////////////////////////////////////////242////////// miscellaneous //////////////////////////////////////////////////////
205243
206#ifndef ZORBA_WITH_BIG_INTEGER244#ifndef ZORBA_WITH_BIG_INTEGER
207Integer::value_type Integer::ftoi( MAPM const &d ) {245TEMPLATE_DECL(T)
246typename INTEGER_IMPL(T)::value_type INTEGER_IMPL(T)::ftoi( MAPM const &d ) {
208 MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() );247 MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() );
209 char *const buf = new char[ temp.exponent() + 3 ];248 char *const buf = new char[ temp.exponent() + 3 ];
210 temp.toIntegerString( buf );249 temp.toIntegerString( buf );
211 value_type const result( std::strtoll( buf, nullptr, 10 ) );250 value_type const result( ztd::aton<value_type>( buf ) );
212 delete[] buf;251 delete[] buf;
213 return result;252 return result;
214}253}
215254
216MAPM Integer::itod() const {255TEMPLATE_DECL(T)
256MAPM INTEGER_IMPL(T)::itod() const {
217 if ( is_long() )257 if ( is_long() )
218 return static_cast<long>( value_ );258 return static_cast<long>( value_ );
219 ztd::itoa_buf_type buf;259 ztd::itoa_buf_type buf;
@@ -222,17 +262,19 @@
222#endif /* ZORBA_WITH_BIG_INTEGER */262#endif /* ZORBA_WITH_BIG_INTEGER */
223263
224#ifdef ZORBA_WITH_BIG_INTEGER264#ifdef ZORBA_WITH_BIG_INTEGER
225uint32_t Integer::hash() const {265uint32_t IntegerImpl::hash() const {
226 return Decimal::hash( value_ );266 return Decimal::hash( value_ );
227}267}
228#endif /* ZORBA_WITH_BIG_INTEGER */268#endif /* ZORBA_WITH_BIG_INTEGER */
229269
230Integer const& Integer::one() {270TEMPLATE_DECL(T)
231 static Integer const i(1);271INTEGER_IMPL(T) const& INTEGER_IMPL(T)::one() {
272 static INTEGER_IMPL(T) const i(1);
232 return i;273 return i;
233}274}
234275
235zstring Integer::toString() const {276TEMPLATE_DECL(T)
277zstring INTEGER_IMPL(T)::toString() const {
236#ifdef ZORBA_WITH_BIG_INTEGER278#ifdef ZORBA_WITH_BIG_INTEGER
237 char *const buf = new char[ value_.exponent() + 3 ];279 char *const buf = new char[ value_.exponent() + 3 ];
238 value_.toIntegerString( buf );280 value_.toIntegerString( buf );
@@ -245,12 +287,18 @@
245#endif /* ZORBA_WITH_BIG_INTEGER */287#endif /* ZORBA_WITH_BIG_INTEGER */
246}288}
247289
248Integer const& Integer::zero() {290TEMPLATE_DECL(T)
249 static Integer const i(0);291INTEGER_IMPL(T) const& INTEGER_IMPL(T)::zero() {
292 static INTEGER_IMPL(T) const i(0);
250 return i;293 return i;
251}294}
252295
253///////////////////////////////////////////////////////////////////////////////296///////////////////////////////////////////////////////////////////////////////
254297
298#ifndef ZORBA_WITH_BIG_INTEGER
299template class IntegerImpl<long long>;
300template class IntegerImpl<unsigned long long>;
301#endif /* ZORBA_WITH_BIG_INTEGER */
302
255} // namespace zorba303} // namespace zorba
256/* vim:set et sw=2 ts=2: */304/* vim:set et sw=2 ts=2: */
257305
=== modified file 'src/zorbatypes/integer.h'
--- src/zorbatypes/integer.h 2011-06-29 20:31:44 +0000
+++ src/zorbatypes/integer.h 2012-02-28 18:23:19 +0000
@@ -24,6 +24,7 @@
24#include <zorba/config.h>24#include <zorba/config.h>
25#include "common/common.h"25#include "common/common.h"
2626
27#include "util/stl_util.h"
27#include "zorbaserialization/archiver.h"28#include "zorbaserialization/archiver.h"
28#include "zorbaserialization/zorba_class_serializer.h"29#include "zorbaserialization/zorba_class_serializer.h"
2930
@@ -32,39 +33,53 @@
32#include "zorbatypes_decl.h"33#include "zorbatypes_decl.h"
33#include "zstring.h"34#include "zstring.h"
3435
36#ifdef ZORBA_WITH_BIG_INTEGER
37# define TEMPLATE_DECL(T) /* nothing */
38# define INTEGER_IMPL(T) IntegerImpl
39#else
40# define TEMPLATE_DECL(T) template<typename T>
41# define INTEGER_IMPL(T) IntegerImpl<T>
42#endif /* ZORBA_WITH_BIG_INTEGER */
43#define INTEGER_IMPL_LL INTEGER_IMPL(long long)
44#define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long)
45
35namespace zorba {46namespace zorba {
3647
37class Integer;48TEMPLATE_DECL(T)
49class IntegerImpl;
50
38namespace serialization {51namespace serialization {
39 void operator&(serialization::Archiver&, zorba::Integer&);52 TEMPLATE_DECL(T) void operator&( Archiver&, INTEGER_IMPL(T)& );
40}53}
4154
42///////////////////////////////////////////////////////////////////////////////55///////////////////////////////////////////////////////////////////////////////
4356
44// exported for testing only57TEMPLATE_DECL(IntType)
45class ZORBA_DLL_PUBLIC Integer {58class IntegerImpl {
46public:59public:
4760
48 ////////// constructors /////////////////////////////////////////////////////61 ////////// constructors /////////////////////////////////////////////////////
4962
50 Integer( char c );63 IntegerImpl( char c );
51 Integer( signed char c );64 IntegerImpl( signed char c );
52 Integer( short n );65 IntegerImpl( short n );
53 Integer( int n = 0 );66 IntegerImpl( int n = 0 );
54 Integer( long n );67 IntegerImpl( long n );
55 Integer( long long n );68 IntegerImpl( long long n );
56 Integer( unsigned char c );69 IntegerImpl( unsigned char c );
57 Integer( unsigned short n );70 IntegerImpl( unsigned short n );
58 Integer( unsigned int n );71 IntegerImpl( unsigned int n );
59 Integer( unsigned long n );72 IntegerImpl( unsigned long n );
60 Integer( unsigned long long n );73 IntegerImpl( unsigned long long n );
61 Integer( float n );74 IntegerImpl( float n );
62 Integer( double n );75 IntegerImpl( double n );
63 Integer( Decimal const &d );76 IntegerImpl( Decimal const &d );
64 Integer( Integer const &i );77
78 TEMPLATE_DECL(U)
79 IntegerImpl( INTEGER_IMPL(U) const &i );
6580
66 /**81 /**
67 * Constructs an %Integer from a C string.82 * Constructs an %IntegerImpl from a C string.
68 *83 *
69 * @param s The null-terminated C string to parse. Leading and trailing84 * @param s The null-terminated C string to parse. Leading and trailing
70 * whitespace is ignored.85 * whitespace is ignored.
@@ -73,115 +88,110 @@
73 * or overflows the smallest or largest representable integer (only when not88 * or overflows the smallest or largest representable integer (only when not
74 * compiled with ZORBA_WITH_BIG_INTEGER).89 * compiled with ZORBA_WITH_BIG_INTEGER).
75 */90 */
76 Integer( char const *s );91 IntegerImpl( char const *s );
7792
78 /**93 /**
79 * Constructs an %Integer from a Double.94 * Constructs an %IntegerImpl from a Double.
80 *95 *
81 * @param d The Double.96 * @param d The Double.
82 * @throw std::invalid_argument if \a d is not finite.97 * @throw std::invalid_argument if \a d is not finite.
83 */98 */
84 Integer( Double const &d );99 IntegerImpl( Double const &d );
85100
86 /**101 /**
87 * Constructs an %Integer from a Float.102 * Constructs an %IntegerImpl from a Float.
88 *103 *
89 * @param f The Float.104 * @param f The Float.
90 * @throw std::invalid_argument if \a f is not finite.105 * @throw std::invalid_argument if \a f is not finite.
91 */106 */
92 Integer( Float const &f );107 IntegerImpl( Float const &f );
93108
94 ////////// assignment operators /////////////////////////////////////////////109 ////////// assignment operators /////////////////////////////////////////////
95110
96 Integer& operator=( char c );111 IntegerImpl& operator=( char c );
97 Integer& operator=( signed char c );112 IntegerImpl& operator=( signed char c );
98 Integer& operator=( short n );113 IntegerImpl& operator=( short n );
99 Integer& operator=( int n );114 IntegerImpl& operator=( int n );
100 Integer& operator=( long n );115 IntegerImpl& operator=( long n );
101 Integer& operator=( long long n );116 IntegerImpl& operator=( long long n );
102 Integer& operator=( unsigned char c );117 IntegerImpl& operator=( unsigned char c );
103 Integer& operator=( unsigned short n );118 IntegerImpl& operator=( unsigned short n );
104 Integer& operator=( unsigned int n );119 IntegerImpl& operator=( unsigned int n );
105 Integer& operator=( unsigned long n );120 IntegerImpl& operator=( unsigned long n );
106 Integer& operator=( unsigned long long n );121 IntegerImpl& operator=( unsigned long long n );
107 Integer& operator=( float n );122 IntegerImpl& operator=( float n );
108 Integer& operator=( double n );123 IntegerImpl& operator=( double n );
109 Integer& operator=( char const *s );124 IntegerImpl& operator=( char const *s );
110 Integer& operator=( Decimal const &d );125 IntegerImpl& operator=( Decimal const &d );
111 Integer& operator=( Double const &d );126 IntegerImpl& operator=( Double const &d );
112 Integer& operator=( Float const &f );127 IntegerImpl& operator=( Float const &f );
113 Integer& operator=( Integer const &i );128
129 TEMPLATE_DECL(U)
130 IntegerImpl& operator=( INTEGER_IMPL(U) const &i );
114131
115 ////////// arithmetic operators /////////////////////////////////////////////132 ////////// arithmetic operators /////////////////////////////////////////////
116133
117 friend Integer operator+( Integer const &i, Integer const &j );134#define ZORBA_INTEGER_OP(OP) \
118 friend Integer operator-( Integer const &i, Integer const &j );135 TEMPLATE_DECL(T) friend \
119 friend Integer operator*( Integer const &i, Integer const &j );136 INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const&, \
120 friend Integer operator/( Integer const &i, Integer const &j );137 INTEGER_IMPL(T) const& ); \
121 friend Integer operator%( Integer const &i, Integer const &j );138 TEMPLATE_DECL(T) friend \
122139 Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \
123 friend Decimal operator+( Integer const &i, Decimal const &d );140 TEMPLATE_DECL(T) friend \
124 friend Decimal operator-( Integer const &i, Decimal const &d );141 Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& )
125 friend Decimal operator*( Integer const &i, Decimal const &d );142
126 friend Decimal operator/( Integer const &i, Decimal const &d );143 ZORBA_INTEGER_OP(+);
127 friend Decimal operator%( Integer const &i, Decimal const &d );144 ZORBA_INTEGER_OP(-);
128145 ZORBA_INTEGER_OP(*);
129 friend Decimal operator+( Decimal const &d, Integer const &i );146 ZORBA_INTEGER_OP(/);
130 friend Decimal operator-( Decimal const &d, Integer const &i );147 ZORBA_INTEGER_OP(%);
131 friend Decimal operator*( Decimal const &d, Integer const &i );148#undef ZORBA_INTEGER_OP
132 friend Decimal operator/( Decimal const &d, Integer const &i );149
133 friend Decimal operator%( Decimal const &d, Integer const &i );150 IntegerImpl& operator+=( IntegerImpl const& );
134151 IntegerImpl& operator-=( IntegerImpl const& );
135 Integer& operator+=( Integer const &i );152 IntegerImpl& operator*=( IntegerImpl const& );
136 Integer& operator-=( Integer const &i );153 IntegerImpl& operator/=( IntegerImpl const& );
137 Integer& operator*=( Integer const &i );154 IntegerImpl& operator%=( IntegerImpl const& );
138 Integer& operator/=( Integer const &i );155
139 Integer& operator%=( Integer const &i );156 IntegerImpl operator-() const;
140157
141 Integer operator-() const;158 IntegerImpl& operator++();
142159 IntegerImpl operator++(int);
143 Integer& operator++();160 IntegerImpl& operator--();
144 Integer operator++(int);161 IntegerImpl operator--(int);
145 Integer& operator--();
146 Integer operator--(int);
147162
148 ////////// relational operators /////////////////////////////////////////////163 ////////// relational operators /////////////////////////////////////////////
149164
150 friend bool operator==( Integer const &i, Integer const &j );165#define ZORBA_INTEGER_OP(OP) \
151 friend bool operator!=( Integer const &i, Integer const &j );166 TEMPLATE_DECL(T) friend \
152 friend bool operator< ( Integer const &i, Integer const &j );167 bool operator OP( INTEGER_IMPL(T) const&, INTEGER_IMPL(T) const& ); \
153 friend bool operator<=( Integer const &i, Integer const &j );168 TEMPLATE_DECL(T) friend \
154 friend bool operator> ( Integer const &i, Integer const &j );169 bool operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \
155 friend bool operator>=( Integer const &i, Integer const &j );170 TEMPLATE_DECL(T) friend \
156171 bool operator OP( Decimal const&, INTEGER_IMPL(T) const& )
157 friend bool operator==( Integer const &i, Decimal const &d );172
158 friend bool operator!=( Integer const &i, Decimal const &d );173 ZORBA_INTEGER_OP(==);
159 friend bool operator< ( Integer const &i, Decimal const &d );174 ZORBA_INTEGER_OP(!=);
160 friend bool operator<=( Integer const &i, Decimal const &d );175 ZORBA_INTEGER_OP(< );
161 friend bool operator> ( Integer const &i, Decimal const &d );176 ZORBA_INTEGER_OP(<=);
162 friend bool operator>=( Integer const &i, Decimal const &d );177 ZORBA_INTEGER_OP(> );
163178 ZORBA_INTEGER_OP(>=);
164 friend bool operator==( Decimal const &d, Integer const &i );179#undef ZORBA_INTEGER_OP
165 friend bool operator!=( Decimal const &d, Integer const &i );
166 friend bool operator< ( Decimal const &d, Integer const &i );
167 friend bool operator<=( Decimal const &d, Integer const &i );
168 friend bool operator> ( Decimal const &d, Integer const &i );
169 friend bool operator>=( Decimal const &d, Integer const &i );
170180
171 ////////// math functions ///////////////////////////////////////////////////181 ////////// math functions ///////////////////////////////////////////////////
172182
173 Double pow( Integer const &power ) const;183 Double pow( IntegerImpl const &power ) const;
174 Integer round( Integer const &precision ) const;184 IntegerImpl round( IntegerImpl const &precision ) const;
175 Integer roundHalfToEven( Integer const &precision ) const;185 IntegerImpl roundHalfToEven( IntegerImpl const &precision ) const;
176186
177 ////////// miscellaneous ////////////////////////////////////////////////////187 ////////// miscellaneous ////////////////////////////////////////////////////
178188
179 int compare( Integer const &i ) const;189 int compare( IntegerImpl const& ) const;
180 uint32_t hash() const;190 uint32_t hash() const;
181 int sign() const;191 int sign() const;
182 zstring toString() const;192 zstring toString() const;
183 static Integer const& one();193 static IntegerImpl const& one();
184 static Integer const& zero();194 static IntegerImpl const& zero();
185195
186 /////////////////////////////////////////////////////////////////////////////196 /////////////////////////////////////////////////////////////////////////////
187197
@@ -189,13 +199,13 @@
189#ifdef ZORBA_WITH_BIG_INTEGER199#ifdef ZORBA_WITH_BIG_INTEGER
190 typedef MAPM value_type;200 typedef MAPM value_type;
191#else201#else
192 typedef long long value_type;202 typedef IntType value_type;
193#endif /* ZORBA_WITH_BIG_INTEGER */203#endif /* ZORBA_WITH_BIG_INTEGER */
194204
195 value_type value_;205 value_type value_;
196206
197#ifdef ZORBA_WITH_BIG_INTEGER207#ifdef ZORBA_WITH_BIG_INTEGER
198 Integer( value_type const &v ) : value_( v ) { }208 IntegerImpl( value_type const &v ) : value_( v ) { }
199#endif /* ZORBA_WITH_BIG_INTEGER */209#endif /* ZORBA_WITH_BIG_INTEGER */
200210
201 static value_type ftoi( double d ) {211 static value_type ftoi( double d ) {
@@ -227,58 +237,96 @@
227 friend class Decimal;237 friend class Decimal;
228 template<typename T> friend class FloatImpl;238 template<typename T> friend class FloatImpl;
229239
230 friend xs_int to_xs_int( Integer const& );240#ifndef ZORBA_WITH_BIG_INTEGER
231 friend xs_long to_xs_long( Integer const& );241 template<typename U> friend class IntegerImpl;
232 friend xs_unsignedInt to_xs_unsignedInt( Integer const& );242#endif /* ZORBA_WITH_BIG_INTEGER */
233 friend xs_unsignedLong to_xs_unsignedLong( Integer const& );243
234244 friend xs_int to_xs_int( INTEGER_IMPL_LL const& );
235 friend void serialization::operator&(serialization::Archiver&, Integer&);245 friend xs_long to_xs_long( INTEGER_IMPL_LL const& );
246 friend xs_unsignedInt to_xs_unsignedInt( INTEGER_IMPL_LL const& );
247 friend xs_unsignedLong to_xs_unsignedLong( INTEGER_IMPL_LL const& );
248
249 TEMPLATE_DECL(T) friend
250 void serialization::operator&( serialization::Archiver&, INTEGER_IMPL(T)& );
236};251};
237252
253typedef INTEGER_IMPL_LL Integer;
254typedef INTEGER_IMPL_ULL UInteger;
255
238////////// constructors ///////////////////////////////////////////////////////256////////// constructors ///////////////////////////////////////////////////////
239257
240inline Integer::Integer( char c ) : value_( static_cast<long>( c ) ) {258TEMPLATE_DECL(T)
241}259inline INTEGER_IMPL(T)::IntegerImpl( char c ) :
242260 value_( static_cast<long>( c ) )
243inline Integer::Integer( signed char c ) : value_( static_cast<long>( c ) ) {261{
244}262}
245263
246inline Integer::Integer( short n ) : value_( static_cast<long>( n ) ) {264TEMPLATE_DECL(T)
247}265inline INTEGER_IMPL(T)::IntegerImpl( signed char c ) :
248266 value_( static_cast<long>( c ) )
249inline Integer::Integer( int n ) : value_( static_cast<long>( n ) ) {267{
250}268}
251269
252inline Integer::Integer( long n ) : value_( n ) {270TEMPLATE_DECL(T)
253}271inline INTEGER_IMPL(T)::IntegerImpl( short n ) :
254272 value_( static_cast<long>( n ) )
255#ifndef ZORBA_WITH_BIG_INTEGER273{
256inline Integer::Integer( long long n ) : value_( n ) {274}
257}275
258#endif /* ZORBA_WITH_BIG_INTEGER */276TEMPLATE_DECL(T)
259277inline INTEGER_IMPL(T)::IntegerImpl( int n ) :
260inline Integer::Integer( unsigned char c ) : value_( static_cast<long>( c ) ) {278 value_( static_cast<long>( n ) )
261}279{
262280}
263inline Integer::Integer( unsigned short n ) : value_( static_cast<long>( n ) ) {281
264}282TEMPLATE_DECL(T)
265283inline INTEGER_IMPL(T)::IntegerImpl( long n ) :
266inline Integer::Integer( unsigned int n ) : value_( static_cast<long>( n ) ) {284 value_( n )
267}285{
268286}
269#ifndef ZORBA_WITH_BIG_INTEGER287
270inline Integer::Integer( unsigned long n ) :288#ifndef ZORBA_WITH_BIG_INTEGER
271 value_( static_cast<value_type>( n ) )289TEMPLATE_DECL(T)
272{290inline INTEGER_IMPL(T)::IntegerImpl( long long n ) :
273}291 value_( n )
274292{
275inline Integer::Integer( unsigned long long n ) :293}
276 value_( static_cast<value_type>( n ) )294#endif /* ZORBA_WITH_BIG_INTEGER */
277{295
278}296TEMPLATE_DECL(T)
279#endif /* ZORBA_WITH_BIG_INTEGER */297inline INTEGER_IMPL(T)::IntegerImpl( unsigned char c ) :
280298 value_( static_cast<long>( c ) )
281inline Integer::Integer( float n ) :299{
300}
301
302TEMPLATE_DECL(T)
303inline INTEGER_IMPL(T)::IntegerImpl( unsigned short n ) :
304 value_( static_cast<long>( n ) )
305{
306}
307
308TEMPLATE_DECL(T)
309inline INTEGER_IMPL(T)::IntegerImpl( unsigned int n ) :
310 value_( static_cast<long>( n ) )
311{
312}
313
314#ifndef ZORBA_WITH_BIG_INTEGER
315TEMPLATE_DECL(T)
316inline INTEGER_IMPL(T)::IntegerImpl( unsigned long n ) :
317 value_( static_cast<value_type>( n ) )
318{
319}
320
321TEMPLATE_DECL(T)
322inline INTEGER_IMPL(T)::IntegerImpl( unsigned long long n ) :
323 value_( static_cast<value_type>( n ) )
324{
325}
326#endif /* ZORBA_WITH_BIG_INTEGER */
327
328TEMPLATE_DECL(T)
329inline INTEGER_IMPL(T)::IntegerImpl( float n ) :
282#ifdef ZORBA_WITH_BIG_INTEGER330#ifdef ZORBA_WITH_BIG_INTEGER
283 value_( static_cast<double>( n ) )331 value_( static_cast<double>( n ) )
284#else332#else
@@ -287,7 +335,8 @@
287{335{
288}336}
289337
290inline Integer::Integer( double n ) :338TEMPLATE_DECL(T)
339inline INTEGER_IMPL(T)::IntegerImpl( double n ) :
291#ifdef ZORBA_WITH_BIG_INTEGER340#ifdef ZORBA_WITH_BIG_INTEGER
292 value_( n )341 value_( n )
293#else342#else
@@ -296,240 +345,252 @@
296{345{
297}346}
298347
299inline Integer::Integer( char const *s ) {348TEMPLATE_DECL(T)
349inline INTEGER_IMPL(T)::IntegerImpl( char const *s ) {
300 parse( s );350 parse( s );
301}351}
302352
303inline Integer::Integer( Integer const &i ) :353TEMPLATE_DECL(T)
354TEMPLATE_DECL(U)
355inline INTEGER_IMPL(T)::IntegerImpl( INTEGER_IMPL(U) const &i ) :
304 value_( i.value_ )356 value_( i.value_ )
305{357{
306}358}
307359
308////////// assignment operators ///////////////////////////////////////////////360////////// assignment operators ///////////////////////////////////////////////
309361
310inline Integer& Integer::operator=( char c ) {362TEMPLATE_DECL(T)
311 value_ = static_cast<long>( c );363inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char c ) {
312 return *this;364 value_ = static_cast<long>( c );
313}365 return *this;
314366}
315inline Integer& Integer::operator=( signed char c ) {367
316 value_ = static_cast<long>( c );368TEMPLATE_DECL(T)
317 return *this;369inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( signed char c ) {
318}370 value_ = static_cast<long>( c );
319371 return *this;
320inline Integer& Integer::operator=( short n ) {372}
321 value_ = static_cast<long>( n );373
322 return *this;374TEMPLATE_DECL(T)
323}375inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( short n ) {
324376 value_ = static_cast<long>( n );
325inline Integer& Integer::operator=( int n ) {377 return *this;
326 value_ = static_cast<long>( n );378}
327 return *this;379
328}380TEMPLATE_DECL(T)
329381inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( int n ) {
330inline Integer& Integer::operator=( long n ) {382 value_ = static_cast<long>( n );
331 value_ = n;383 return *this;
332 return *this;384}
333}385
334386TEMPLATE_DECL(T)
335#ifndef ZORBA_WITH_BIG_INTEGER387inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long n ) {
336inline Integer& Integer::operator=( long long n ) {388 value_ = n;
337 value_ = n;389 return *this;
338 return *this;390}
339}391
340#endif /* ZORBA_WITH_BIG_INTEGER */392#ifndef ZORBA_WITH_BIG_INTEGER
341393TEMPLATE_DECL(T)
342inline Integer& Integer::operator=( unsigned char c ) {394inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long long n ) {
343 value_ = static_cast<long>( c );395 value_ = n;
344 return *this;396 return *this;
345}397}
346398#endif /* ZORBA_WITH_BIG_INTEGER */
347inline Integer& Integer::operator=( unsigned short n ) {399
348 value_ = static_cast<long>( n );400TEMPLATE_DECL(T)
349 return *this;401inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned char c ) {
350}402 value_ = static_cast<long>( c );
351403 return *this;
352inline Integer& Integer::operator=( unsigned int n ) {404}
353 value_ = static_cast<long>( n );405
354 return *this;406TEMPLATE_DECL(T)
355}407inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned short n ) {
356408 value_ = static_cast<long>( n );
357#ifndef ZORBA_WITH_BIG_INTEGER409 return *this;
358inline Integer& Integer::operator=( unsigned long n ) {410}
359 value_ = static_cast<long>( n );411
360 return *this;412TEMPLATE_DECL(T)
361}413inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned int n ) {
362414 value_ = static_cast<long>( n );
363inline Integer& Integer::operator=( unsigned long long n ) {415 return *this;
364 value_ = n;416}
365 return *this;417
366}418#ifndef ZORBA_WITH_BIG_INTEGER
367#endif /* ZORBA_WITH_BIG_INTEGER */419TEMPLATE_DECL(T)
368420inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long n ) {
369inline Integer& Integer::operator=( float n ) {421 value_ = static_cast<long>( n );
370 value_ = static_cast<long>( n );422 return *this;
371 return *this;423}
372}424
373425TEMPLATE_DECL(T)
374inline Integer& Integer::operator=( double n ) {426inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long long n ) {
375 value_ = static_cast<long>( n );427 value_ = n;
376 return *this;428 return *this;
377}429}
378430#endif /* ZORBA_WITH_BIG_INTEGER */
379inline Integer& Integer::operator=( char const *s ) {431
432TEMPLATE_DECL(T)
433inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( float n ) {
434 value_ = static_cast<long>( n );
435 return *this;
436}
437
438TEMPLATE_DECL(T)
439inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( double n ) {
440 value_ = static_cast<long>( n );
441 return *this;
442}
443
444TEMPLATE_DECL(T)
445inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char const *s ) {
380 parse( s );446 parse( s );
381 return *this;447 return *this;
382}448}
383449
384inline Integer& Integer::operator=( Integer const &i ) {450TEMPLATE_DECL(T)
451TEMPLATE_DECL(U)
452inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( INTEGER_IMPL(U) const &i ) {
385 value_ = i.value_;453 value_ = i.value_;
386 return *this;454 return *this;
387}455}
388456
389////////// arithmetic operators ///////////////////////////////////////////////457////////// arithmetic operators ///////////////////////////////////////////////
390458
391inline Integer operator+( Integer const &i, Integer const &j ) {459#define ZORBA_INTEGER_OP(OP) \
392 return i.value_ + j.value_;460 TEMPLATE_DECL(T) inline \
393}461 INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const &i, \
394462 INTEGER_IMPL(T) const &j ) { \
395inline Integer operator-( Integer const &i, Integer const &j ) {463 return i.value_ OP j.value_; \
396 return i.value_ - j.value_;464 }
397}465
398466ZORBA_INTEGER_OP(+)
399inline Integer operator*( Integer const &i, Integer const &j ) {467ZORBA_INTEGER_OP(-)
400 return i.value_ * j.value_;468ZORBA_INTEGER_OP(*)
401}469ZORBA_INTEGER_OP(%)
402470#undef ZORBA_INTEGER_OP
403inline Integer operator/( Integer const &i, Integer const &j ) {471
404 return Integer::ftoi( i.value_ / j.value_ );472TEMPLATE_DECL(T) inline
405}473INTEGER_IMPL(T) operator/( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) {
406474 return INTEGER_IMPL(T)::ftoi( i.value_ / j.value_ );
407inline Integer operator%( Integer const &i, Integer const &j ) {475}
408 return i.value_ % j.value_;476
409}477#define ZORBA_INTEGER_OP(OP) \
410478 TEMPLATE_DECL(T) inline \
411inline Integer& Integer::operator+=( Integer const &i ) {479 INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator OP( IntegerImpl const &i ) { \
412 value_ += i.value_;480 value_ OP i.value_; \
413 return *this;481 return *this; \
414}482 }
415483
416inline Integer& Integer::operator-=( Integer const &i ) {484ZORBA_INTEGER_OP(+=)
417 value_ -= i.value_;485ZORBA_INTEGER_OP(-=)
418 return *this;486ZORBA_INTEGER_OP(*=)
419}487ZORBA_INTEGER_OP(%=)
420488#undef ZORBA_INTEGER_OP
421inline Integer& Integer::operator*=( Integer const &i ) {489
422 value_ *= i.value_;490TEMPLATE_DECL(T)
423 return *this;491inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator/=( IntegerImpl const &i ) {
424}
425
426inline Integer& Integer::operator/=( Integer const &i ) {
427 value_ = ftoi( value_ / i.value_ );492 value_ = ftoi( value_ / i.value_ );
428 return *this;493 return *this;
429}494}
430495
431inline Integer& Integer::operator%=( Integer const &i ) {496TEMPLATE_DECL(T)
432 value_ %= i.value_;497inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator-() const {
433 return *this;
434}
435
436inline Integer Integer::operator-() const {
437 return -value_;498 return -value_;
438}499}
439500
440inline Integer& Integer::operator++() {501TEMPLATE_DECL(T)
502inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator++() {
441 ++value_;503 ++value_;
442 return *this;504 return *this;
443}505}
444506
445inline Integer Integer::operator++(int) {507TEMPLATE_DECL(T)
446 Integer const result( *this );508inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator++(int) {
509 INTEGER_IMPL(T) const result( *this );
447 ++value_;510 ++value_;
448 return result;511 return result;
449}512}
450513
451inline Integer& Integer::operator--() {514TEMPLATE_DECL(T)
515inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator--() {
452 --value_;516 --value_;
453 return *this;517 return *this;
454}518}
455519
456inline Integer Integer::operator--(int) {520TEMPLATE_DECL(T)
457 Integer const result( *this );521inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator--(int) {
522 INTEGER_IMPL(T) const result( *this );
458 --value_;523 --value_;
459 return result;524 return result;
460}525}
461526
462////////// relational operators ///////////////////////////////////////////////527////////// relational operators ///////////////////////////////////////////////
463528
464inline bool operator==( Integer const &i, Integer const &j ) {529#define ZORBA_INTEGER_OP(OP) \
465 return i.value_ == j.value_;530 TEMPLATE_DECL(T) inline \
466}531 bool operator OP( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) { \
467532 return i.value_ OP j.value_; \
468inline bool operator!=( Integer const &i, Integer const &j ) {533 }
469 return i.value_ != j.value_;534
470}535ZORBA_INTEGER_OP(==)
471536ZORBA_INTEGER_OP(!=)
472inline bool operator<( Integer const &i, Integer const &j ) {537ZORBA_INTEGER_OP(< )
473 return i.value_ < j.value_;538ZORBA_INTEGER_OP(<=)
474}539ZORBA_INTEGER_OP(> )
475540ZORBA_INTEGER_OP(>=)
476inline bool operator<=( Integer const &i, Integer const &j ) {541#undef ZORBA_INTEGER_OP
477 return i.value_ <= j.value_;
478}
479
480inline bool operator>( Integer const &i, Integer const &j ) {
481 return i.value_ > j.value_;
482}
483
484inline bool operator>=( Integer const &i, Integer const &j ) {
485 return i.value_ >= j.value_;
486}
487542
488////////// miscellaneous //////////////////////////////////////////////////////543////////// miscellaneous //////////////////////////////////////////////////////
489544
490#ifdef ZORBA_WITH_BIG_INTEGER545#ifdef ZORBA_WITH_BIG_INTEGER
491546
492inline int Integer::compare( Integer const &i ) const {547inline int IntegerImpl::compare( IntegerImpl const &i ) const {
493 return value_.compare( i.value_ );548 return value_.compare( i.value_ );
494}549}
495550
496inline int Integer::sign() const {551inline int IntegerImpl::sign() const {
497 return value_.sign();552 return value_.sign();
498}553}
499554
500#else555#else
501556
502inline int Integer::compare( Integer const &i ) const {557template<typename IntType>
503 //558inline int IntegerImpl<IntType>::compare( IntegerImpl const &i ) const {
504 // Note that we can't return the difference directly since it will be559 return value_ < i.value_ ? -1 : value_ > i.value_ ? 1 : 0;
505 // truncated if it's ether > max(int) or < min(int) yielding a wrong result.
506 //
507 value_type const temp = value_ - i.value_;
508 return temp < 0 ? -1 : temp > 0 ? 1 : 0;
509}560}
510561
511inline uint32_t Integer::hash() const {562template<typename IntType>
563inline uint32_t IntegerImpl<IntType>::hash() const {
512 return static_cast<uint32_t>( value_ );564 return static_cast<uint32_t>( value_ );
513}565}
514566
515inline bool Integer::is_long() const {567template<typename IntType>
568inline bool IntegerImpl<IntType>::is_long() const {
516 return value_ >= std::numeric_limits<long>::min() &&569 return value_ >= std::numeric_limits<long>::min() &&
517 value_ <= std::numeric_limits<long>::max();570 value_ <= std::numeric_limits<long>::max();
518}571}
519572
520inline int Integer::sign() const {573template<typename IntType>
521 return value_ < 0 ? -1 : value_ > 0 ? 1 : 0;574inline int IntegerImpl<IntType>::sign() const {
575 return ztd::lt0( value_ ) ? -1 : value_ > 0 ? 1 : 0;
522}576}
523577
524#endif /* ZORBA_WITH_BIG_INTEGER */578#endif /* ZORBA_WITH_BIG_INTEGER */
525579
526inline std::ostream& operator<<( std::ostream &os, Integer const &i ) {580TEMPLATE_DECL(T)
581inline std::ostream& operator<<( std::ostream &os, INTEGER_IMPL(T) const &i ) {
527 return os << i.toString();582 return os << i.toString();
528}583}
529584
530///////////////////////////////////////////////////////////////////////////////585///////////////////////////////////////////////////////////////////////////////
531586
532} // namespace zorba587} // namespace zorba
588
589#undef TEMPLATE_DECL
590#undef INTEGER_IMPL
591#undef INTEGER_IMPL_LL
592#undef INTEGER_IMPL_ULL
593
533#endif // ZORBA_INTEGER_H594#endif // ZORBA_INTEGER_H
534/*595/*
535 * Local variables:596 * Local variables:
536597
=== modified file 'src/zorbatypes/numconversions.cpp'
--- src/zorbatypes/numconversions.cpp 2011-06-29 20:31:44 +0000
+++ src/zorbatypes/numconversions.cpp 2012-02-28 18:23:19 +0000
@@ -33,7 +33,7 @@
33 zstring const temp( i.toString() );33 zstring const temp( i.toString() );
34 return ztd::aton<xs_int>( temp.c_str() );34 return ztd::aton<xs_int>( temp.c_str() );
35#else35#else
36 return static_cast<xs_int>(i.value_);36 return static_cast<xs_int>( i.value_ );
37#endif /* ZORBA_WITH_BIG_INTEGER */37#endif /* ZORBA_WITH_BIG_INTEGER */
38}38}
3939
@@ -56,6 +56,13 @@
56#endif /* ZORBA_WITH_BIG_INTEGER */56#endif /* ZORBA_WITH_BIG_INTEGER */
57}57}
5858
59#ifndef ZORBA_WITH_BIG_INTEGER
60xs_long to_xs_long( xs_nonNegativeInteger const &i ) {
61 zstring const temp( i.toString() );
62 return ztd::aton<xs_long>( temp.c_str() );
63}
64#endif /* ZORBA_WITH_BIG_INTEGER */
65
59xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) {66xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) {
60#ifdef ZORBA_WITH_BIG_INTEGER67#ifdef ZORBA_WITH_BIG_INTEGER
61 zstring const temp( i.toString() );68 zstring const temp( i.toString() );
6269
=== modified file 'src/zorbatypes/numconversions.h'
--- src/zorbatypes/numconversions.h 2011-06-29 20:31:44 +0000
+++ src/zorbatypes/numconversions.h 2012-02-28 18:23:19 +0000
@@ -64,6 +64,10 @@
64 */64 */
65xs_long to_xs_long( xs_integer const &i );65xs_long to_xs_long( xs_integer const &i );
6666
67#ifndef ZORBA_WITH_BIG_INTEGER
68xs_long to_xs_long( xs_nonNegativeInteger const &i );
69#endif /* ZORBA_WITH_BIG_INTEGER */
70
67/**71/**
68 * Converts an \c xs:integer value to an \c xs:unsignedInt.72 * Converts an \c xs:integer value to an \c xs:unsignedInt.
69 *73 *
7074
=== modified file 'src/zorbatypes/schema_types.h'
--- src/zorbatypes/schema_types.h 2011-06-24 13:38:42 +0000
+++ src/zorbatypes/schema_types.h 2012-02-28 18:23:19 +0000
@@ -46,8 +46,12 @@
46typedef DateTime xs_gYearMonth;46typedef DateTime xs_gYearMonth;
47typedef Base16 xs_hexBinary;47typedef Base16 xs_hexBinary;
48typedef Integer xs_integer;48typedef Integer xs_integer;
49typedef Integer xs_negativeInteger; // this isn't quite right
50typedef UInteger xs_nonNegativeInteger; // i.e., "unsigned"
51typedef Integer xs_nonPositiveInteger; // this isn't quite right either
52typedef UInteger xs_positiveInteger;
49typedef DateTime xs_time;53typedef DateTime xs_time;
50typedef Integer xs_uinteger;54typedef UInteger xs_uinteger; // old, deprecated name
51typedef Duration xs_yearMonthDuration;55typedef Duration xs_yearMonthDuration;
5256
53///////////////////////////////////////////////////////////////////////////////57///////////////////////////////////////////////////////////////////////////////
5458
=== modified file 'src/zorbatypes/zorbatypes_decl.h'
--- src/zorbatypes/zorbatypes_decl.h 2011-06-14 17:26:33 +0000
+++ src/zorbatypes/zorbatypes_decl.h 2012-02-28 18:23:19 +0000
@@ -18,11 +18,23 @@
18#ifndef ZORBA_ZORBATYPES_DECL_H18#ifndef ZORBA_ZORBATYPES_DECL_H
19#define ZORBA_ZORBATYPES_DECL_H19#define ZORBA_ZORBATYPES_DECL_H
2020
21#include <zorba/config.h>
22
21namespace zorba 23namespace zorba
22{24{
23 /* numerics */25 /* numerics */
24 class Decimal;26 class Decimal;
25 class Integer;27
28#ifdef ZORBA_WITH_BIG_INTEGER
29 class IntegerImpl;
30 typedef IntegerImpl Integer;
31 typedef IntegerImpl UInteger;
32#else
33 template<typename T> class IntegerImpl;
34 typedef IntegerImpl<long long> Integer;
35 typedef IntegerImpl<unsigned long long> UInteger;
36#endif /* ZORBA_WITH_BIG_INTEGER */
37
26 template<typename T> class FloatImpl;38 template<typename T> class FloatImpl;
27 typedef FloatImpl<double> Double;39 typedef FloatImpl<double> Double;
28 typedef FloatImpl<float> Float;40 typedef FloatImpl<float> Float;
2941
=== modified file 'test/rbkt/Queries/CMakeLists.txt'
--- test/rbkt/Queries/CMakeLists.txt 2012-02-22 02:41:05 +0000
+++ test/rbkt/Queries/CMakeLists.txt 2012-02-28 18:23:19 +0000
@@ -235,15 +235,7 @@
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)
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)
237237
238 IF(NOT ZORBA_WITH_BIG_INTEGER)238 IF (ZORBA_TEST_XQUERYX)
239 # These tests fail due to integer overflow.
240 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 3323548)
241 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 3323548)
242 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 3323548)
243 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 3323548)
244 ENDIF(NOT ZORBA_WITH_BIG_INTEGER)
245
246 IF(ZORBA_TEST_XQUERYX)
247239
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)
249 241
@@ -263,12 +255,22 @@
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)
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)
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)
266 ENDIF(ZORBA_TEST_XQUERYX)258 ENDIF (ZORBA_TEST_XQUERYX)
267 259
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.
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=12542261 #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
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)
271263
264 IF (NOT ZORBA_WITH_BIG_INTEGER)
265 # These test will never pass without big integers beause the integers used
266 # in the queries exceed a 63-bit signed integer.
267 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 867059)
268 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 867059)
269 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 867059)
270 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 867059)
271 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 867059)
272 ENDIF (NOT ZORBA_WITH_BIG_INTEGER)
273
272ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS)274ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS)
273275
274276
275277
=== modified file 'test/rbkt/Queries/w3c_known_failures.txt'
--- test/rbkt/Queries/w3c_known_failures.txt 2012-02-02 09:56:52 +0000
+++ test/rbkt/Queries/w3c_known_failures.txt 2012-02-28 18:23:19 +0000
@@ -77,4 +77,14 @@
77test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch1077test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch10
78test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch1178test/rbkt/w3c_testsuite/XQuery/Functions/AllStringFunc/MatchStringFunc/MatchesFunc/caselessmatch11
79test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-2279test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-22
8080test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-02
81test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-WhereExpr001
82test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/statictyping-24
83test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01
84test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001
85test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context
86test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22
87test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1
88test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2
89test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1
90test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2

Subscribers

People subscribed via source and target branches