[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Avoiding svn_iter_apr_hash/array() [was: svn commit: r935579]

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 20 Apr 2010 17:31:10 +0300 (Jerusalem Daylight Time)

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
>
>
>
Received on 2010-04-20 16:30:58 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.