diff options
| author | Ted Gould <ted@gould.cx> | 2006-05-02 05:49:17 +0000 |
|---|---|---|
| committer | gouldtj <gouldtj@users.sourceforge.net> | 2006-05-02 05:49:17 +0000 |
| commit | c0f13f760674b431f30b5ff17469030c5fa5a8d4 (patch) | |
| tree | 6286959e37edefe5122a963efe6f8f66fdd67bcc /src/dom | |
| parent | r11623@tres: ted | 2006-05-01 22:17:40 -0700 (diff) | |
| download | inkscape-c0f13f760674b431f30b5ff17469030c5fa5a8d4.tar.gz inkscape-c0f13f760674b431f30b5ff17469030c5fa5a8d4.zip | |
r11667@tres: ted | 2006-05-01 22:48:49 -0700
Backing out version 11530. SVK is so liberating and so frustrating all
at the same time.
(bzr r697)
Diffstat (limited to 'src/dom')
| -rw-r--r-- | src/dom/domimpl.cpp | 2 | ||||
| -rw-r--r-- | src/dom/xpathtoken.cpp | 120 | ||||
| -rw-r--r-- | src/dom/xpathtoken.h | 162 |
3 files changed, 156 insertions, 128 deletions
diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 026dc37c6..ecbfd123d 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -936,7 +936,7 @@ NodeImpl::NodeImpl() : Node() /** * */ -NodeImpl::NodeImpl(const NodeImpl &other) +NodeImpl::NodeImpl(const NodeImpl &other) : Node() { init(); assign(other); diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp index 2d5dfc1d7..c9d4898d7 100644 --- a/src/dom/xpathtoken.cpp +++ b/src/dom/xpathtoken.cpp @@ -131,12 +131,12 @@ static TokenStringPair tokenStrings[] = /**
- * Return the enumerated TokenType of this token
+ * Return the string TokenType of this token
* (in the .cpp file)
*/
DOMString Token::getTypeString()
{
- DOMString ret;
+ DOMString ret = "unknown";
for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++)
{
if (pair->ival == type)
@@ -148,6 +148,8 @@ DOMString Token::getTypeString() return ret;
}
+
+
//########################################################################
//# X P A T H A X I S
//########################################################################
@@ -166,7 +168,8 @@ Axis::Axis() */
Axis::Axis(int tokPos)
{
- assign(other);
+ init();
+ tokenPosition = tokPos;
}
@@ -183,7 +186,15 @@ Axis::Axis(const Axis &other) /**
*
*/
-StackItem &StackItem::operator=(const StackItem &other)
+Axis::~Axis()
+{
+}
+
+
+/**
+ *
+ */
+Axis &Axis::operator=(const Axis &other)
{
assign(other);
return *this;
@@ -192,105 +203,99 @@ StackItem &StackItem::operator=(const StackItem &other) /**
*
*/
-void StackItem::assign(const StackItem &other)
+void Axis::init()
{
- sval = other.sval;
- ival = other.ival;
- dval = other.dval;
+ tokenPosition = 0;
}
-
-//########################################################################
-//# X P A T H S T A C K I T E M
-//########################################################################
-
/**
*
*/
-StackItem::StackItem()
+void Axis::assign(const Axis &other)
{
- ival = 0L;
- dval = 0.0;
+ tokenPosition = other.tokenPosition;
}
-
/**
*
*/
-StackItem::StackItem(const StackItem &other)
+void Axis::setPosition(unsigned int val)
{
- assign(other);
+ tokenPosition = val;
}
-
/**
*
*/
-Stack::~Stack()
+unsigned int Axis::getPosition()
{
+ return tokenPosition;
}
-
/**
*
*/
-void Stack::assign(const Stack &other)
+void Axis::setNode(const Node *val)
{
- root = other.root;
- nodeList = other.nodeList;
- size = other.size;
- for (int i=0 ; i<size ; i++)
- items[i] = other.items[i];
+ node = (Node *)val;
}
-
/**
*
*/
-void Stack::reset()
+Node *Axis::getNode()
{
- root = NULL;
- NodeList n; /*no "clear" in api*/
- nodeList = n;
- size = 0;
+ return node;
}
+//########################################################################
+//# X P A T H S T A C K I T E M
+//########################################################################
+/**
+ *
+ */
+StackItem::StackItem()
+{
+ ival = 0L;
+ dval = 0.0;
+}
/**
*
*/
-StackItem &StackItem::operator=(const StackItem &other)
+StackItem::StackItem(const StackItem &other)
{
assign(other);
- return *this;
}
+
/**
*
*/
-void StackItem::assign(const StackItem &other)
+StackItem::~StackItem()
{
- sval = other.sval;
- ival = other.ival;
- dval = other.dval;
}
+
/**
- * Set the root node
+ *
*/
-void Stack::setRootNode(const Node *node)
+StackItem &StackItem::operator=(const StackItem &other)
{
- root = (Node *)node;
+ assign(other);
+ return *this;
}
/**
- * Get the current node list;
+ *
*/
-NodeList &Stack::getNodeList()
+void StackItem::assign(const StackItem &other)
{
- return nodeList;
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
}
@@ -370,22 +375,31 @@ unsigned int TokenList::size() const }
- Stack stack;
- stack.setRootNode(root);
-
- //### Execute the token list
+/**
+ *
+ */
+void TokenList::dump()
+{
std::vector<Token *>::iterator iter;
printf("############# TOKENS\n");
for (iter = tokens.begin() ; iter != tokens.end() ; iter++)
{
Token *tok = *iter;
- tok->execute(stack);
+ tok->dump();
}
}
- list = stack.getNodeList();
- return list;
+//########################################################################
+//# X P A T H E X E C U T O R
+//########################################################################
+
+/**
+ *
+ */
+TokenExecutor::TokenExecutor()
+{
+ reset();
}
diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index 03175efb1..d595ad43c 100644 --- a/src/dom/xpathtoken.h +++ b/src/dom/xpathtoken.h @@ -199,7 +199,7 @@ public: /**
* Assign our values to those of the other
*/
- virtual void assign(const Stack &other);
+ virtual void assign(const TokenExecutor &other);
/**
* Reset the stack to its original settings
@@ -217,23 +217,38 @@ public: virtual StackItem pop();
/**
- * Set the root node
+ * Execute a token list on the stack
*/
- virtual void setRootNode(const Node *node);
+ NodeList execute(const TokenList &list, const Node *node);
/**
- * Get the current node list;
+ *
*/
- virtual NodeList &getNodeList();
+ Axis axis;
+ /**
+ *
+ */
+ std::vector<Axis> axisStack;
private:
- Node *root;
+ /**
+ * Contains the StackItem stack;
+ */
+ StackItem stack[STACK_SIZE];
+
+ /**
+ * Marks the head of the stack, for push() and pop()
+ */
+ int stackSize;
+
+ /**
+ * Current list of nodes found by the expression
+ */
NodeList nodeList;
- StackItem items[STACK_SIZE];
- int size;
+
};
@@ -372,8 +387,7 @@ public: virtual int getType()
{ return type; }
/**
- * Return the enumerated TokenType of this token
- * (in the .cpp file)
+ * Return the string TokenType of this token
*/
virtual DOMString getTypeString();
@@ -381,7 +395,7 @@ public: * Let this token execute itself on the given stack,
* possibly adding Nodes to the node list.
*/
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &stack)
{ return true; }
/**
@@ -442,7 +456,7 @@ public: type = TOK_STR;
sval = val;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item;
item.sval = sval;
@@ -459,7 +473,7 @@ public: type = TOK_FLOAT;
dval = val;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item;
item.dval = dval;
@@ -476,7 +490,7 @@ public: type = TOK_INT;
ival = val;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item;
item.ival = ival;
@@ -492,7 +506,7 @@ public: {
type = TOK_AND;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -509,7 +523,7 @@ public: {
type = TOK_OR;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -526,7 +540,7 @@ public: {
type = TOK_MOD;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -543,7 +557,7 @@ public: {
type = TOK_DIV;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -560,7 +574,7 @@ public: {
type = TOK_MULTIPLY;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -577,7 +591,7 @@ public: {
type = TOK_PLUS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -594,7 +608,7 @@ public: {
type = TOK_MINUS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -611,7 +625,7 @@ public: {
type = TOK_NEG;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item = exec.pop();
item.dval = -item.dval;
@@ -628,7 +642,7 @@ public: {
type = TOK_EQUALS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -645,7 +659,7 @@ public: {
type = TOK_NOT_EQUALS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -662,7 +676,7 @@ public: {
type = TOK_LESS_THAN_EQUALS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -679,7 +693,7 @@ public: {
type = TOK_LESS_THAN;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -696,7 +710,7 @@ public: {
type = TOK_GREATER_THAN_EQUALS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -713,7 +727,7 @@ public: {
type = TOK_GREATER_THAN;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
StackItem item1 = exec.pop();
StackItem item2 = exec.pop();
@@ -735,7 +749,7 @@ public: {
type = TOK_ABSOLUTE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
Node *n = exec.axis.getNode();
while (n->getParentNode())
@@ -752,7 +766,7 @@ public: {
type = TOK_RELATIVE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
///exec.axis.currentNode = stack.rootNode;
return true;
@@ -766,7 +780,7 @@ public: {
type = TOK_STEP;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -780,7 +794,7 @@ public: type = TOK_NAME_TEST;
sval = name;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -793,7 +807,7 @@ public: {
type = TOK_EXPR;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -806,7 +820,7 @@ public: {
type = TOK_UNION;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -827,7 +841,7 @@ public: {
type = TOK_AXIS_ANCESTOR_OR_SELF;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -840,7 +854,7 @@ public: {
type = TOK_AXIS_ANCESTOR;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -853,7 +867,7 @@ public: {
type = TOK_AXIS_ATTRIBUTE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -866,7 +880,7 @@ public: {
type = TOK_AXIS_CHILD;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -879,7 +893,7 @@ public: {
type = TOK_AXIS_DESCENDANT_OR_SELF;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -892,7 +906,7 @@ public: {
type = TOK_AXIS_DESCENDANT;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -905,7 +919,7 @@ public: {
type = TOK_AXIS_FOLLOWING_SIBLING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -918,7 +932,7 @@ public: {
type = TOK_AXIS_FOLLOWING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -931,7 +945,7 @@ public: {
type = TOK_AXIS_NAMESPACE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -944,7 +958,7 @@ public: {
type = TOK_AXIS_PARENT;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -957,7 +971,7 @@ public: {
type = TOK_AXIS_PRECEDING_SIBLING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -970,7 +984,7 @@ public: {
type = TOK_AXIS_PRECEDING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -983,7 +997,7 @@ public: {
type = TOK_AXIS_SELF;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1002,7 +1016,7 @@ public: {
type = TOK_FUNC_LAST;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1015,7 +1029,7 @@ public: {
type = TOK_FUNC_POSITION;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1028,7 +1042,7 @@ public: {
type = TOK_FUNC_COUNT;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1041,7 +1055,7 @@ public: {
type = TOK_FUNC_ID;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1054,7 +1068,7 @@ public: {
type = TOK_FUNC_LOCAL_NAME;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1067,7 +1081,7 @@ public: {
type = TOK_FUNC_NAMESPACE_URI;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1080,7 +1094,7 @@ public: {
type = TOK_FUNC_NAME;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1093,7 +1107,7 @@ public: {
type = TOK_FUNC_STRING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1106,7 +1120,7 @@ public: {
type = TOK_FUNC_CONCAT;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1119,7 +1133,7 @@ public: {
type = TOK_FUNC_STARTS_WITH;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1132,7 +1146,7 @@ public: {
type = TOK_FUNC_CONTAINS;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1145,7 +1159,7 @@ public: {
type = TOK_FUNC_SUBSTRING_BEFORE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1158,7 +1172,7 @@ public: {
type = TOK_FUNC_SUBSTRING_AFTER;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1171,7 +1185,7 @@ public: {
type = TOK_FUNC_SUBSTRING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1184,7 +1198,7 @@ public: {
type = TOK_FUNC_STRING_LENGTH;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1197,7 +1211,7 @@ public: {
type = TOK_FUNC_NORMALIZE_SPACE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1210,7 +1224,7 @@ public: {
type = TOK_FUNC_TRANSLATE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1223,7 +1237,7 @@ public: {
type = TOK_FUNC_BOOLEAN;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1236,7 +1250,7 @@ public: {
type = TOK_FUNC_NOT;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1249,7 +1263,7 @@ public: {
type = TOK_FUNC_TRUE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1262,7 +1276,7 @@ public: {
type = TOK_FUNC_FALSE;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1275,7 +1289,7 @@ public: {
type = TOK_FUNC_LANG;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1288,7 +1302,7 @@ public: {
type = TOK_FUNC_NUMBER;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1301,7 +1315,7 @@ public: {
type = TOK_FUNC_SUM;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1314,7 +1328,7 @@ public: {
type = TOK_FUNC_FLOOR;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1327,7 +1341,7 @@ public: {
type = TOK_FUNC_CEILING;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
@@ -1340,7 +1354,7 @@ public: {
type = TOK_FUNC_ROUND;
}
- virtual bool execute(Stack &stack)
+ virtual bool execute(TokenExecutor &exec)
{
return true;
}
|
