feature intent: external alias loader and external alias deprecation
- Add an alias loader. Make it the last loader on the loader list. It should map aliases to object names for all externals that have aliases. We should hard-code these into the loader source.
-
Instead of using class_addcreator, let the alias loader do the work.Let the alias loader do the load time work, and add_creator will then solve the rest with no further work (Well, this happens automatically, so we're already 1 for 3-- yay :) - Once we have all extant externals covered, deprecate the use of class_addcreator in externals. Also try to get Vanilla to do the same deprecation. Persuade anybody who wants aliases in new externals to work on tab completion instead.
Reasoning: class_addcreator simply does not work with the one-class-per-file style of writing externals. It has never worked, and it never will. Worse, most developers don't even understand that it doesn't work, leading to needless user confusion and perpetuation of loader bugs. Worst, it aliases are the wrong solution to ease typing-- that's what tab completion is for.
It does not appear that external developers are going to change their one-class-per-file style any time soon. Therefore we need to implement a workaround for aliases in the existing external libs (aliases which have been buggy since the beginning of Pd AFAICT), and keep external developers from using class_addcreator in the future. (Perhaps print a warning whenever it is used.)
Lazy ten-minute psuedo-code implementation:
The map for the loader could be an array of structs that look something like this:
struct _alias_loader_map {
const char *alias;
const char *realname;
int am_recursing; /* init to 0 */
}
Then the alias_loader does something like this:
See if the classname argument matches any alias in our array of aliases.
If not, return 0.
If so, check if am_recursing in the matching alias is 1-- if it is, set it to 0 and return 0.
Otherwise set am_recursing to 1 and return the result of calling the loader with realname instead of alias.
edit: remove unnecessary parenthetical edit: clarify step two