]> git.ipfire.org Git - thirdparty/bird.git/commit - conf/cf-lex.l
Filter: Methods rework
authorMaria Matejka <mq@ucw.cz>
Fri, 16 Jun 2023 15:35:37 +0000 (17:35 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 12 Sep 2023 14:19:33 +0000 (16:19 +0200)
commitfc9d471b36b91429e5d86aa794716683a5281449
treeffe1298e55f99f0d6198aa6836213006e6a0dd89
parent39f8f46d81203ebd6b976da56e83930f972dccab
Filter: Methods rework

Methods can now be called as x.m(y), as long as x can have its type
inferred in config time. If used as a command, it modifies the object,
if used as a value, it keeps the original object intact.

Also functions add(x,y), delete(x,y), filter(x,y) and prepend(x,y) now
spit a warning and are considered deprecated.

It's also possible to call a method on a constant, see filter/test.conf
for examples like bgp_path = +empty+.prepend(1).

Inside instruction definitions (filter/f-inst.c), a METHOD_CONSTRUCTOR()
call is added, which registers the instruction as a method for the type
of its first argument. Each type has its own method symbol table and
filter parser switches between them based on the inferred type of the
object calling the method.

Also FI_CLIST_(ADD|DELETE|FILTER) instructions have been split to allow
for this method dispatch. With type inference, it's now possible.
conf/cf-lex.l
conf/conf.h
conf/confbase.Y
conf/gen_keywords.m4
doc/bird.sgml
filter/config.Y
filter/data.c
filter/data.h
filter/decl.m4
filter/f-inst.c
filter/test.conf