diff options
Diffstat (limited to 'gdb/dictionary.h')
-rw-r--r-- | gdb/dictionary.h | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/gdb/dictionary.h b/gdb/dictionary.h index 9dc02c9..d982396 100644 --- a/gdb/dictionary.h +++ b/gdb/dictionary.h @@ -164,16 +164,49 @@ extern struct symbol *mdict_iter_match_next (const lookup_name_info &name, extern int mdict_size (const struct multidictionary *mdict); -/* Macro to loop through all symbols in a dictionary DICT, in no - particular order. ITER is a struct dict_iterator (NOTE: __not__ a - struct dict_iterator *), and SYM points to the current symbol. - - It's implemented as a single loop, so you can terminate the loop - early by a break if you desire. */ - -#define ALL_DICT_SYMBOLS(dict, iter, sym) \ - for ((sym) = mdict_iterator_first ((dict), &(iter)); \ - (sym); \ - (sym) = mdict_iterator_next (&(iter))) +/* An iterator that wraps an mdict_iterator. The naming here is + unfortunate, but mdict_iterator was named before gdb switched to + C++. */ +struct mdict_iterator_wrapper +{ + typedef mdict_iterator_wrapper self_type; + typedef struct symbol *value_type; + + explicit mdict_iterator_wrapper (const struct multidictionary *mdict) + : m_sym (mdict_iterator_first (mdict, &m_iter)) + { + } + + mdict_iterator_wrapper () + : m_sym (nullptr) + { + } + + value_type operator* () const + { + return m_sym; + } + + bool operator== (const self_type &other) const + { + return m_sym == other.m_sym; + } + + bool operator!= (const self_type &other) const + { + return m_sym != other.m_sym; + } + + self_type &operator++ () + { + m_sym = mdict_iterator_next (&m_iter); + return *this; + } + +private: + + struct symbol *m_sym; + struct mdict_iterator m_iter; +}; #endif /* DICTIONARY_H */ |