diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-11 09:33:36 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-11 09:33:38 -0700 |
commit | 54746ce37a483e235ac128b6f545be9888bf3521 (patch) | |
tree | 00098f97c2514f9895f1e7bab52678ed4dba9dee /gdb/varobj-iter.h | |
parent | d8f168ddd08f1d5fde1a193724cdc40d524039a7 (diff) | |
download | gdb-54746ce37a483e235ac128b6f545be9888bf3521.zip gdb-54746ce37a483e235ac128b6f545be9888bf3521.tar.gz gdb-54746ce37a483e235ac128b6f545be9888bf3521.tar.bz2 |
C++-ify varobj iteration
This changes the varobj iteration code to use a C++ class rather than
a C struct with a separate "ops" structure. The only implementation
is updated to use inheritance. This simplifies the code quite nicely.
gdb/ChangeLog
2020-12-11 Tom Tromey <tom@tromey.com>
* varobj.c (update_dynamic_varobj_children, install_visualizer)
(varobj::~varobj): Update.
* varobj-iter.h (struct varobj_iter): Change to interface class.
(struct varobj_iter_ops): Remove.
(varobj_iter_next, varobj_iter_delete): Remove.
* python/py-varobj.c (struct py_varobj_iter): Derive from
varobj_iter. Add constructor, destructor. Rename members.
(py_varobj_iter::~py_varobj_iter): Rename from
py_varobj_iter_dtor.
(py_varobj_iter::next): Rename from py_varobj_iter_next.
(py_varobj_iter_ops): Remove.
(py_varobj_iter): Rename from py_varobj_iter_ctor.
(py_varobj_iter_new): Remove.
(py_varobj_get_iterator): Update.
Diffstat (limited to 'gdb/varobj-iter.h')
-rw-r--r-- | gdb/varobj-iter.h | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h index 240b686..ed65419 100644 --- a/gdb/varobj-iter.h +++ b/gdb/varobj-iter.h @@ -28,50 +28,15 @@ struct varobj_item struct value *value; }; -struct varobj_iter_ops; - /* A dynamic varobj iterator "class". */ struct varobj_iter { - /* The 'vtable'. */ - const struct varobj_iter_ops *ops; - - /* The varobj this iterator is listing children for. */ - struct varobj *var; - - /* The next raw index we will try to check is available. If it is - equal to number_of_children, then we've already iterated the - whole set. */ - int next_raw_index; -}; - -/* The vtable of the varobj iterator class. */ +public: -struct varobj_iter_ops -{ - /* Destructor. Releases everything from SELF (but not SELF - itself). */ - void (*dtor) (struct varobj_iter *self); + virtual ~varobj_iter () = default; - /* Returns the next object or NULL if it has reached the end. */ - varobj_item *(*next) (struct varobj_iter *self); + virtual varobj_item *next () = 0; }; -/* Returns the next varobj or NULL if it has reached the end. */ - -#define varobj_iter_next(ITER) (ITER)->ops->next (ITER) - -/* Delete a varobj_iter object. */ - -#define varobj_iter_delete(ITER) \ - do \ - { \ - if ((ITER) != NULL) \ - { \ - (ITER)->ops->dtor (ITER); \ - xfree (ITER); \ - } \ - } while (0) - #endif /* VAROBJ_ITER_H */ |