Hi there,
I wrote the issue #22 back in the day.
I said that "I am working on a fix for [it]" but haven't done anything
since then, because the project I used cppcms for got suspended.
Now I use cppcms for something else and ran into the same problem.
I'd like to discuss a possible solution before submitting a PR.
How about checking if seq_name contains a opening parenthesis '('?
When a '(' is encountered there is most likely a function call involved.
There may not, but this would be a corner case when a '(' is still needed
(none of which come to my mind as of now).
I propose to adapt the foreach syntax as follows:
'foreach' NAME ['as' IDENTIFIER ] [ 'rowid' IDENTIFIER [ 'from'
NUMBER ] ] [ 'reverse' ] 'in' ['direct' | 'smart'] VARIABLE
where 'direct' forces the old generation of C++ code (and being the default
for backwards compatibility)
and 'smart' (for the lack of a better term) checks for '(' and if present
changes the code generation to output a stack variable for the call
embedded in seq_name.
I am thinking of something like:
decltype(seq_name) v_ident = seq_name;
and subsequently changing
for (ptr_type ident_ptr = seq_name.begin [...]
to
for (ptr_type ident_ptr = v_ident.begin [...]
I have attached a diff of my proposed changes to the tmpl_cc.
Looking forward to your reply,
Martin Bürgmann
|