mkvsynth/mkvsynth — pull request #15 by lukechampine (2014-03-14 05:46:43+00:00)
Title: Change way arguments are handled

This change is mostly internal to delbrot, but it also changes the semantics of how filters are written, so I figured a pull request was in order.

Currently, function arguments are passed as a linked list of ASTnodes. While this makes some code more elegant, it's also a lot more error prone. More importantly, it means that functions can't know how many arguments they're receiving without traversing the whole list. Even *more* importantly, it means that arguments aren't random access, which is a big problem.

If you look at the argument macros defined in delbrot.h, you'll see that they're actually two statements: the first part accesses the argument, and the second part advances the linked list. The problem with this is that it means you can't write something like `if (MANDNUM() > 3)`, because you'll be inserting a semicolon in the middle of a conditional.

With this change, arguments are now implemented as static arrays of varNodes, which are ASTnodes bundled with a name and argument type (either mandatory or optional). This allows for random access, and it turns out it makes certain functions like `userDefFnCall()` much cleaner.

As a consequence, filters now take `argList *a` as their second argument instead of `ASTnode *args`. Existing filters and documentation have been updated to reflect this.