brian-team/brian2 — pull request #190 by mstimberg (2013-12-18 17:39:52+00:00)
Title: Codegen interface refactoring

This branch is work towards fixing the part of #131 (the interface between non-codegen and codegen code). It's far from merge-ready but I wanted to get some early feedback.

The `ArrayVariable` objects now no longer store an `arrayname` argument, codegen can use whatever names it wants. For runtime, they now simply use `variablename + '_array'` because the names in a single codeobject cannot be ambiguous in the first place. Previously, arrays were available under two names in the codeobject: the simple name (e.g. `v`) and the array name (e.g. `_array_neurongroup_v`). I removed the first variant because it could lead to problems and made some workarounds with template arguments necessary.
Now, simple names only occur in generated snippets and refer to an indexed array (in numpy) or a single value (in C). If some template code wants to use arrays outside of the generated parts it has to append the `_array`. This makes some thresholds slightly harder to read (e.g. https://github.com/brian-team/brian2/blob/codegen_interface_refactoring/brian2/codegen/runtime/numpy_rt/templates/threshold.py_) but is more explicit on the other hand and simplifies things in some cases (e.g. here: https://github.com/brian-team/brian2/blob/master/brian2/codegen/runtime/weave_rt/templates/threshold.cpp). Even though strictly speaking we might violate the `__restrict__` promise here, I don't think it matters since we only loop once.

Any thoughts on this?

Note that I did not take care of adapting standalone to the changes yet.