From bd17107d17663c847e671ff736af969b5c441e71 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Thu, 15 Aug 2013 12:39:00 +0200 Subject: Some debugging stuff. --- dw/iterator.cc | 25 ++++++++++++++++++++ dw/iterator.hh | 1 + dw/types.cc | 72 ++++++++++++++++++++++++++++++++++++++++++---------------- dw/types.hh | 3 +++ 4 files changed, 81 insertions(+), 20 deletions(-) (limited to 'dw') 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 (""); + sb->append (""); break; case END: - printf (""); + sb->append (""); break; case TEXT: - printf ("\"%s\"", content->text); + sb->append ("\""); + sb->append (content->text); + sb->append ("\""); break; case WIDGET_IN_FLOW: - printf ("", - content->widget, content->widget->getClassName()); + sb->append ("appendPointer (content->widget); + sb->append (" ("); + sb->append (content->widget->getClassName()); + sb->append (")>"); break; case WIDGET_OOF_REF: - printf ("", - content->widget, content->widget->getClassName()); + sb->append ("appendPointer (content->widget); + sb->append (" ("); + sb->append (content->widget->getClassName()); + sb->append (")>"); break; case WIDGET_OOF_CONT: - printf ("", - content->widget, content->widget->getClassName()); + sb->append ("appendPointer (content->widget); + sb->append (" ("); + sb->append (content->widget->getClassName()); + sb->append (")>"); break; case BREAK: - printf (""); + sb->append (""); 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); }; -- cgit v1.2.3