-# Regular expression used to parse "mesa_name" attributes. A
-# mesa_name attribute describes how to adjust a GL function name
-# suffix to obtain the name of the function in Mesa that implements
-# the functionality. The attribute string consists of a part preceded
-# by a "-", indicating the suffix to remove, and a part preceded by a
-# "+" indicating the suffix to add. Either part is optional.
-#
-# For example:
-#
-# <function name="EnableIndexedEXT" mesa_name="-EXT">...</function>
-# <function name="IsProgramNV" mesa_name="-NV+ARB">...</function>
-#
-# means that EnableIndexedEXT is implemented by a Mesa function called
-# _mesa_EnableIndexed, and IsProgramNV is implemented by a Mesa function
-# called _mesa_IsProgramARB.
-#
-# Note: the prefix "_mesa_" is handled separately, by the "exec"
-# attribute.
-name_modification_regexp = re.compile(
- r'^(-(?P<minus>[a-zA-Z0-9_]+))?(\+(?P<plus>[a-zA-Z0-9_]+))?$')
-
-
-# Interpret a "mesa_name" attribute (see above) to determine the
-# appropriate suffix for the Mesa function implementing a piece of GL
-# functionality, and return the properly suffixed name.
-def interpret_name_modification(name, mod):
- m = name_modification_regexp.match(mod)
- if m is None:
- raise Exception('Unintelligible mesa_name property: {0!r}'.format(mod))
- new_name = name
- if m.group('minus'):
- if not new_name.endswith(m.group('minus')):
- raise Exception(
- 'Cannot subtract suffix {0!r} from function {1}'.format(
- m.group('minus'), name))
- new_name = new_name[:-len(m.group('minus'))]
- if m.group('plus'):
- new_name += m.group('plus')
- return new_name
-
-