]> git.ipfire.org Git - thirdparty/bird.git/commit
Filter: Methods rework
authorMaria Matejka <mq@ucw.cz>
Fri, 16 Jun 2023 15:35:37 +0000 (17:35 +0200)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 30 May 2024 10:30:00 +0000 (12:30 +0200)
commit8ac15bf7a458537f51e5eff7d25b736efc3e3b31
tree0999ca7ecedf4cffc62c820997928fba531f554d
parent44bac393611fd7a68f73e7d04550097578e6f74e
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