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

Proposed by Paul J. Lucas
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug-867059
Merge into: lp:zorba
Diff against target: 3492 lines (+1442/-690)
39 files modified
NOTICE.txt (+1/-1)
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 (+192/-27)
src/store/naive/atomic_items.h (+103/-47)
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 (+252/-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/-12)
test/rbkt/Queries/w3c_known_failures.txt (+3/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-867059
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Pending
Matthias Brantner Pending
Review via email: mp+80848@code.launchpad.net

This proposal has been superseded by a proposal from 2011-11-29.

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 :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

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 :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in test/rbkt/Queries/CMakeLists.txt

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

Merge from trunk.

10515. By Paul J. Lucas

Merge from trunk.

10516. By Paul J. Lucas

Merge from trunk.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NOTICE.txt'
--- NOTICE.txt 2011-10-21 08:09:17 +0000
+++ NOTICE.txt 2011-11-29 00:43:26 +0000
@@ -1,5 +1,5 @@
1-----------1-----------
2Zorba 2.1.02Zorba 2.0.1
3-----------3-----------
44
5(Note: This file is generated automatically from NOTICE.xml.5(Note: This file is generated automatically from NOTICE.xml.
66
=== modified file 'doc/zorba/build.dox'
--- doc/zorba/build.dox 2011-09-23 10:54:01 +0000
+++ doc/zorba/build.dox 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-07-22 07:23:17 +0000
+++ src/api/itemfactoryimpl.cpp 2011-11-29 00:43:26 +0000
@@ -269,7 +269,7 @@
269ItemFactoryImpl::createInteger(long long aInteger)269ItemFactoryImpl::createInteger(long long aInteger)
270{270{
271 store::Item_t lItem;271 store::Item_t lItem;
272 Integer const lInteger(aInteger);272 xs_integer const lInteger(aInteger);
273 theItemFactory->createInteger(lItem, lInteger);273 theItemFactory->createInteger(lItem, lInteger);
274 return &*lItem;274 return &*lItem;
275}275}
@@ -281,7 +281,7 @@
281 zstring const &lString = Unmarshaller::getInternalString( aInteger );281 zstring const &lString = Unmarshaller::getInternalString( aInteger );
282 store::Item_t lItem;282 store::Item_t lItem;
283 try {283 try {
284 Integer const lInteger( lString.c_str() );284 xs_integer const lInteger( lString.c_str() );
285 theItemFactory->createInteger(lItem, lInteger);285 theItemFactory->createInteger(lItem, lInteger);
286 }286 }
287 catch ( std::exception const& ) {287 catch ( std::exception const& ) {
@@ -447,7 +447,7 @@
447{447{
448 store::Item_t lItem;448 store::Item_t lItem;
449 if (aValue < 0) {449 if (aValue < 0) {
450 Integer const lInteger(aValue);450 xs_integer const lInteger(aValue);
451 theItemFactory->createNegativeInteger(lItem, lInteger);451 theItemFactory->createNegativeInteger(lItem, lInteger);
452 }452 }
453 return &*lItem;453 return &*lItem;
@@ -457,7 +457,7 @@
457Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue )457Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue )
458{458{
459 store::Item_t lItem;459 store::Item_t lItem;
460 Integer lInteger(aValue);460 xs_nonNegativeInteger lInteger(aValue);
461 theItemFactory->createNonNegativeInteger(lItem, lInteger);461 theItemFactory->createNonNegativeInteger(lItem, lInteger);
462 return &*lItem;462 return &*lItem;
463}463}
@@ -467,7 +467,7 @@
467{467{
468 store::Item_t lItem;468 store::Item_t lItem;
469 if (aValue < 0) {469 if (aValue < 0) {
470 Integer const lInteger(aValue);470 xs_integer const lInteger(aValue);
471 theItemFactory->createNonPositiveInteger(lItem, lInteger);471 theItemFactory->createNonPositiveInteger(lItem, lInteger);
472 }472 }
473 return &*lItem;473 return &*lItem;
@@ -477,7 +477,7 @@
477Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue )477Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue )
478{478{
479 store::Item_t lItem;479 store::Item_t lItem;
480 Integer lInteger(aValue);480 xs_nonNegativeInteger lInteger(aValue);
481 theItemFactory->createPositiveInteger(lItem, lInteger);481 theItemFactory->createPositiveInteger(lItem, lInteger);
482 return &*lItem;482 return &*lItem;
483}483}
484484
=== modified file 'src/common/shared_types.h'
--- src/common/shared_types.h 2011-09-12 22:42:28 +0000
+++ src/common/shared_types.h 2011-11-29 00:43:26 +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 2011-09-02 20:43:46 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp 2011-11-29 00:43:26 +0000
@@ -950,7 +950,7 @@
950 (a) op is eq or =, and950 (a) op is eq or =, and
951 (b1) posExpr is an integer literal with value >= 1, or951 (b1) posExpr is an integer literal with value >= 1, or
952 (b2) the flwor expr has no sequential clauses and posExpr is an expression 952 (b2) the flwor expr has no sequential clauses and posExpr is an expression
953 whose type is xs:Integer? and which does not reference the for var 953 whose type is xs:integer? and which does not reference the for var
954 associated with posVar nor any other vars that are defined after that 954 associated with posVar nor any other vars that are defined after that
955 for var.955 for var.
956956
957957
=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
--- src/compiler/rewriter/rules/fold_rules.cpp 2011-11-22 13:28:23 +0000
+++ src/compiler/rewriter/rules/fold_rules.cpp 2011-11-29 00:43:26 +0000
@@ -754,7 +754,7 @@
754 {754 {
755 return new const_expr(fo->get_sctx(),755 return new const_expr(fo->get_sctx(),
756 fo->get_loc(),756 fo->get_loc(),
757 Integer(type_cnt));757 xs_integer(type_cnt));
758 }758 }
759 else if (fkind == FunctionConsts::FN_EMPTY_1)759 else if (fkind == FunctionConsts::FN_EMPTY_1)
760 {760 {
761761
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2011-11-29 00:16:24 +0000
+++ src/compiler/translator/translator.cpp 2011-11-29 00:43:26 +0000
@@ -9666,8 +9666,8 @@
9666 {9666 {
9667 case FunctionConsts::FN_HEAD_1:9667 case FunctionConsts::FN_HEAD_1:
9668 {9668 {
9669 arguments.push_back(new const_expr(theRootSctx, loc, Integer(1)));9669 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1)));
9670 arguments.push_back(new const_expr(theRootSctx, loc, Integer(1)));9670 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1)));
9671 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);9671 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);
9672 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);9672 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);
9673 normalize_fo(foExpr);9673 normalize_fo(foExpr);
@@ -9676,7 +9676,7 @@
9676 }9676 }
9677 case FunctionConsts::FN_TAIL_1:9677 case FunctionConsts::FN_TAIL_1:
9678 {9678 {
9679 arguments.push_back(new const_expr(theRootSctx, loc, Integer(2)));9679 arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(2)));
9680 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);9680 function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);
9681 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);9681 fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments);
9682 normalize_fo(foExpr);9682 normalize_fo(foExpr);
96839683
=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp 2011-08-08 17:46:14 +0000
+++ src/runtime/booleans/BooleanImpl.cpp 2011-11-29 00:43:26 +0000
@@ -852,7 +852,7 @@
852 {852 {
853 // There are 2 cases when two types are comparable without one being a853 // There are 2 cases when two types are comparable without one being a
854 // subtype of the other: (a) they belong to different branches under of854 // subtype of the other: (a) they belong to different branches under of
855 // the type-inheritance subtree rooted at xs:Integer, (b) they belong to855 // the type-inheritance subtree rooted at xs:integer, (b) they belong to
856 // different branches under of the type-inheritance subtree rooted at856 // different branches under of the type-inheritance subtree rooted at
857 // xs::duration (i.e. one is xs:yearMonthDuration and the other is857 // xs::duration (i.e. one is xs:yearMonthDuration and the other is
858 // xs:dayTimeDuration).858 // xs:dayTimeDuration).
@@ -949,7 +949,7 @@
949 {949 {
950 // There is 1 case when two types are order-comparable without one being a950 // There is 1 case when two types are order-comparable without one being a
951 // subtype of the other: they belong to different branches under of the951 // subtype of the other: they belong to different branches under of the
952 // type-inheritance subtree rooted at xs:Integer.952 // type-inheritance subtree rooted at xs:integer.
953 if (TypeOps::is_subtype(tm, *type0, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE) &&953 if (TypeOps::is_subtype(tm, *type0, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE) &&
954 TypeOps::is_subtype(tm, *type1, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE))954 TypeOps::is_subtype(tm, *type1, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE))
955 {955 {
956956
=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp 2011-11-22 13:42:18 +0000
+++ src/runtime/core/flwor_iterator.cpp 2011-11-29 00:43:26 +0000
@@ -1215,7 +1215,7 @@
1215 if (!flc.thePosVarRefs.empty())1215 if (!flc.thePosVarRefs.empty())
1216 {1216 {
1217 store::Item_t posItem;1217 store::Item_t posItem;
1218 GENV_ITEMFACTORY->createInteger(posItem, Integer(bindingState));1218 GENV_ITEMFACTORY->createInteger(posItem, xs_integer(bindingState));
12191219
1220 std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin();1220 std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin();
1221 std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end();1221 std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end();
12221222
=== 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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-07-10 14:04:53 +0000
+++ src/runtime/numerics/NumericsImpl.cpp 2011-11-29 00:43:26 +0000
@@ -441,10 +441,11 @@
441 xs_integer ll0 = i0->getIntegerValue();441 xs_integer ll0 = i0->getIntegerValue();
442 xs_integer ll1 = i1->getIntegerValue();442 xs_integer ll1 = i1->getIntegerValue();
443443
444 if ( ll1 == Integer::zero() )444 if ( ll1.sign() == 0 )
445 {445 {
446 throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) );446 throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) );
447 }447 }
448
448 return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1);449 return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1);
449}450}
450451
451452
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2011-10-15 10:41:19 +0000
+++ src/store/api/item.h 2011-11-29 00:43:26 +0000
@@ -292,7 +292,7 @@
292292
293 /** Accessor for xs:nonNegativeInteager, xs:positiveInteger293 /** Accessor for xs:nonNegativeInteager, xs:positiveInteger
294 */294 */
295 virtual xs_uinteger295 virtual xs_nonNegativeInteger
296 getUnsignedIntegerValue() const;296 getUnsignedIntegerValue() const;
297297
298 /** Accessor for xs:long298 /** Accessor for xs:long
299299
=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h 2011-07-22 07:23:17 +0000
+++ src/store/api/item_factory.h 2011-11-29 00:43:26 +0000
@@ -236,13 +236,13 @@
236 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]236 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
237 * @param value237 * @param value
238 */238 */
239 virtual bool createNonNegativeInteger(Item_t& result, const xs_uinteger& value) = 0;239 virtual bool createNonNegativeInteger(Item_t& result, const xs_nonNegativeInteger& value) = 0;
240240
241 /**241 /**
242 * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger]242 * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
243 * @param value243 * @param value
244 */244 */
245 virtual bool createPositiveInteger(Item_t& result, const xs_uinteger& value) = 0;245 virtual bool createPositiveInteger(Item_t& result, const xs_positiveInteger& value) = 0;
246246
247 /**247 /**
248 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]248 * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
249249
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2011-10-27 20:55:51 +0000
+++ src/store/naive/atomic_items.cpp 2011-11-29 00:43:26 +0000
@@ -147,7 +147,7 @@
147 const IntegerItem* item = static_cast<const IntegerItem*>(item1);147 const IntegerItem* item = static_cast<const IntegerItem*>(item1);
148 try148 try
149 {149 {
150 longValue = to_xs_long(item->theValue);150 longValue = item->getLongValue();
151 GET_FACTORY().createLong(result, longValue);151 GET_FACTORY().createLong(result, longValue);
152 }152 }
153 catch (std::range_error const&)153 catch (std::range_error const&)
@@ -217,11 +217,11 @@
217 {217 {
218 const IntegerItem* item = static_cast<const IntegerItem*>(item1);218 const IntegerItem* item = static_cast<const IntegerItem*>(item1);
219219
220 doubleValue = item->theValue;220 doubleValue = item->getIntegerValue();
221221
222 const xs_integer intValue(doubleValue);222 const xs_integer intValue(doubleValue);
223223
224 lossy = (intValue != item->theValue);224 lossy = (intValue != item->getIntegerValue());
225 break;225 break;
226 }226 }
227227
@@ -2400,10 +2400,11 @@
24002400
24012401
2402/*******************************************************************************2402/*******************************************************************************
2403 class IntegerItem2403 class IntegerItemImpl
2404********************************************************************************/2404********************************************************************************/
24052405
2406long IntegerItem::compare( Item const *other, long, const XQPCollator* ) const {2406long IntegerItemImpl::compare( Item const *other, long,
2407 const XQPCollator* ) const {
2407 try2408 try
2408 {2409 {
2409 return theValue.compare( other->getIntegerValue() );2410 return theValue.compare( other->getIntegerValue() );
@@ -2414,8 +2415,8 @@
2414 }2415 }
2415}2416}
24162417
2417bool IntegerItem::equals( const store::Item* other, long,2418bool IntegerItemImpl::equals( const store::Item* other, long,
2418 const XQPCollator*) const2419 const XQPCollator*) const
2419{2420{
2420 try2421 try
2421 {2422 {
@@ -2427,13 +2428,13 @@
2427 }2428 }
2428}2429}
24292430
2430xs_decimal IntegerItem::getDecimalValue() const2431xs_decimal IntegerItemImpl::getDecimalValue() const
2431{2432{
2432 return xs_decimal(theValue);2433 return xs_decimal(theValue);
2433}2434}
24342435
24352436
2436xs_long IntegerItem::getLongValue() const2437xs_long IntegerItemImpl::getLongValue() const
2437{2438{
2438 try2439 try
2439 {2440 {
@@ -2449,44 +2450,45 @@
2449}2450}
24502451
24512452
2452store::Item* IntegerItem::getType() const2453store::Item* IntegerItemImpl::getType() const
2453{2454{
2454 return GET_STORE().theSchemaTypeNames[XS_INTEGER];2455 return GET_STORE().theSchemaTypeNames[XS_INTEGER];
2455}2456}
24562457
24572458
2458store::Item_t IntegerItem::getEBV() const2459store::Item_t IntegerItemImpl::getEBV() const
2459{2460{
2460 bool b = ( theValue != xs_integer::zero() );2461 bool b = !!theValue.sign();
2461 store::Item_t bVal;2462 store::Item_t bVal;
2462 CREATE_BOOLITEM(bVal, b);2463 CREATE_BOOLITEM(bVal, b);
2463 return bVal;2464 return bVal;
2464}2465}
24652466
24662467
2467zstring IntegerItem::getStringValue() const2468zstring IntegerItemImpl::getStringValue() const
2468{2469{
2469 return theValue.toString();2470 return theValue.toString();
2470}2471}
24712472
24722473
2473void IntegerItem::getStringValue2(zstring& val) const2474void IntegerItemImpl::getStringValue2(zstring& val) const
2474{2475{
2475 val = theValue.toString();2476 val = theValue.toString();
2476}2477}
24772478
2478uint32_t IntegerItem::hash(long, const XQPCollator*) const2479uint32_t IntegerItemImpl::hash(long, const XQPCollator*) const
2479{2480{
2480 return theValue.hash();2481 return theValue.hash();
2481}2482}
24822483
2483void IntegerItem::appendStringValue(zstring& buf) const2484
2485void IntegerItemImpl::appendStringValue(zstring& buf) const
2484{2486{
2485 buf += theValue.toString();2487 buf += theValue.toString();
2486}2488}
24872489
24882490
2489zstring IntegerItem::show() const2491zstring IntegerItemImpl::show() const
2490{2492{
2491 zstring res("xs:integer(");2493 zstring res("xs:integer(");
2492 appendStringValue(res);2494 appendStringValue(res);
@@ -2498,11 +2500,91 @@
2498/*******************************************************************************2500/*******************************************************************************
2499 class NonPositiveIntegerItem2501 class NonPositiveIntegerItem
2500********************************************************************************/2502********************************************************************************/
2503long NonPositiveIntegerItem::compare( Item const *other, long,
2504 const XQPCollator* ) const {
2505 try
2506 {
2507 return theValue.compare( other->getIntegerValue() );
2508 }
2509 catch ( ZorbaException const& )
2510 {
2511 return getDecimalValue().compare( other->getDecimalValue() );
2512 }
2513}
2514
2515bool NonPositiveIntegerItem::equals( const store::Item* other, long,
2516 const XQPCollator* ) const
2517{
2518 try
2519 {
2520 return theValue == other->getIntegerValue();
2521 }
2522 catch (ZorbaException const&)
2523 {
2524 return getDecimalValue() == other->getDecimalValue();
2525 }
2526}
2527
2501store::Item* NonPositiveIntegerItem::getType() const2528store::Item* NonPositiveIntegerItem::getType() const
2502{2529{
2503 return GET_STORE().theSchemaTypeNames[XS_NON_POSITIVE_INTEGER];2530 return GET_STORE().theSchemaTypeNames[XS_NON_POSITIVE_INTEGER];
2504}2531}
25052532
2533xs_decimal NonPositiveIntegerItem::getDecimalValue() const
2534{
2535 return xs_decimal(theValue);
2536}
2537
2538xs_integer NonPositiveIntegerItem::getIntegerValue() const
2539{
2540 return xs_integer(theValue);
2541}
2542
2543xs_long NonPositiveIntegerItem::getLongValue() const
2544{
2545 try
2546 {
2547 return to_xs_long(theValue);
2548 }
2549 catch ( std::range_error const& )
2550 {
2551 throw XQUERY_EXCEPTION(
2552 err::FORG0001,
2553 ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
2554 );
2555 }
2556}
2557
2558zstring NonPositiveIntegerItem::getStringValue() const
2559{
2560 return theValue.toString();
2561}
2562
2563
2564void NonPositiveIntegerItem::getStringValue2(zstring& val) const
2565{
2566 val = theValue.toString();
2567}
2568
2569uint32_t NonPositiveIntegerItem::hash(long, const XQPCollator*) const
2570{
2571 return theValue.hash();
2572}
2573
2574
2575void NonPositiveIntegerItem::appendStringValue(zstring& buf) const
2576{
2577 buf += theValue.toString();
2578}
2579
2580store::Item_t NonPositiveIntegerItem::getEBV() const
2581{
2582 bool b = !!theValue.sign();
2583 store::Item_t bVal;
2584 CREATE_BOOLITEM(bVal, b);
2585 return bVal;
2586}
2587
2506zstring NonPositiveIntegerItem::show() const2588zstring NonPositiveIntegerItem::show() const
2507{2589{
2508 zstring res("xs:nonPositiveInteger(");2590 zstring res("xs:nonPositiveInteger(");
@@ -2531,14 +2613,94 @@
25312613
25322614
2533/*******************************************************************************2615/*******************************************************************************
2534 class NonNegativeINtegerItem2616 class NonNegativeIntegerItem
2535********************************************************************************/2617********************************************************************************/
2618long NonNegativeIntegerItem::compare( Item const *other, long,
2619 const XQPCollator* ) const {
2620 try
2621 {
2622 return theValue.compare( other->getUnsignedIntegerValue() );
2623 }
2624 catch ( ZorbaException const& )
2625 {
2626 return getDecimalValue().compare( other->getDecimalValue() );
2627 }
2628}
2629
2630bool NonNegativeIntegerItem::equals( const store::Item* other, long,
2631 const XQPCollator* ) const
2632{
2633 try
2634 {
2635 return theValue == other->getUnsignedIntegerValue();
2636 }
2637 catch (ZorbaException const&)
2638 {
2639 return getDecimalValue() == other->getDecimalValue();
2640 }
2641}
2642
2536store::Item* NonNegativeIntegerItem::getType() const2643store::Item* NonNegativeIntegerItem::getType() const
2537{2644{
2538 return GET_STORE().theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER];2645 return GET_STORE().theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER];
2539}2646}
25402647
25412648
2649xs_decimal NonNegativeIntegerItem::getDecimalValue() const
2650{
2651 return xs_decimal(theValue);
2652}
2653
2654xs_integer NonNegativeIntegerItem::getIntegerValue() const
2655{
2656 return xs_integer(theValue);
2657}
2658
2659xs_long NonNegativeIntegerItem::getLongValue() const
2660{
2661 try
2662 {
2663 return to_xs_long(theValue);
2664 }
2665 catch ( std::range_error const& )
2666 {
2667 throw XQUERY_EXCEPTION(
2668 err::FORG0001,
2669 ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
2670 );
2671 }
2672}
2673
2674zstring NonNegativeIntegerItem::getStringValue() const
2675{
2676 return theValue.toString();
2677}
2678
2679
2680void NonNegativeIntegerItem::getStringValue2(zstring& val) const
2681{
2682 val = theValue.toString();
2683}
2684
2685uint32_t NonNegativeIntegerItem::hash(long, const XQPCollator*) const
2686{
2687 return theValue.hash();
2688}
2689
2690
2691void NonNegativeIntegerItem::appendStringValue(zstring& buf) const
2692{
2693 buf += theValue.toString();
2694}
2695
2696store::Item_t NonNegativeIntegerItem::getEBV() const
2697{
2698 bool b = !!theValue.sign();
2699 store::Item_t bVal;
2700 CREATE_BOOLITEM(bVal, b);
2701 return bVal;
2702}
2703
2542zstring NonNegativeIntegerItem::show() const2704zstring NonNegativeIntegerItem::show() const
2543{2705{
2544 zstring res("xs:nonNegativeInteger(");2706 zstring res("xs:nonNegativeInteger(");
@@ -2580,6 +2742,9 @@
2580 return xs_integer(theValue);2742 return xs_integer(theValue);
2581}2743}
25822744
2745xs_nonNegativeInteger LongItem::getUnsignedIntegerValue() const {
2746 return theValue >= 0 ? theValue : -theValue;
2747}
25832748
2584store::Item* LongItem::getType() const2749store::Item* LongItem::getType() const
2585{2750{
@@ -2824,9 +2989,9 @@
2824}2989}
28252990
28262991
2827xs_uinteger UnsignedLongItem::getUnsignedIntegerValue() const2992xs_nonNegativeInteger UnsignedLongItem::getUnsignedIntegerValue() const
2828{2993{
2829 return xs_uinteger(theValue);2994 return xs_nonNegativeInteger(theValue);
2830}2995}
28312996
28322997
@@ -2891,9 +3056,9 @@
2891}3056}
28923057
28933058
2894xs_uinteger UnsignedIntItem::getUnsignedIntegerValue() const3059xs_nonNegativeInteger UnsignedIntItem::getUnsignedIntegerValue() const
2895{3060{
2896 return Integer(theValue);3061 return xs_nonNegativeInteger(theValue);
2897}3062}
28983063
28993064
@@ -2958,9 +3123,9 @@
2958}3123}
29593124
29603125
2961xs_uinteger UnsignedShortItem::getUnsignedIntegerValue() const3126xs_nonNegativeInteger UnsignedShortItem::getUnsignedIntegerValue() const
2962{3127{
2963 return Integer(theValue);3128 return xs_nonNegativeInteger(theValue);
2964}3129}
29653130
29663131
@@ -3021,13 +3186,13 @@
30213186
3022xs_integer UnsignedByteItem::getIntegerValue() const3187xs_integer UnsignedByteItem::getIntegerValue() const
3023{3188{
3024 return Integer((uint32_t)theValue);3189 return xs_integer((uint32_t)theValue);
3025}3190}
30263191
30273192
3028xs_uinteger UnsignedByteItem::getUnsignedIntegerValue() const3193xs_nonNegativeInteger UnsignedByteItem::getUnsignedIntegerValue() const
3029{3194{
3030 return Integer(theValue);3195 return xs_nonNegativeInteger(theValue);
3031}3196}
30323197
30333198
30343199
=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h 2011-11-02 17:19:09 +0000
+++ src/store/naive/atomic_items.h 2011-11-29 00:43:26 +0000
@@ -173,7 +173,7 @@
173173
174 xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); }174 xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); }
175175
176 xs_uinteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); }176 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); }
177177
178 xs_long getLongValue() const { return theBaseItem->getLongValue(); }178 xs_long getLongValue() const { return theBaseItem->getLongValue(); }
179179
@@ -1333,6 +1333,31 @@
1333********************************************************************************/1333********************************************************************************/
1334class IntegerItem : public AtomicItem1334class IntegerItem : public AtomicItem
1335{1335{
1336protected:
1337 IntegerItem() {}
1338
1339public:
1340 virtual xs_decimal getDecimalValue() const = 0;
1341 virtual xs_integer getIntegerValue() const = 0;
1342 virtual xs_long getLongValue() const = 0;
1343
1344 virtual store::Item_t getEBV() const = 0;
1345 virtual store::Item* getType() const = 0;
1346
1347 virtual zstring getStringValue() const = 0;
1348 virtual void getStringValue2(zstring&) const = 0;
1349 virtual void appendStringValue(zstring& buf) const = 0;
1350
1351 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const = 0;
1352 bool isNaN() const { return false; }
1353};
1354
1355
1356/*******************************************************************************
1357 class IntegerItemImpl
1358********************************************************************************/
1359class IntegerItemImpl : public IntegerItem
1360{
1336 friend class BasicItemFactory;1361 friend class BasicItemFactory;
1337 friend class AtomicItem;1362 friend class AtomicItem;
13381363
@@ -1340,44 +1365,35 @@
1340 xs_integer theValue;1365 xs_integer theValue;
13411366
1342protected:1367protected:
1343 IntegerItem(const xs_integer& aValue) : theValue ( aValue ) {}1368 IntegerItemImpl(const xs_integer& aValue) : theValue ( aValue ) {}
13441369
1345 IntegerItem() {}1370 IntegerItemImpl() {}
13461371
1347public:1372public:
1348 xs_decimal getDecimalValue() const;1373 xs_decimal getDecimalValue() const;
1349
1350 xs_integer getIntegerValue() const { return theValue; }1374 xs_integer getIntegerValue() const { return theValue; }
13511375 xs_long getLongValue() const;
1352 xs_long getLongValue() const;1376 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
13531377
1378 zstring getStringValue() const;
1379 void getStringValue2(zstring&) const;
1380 void appendStringValue(zstring&) const;
1381
1382 store::Item_t getEBV() const;
1354 virtual SchemaTypeCode getTypeCode() const { return XS_INTEGER; }1383 virtual SchemaTypeCode getTypeCode() const { return XS_INTEGER; }
1355
1356 virtual store::Item* getType() const;1384 virtual store::Item* getType() const;
1357
1358 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;1385 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
1386 virtual zstring show() const;
1387
1388 long compare(
1389 const Item* other,
1390 long timezone = 0,
1391 const XQPCollator* aCollation = 0) const;
13591392
1360 bool equals(1393 bool equals(
1361 const store::Item* other,1394 const store::Item* other,
1362 long timezone = 0,1395 long timezone = 0,
1363 const XQPCollator* aCollation = 0) const;1396 const XQPCollator* aCollation = 0) const;
1364
1365 long compare(
1366 const Item* other,
1367 long timezone = 0,
1368 const XQPCollator* aCollation = 0) const;
1369
1370 store::Item_t getEBV( ) const;
1371
1372 zstring getStringValue() const;
1373
1374 void getStringValue2(zstring& val) const;
1375
1376 void appendStringValue(zstring& buf) const;
1377
1378 bool isNaN() const { return false; }
1379
1380 virtual zstring show() const;
1381};1397};
13821398
13831399
@@ -1389,28 +1405,50 @@
1389 friend class BasicItemFactory;1405 friend class BasicItemFactory;
13901406
1391protected:1407protected:
1392 NonPositiveIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {}1408 xs_nonPositiveInteger theValue;
1409
1410 NonPositiveIntegerItem(const xs_integer& aValue) : theValue(aValue) {}
13931411
1394 NonPositiveIntegerItem() {}1412 NonPositiveIntegerItem() {}
13951413
1396public:1414public:
1415 // inherited
1416 xs_decimal getDecimalValue() const;
1417 xs_integer getIntegerValue() const;
1418 xs_long getLongValue() const;
1419 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
1420
1421 zstring getStringValue() const;
1422 void getStringValue2(zstring& val) const;
1423 void appendStringValue(zstring&) const;
1424
1425 store::Item_t getEBV() const;
1426 store::Item* getType() const;
1397 SchemaTypeCode getTypeCode() const { return XS_NON_POSITIVE_INTEGER; }1427 SchemaTypeCode getTypeCode() const { return XS_NON_POSITIVE_INTEGER; }
13981428 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
1399 store::Item* getType() const;
1400
1401 zstring show() const;1429 zstring show() const;
1430
1431 long compare(
1432 const Item* other,
1433 long timezone = 0,
1434 const XQPCollator* aCollation = 0) const;
1435
1436 bool equals(
1437 const store::Item* other,
1438 long timezone = 0,
1439 const XQPCollator* aCollation = 0) const;
1402};1440};
14031441
14041442
1405/*******************************************************************************1443/*******************************************************************************
1406 class NegativeIntegerItem1444 class NegativeIntegerItem
1407********************************************************************************/1445********************************************************************************/
1408class NegativeIntegerItem : public IntegerItem1446class NegativeIntegerItem : public NonPositiveIntegerItem
1409{1447{
1410 friend class BasicItemFactory;1448 friend class BasicItemFactory;
14111449
1412protected:1450protected:
1413 NegativeIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {}1451 NegativeIntegerItem(const xs_integer& aValue) : NonPositiveIntegerItem(aValue) {}
14141452
1415 NegativeIntegerItem() {}1453 NegativeIntegerItem() {}
14161454
@@ -1425,44 +1463,60 @@
14251463
1426/*******************************************************************************1464/*******************************************************************************
1427 class NonNegativeIntegerItem1465 class NonNegativeIntegerItem
1428
1429 Note: xs_uinteger is typedef of Integer
1430********************************************************************************/1466********************************************************************************/
1431class NonNegativeIntegerItem : public IntegerItem1467class NonNegativeIntegerItem : public IntegerItem
1432{1468{
1433 friend class BasicItemFactory;1469 friend class BasicItemFactory;
14341470
1435protected:1471protected:
1436 NonNegativeIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) {}1472 xs_nonNegativeInteger theValue;
1473
1474 NonNegativeIntegerItem(const xs_nonNegativeInteger& aValue) : theValue(aValue) {}
14371475
1438 NonNegativeIntegerItem() {}1476 NonNegativeIntegerItem() {}
14391477
1440public:1478public:
1441 xs_uinteger getUnsignedIntegerValue() const { return theValue; }1479 // inherited
1480 xs_decimal getDecimalValue() const;
1481 xs_integer getIntegerValue() const;
1482 xs_long getLongValue() const;
1483 xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
14421484
1485 store::Item_t getEBV() const;
1486 store::Item* getType() const;
1443 SchemaTypeCode getTypeCode() const { return XS_NON_NEGATIVE_INTEGER; }1487 SchemaTypeCode getTypeCode() const { return XS_NON_NEGATIVE_INTEGER; }
14441488 uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
1445 store::Item* getType() const;
1446
1447 zstring show() const;1489 zstring show() const;
1490
1491 zstring getStringValue() const;
1492 void getStringValue2(zstring& val) const;
1493 void appendStringValue(zstring&) const;
1494
1495 long compare(
1496 const Item* other,
1497 long timezone = 0,
1498 const XQPCollator* aCollation = 0) const;
1499
1500 bool equals(
1501 const store::Item* other,
1502 long timezone = 0,
1503 const XQPCollator* aCollation = 0) const;
1448};1504};
14491505
14501506
1451/*******************************************************************************1507/*******************************************************************************
1452 class PositiveIntegerItem1508 class PositiveIntegerItem
1453********************************************************************************/1509********************************************************************************/
1454class PositiveIntegerItem : public IntegerItem1510class PositiveIntegerItem : public NonNegativeIntegerItem
1455{1511{
1456 friend class BasicItemFactory;1512 friend class BasicItemFactory;
14571513
1458protected:1514protected:
1459 PositiveIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) { }1515 PositiveIntegerItem(const xs_positiveInteger& aValue) : NonNegativeIntegerItem(aValue) { }
14601516
1461 PositiveIntegerItem() {}1517 PositiveIntegerItem() {}
14621518
1463public:1519public:
1464 xs_uinteger getUnsignedIntegerValue() const { return theValue; }
1465
1466 SchemaTypeCode getTypeCode() const { return XS_POSITIVE_INTEGER; }1520 SchemaTypeCode getTypeCode() const { return XS_POSITIVE_INTEGER; }
14671521
1468 store::Item* getType() const;1522 store::Item* getType() const;
@@ -1494,6 +1548,8 @@
14941548
1495 xs_long getLongValue() const { return theValue; }1549 xs_long getLongValue() const { return theValue; }
14961550
1551 xs_nonNegativeInteger getUnsignedIntegerValue() const;
1552
1497 SchemaTypeCode getTypeCode() const { return XS_LONG; }1553 SchemaTypeCode getTypeCode() const { return XS_LONG; }
14981554
1499 store::Item* getType() const;1555 store::Item* getType() const;
@@ -1818,7 +1874,7 @@
18181874
1819 xs_integer getIntegerValue() const;1875 xs_integer getIntegerValue() const;
18201876
1821 xs_uinteger getUnsignedIntegerValue() const;1877 xs_nonNegativeInteger getUnsignedIntegerValue() const;
18221878
1823 xs_unsignedLong getUnsignedLongValue() const { return theValue; }1879 xs_unsignedLong getUnsignedLongValue() const { return theValue; }
18241880
@@ -1898,7 +1954,7 @@
18981954
1899 xs_integer getIntegerValue() const;1955 xs_integer getIntegerValue() const;
19001956
1901 xs_uinteger getUnsignedIntegerValue() const;1957 xs_nonNegativeInteger getUnsignedIntegerValue() const;
19021958
1903 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }1959 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
19041960
@@ -1987,7 +2043,7 @@
19872043
1988 xs_integer getIntegerValue() const;2044 xs_integer getIntegerValue() const;
19892045
1990 xs_uinteger getUnsignedIntegerValue() const;2046 xs_nonNegativeInteger getUnsignedIntegerValue() const;
19912047
1992 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }2048 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
19932049
@@ -2080,7 +2136,7 @@
20802136
2081 xs_integer getIntegerValue() const;2137 xs_integer getIntegerValue() const;
20822138
2083 xs_uinteger getUnsignedIntegerValue() const;2139 xs_nonNegativeInteger getUnsignedIntegerValue() const;
20842140
2085 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }2141 xs_long getLongValue() const { return static_cast<xs_long>(theValue); }
20862142
20872143
=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp 2011-10-15 10:41:19 +0000
+++ src/store/naive/item.cpp 2011-11-29 00:43:26 +0000
@@ -508,7 +508,7 @@
508 * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort,508 * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort,
509 * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger509 * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger
510 */510 */
511xs_uinteger Item::getUnsignedIntegerValue() const511xs_nonNegativeInteger Item::getUnsignedIntegerValue() const
512{512{
513 throw ZORBA_EXCEPTION(513 throw ZORBA_EXCEPTION(
514 zerr::ZSTR0040_TYPE_ERROR,514 zerr::ZSTR0040_TYPE_ERROR,
515515
=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp 2011-10-15 10:41:19 +0000
+++ src/store/naive/simple_item_factory.cpp 2011-11-29 00:43:26 +0000
@@ -314,7 +314,7 @@
314314
315bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value)315bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value)
316{316{
317 result = new IntegerItem( value );317 result = new IntegerItemImpl( value );
318 return true;318 return true;
319}319}
320320
@@ -323,7 +323,7 @@
323 store::Item_t& result,323 store::Item_t& result,
324 const xs_integer& value)324 const xs_integer& value)
325{325{
326 ZORBA_ASSERT(value <= Integer::zero());326 ZORBA_ASSERT(value.sign() <= 0);
327 result = new NonPositiveIntegerItem( value );327 result = new NonPositiveIntegerItem( value );
328 return true;328 return true;
329}329}
@@ -333,7 +333,7 @@
333 store::Item_t& result,333 store::Item_t& result,
334 const xs_integer& value)334 const xs_integer& value)
335{335{
336 ZORBA_ASSERT(value < xs_integer::zero());336 ZORBA_ASSERT(value.sign() < 0);
337 result = new NegativeIntegerItem(value);337 result = new NegativeIntegerItem(value);
338 return true;338 return true;
339}339}
@@ -341,7 +341,7 @@
341341
342bool BasicItemFactory::createNonNegativeInteger(342bool BasicItemFactory::createNonNegativeInteger(
343 store::Item_t& result,343 store::Item_t& result,
344 const xs_uinteger& value )344 const xs_nonNegativeInteger& value )
345{345{
346 result = new NonNegativeIntegerItem( value );346 result = new NonNegativeIntegerItem( value );
347 return true;347 return true;
@@ -351,9 +351,9 @@
351351
352bool BasicItemFactory::createPositiveInteger(352bool BasicItemFactory::createPositiveInteger(
353 store::Item_t& result,353 store::Item_t& result,
354 const xs_uinteger& value)354 const xs_positiveInteger& value)
355{355{
356 ZORBA_ASSERT(value > Integer::zero());356 ZORBA_ASSERT(value.sign() > 0);
357 result = new PositiveIntegerItem( value );357 result = new PositiveIntegerItem( value );
358 return true;358 return true;
359}359}
360360
=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h 2011-10-15 10:41:19 +0000
+++ src/store/naive/simple_item_factory.h 2011-11-29 00:43:26 +0000
@@ -111,9 +111,9 @@
111111
112 bool createInteger(store::Item_t& result, const xs_integer& value);112 bool createInteger(store::Item_t& result, const xs_integer& value);
113113
114 bool createNonNegativeInteger(store::Item_t& result, const xs_uinteger& value);114 bool createNonNegativeInteger(store::Item_t& result, const xs_nonNegativeInteger& value);
115115
116 bool createPositiveInteger(store::Item_t& result, const xs_uinteger& value );116 bool createPositiveInteger(store::Item_t& result, const xs_positiveInteger& value );
117117
118 bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value);118 bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value);
119119
120120
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2011-10-22 15:44:45 +0000
+++ src/types/casting.cpp 2011-11-29 00:43:26 +0000
@@ -119,6 +119,7 @@
119SAME_S_AND_T(aURI)119SAME_S_AND_T(aURI)
120SAME_S_AND_T(QN)120SAME_S_AND_T(QN)
121SAME_S_AND_T(NOT)121SAME_S_AND_T(NOT)
122SAME_S_AND_T(uint)
122123
123#undef SAME_S_AND_T124#undef SAME_S_AND_T
124125
@@ -1263,6 +1264,148 @@
1263 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);1264 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
1264}1265}
12651266
1267T1_TO_T2(uint, uA)
1268{
1269 zstring strval2;
1270 aItem->getStringValue2(strval2);
1271 return str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
1272}
1273
1274
1275T1_TO_T2(uint, str)
1276{
1277 return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
1278}
1279
1280
1281T1_TO_T2(uint, flt)
1282{
1283 return aFactory->createFloat(
1284 result, xs_float(aItem->getUnsignedIntegerValue())
1285 );
1286}
1287
1288
1289T1_TO_T2(uint, dbl)
1290{
1291 return aFactory->createDouble(
1292 result, xs_double(aItem->getUnsignedIntegerValue())
1293 );
1294}
1295
1296
1297T1_TO_T2(uint, dec)
1298{
1299 return aFactory->createDecimal(
1300 result, xs_decimal(aItem->getUnsignedIntegerValue())
1301 );
1302}
1303
1304
1305T1_TO_T2(uint, bool)
1306{
1307 result = aItem->getEBV();
1308 return true;
1309}
1310
1311
1312T1_TO_T2(uA, uint)
1313{
1314 zstring strval2;
1315 aItem->getStringValue2(strval2);
1316 return str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
1317}
1318
1319
1320T1_TO_T2(flt, uint)
1321{
1322 try
1323 {
1324 xs_nonNegativeInteger const n(aItem->getFloatValue());
1325 return aFactory->createNonNegativeInteger(result, n);
1326 }
1327 catch ( std::exception const& )
1328 {
1329 throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo );
1330 }
1331}
1332
1333
1334T1_TO_T2(int, uint)
1335{
1336 try
1337 {
1338 xs_nonNegativeInteger const n(aItem->getIntegerValue());
1339 return aFactory->createNonNegativeInteger(result, n);
1340 }
1341 catch ( std::exception const& )
1342 {
1343 throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo );
1344 }
1345}
1346
1347
1348T1_TO_T2(uint, int)
1349{
1350 try
1351 {
1352 xs_integer const n(aItem->getIntegerValue());
1353 return aFactory->createInteger(result, n);
1354 }
1355 catch ( std::exception const& )
1356 {
1357 throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo );
1358 }
1359}
1360
1361
1362T1_TO_T2(dbl, uint)
1363{
1364 try
1365 {
1366 xs_nonNegativeInteger const n(aItem->getDoubleValue());
1367 return aFactory->createInteger(result, n);
1368 }
1369 catch ( std::exception const& )
1370 {
1371 throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo );
1372 }
1373}
1374
1375
1376T1_TO_T2(dec, uint)
1377{
1378 xs_nonNegativeInteger const n(aItem->getDecimalValue());
1379 return aFactory->createNonNegativeInteger(result, n);
1380}
1381
1382
1383T1_TO_T2(bool, uint)
1384{
1385 if (aItem->getBooleanValue())
1386 return aFactory->createNonNegativeInteger(
1387 result, xs_nonNegativeInteger::one()
1388 );
1389 else
1390 return aFactory->createNonNegativeInteger(
1391 result, xs_nonNegativeInteger::zero()
1392 );
1393}
1394
1395
1396T1_TO_T2(str, uint)
1397{
1398 try {
1399 xs_nonNegativeInteger const n(strval.c_str());
1400 return aFactory->createNonNegativeInteger(result, n);
1401 }
1402 catch ( std::invalid_argument const& ) {
1403 throw TYPE_EXCEPTION( err::FORG0001, aErrorInfo );
1404 }
1405 catch ( std::range_error const& ) {
1406 throw TYPE_EXCEPTION( err::FOAR0002, aErrorInfo );
1407 }
1408}
12661409
1267/*******************************************************************************1410/*******************************************************************************
12681411
@@ -1371,14 +1514,14 @@
1371 case TypeConstants::XS_NON_POSITIVE_INTEGER:1514 case TypeConstants::XS_NON_POSITIVE_INTEGER:
1372 {1515 {
1373 xs_integer const lInteger = aItem->getIntegerValue();1516 xs_integer const lInteger = aItem->getIntegerValue();
1374 if (lInteger <= xs_integer::zero())1517 if (lInteger.sign() <= 0)
1375 return aFactory->createNonPositiveInteger(result, lInteger);1518 return aFactory->createNonPositiveInteger(result, lInteger);
1376 break;1519 break;
1377 }1520 }
1378 case TypeConstants::XS_NEGATIVE_INTEGER:1521 case TypeConstants::XS_NEGATIVE_INTEGER:
1379 {1522 {
1380 xs_integer const lInteger = aItem->getIntegerValue();1523 xs_integer const lInteger = aItem->getIntegerValue();
1381 if (lInteger < xs_integer::zero())1524 if (lInteger.sign() < 0)
1382 return aFactory->createNegativeInteger(result, lInteger);1525 return aFactory->createNegativeInteger(result, lInteger);
1383 break;1526 break;
1384 }1527 }
@@ -1436,9 +1579,15 @@
1436 }1579 }
1437 case TypeConstants::XS_NON_NEGATIVE_INTEGER:1580 case TypeConstants::XS_NON_NEGATIVE_INTEGER:
1438 {1581 {
1439 xs_integer const lInteger = aItem->getIntegerValue();1582 xs_decimal const d = aItem->getDecimalValue();
1440 if (lInteger >= xs_integer::zero())1583 if (d.sign() >= 0)
1441 return aFactory->createNonNegativeInteger(result, lInteger);1584 try {
1585 xs_nonNegativeInteger const i(d);
1586 return aFactory->createNonNegativeInteger(result, i);
1587 }
1588 catch ( std::exception const& ) {
1589 // ignore
1590 }
1442 break;1591 break;
1443 }1592 }
1444 case TypeConstants::XS_UNSIGNED_LONG:1593 case TypeConstants::XS_UNSIGNED_LONG:
@@ -1495,9 +1644,9 @@
1495 }1644 }
1496 case TypeConstants::XS_POSITIVE_INTEGER:1645 case TypeConstants::XS_POSITIVE_INTEGER:
1497 {1646 {
1498 xs_integer lInteger = aItem->getIntegerValue();1647 xs_positiveInteger const i = aItem->getUnsignedIntegerValue();
1499 if (lInteger > xs_integer::zero())1648 if (i.sign() > 0)
1500 return aFactory->createPositiveInteger(result, lInteger);1649 return aFactory->createPositiveInteger(result, i);
1501 break;1650 break;
1502 }1651 }
1503 default:1652 default:
@@ -1541,12 +1690,12 @@
1541 5, // 25 XS_INT1690 5, // 25 XS_INT
1542 5, // 26 XS_SHORT1691 5, // 26 XS_SHORT
1543 5, // 27 XS_BYTE1692 5, // 27 XS_BYTE
1544 5, // 28 XS_NON_NEGATIVE_INTEGER1693 23, // 28 XS_NON_NEGATIVE_INTEGER
1545 5, // 29 XS_UNSIGNED_LONG1694 23, // 29 XS_UNSIGNED_LONG
1546 5, // 30 XS_UNSIGNED_INT1695 23, // 30 XS_UNSIGNED_INT
1547 5, // 31 XS_UNSIGNED_SHORT1696 23, // 31 XS_UNSIGNED_SHORT
1548 5, // 32 XS_UNSIGNED_BYTE1697 23, // 32 XS_UNSIGNED_BYTE
1549 5, // 33 XS_POSITIVE_INTEGER1698 23, // 33 XS_POSITIVE_INTEGER
1550 12, // 34 XS_GYEAR_MONTH1699 12, // 34 XS_GYEAR_MONTH
1551 13, // 35 XS_GYEAR1700 13, // 35 XS_GYEAR
1552 14, // 36 XS_GMONTH_DAY1701 14, // 36 XS_GMONTH_DAY
@@ -1564,98 +1713,155 @@
1564/*******************************************************************************1713/*******************************************************************************
15651714
1566********************************************************************************/1715********************************************************************************/
1567const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[23] =1716const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[24] =
1568{1717{
1569/*uA*/ 0, /*str*/ str_down, /*flt*/ 0, /*dbl*/ 0, /*dec*/ 0, /*int*/ int_down, /*dur*/ 0,1718/*uA*/ 0,
1570/*yMD*/ 0, /*dTD*/ 0, /*dT*/ 0, /*tim*/ 0, /*dat*/ 0, /*gYM*/ 0, /*gYr*/ 0, /*gMD*/ 0,1719/*str*/ str_down,
1571/*gDay*/0, /*gMon*/0, /*bool*/0, /*b64*/ 0, /*hxB*/ 0, /*aURI*/0, /*QN*/ 0, /*NOT*/ 01720/*flt*/ 0,
1721/*dbl*/ 0,
1722/*dec*/ 0,
1723/*int*/ int_down,
1724/*dur*/ 0,
1725/*yMD*/ 0,
1726/*dTD*/ 0,
1727/*dT*/ 0,
1728/*tim*/ 0,
1729/*dat*/ 0,
1730/*gYM*/ 0,
1731/*gYr*/ 0,
1732/*gMD*/ 0,
1733/*gDay*/ 0,
1734/*gMon*/ 0,
1735/*bool*/ 0,
1736/*b64*/ 0,
1737/*hxB*/ 0,
1738/*aURI*/ 0,
1739/*QN*/ 0,
1740/*NOT*/ 0,
1741/*uint*/ int_down,
1572};1742};
15731743
15741744
1575/*******************************************************************************1745/*******************************************************************************
15761746
1577********************************************************************************/1747********************************************************************************/
1578const GenericCast::CastFunc GenericCast::theCastMatrix[23][23] =1748const GenericCast::CastFunc GenericCast::theCastMatrix[24][24] =
1579{1749{
1580 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/1750 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1581 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/1751 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1582 /*aURI*/ /*QN*/ /*NOT*/1752 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1753
1583/*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT,1754/*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT,
1584 &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB,1755 &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB,
1585 &uA_aURI, 0, 0},1756 &uA_aURI, 0, 0, &uA_uint},
15861757
1587/*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT,1758/*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT,
1588 &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB,1759 &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB,
1589 &str_aURI, &str_QN, &str_NOT},1760 &str_aURI, &str_QN, &str_NOT, &str_uint},
15901761
1591/*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0,1762/*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0,
1592 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0,1763 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0,
1593 0, 0, 0},1764 0, 0, 0, &flt_uint},
15941765
1595/*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0,1766/*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0,
1596 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0,1767 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0,
1597 0, 0, 0},1768 0, 0, 0, &dbl_uint},
15981769
1599/*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0,1770/*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0,
1600 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0,1771 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0,
1601 0, 0, 0},1772 0, 0, 0, &dec_uint},
1773
1774 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1775 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1776 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1777
1602/*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0,1778/*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0,
1603 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0,1779 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0,
1604 0, 0, 0},1780 0, 0, 0, &int_uint},
1781
1605/*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0,1782/*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0,
1606 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1783 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1607 0, 0, 0},1784 0, 0, 0, 0},
1785
1608/*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0,1786/*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0,
1609 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1787 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1610 0, 0, 0},1788 0, 0, 0, 0},
1789
1611/*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0,1790/*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0,
1612 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1791 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1613 0, 0, 0},1792 0, 0, 0, 0},
1614 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/1793
1615 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1616 /*aURI*/ /*QN*/ /*NOT*/
1617/*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT,1794/*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT,
1618 &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0,1795 &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0,
1619 0, 0, 0},1796 0, 0, 0, 0},
1797
1798 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1799 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1800 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1801
1620/*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0,1802/*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0,
1621 &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0,1803 &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1622 0, 0, 0},1804 0, 0, 0, 0},
1805
1623/*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT,1806/*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT,
1624 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0,1807 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0,
1625 0, 0, 0},1808 0, 0, 0, 0},
1809
1626/*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0,1810/*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0,
1627 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0,1811 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0,
1628 0, 0, 0},1812 0, 0, 0, 0},
1813
1629/*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0,1814/*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0,
1630 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0,1815 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0,
1631 0, 0, 0},1816 0, 0, 0, 0},
1817
1632/*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0,1818/*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0,
1633 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0,1819 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0,
1634 0, 0, 0},1820 0, 0, 0, 0},
1821
1822 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1823 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1824 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1825
1635/*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0,1826/*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0,
1636 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0,1827 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0,
1637 0, 0, 0},1828 0, 0, 0, 0},
1829
1638/*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0,1830/*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0,
1639 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0,1831 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0,
1640 0, 0, 0},1832 0, 0, 0, 0},
1833
1641/*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0,1834/*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0,
1642 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0,1835 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0,
1643 0, 0, 0},1836 0, 0, 0, &bool_uint},
1837
1644/*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0,1838/*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0,
1645 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB,1839 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB,
1646 0, 0, 0},1840 0, 0, 0, 0},
1841
1647/*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0,1842/*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0,
1648 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB,1843 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB,
1649 0, 0, 0},1844 0, 0, 0, 0},
1845
1846 /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/
1847 /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/
1848 /*aURI*/ /*QN*/ /*NOT*/ /*uint*/
1849
1650/*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0,1850/*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0,
1651 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1851 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1652 &aURI_aURI,0, 0},1852 &aURI_aURI,0, 0, 0},
1853
1653/*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0,1854/*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1855 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, &QN_QN, 0},1856 0, &QN_QN, 0, 0},
1857
1656/*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0,1858/*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0,
1657 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1859 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1658 0, 0, &NOT_NOT}1860 0, 0, &NOT_NOT, 0},
1861
1862/*uint*/ {&uint_uA, &uint_str, &uint_flt, &uint_dbl, &uint_dec, &uint_int, 0, 0, 0, 0,
1863 0, 0, 0, 0, 0, 0, 0, &uint_bool,0, 0,
1864 0, 0, 0, &uint_uint},
1659};1865};
16601866
16611867
16621868
=== modified file 'src/types/casting.h'
--- src/types/casting.h 2011-06-14 17:26:33 +0000
+++ src/types/casting.h 2011-11-29 00:43:26 +0000
@@ -49,8 +49,8 @@
49 ); 49 );
50private:50private:
51 static const int theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];51 static const int theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
52 static const CastFunc theCastMatrix[23][23];52 static const CastFunc theCastMatrix[24][24];
53 static const DownCastFunc theDownCastMatrix[23];53 static const DownCastFunc theDownCastMatrix[24];
5454
55 GenericCast() {}55 GenericCast() {}
56 56
5757
=== modified file 'src/types/schema/XercesParseUtils.cpp'
--- src/types/schema/XercesParseUtils.cpp 2011-06-30 05:16:55 +0000
+++ src/types/schema/XercesParseUtils.cpp 2011-11-29 00:43:26 +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 2011-10-11 17:59:20 +0000
+++ src/util/stl_util.h 2011-11-29 00:43:26 +0000
@@ -199,6 +199,13 @@
199///////////////////////////////////////////////////////////////////////////////199///////////////////////////////////////////////////////////////////////////////
200200
201template<typename NumericType> inline201template<typename NumericType> inline
202typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<NumericType>::value,
203 bool>::type
204gt0( NumericType n ) { // for completeness
205 return n > 0;
206}
207
208template<typename NumericType> inline
202typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type209typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
203ge0( NumericType n ) {210ge0( NumericType n ) {
204 return n >= 0;211 return n >= 0;
@@ -210,6 +217,30 @@
210 return true;217 return true;
211}218}
212219
220template<typename NumericType> inline
221typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
222lt0( NumericType n ) {
223 return n < 0;
224}
225
226template<typename IntType> inline
227typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type
228lt0( IntType ) {
229 return false;
230}
231
232template<typename NumericType> inline
233typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type
234le0( NumericType n ) {
235 return n <= 0;
236}
237
238template<typename IntType> inline
239typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type
240le0( IntType n ) {
241 return n == 0;
242}
243
213///////////////////////////////////////////////////////////////////////////////244///////////////////////////////////////////////////////////////////////////////
214245
215template<typename T> class stack_generator {246template<typename T> class stack_generator {
216247
=== modified file 'src/util/string_util.cpp'
--- src/util/string_util.cpp 2011-07-07 18:48:27 +0000
+++ src/util/string_util.cpp 2011-11-29 00:43:26 +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 2011-09-30 14:06:33 +0000
+++ src/zorbaserialization/zorba_class_serializer.cpp 2011-11-29 00:43:26 +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 2011-07-07 12:05:43 +0000
+++ src/zorbaserialization/zorba_class_serializer.h 2011-11-29 00:43:26 +0000
@@ -37,13 +37,22 @@
37 class function;37 class function;
38 class Diagnostic;38 class Diagnostic;
39 class ZorbaException;39 class ZorbaException;
40 class Integer;40#ifdef ZORBA_WITH_BIG_INTEGER
41 class IntegerImpl;
42#else
43 template<typename IntType> class IntegerImpl;
44#endif /* ZORBA_WITH_BIG_INTEGER */
4145
42 namespace serialization{46 namespace serialization{
43//void operator&(Archiver &ar, XQType *&obj);47//void operator&(Archiver &ar, XQType *&obj);
44void operator&(Archiver &ar, const XQType *&obj);48void operator&(Archiver &ar, const XQType *&obj);
45void operator&(Archiver &ar, MAPM &obj);49void operator&(Archiver &ar, MAPM &obj);
46void operator&(Archiver &ar, Integer &obj);50#ifdef ZORBA_WITH_BIG_INTEGER
51void operator&(Archiver &ar, IntegerImpl &obj);
52#else
53template<typename IntType>
54void operator&(Archiver &ar, IntegerImpl<IntType> &obj);
55#endif /* ZORBA_WITH_BIG_INTEGER */
4756
48void operator&(Archiver &ar, XQPCollator *&obj);57void operator&(Archiver &ar, XQPCollator *&obj);
49void operator&(Archiver &ar, store::Item* &obj);58void operator&(Archiver &ar, store::Item* &obj);
5059
=== modified file 'src/zorbatypes/decimal.cpp'
--- src/zorbatypes/decimal.cpp 2011-07-06 19:59:26 +0000
+++ src/zorbatypes/decimal.cpp 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-11-29 00:43:26 +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 2011-10-26 13:43:15 +0000
+++ test/rbkt/Queries/CMakeLists.txt 2011-11-29 00:43:26 +0000
@@ -213,15 +213,7 @@
213 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285)213 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285)
214 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732)214 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732)
215215
216 IF(NOT ZORBA_WITH_BIG_INTEGER)216 IF (ZORBA_TEST_XQUERYX)
217 # These tests fail due to integer overflow.
218 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 3323548)
219 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 3323548)
220 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 3323548)
221 EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 3323548)
222 ENDIF(NOT ZORBA_WITH_BIG_INTEGER)
223
224 IF(ZORBA_TEST_XQUERYX)
225217
226 #w3c bug218 #w3c bug
227 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes011 3355019)219 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes011 3355019)
@@ -229,12 +221,22 @@
229 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019)221 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019)
230 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019)222 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019)
231 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019)223 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019)
232 ENDIF(ZORBA_TEST_XQUERYX)224 ENDIF (ZORBA_TEST_XQUERYX)
233 225
234 #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.226 #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.
235 #W3C has changed the expected result for this test in the meantime: please see http://www.w3.org/Bugs/Public/show_bug.cgi?id=12542227 #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
236 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002)228 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002)
237229
230 IF (NOT ZORBA_WITH_BIG_INTEGER)
231 # These test will never pass without big integers beause the integers used
232 # in the queries exceed a 63-bit signed integer.
233 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 867059)
234 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 867059)
235 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 867059)
236 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 867059)
237 EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 867059)
238 ENDIF (NOT ZORBA_WITH_BIG_INTEGER)
239
238ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS)240ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS)
239241
240# The dirname_basename test depends on the system module242# The dirname_basename test depends on the system module
@@ -293,4 +295,3 @@
293EXPECTED_FAILURE(test/rbkt/zorba/http-client/post/post3_binary_element 3391756)295EXPECTED_FAILURE(test/rbkt/zorba/http-client/post/post3_binary_element 3391756)
294296
295EXPECTED_FAILURE(test/rbkt/zorba/reference/reference_5 868640)297EXPECTED_FAILURE(test/rbkt/zorba/reference/reference_5 868640)
296
297298
=== modified file 'test/rbkt/Queries/w3c_known_failures.txt'
--- test/rbkt/Queries/w3c_known_failures.txt 2011-10-26 13:43:15 +0000
+++ test/rbkt/Queries/w3c_known_failures.txt 2011-11-29 00:43:26 +0000
@@ -117,7 +117,8 @@
117test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01117test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01
118test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001118test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001
119test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context119test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context
120test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22
121test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1
120test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2122test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2
121test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1123test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1
122test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2124test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2
123test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1

Subscribers

People subscribed via source and target branches