aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-08-15 12:39:00 +0200
committerSebastian Geerken <devnull@localhost>2013-08-15 12:39:00 +0200
commitbd17107d17663c847e671ff736af969b5c441e71 (patch)
treeaabb246d5d8b333ee126c2f66ffa7a55ed7091aa /dw
parent8327ae5fc00726c4746c085ed35c3f0d02890616 (diff)
Some debugging stuff.
Diffstat (limited to 'dw')
-rw-r--r--dw/iterator.cc25
-rw-r--r--dw/iterator.hh1
-rw-r--r--dw/types.cc72
-rw-r--r--dw/types.hh3
4 files changed, 81 insertions, 20 deletions
diff --git a/dw/iterator.cc b/dw/iterator.cc
index c31c2706..cdbc58bd 100644
--- a/dw/iterator.cc
+++ b/dw/iterator.cc
@@ -55,6 +55,24 @@ bool Iterator::equals (Object *other)
(getWidget() == otherIt->getWidget() && compareTo(otherIt) == 0);
}
+void Iterator::intoStringBuffer(misc::StringBuffer *sb)
+{
+ sb->append ("{ content = ");
+ Content::intoStringBuffer (&content, sb);
+
+ sb->append (", widget = ");
+ //widget->intoStringBuffer (sb);
+ sb->appendPointer (widget);
+ sb->append (" (");
+ sb->append (widget->getClassName());
+ sb->append (")>");
+
+ sb->append (", mask = ");
+ Content::maskIntoStringBuffer (mask, sb);
+
+ sb->append (" }");
+}
+
/**
* \brief Delete the iterator.
*
@@ -583,6 +601,9 @@ int DeepIterator::compareTo (object::Comparable *other)
{
DeepIterator *otherDeepIterator = (DeepIterator*)other;
+ //printf ("Compare: %s\n", stack.toString ());
+ //printf (" to: %s\n", otherDeepIterator->stack.toString ());
+
// Search the highest level, where the widgets are the same.
int level = 0;
@@ -594,10 +615,14 @@ int DeepIterator::compareTo (object::Comparable *other)
level++;
}
+ //printf (" => level = %d (temorally)\n", level);
+
while (stack.get(level)->getWidget ()
!= otherDeepIterator->stack.get(level)->getWidget ())
level--;
+ //printf (" => level = %d (finally)\n", level);
+
return stack.get(level)->compareTo (otherDeepIterator->stack.get(level));
}
diff --git a/dw/iterator.hh b/dw/iterator.hh
index d8a59eec..44cb6042 100644
--- a/dw/iterator.hh
+++ b/dw/iterator.hh
@@ -31,6 +31,7 @@ private:
public:
bool equals (Object *other);
+ void intoStringBuffer(lout::misc::StringBuffer *sb);
inline Widget *getWidget () { return widget; }
inline Content *getContent () { return &content; }
diff --git a/dw/types.cc b/dw/types.cc
index a2f0737e..56af66d1 100644
--- a/dw/types.cc
+++ b/dw/types.cc
@@ -276,49 +276,81 @@ Content::Type Content::maskForSelection (bool followReferences)
return (Content::Type)(Content::SELECTION_CONTENT | widgetMask);
}
-void Content::print (Content *content)
+void Content::intoStringBuffer(Content *content, misc::StringBuffer *sb)
{
switch(content->type) {
case START:
- printf ("<start>");
+ sb->append ("<start>");
break;
case END:
- printf ("<end>");
+ sb->append ("<end>");
break;
case TEXT:
- printf ("\"%s\"", content->text);
+ sb->append ("\"");
+ sb->append (content->text);
+ sb->append ("\"");
break;
case WIDGET_IN_FLOW:
- printf ("<widget in flow: %p (%s)>",
- content->widget, content->widget->getClassName());
+ sb->append ("<widget in flow: ");
+ sb->appendPointer (content->widget);
+ sb->append (" (");
+ sb->append (content->widget->getClassName());
+ sb->append (")>");
break;
case WIDGET_OOF_REF:
- printf ("<widget oof ref: %p (%s)>",
- content->widget, content->widget->getClassName());
+ sb->append ("<widget oof ref: ");
+ sb->appendPointer (content->widget);
+ sb->append (" (");
+ sb->append (content->widget->getClassName());
+ sb->append (")>");
break;
case WIDGET_OOF_CONT:
- printf ("<widge oof cont: %p (%s)>",
- content->widget, content->widget->getClassName());
+ sb->append ("<widget oof cont: ");
+ sb->appendPointer (content->widget);
+ sb->append (" (");
+ sb->append (content->widget->getClassName());
+ sb->append (")>");
break;
case BREAK:
- printf ("<break>");
+ sb->append ("<break>");
break;
default:
- printf ("<%d?>", content->type);
+ sb->append ("<");
+ sb->appendInt (content->type);
+ sb->append ("?>");
break;
}
}
+void Content::maskIntoStringBuffer(Type mask, misc::StringBuffer *sb)
+{
+ sb->append ((mask & START) ? "st" : "--");
+ sb->append (":");
+ sb->append ((mask & END) ? "en" : "--");
+ sb->append (":");
+ sb->append ((mask & TEXT) ? "tx" : "--");
+ sb->append (":");
+ sb->append ((mask & WIDGET_IN_FLOW) ? "wf" : "--");
+ sb->append (":");
+ sb->append ((mask & WIDGET_OOF_REF) ? "Wr" : "--");
+ sb->append (":");
+ sb->append ((mask & WIDGET_OOF_CONT) ? "Wc" : "--");
+ sb->append (":");
+ sb->append ((mask & BREAK) ? "br" : "--");
+}
+
+void Content::print (Content *content)
+{
+ misc::StringBuffer sb;
+ intoStringBuffer (content, &sb);
+ printf ("%s", sb.getChars ());
+}
+
void Content::printMask (Type mask)
{
- printf ("%s:%s:%s:%s:%s:%s:%s",
- (mask & START) ? "st" : "--",
- (mask & END) ? "en" : "--",
- (mask & TEXT) ? "tx" : "--",
- (mask & WIDGET_IN_FLOW) ? "wf" : "--",
- (mask & WIDGET_OOF_REF) ? "Wr" : "--",
- (mask & WIDGET_OOF_CONT) ? "Wc" : "--",
- (mask & BREAK) ? "br" : "--");
+ misc::StringBuffer sb;
+ maskIntoStringBuffer (mask, &sb);
+ printf ("%s", sb.getChars ());
}
} // namespace core
diff --git a/dw/types.hh b/dw/types.hh
index 0e664895..e910d296 100644
--- a/dw/types.hh
+++ b/dw/types.hh
@@ -223,6 +223,9 @@ struct Content
};
static Content::Type maskForSelection (bool followReferences);
+
+ static void intoStringBuffer(Content *content, lout::misc::StringBuffer *sb);
+ static void maskIntoStringBuffer(Type mask, lout::misc::StringBuffer *sb);
static void print (Content *content);
static void printMask (Type mask);
};