'Replace \'PYIDENT("xyz")\' by a constant Python identifier cname.'

def inject_string_constants(self, impl, output):

    if ('PYIDENT(' not in impl):
        return (False, impl)
    replacements = {}
    def externalise(matchobj):
        name = matchobj.group(1)
        try:
            cname = replacements[name]
        except KeyError:
            cname = replacements[name] = output.get_interned_identifier(StringEncoding.EncodedString(name)).cname
        return cname
    impl = re.sub('PYIDENT\\("([^"]+)"\\)', externalise, impl)
    assert ('PYIDENT(' not in impl)
    return (bool(replacements), impl)
