zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #00093
[Merge] lp:~ceejatec/zorba/sf-trunk into lp:zorba
Chris Hillery has proposed merging lp:~ceejatec/zorba/sf-trunk into lp:zorba.
Requested reviews:
Chris Hillery (ceejatec)
For more details, see:
https://code.launchpad.net/~ceejatec/zorba/sf-trunk/+merge/76673
Merge of Sourceforge changes through r12126.
--
https://code.launchpad.net/~ceejatec/zorba/sf-trunk/+merge/76673
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/dynamic_context.h'
--- include/zorba/dynamic_context.h 2011-07-24 22:28:31 +0000
+++ include/zorba/dynamic_context.h 2011-09-23 06:20:29 +0000
@@ -211,7 +211,7 @@
/** \brief Add a name-value pair the this context.
* The value can be accessed in the evaluate method
- * of external functions (see NonePureStatelessExternalFunction).
+ * of external functions (see ContextualExternalFunction).
*
* @param aName the name of the parameter to add
* @param aValue the value that can be accessed in the evaluate method.
@@ -224,7 +224,7 @@
/** \brief Get the value of a pair that was registered using
* the addExternalFunctionParam method. This can
* be used in the evaluate method
- * of external functions (see NonePureStatelessExternalFunction).
+ * of external functions (see ContextualExternalFunction).
*
* @param aName the name of the parameter to retrieve
* @param aValue the value matching the given name if true is returned.
=== modified file 'include/zorba/identtypes.h'
--- include/zorba/identtypes.h 2011-06-14 17:26:33 +0000
+++ include/zorba/identtypes.h 2011-09-23 06:20:29 +0000
@@ -22,16 +22,16 @@
class ZORBA_DLL_PUBLIC IdentTypes {
public:
typedef enum {
- NAMED_TYPE,
+ NAMED_TYPE, // builtin atomic type
ELEMENT_TYPE,
ATTRIBUTE_TYPE,
DOCUMENT_TYPE,
PI_TYPE,
TEXT_TYPE,
COMMENT_TYPE,
- ANY_NODE_TYPE,
- ITEM_TYPE,
- EMPTY_TYPE,
+ ANY_NODE_TYPE, // node()
+ ITEM_TYPE, // item()
+ EMPTY_TYPE, // empty-sequence()
INVALID_TYPE,
} kind_t;
=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp 2011-09-21 04:14:38 +0000
+++ src/store/naive/pul_primitives.cpp 2011-09-23 06:20:29 +0000
@@ -182,11 +182,11 @@
{
theSibling.transfer(sibling);
- size_t numNewChildren = 0;
- size_t numChildren = children.size();
+ std::size_t numNewChildren = 0;
+ std::size_t numChildren = children.size();
theNewChildren.resize(numChildren);
- for (size_t i = 0; i < numChildren; i++)
+ for (std::size_t i = 0; i < numChildren; i++)
{
if (i > 0 &&
children[i]->getNodeKind() == store::StoreConsts::textNode &&
@@ -286,9 +286,10 @@
UpdatePrimitive(pul, aLoc, target),
theNumApplied(0)
{
- size_t numAttrs = attrs.size();
+ std::size_t numAttrs = attrs.size();
theNewAttrs.resize(numAttrs);
- for (size_t i = 0; i < numAttrs; i++) {
+ for (std::size_t i = 0; i < numAttrs; i++)
+ {
theNewAttrs[i].transfer(attrs[i]);
}
}
@@ -336,9 +337,10 @@
{
theAttr.transfer(attr);
- size_t numAttrs = (uint64_t)newAttrs.size();
+ std::size_t numAttrs = newAttrs.size();
theNewAttrs.resize(numAttrs);
- for (size_t i = 0; i < numAttrs; i++) {
+ for (std::size_t i = 0; i < numAttrs; i++)
+ {
theNewAttrs[i].transfer(newAttrs[i]);
}
}
@@ -739,10 +741,11 @@
{
theName.transfer(name);
- size_t numNodes = (uint64_t)nodes.size();
+ std::size_t numNodes = nodes.size();
theNodes.resize(numNodes);
- for (size_t i = 0; i < numNodes; ++i) {
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
theNodes[i].transfer(nodes[i]);
}
}
@@ -761,10 +764,11 @@
{
theName.transfer(name);
- size_t numNodes = (uint64_t)nodes.size();
+ std::size_t numNodes = nodes.size();
theNodes.resize(numNodes);
- for (size_t i = 0; i < numNodes; ++i) {
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
theNodes[i].transfer(nodes[i]);
}
}
@@ -877,8 +881,9 @@
theIsApplied = true;
- size_t numNodes = (uint64_t)theNodes.size();
- for (size_t i = 0; i < numNodes; ++i) {
+ std::size_t numNodes = theNodes.size();
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
lColl->addNode(theNodes[i], -1);
++theNumApplied;
}
@@ -927,8 +932,9 @@
theCollectionPul->setAdjustTreePositions();
- size_t numNodes = (uint64_t)theNodes.size();
- for (size_t i = 0; i < numNodes; ++i) {
+ std::size_t numNodes = theNodes.size();
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
lColl->addNode(theNodes[i], i);
++theNumApplied;
}
@@ -941,7 +947,8 @@
(GET_STORE().getCollection(theName, theDynamicCollection).getp());
assert(lColl);
- for (size_t i = 0; i < theNumApplied; ++i) {
+ for (std::size_t i = 0; i < theNumApplied; ++i)
+ {
ZORBA_ASSERT(theNodes[i] == lColl->nodeAt(0));
lColl->removeNode((uint64_t)0);
@@ -960,8 +967,9 @@
theIsApplied = true;
- size_t numNodes = (uint64_t)theNodes.size();
- for (size_t i = 0; i < numNodes; ++i) {
+ std::size_t numNodes = theNodes.size();
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
lColl->addNode(theNodes[i], -1);
}
}
@@ -1069,9 +1077,12 @@
theIsApplied = true;
uint64_t size;
- try {
+ try
+ {
size = to_xs_unsignedLong(lColl->size());
- } catch (std::range_error& e) {
+ }
+ catch (std::range_error& e)
+ {
throw ZORBA_EXCEPTION(
zerr::ZSTR0060_RANGE_EXCEPTION,
ERROR_PARAMS(
@@ -1081,27 +1092,32 @@
);
}
- size_t numNodes = theNodes.size();
+ std::size_t numNodes = theNodes.size();
bool isLast = theIsLast;
- if (theIsLast) {
- for (size_t i = numNodes; i > 0; --i) {
- if (theNodes[i-1] != lColl->nodeAt(size - i)) {
+ if (theIsLast)
+ {
+ for (std::size_t i = numNodes; i > 0; --i)
+ {
+ if (theNodes[i-1] != lColl->nodeAt(size - i))
+ {
isLast = false;
break;
}
}
}
- if (!isLast) {
+ if (!isLast)
+ {
theCollectionPul->setAdjustTreePositions();
}
theFound.resize(numNodes);
thePositions.resize(numNodes);
- for (size_t i = 0; i < numNodes; ++i) {
+ for (std::size_t i = 0; i < numNodes; ++i)
+ {
theFound[i] = lColl->removeNode(theNodes[i], thePositions[i]);
++theNumApplied;
}
@@ -1113,8 +1129,10 @@
(GET_STORE().getCollection(theName, theDynamicCollection).getp());
assert(lColl);
- for (size_t i = 0; i < theNumApplied; ++i) {
- if (theFound[i]) {
+ for (std::size_t i = 0; i < theNumApplied; ++i)
+ {
+ if (theFound[i])
+ {
lColl->addNode(theNodes[i], thePositions[i]);
}
}
=== modified file 'src/store/naive/simple_collection.cpp'
--- src/store/naive/simple_collection.cpp 2011-09-12 22:42:28 +0000
+++ src/store/naive/simple_collection.cpp 2011-09-23 06:20:29 +0000
@@ -128,8 +128,9 @@
}
else
{
- theXmlTrees.insert(theXmlTrees.begin() + lPosition, nodeItem);
- node->setCollection(this, lPosition);
+
+ theXmlTrees.insert(theXmlTrees.begin() + (std::size_t)lPosition, nodeItem);
+ node->setCollection(this, to_xs_unsignedInt(lPosition));
}
}
@@ -149,7 +150,6 @@
xs_integer targetPos;
bool found = findNode(targetNode, targetPos);
- uint64_t lTargetPos = to_xs_long(targetPos);
if (!found)
{
@@ -159,13 +159,17 @@
);
}
+ std::size_t lTargetPos = to_xs_unsignedInt(targetPos);
+
if (!before)
+ {
++lTargetPos;
+ }
- uint64_t numNodes = (uint64_t)theXmlTrees.size();
- uint64_t numNewNodes = (uint64_t)nodes.size();
+ std::size_t numNodes = theXmlTrees.size();
+ std::size_t numNewNodes = nodes.size();
- for (uint64_t i = 0; i < numNewNodes; ++i)
+ for (std::size_t i = 0; i < numNewNodes; ++i)
{
if (!nodes[i]->isNode())
{
@@ -209,8 +213,10 @@
(numNodes-lTargetPos) * sizeof(store::Item_t));
}
- for (uint64_t i = lTargetPos; i < lTargetPos + numNewNodes; ++i)
+ for (std::size_t i = lTargetPos; i < lTargetPos + numNewNodes; ++i)
+ {
theXmlTrees[i].setNull();
+ }
#else
for (long j = numNodes-1, i = theXmlTrees.size()-1; j >= lTargetPos; --j, --i)
{
@@ -218,7 +224,7 @@
}
#endif
- for (uint64_t i = 0; i < numNewNodes; ++i)
+ for (std::size_t i = 0; i < numNewNodes; ++i)
{
theXmlTrees[lTargetPos + i].transfer(nodes[i]);
}
@@ -247,13 +253,13 @@
SYNC_CODE(AutoLatch lock(theLatch, Latch::WRITE);)
bool found = findNode(nodeItem, position);
- uint64_t lPosition = to_xs_long(position);
if (found)
{
ZORBA_ASSERT(node->getCollection() == this);
node->setCollection(NULL, 0);
+ std::size_t lPosition = to_xs_unsignedInt(position);
theXmlTrees.erase(theXmlTrees.begin() + lPosition);
return true;
}
@@ -273,13 +279,12 @@
{
SYNC_CODE(AutoLatch lock(theLatch, Latch::WRITE);)
- uint64_t lPosition = to_xs_long(position);
+ std::size_t lPosition = to_xs_unsignedInt(position);
- if (lPosition >= theXmlTrees.size())
- {
+ if (lPosition >= theXmlTrees.size()) {
return false;
}
- else
+ else
{
XmlNode* node = static_cast<XmlNode*>(theXmlTrees[lPosition].getp());
ZORBA_ASSERT(node->getCollection() == this);
@@ -301,20 +306,22 @@
{
SYNC_CODE(AutoLatch lock(theLatch, Latch::WRITE);)
- uint64_t lPosition = to_xs_long(position);
- uint64_t lNum = to_xs_long(num);
+ std::size_t lPosition = to_xs_unsignedInt(position);
+ std::size_t lNum = to_xs_unsignedInt(num);
if (lNum == 0 || lPosition >= theXmlTrees.size())
{
return 0;
}
- else
+ else
{
uint64_t last = lPosition + lNum;
if (last > theXmlTrees.size())
+ {
last = theXmlTrees.size();
+ }
- for (uint64_t i = lPosition; i < last; ++i)
+ for (std::size_t i = lPosition; i < last; ++i)
{
XmlNode* node = static_cast<XmlNode*>(theXmlTrees[lPosition].getp());
ZORBA_ASSERT(node->getCollection() == this);
@@ -334,7 +341,7 @@
********************************************************************************/
store::Item_t SimpleCollection::nodeAt(xs_integer position)
{
- uint64_t lPosition = to_xs_long(position);
+ std::size_t lPosition = to_xs_unsignedInt(position);
if (lPosition >= theXmlTrees.size())
{
return NULL;
@@ -369,7 +376,7 @@
position = n->getTree()->getPosition();
- uint64_t lPosition = to_xs_long(position);
+ std::size_t lPosition = to_xs_unsignedInt(position);
if (lPosition < theXmlTrees.size() &&
BASE_NODE(theXmlTrees[lPosition])->getTreeId() == n->getTreeId())
@@ -377,9 +384,9 @@
return true;
}
- uint64_t numTrees = (uint64_t)theXmlTrees.size();
+ std::size_t numTrees = theXmlTrees.size();
- for (uint64_t i = 0; i < numTrees; ++i)
+ for (std::size_t i = 0; i < numTrees; ++i)
{
// check if the nodes are the same
if (node->equals(theXmlTrees[i]))
@@ -407,9 +414,9 @@
********************************************************************************/
void SimpleCollection::adjustTreePositions()
{
- uint64_t numTrees = (uint64_t)theXmlTrees.size();
+ std::size_t numTrees = (uint64_t)theXmlTrees.size();
- for (uint64_t i = 0; i < numTrees; ++i)
+ for (std::size_t i = 0; i < numTrees; ++i)
{
BASE_NODE(theXmlTrees[i])->getTree()->setPosition(i);
}
@@ -435,7 +442,7 @@
const std::vector<store::Item_t>& indexSources = indexSpec.theSources;
uint64_t numIndexSources = (uint64_t)indexSources.size();
- for (uint64_t i = 0; i < numIndexSources; ++i)
+ for (std::size_t i = 0; i < numIndexSources; ++i)
{
if (indexSources[i]->equals(getName()))
{
Follow ups