Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
From a user perspective, not much changes with this commit - the only difference is that now the Render Result node will only update its sockets after rendering (but before running the compositor), not as soon as the render layer options are changed.
The actual RNA function that allows render engines to create own passes and a new integration of the Cycles Debug passes will follow later, I guess it's easier to review the changes one at a time. This one is already big enough :)
Also, included as a separate commit, a visual improvement:
To provide better visual indication in the compositor, sockets for passes that aren't availiable are still drawn, but all their links are dashed and they behave as if SOCK_UNAVAIL was set. This is handled by the new socket flag SOCK_VIRTUAL.
This is to avoid confusion since, when the user hasn't rendered yet after loading a file, only the Image and Alpha sockets are available. Therefore, without this change, the compositor setup would appear broken until the first render.
Since this comes down to UI preference, I'll just go ahead and poke @Julian Eisel (Severin) as well :)