Generalize varobj iterator
[deliverable/binutils-gdb.git] / gdb / varobj-iter.h
1 /* Iterator of varobj.
2 Copyright (C) 2013-2014 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 struct varobj_iter_ops;
18
19 typedef PyObject varobj_item;
20
21 /* A dynamic varobj iterator "class". */
22
23 struct varobj_iter
24 {
25 /* The 'vtable'. */
26 const struct varobj_iter_ops *ops;
27
28 /* The varobj this iterator is listing children for. */
29 struct varobj *var;
30
31 /* The next raw index we will try to check is available. If it is
32 equal to number_of_children, then we've already iterated the
33 whole set. */
34 int next_raw_index;
35 };
36
37 /* The vtable of the varobj iterator class. */
38
39 struct varobj_iter_ops
40 {
41 /* Destructor. Releases everything from SELF (but not SELF
42 itself). */
43 void (*dtor) (struct varobj_iter *self);
44
45 /* Returns the next object or NULL if it has reached the end. */
46 varobj_item *(*next) (struct varobj_iter *self);
47 };
48
49 /* Returns the next varobj or NULL if it has reached the end. */
50
51 #define varobj_iter_next(ITER) (ITER)->ops->next (ITER)
52
53 /* Delete a varobj_iter object. */
54
55 #define varobj_iter_delete(ITER) \
56 do \
57 { \
58 if ((ITER) != NULL) \
59 { \
60 (ITER)->ops->dtor (ITER); \
61 xfree (ITER); \
62 } \
63 } while (0)
This page took 0.039862 seconds and 4 git commands to generate.