-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Use the array part of app.input and app.output tables
Previously the links for apps were accessible only by name e.g. input.rx or output.tx. Now they are available both by name and by number e.g. input[1] or output[2]. The exact order is not fixed. This makes it easy to write apps that don't care what their links are called. If there is only one link then it can be accessed as input[1]. If there are many links they can be accessed with an ipairs() loop. The relink() method of apps is also removed. The only way that it was actually used was to emulate this behavior in a more complex way. That code is also removed now from basic_apps and snabbmark. This may resolve the question: what should an app name its input and output links in cases where it does not actually matter? Now instead of having to choose an arbitrary name like 'rx' or 'input' or 'left' or 'west' the app can simply say that it requires one link and then access that by number. So code like this: local rx = input.rx assert(rx, "rx link not connected") could instead be written as: assert(#input == 1, "one input link expected") local rx = input[1] which would be backwards compatible and allow the link to have any name. That would solve the existing problem of apps expecting inconsistent names. (This does not apply to cases where apps actually need to have multiple links that are distinguished by their names e.g. a tunnel app that will encapsulate packets from one input and decapsulate those from another.)
- Loading branch information
Showing
4 changed files
with
21 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters