[Mesa-dev] [PATCH 2/3] mesa: Add _mesa_enum_to_string2()
Chad Versace
chad at kiwitree.net
Thu Aug 11 17:42:20 UTC 2016
On 08/11/2016 10:24 AM, Ian Romanick wrote:
> On 08/11/2016 10:11 AM, Chad Versace wrote:
>> The new function is identical to _mesa_enum_to_string(), except that it
>> returns false if the given number is an invalid enum. Bundling
>> validation and lookup into a single function allows us to do both with
>> a single lookup into the enum table.
>>
>> Cc: Haixia Shi <hshi at chromium.org>
>> Change-Id: I83d9a6e53223d1a971cf8dc22cb34b05b48d7889
>> ---
>> src/mapi/glapi/gen/gl_enums.py | 20 ++++++++++++++++----
>> src/mesa/main/enums.h | 2 ++
>> 2 files changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
>> index 4fc43ab..af21aaf 100644
>> --- a/src/mapi/glapi/gen/gl_enums.py
>> +++ b/src/mapi/glapi/gen/gl_enums.py
>> @@ -89,6 +89,17 @@ static char token_tmp[20];
>> */
>> const char *_mesa_enum_to_string( int nr )
>> {
>> + const char *str;
>> + _mesa_enum_to_string2(nr, &str);
>> + return str;
>> +}
>> +
>> +/**
>> + * Identical to _mesa_enum_to_string(), except that this function returns false
>> + * when the number is an invalid enum.
>> + */
>> +bool _mesa_enum_to_string2(int nr, const char **str)
>> +{
>> enum_elt *elt;
>>
>
> Add an
>
> assert(str != NULL);
>
> and maybe document that in the function header.
Done.
The hunk now starts with this:
/**
* Identical to _mesa_enum_to_string(), except that this function returns false
* when the number is an invalid enum. The out parameter \\a str must be non-null.
*/
bool _mesa_enum_to_string2(int nr, const char **str)
{
enum_elt *elt;
assert(str != NULL);
elt = ...
More information about the mesa-dev
mailing list