Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-27 Thread Eric Anholt
Francisco Jerez curroje...@riseup.net writes: Ian Romanick i...@freedesktop.org writes: On 08/26/2013 01:10 PM, Francisco Jerez wrote: [...] The thing is that defining bitwise operators separately for each enum type, as this patch and the macro solution do, doesn't stop the compiler From

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-26 Thread Ian Romanick
On 08/24/2013 10:41 AM, Francisco Jerez wrote: Chad Versace chad.vers...@linux.intel.com writes: On 08/23/2013 02:18 PM, Paul Berry wrote: The disadvantages are that (a) we need an explicit enum value for 0, and (b) we can't use related operators like |= unless we define additional

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-26 Thread Francisco Jerez
Ian Romanick i...@freedesktop.org writes: [...] Disadvantage (b) can be made painless with the macro I discuss below. IMHO it would be nicer to define generic templates implementing overloads for all bitwise operators. They would have to reference the bitmask_enumeration_traits structure

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-26 Thread Ian Romanick
On 08/26/2013 01:10 PM, Francisco Jerez wrote: Ian Romanick i...@freedesktop.org writes: [...] Disadvantage (b) can be made painless with the macro I discuss below. IMHO it would be nicer to define generic templates implementing overloads for all bitwise operators. They would have to

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-26 Thread Francisco Jerez
Ian Romanick i...@freedesktop.org writes: On 08/26/2013 01:10 PM, Francisco Jerez wrote: [...] The thing is that defining bitwise operators separately for each enum type, as this patch and the macro solution do, doesn't stop the compiler From using the corresponding built-in integer

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-24 Thread Francisco Jerez
Chad Versace chad.vers...@linux.intel.com writes: On 08/23/2013 02:18 PM, Paul Berry wrote: The disadvantages are that (a) we need an explicit enum value for 0, and (b) we can't use related operators like |= unless we define additional overloads. Disadvantage (a) is trivial, not really a

[Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-23 Thread Paul Berry
(From a suggestion by Francisco Jerez) If an enum represents a bitfield of flags, e.g.: enum E { A = 1, B = 2, C = 4, D = 8, }; then C++ normally prohibits statements like this: enum E x = A | B; because A and B are implicitly converted to ints before OR-ing them, and an int can't be

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-23 Thread Mark Mueller
This is a nice improvement over the explicit cast, which is how I've always done it in the past - which is the ugly part of an otherwise great method for flags. Also I use a lot with enum for clearing bits. On Fri, Aug 23, 2013 at 3:18 PM, Paul Berry stereotype...@gmail.com wrote: (From a

Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.

2013-08-23 Thread Chad Versace
On 08/23/2013 02:18 PM, Paul Berry wrote: The disadvantages are that (a) we need an explicit enum value for 0, and (b) we can't use related operators like |= unless we define additional overloads. Disadvantage (a) is trivial, not really a problem. Disadvantage (b) can be made painless with