Code

Rearrange to enable code that does not directly rely on lcms.
[inkscape.git] / src / dom / xpathtoken.cpp
index f08dfe7e3b7498b4d586d4b5d8e5d98499eb7df8..921cbf04437916818ffc2f934d0bb6a45df6b20d 100644 (file)
@@ -10,7 +10,7 @@
  * Authors:
  *   Bob Jamison
  *
- * Copyright (C) 2006 Bob Jamison
+ * Copyright (C) 2006-2008 Bob Jamison
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -58,6 +58,12 @@ namespace xpath
 //# V A L U E S
 //###########################
 
+/**
+ * The following functions are called by a token's execute()
+ * method.  These functions are what differentiate one token
+ * from another and give each its personality.
+*/
+
 static bool tokStr(Token &tok, Stack &stack)
 {
     StackItem item;
@@ -82,7 +88,7 @@ static bool tokInt(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokAnd(Token &tok, Stack &stack)
+static bool tokAnd(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -91,7 +97,7 @@ static bool tokAnd(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokOr(Token &tok, Stack &stack)
+static bool tokOr(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -100,7 +106,7 @@ static bool tokOr(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokMod(Token &tok, Stack &stack)
+static bool tokMod(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -110,7 +116,7 @@ static bool tokMod(Token &tok, Stack &stack)
 }
 
 
-static bool tokDiv(Token &tok, Stack &stack)
+static bool tokDiv(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -119,7 +125,7 @@ static bool tokDiv(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokMul(Token &tok, Stack &stack)
+static bool tokMul(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -128,7 +134,7 @@ static bool tokMul(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokPlus(Token &tok, Stack &stack)
+static bool tokPlus(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -137,7 +143,7 @@ static bool tokPlus(Token &tok, Stack &stack)
     return true;
 }
 
-static bool tokMinus(Token &tok, Stack &stack)
+static bool tokMinus(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -147,7 +153,7 @@ static bool tokMinus(Token &tok, Stack &stack)
 }
 
 
-static bool tokNeg(Token &tok, Stack &stack)
+static bool tokNeg(Token &/*tok*/, Stack &stack)
 {
     StackItem item = stack.pop();
     item.dval = -item.dval;
@@ -157,7 +163,7 @@ static bool tokNeg(Token &tok, Stack &stack)
 }
 
 
-static bool tokEquals(Token &tok, Stack &stack)
+static bool tokEquals(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -167,7 +173,7 @@ static bool tokEquals(Token &tok, Stack &stack)
 }
 
 
-static bool tokNotEquals(Token &tok, Stack &stack)
+static bool tokNotEquals(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -177,7 +183,7 @@ static bool tokNotEquals(Token &tok, Stack &stack)
 }
 
 
-static bool tokLessThan(Token &tok, Stack &stack)
+static bool tokLessThan(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -187,7 +193,7 @@ static bool tokLessThan(Token &tok, Stack &stack)
 }
 
 
-static bool tokLessThanEquals(Token &tok, Stack &stack)
+static bool tokLessThanEquals(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -197,7 +203,7 @@ static bool tokLessThanEquals(Token &tok, Stack &stack)
 }
 
 
-static bool tokGreaterThanEquals(Token &tok, Stack &stack)
+static bool tokGreaterThanEquals(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -207,7 +213,7 @@ static bool tokGreaterThanEquals(Token &tok, Stack &stack)
 }
 
 
-static bool tokGreaterThan(Token &tok, Stack &stack)
+static bool tokGreaterThan(Token &/*tok*/, Stack &stack)
 {
     StackItem item1 = stack.pop();
     StackItem item2 = stack.pop();
@@ -225,32 +231,32 @@ static bool tokGreaterThan(Token &tok, Stack &stack)
 //# X P A T H    I T E M S
 //###########################
 
-static bool tokAbsolute(Token &tok, Stack &stack)
+static bool tokAbsolute(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
-static bool tokRelative(Token &tok, Stack &stack)
+static bool tokRelative(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
-static bool tokStep(Token &tok, Stack &stack)
+static bool tokStep(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
-static bool tokNameTest(Token &tok, Stack &stack)
+static bool tokNameTest(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
-static bool tokExpr(Token &tok, Stack &stack)
+static bool tokExpr(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
-static bool tokUnion(Token &tok, Stack &stack)
+static bool tokUnion(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
@@ -263,79 +269,79 @@ static bool tokUnion(Token &tok, Stack &stack)
 //###########################
 
 
-static bool tokAxisAncestorOrSelf(Token &tok, Stack &stack)
+static bool tokAxisAncestorOrSelf(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisAncestor(Token &tok, Stack &stack)
+static bool tokAxisAncestor(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisAttribute(Token &tok, Stack &stack)
+static bool tokAxisAttribute(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisChild(Token &tok, Stack &stack)
+static bool tokAxisChild(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisDescendantOrSelf(Token &tok, Stack &stack)
+static bool tokAxisDescendantOrSelf(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisDescendant(Token &tok, Stack &stack)
+static bool tokAxisDescendant(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisFollowingSibling(Token &tok, Stack &stack)
+static bool tokAxisFollowingSibling(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisFollowing(Token &tok, Stack &stack)
+static bool tokAxisFollowing(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisNamespace(Token &tok, Stack &stack)
+static bool tokAxisNamespace(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisParent(Token &tok, Stack &stack)
+static bool tokAxisParent(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisPrecedingSibling(Token &tok, Stack &stack)
+static bool tokAxisPrecedingSibling(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisPreceding(Token &tok, Stack &stack)
+static bool tokAxisPreceding(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokAxisSelf(Token &tok, Stack &stack)
+static bool tokAxisSelf(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
@@ -347,178 +353,183 @@ static bool tokAxisSelf(Token &tok, Stack &stack)
 //###########################
 
 
-static bool tokFuncLast(Token &tok, Stack &stack)
+static bool tokFuncLast(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncPosition(Token &tok, Stack &stack)
+static bool tokFuncPosition(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncCount(Token &tok, Stack &stack)
+static bool tokFuncCount(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncId(Token &tok, Stack &stack)
+static bool tokFuncId(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncLocalName(Token &tok, Stack &stack)
+static bool tokFuncLocalName(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncNamespaceUri(Token &tok, Stack &stack)
+static bool tokFuncNamespaceUri(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncName(Token &tok, Stack &stack)
+static bool tokFuncName(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncString(Token &tok, Stack &stack)
+static bool tokFuncString(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncConcat(Token &tok, Stack &stack)
+static bool tokFuncConcat(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncStartsWith(Token &tok, Stack &stack)
+static bool tokFuncStartsWith(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncContains(Token &tok, Stack &stack)
+static bool tokFuncContains(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncSubstringBefore(Token &tok, Stack &stack)
+static bool tokFuncSubstringBefore(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncSubstringAfter(Token &tok, Stack &stack)
+static bool tokFuncSubstringAfter(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncSubstring(Token &tok, Stack &stack)
+static bool tokFuncSubstring(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncStringLength(Token &tok, Stack &stack)
+static bool tokFuncStringLength(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncNormalizeSpace(Token &tok, Stack &stack)
+static bool tokFuncNormalizeSpace(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncTranslate(Token &tok, Stack &stack)
+static bool tokFuncTranslate(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncBoolean(Token &tok, Stack &stack)
+static bool tokFuncBoolean(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncNot(Token &tok, Stack &stack)
+static bool tokFuncNot(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncTrue(Token &tok, Stack &stack)
+static bool tokFuncTrue(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncFalse(Token &tok, Stack &stack)
+static bool tokFuncFalse(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncLang(Token &tok, Stack &stack)
+static bool tokFuncLang(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncNumber(Token &tok, Stack &stack)
+static bool tokFuncNumber(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncSum(Token &tok, Stack &stack)
+static bool tokFuncSum(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncFloor(Token &tok, Stack &stack)
+static bool tokFuncFloor(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncCeiling(Token &tok, Stack &stack)
+static bool tokFuncCeiling(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
-static bool tokFuncRound(Token &tok, Stack &stack)
+static bool tokFuncRound(Token &/*tok*/, Stack &/*stack*/)
 {
     return true;
 }
 
 
 
-
-
+/**
+ * An entry for the token 'personality' table
+ */
 typedef struct
 {
     int ival;
-    char *sval;
+    char const *sval;
     TokenFunc tokenFunc;
 } TokenTableEntry;
 
+
+/**
+ * The token personality table
+ */
 static TokenTableEntry tokenTable[] =
 {
     //### primitives
@@ -976,7 +987,7 @@ void TokenExecutor::reset()
  */
 int TokenExecutor::execute(std::vector<Token> &tokens,
                             int position,
-                            const Node *node,
+                            const NodePtr /*node*/,
                             NodeList &result)
 {
     Stack stack(*this);
@@ -994,7 +1005,7 @@ int TokenExecutor::execute(std::vector<Token> &tokens,
             //Do rest of tokens with the nodes we have found so far
             for (unsigned int i = 0 ; i<contextNodes.getLength() ; i++)
                 {
-                Node *contextNode = contextNodes.item(i);
+                NodePtr contextNode = contextNodes.item(i);
                 pos2 = execute(tokens, position, contextNode, result);
                 if (pos2 < 0)
                     {
@@ -1021,7 +1032,7 @@ int TokenExecutor::execute(std::vector<Token> &tokens,
  * Execute the tokens in a TokenList upon a given node
  */
 bool TokenExecutor::execute(TokenList &tokenList,
-                            const Node *node,
+                            const NodePtr node,
                             NodeList &result)
 {