brian-team/brian2 — pull request #304 by mstimberg (2014-08-07 13:00:18+00:00)
Title: Make sure that arrays have unique names in C++ standalone

The reason for the problem in #302 was that for the synapse creation from arrays we create new arrays of name `source` and `target` in the context of the `Synapses` object. The `CPPStandaloneDevice.add_array` method simply used the owner name and the variable name to create a name for the array. Most of the times this is fine, since we don't have overlapping variable names for the same object. In the case of synapse creation, we do however. I changed the `add_array` method so that it creates unique names using our standard approach (suffixing the name with `_1` etc.). I made the code slightly more complicated than necessary for fixing this bug, it also covers the situation for dynamical arrays which are inserted in two dictionaries (see code comments). I don't really see that we'll ever have the kind of situation it guards against, but better safe than sorry.

The commit also adds a test using the example from #302.

Ready to merge.