2 * prep: strip off casts, they cause things to fail matching later.
10 - (struct casttarget *)vty->index
14 * variant 1: local variable assigned from vty->index
24 + VTY_DECLVAR_CONTEXT (sn, nn);
31 - struct sn *nn = vty->index;
33 - struct sn *nn = vty->index;
48 + struct sn *nn = VTY_GET_CONTEXT(sn);
58 - struct sn *nn = vty->index;
63 - struct sn *nn = vty->index;
74 * variant 2: vty wrapper func with (vty, vty->index, ...) signature
77 /* find calls of this pattern first; arg will be dropped in rule3 */
79 identifier fn !~ "generic_(set|match)_";
83 fn(arg, arg->index, ...)
89 print "R01 removing vty-index argument on %s(%s, ...)" % (fn, arg)
91 #/* strip arg on the vty wrapper func, add local handling */
98 static int fn (struct vty *vty,
102 + VTY_DECLVAR_CONTEXT (T, arg);
106 /* drop argument on call sites identified earlier */
118 * variant 3: function calls with "vty->index" argument (but no vty)
120 * a bit more complicated since we need to find the type from the header.
123 /* find call sites first
124 * remember function name for later declvar insertion
142 print "R11 removing vty-index argument on %s(...)" % (fn)
144 #/* find type of the argument - note args are mostly unnamed in FRR :( */
146 identifier rule11.fn;
147 identifier T, argname;
152 Tr fn(struct T *, ...);
154 Tr fn(struct T * argname, ...);
161 print "R12 removing vty-index type is %s for %s(...)" % (T, fn)
164 # * this is split from rule14 so we support multiple calls in one func */
166 identifier rule11.fparent;
172 + VTY_DECLVAR_CONTEXT(T, T);
177 identifier rule11.fparent;
184 + struct T *T = VTY_GET_CONTEXT(T);
191 /* now replace the argument in the call */
193 identifier rule11.fn;
213 /* special case ... */
215 identifier fn =~ "generic_(set|match)_";
221 + VTY_GET_CONTEXT(route_map_index),
224 /* and finally - PUSH_CONTEXT */
227 identifier vexpr =~ "NULL";
232 - vty->index = vexpr;
233 + VTY_PUSH_CONTEXT_NULL(tnode);
242 - vty->index = vexpr;
243 + VTY_PUSH_CONTEXT(tnode, vexpr);