[FFmpeg-devel] [PATCH 2/2] tablegen: implement and use tablegen_copy_array macros
Reimar Döffinger
Reimar.Doeffinger
Sun Jun 27 09:03:50 CEST 2010
On Sun, Jun 27, 2010 at 02:40:53AM +0200, Diego Elio 'Flameeyes' Petten? wrote:
> +#define tablegen_copy_array(modifier, type, name) \
> + printf(#modifier" "#type" "#name"[%zu] = {\n", \
> + FF_ARRAY_ELEMS(name)); \
> + write_##type##_array(name, FF_ARRAY_ELEMS(name)); \
> + printf("};\n");
> +
> +#define tablegen_copy_2d_array(modifier, type, name) \
> + printf(#modifier" "#type" "#name"[%zu][%zu] = {\n", \
> + FF_ARRAY_ELEMS(name), \
> + FF_ARRAY_ELEMS(name[0]) ); \
> + write_##type##_2d_array(name, \
> + FF_ARRAY_ELEMS(name), \
> + FF_ARRAY_ELEMS(name[0]) ); \
> + printf("};\n");
> +
Nice idea, but some nits.
Please don't call it "copy", I think most people think of something
else by that.
Also, since it is a macro, I think uppercase is more approriate.
Why not
WRITE_ARRAY
and
WRITE_2D_ARRAY?
Michael doesn't like it, but I also slightly prefer macros
to be encased in "do {} while (0)", which would also allow
you to use a variable for FF_ARRAY_ELEMS(name) instead
of writing it multiple times.
One thing I am undecided about is if it would be nicer to use
a string for "modifier" and/or call it "prefix".
Mostly because
WRITE_ARRAY("", uint32_t, array);
looks a bit more natural than
WRITE_ARRAY(, uint32_t, array);
More information about the ffmpeg-devel
mailing list