Julian Foad wrote on Tue, 20 Apr 2010 at 11:49 +0100: > Hmm... I wonder if we could do something with a macro that takes the > whole block of code to be executed as an argument, like: >
A code block inside a macro call?? Perhaps we write a macro in the style of SVN_DBG --- one that is "pseudo-variadic"... For example (not tested): #define SVN_ITER_ARRAY2(element_type, element_name, array, iterpool, pool, func_name, (arg1, arg2)) \ SVN_ITER_ARRAY(element_type, element_name, array, iterpool, pool, func_name(arg1, arg2)) where SVN_ITER_ARRAY() is the macro you defined: > #define SVN_ITER_ARRAY(element_type, element_name, array, \ > iterpool_name, /* as subpool of */ pool, \ > code_block) \ > { apr_pool_t *iterpool_name = ... \ > for (...) \ > { \ > element_type element_name = ...; \ > apr_pool_clear(iterpool_name); \ > code_block \ > } \ > apr_pool_destroy(iterpool_name); \ > } > :-) Daniel > Usage: > SVN_ITER_ARRAY(svn_node_t *, node, nodes_array, > iterpool, existing_pool, > { > if (node->kind == svn_node_file) > SVN_ERR(bar(node, blah, iterpool)); > else > break; /* breaks the iteration */ > } ) /* macro ends here */ > > Hmm... > > - Julian > > >