Author: mvidner Date: Thu Sep 6 16:43:46 2007 New Revision: 40789 URL: http://svn.opensuse.org/viewcvs/yast?rev=40789&view=rev Log: Enabled iterating over all functions of a Y2Namespace, for a more natural call syntax in yast2-python-bindings (#308213). Modified: trunk/core/VERSION trunk/core/libycp/src/SymbolTable.cc trunk/core/libycp/src/include/ycp/SymbolTable.h trunk/core/package/yast2-core.changes Modified: trunk/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=40789&r1=40788&r2=40789&view=diff ============================================================================== --- trunk/core/VERSION (original) +++ trunk/core/VERSION Thu Sep 6 16:43:46 2007 @@ -1 +1 @@ -2.15.10 +2.15.11 Modified: trunk/core/libycp/src/SymbolTable.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/SymbolTable.cc?rev=40789&r1=40788&r2=40789&view=diff ============================================================================== --- trunk/core/libycp/src/SymbolTable.cc (original) +++ trunk/core/libycp/src/SymbolTable.cc Thu Sep 6 16:43:46 2007 @@ -1019,4 +1019,27 @@ } } } + +// for #308213 +void +SymbolTable::forEach(SymbolTable::EntryConsumer consumer) const +{ + for (int i=0; i < m_prime; i++) + { + if (m_table[i] != 0) + { + SymbolEntryPtr s = m_table[i]->sentry (); + if (! consumer (*s)) + return; + + // walk the chain of colliding entries + for (TableEntry* t_next = m_table[i]->m_next; t_next; t_next = t_next->m_next) + { + SymbolEntryPtr s = t_next->sentry (); + if (! consumer (*s)) + return; + } + } + } +} // EOF Modified: trunk/core/libycp/src/include/ycp/SymbolTable.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/SymbolTable.h?rev=40789&r1=40788&r2=40789&view=diff ============================================================================== --- trunk/core/libycp/src/include/ycp/SymbolTable.h (original) +++ trunk/core/libycp/src/include/ycp/SymbolTable.h Thu Sep 6 16:43:46 2007 @@ -149,6 +149,23 @@ // return size of hash table int size() const; + // consumer returns true to continue iterating + typedef bool (* EntryConsumer) (const SymbolEntry&); + /** + * call the consumer for each entry (or until it requests a break) + * + * Example: + * static bool MyClass::DoIt (const SymbolEntry & se) { + * cout << se.name() << endl; + * return true; + * } + * + * void MyClass::Foo () { + * my_y2namespace->table()->forEach (&DoIt); + * } + */ + void forEach (EntryConsumer consumer) const; + //--------------------------------------------------------------- // enter/find/remove Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=40789&r1=40788&r2=40789&view=diff ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Thu Sep 6 16:43:46 2007 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Sep 6 16:43:06 CEST 2007 - mvidner@suse.cz + +- Enabled iterating over all functions of a Y2Namespace, for + a more natural call syntax in yast2-python-bindings (#308213). +- 2.15.11 + +------------------------------------------------------------------- Wed Sep 5 13:18:55 CEST 2007 - mvidner@suse.cz - Fixed missing return value in YSymbolEntry::toXml -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org