/usr/lib/python2.7/dist-packages/pygccxml/declarations/templates.py is in python-pygccxml 1.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | # Copyright 2014-2016 Insight Software Consortium.
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
"""
template instantiation parser
This module provides functionality necessary to
* :func:`parse <pygccxml.declarations.templates.parse>`
* :func:`split <pygccxml.declarations.templates.split>`
* :func:`join <pygccxml.declarations.templates.join>`
* :func:`normalize <pygccxml.declarations.templates.normalize>`
C++ template instantiations
"""
from . import pattern_parser
from . import declaration_utils
__THE_PARSER = pattern_parser.parser_t('<', '>', ',')
def is_instantiation(decl_string):
"""
returns True if `decl_string` is template instantiation and False otherwise
:param decl_string: string that should be checked for pattern presence
:type decl_string: str
:rtype: bool
"""
return __THE_PARSER.has_pattern(decl_string)
def name(decl_string):
"""
returns name of instantiated template
:type decl_string: str
:rtype: str
"""
return __THE_PARSER.name(decl_string)
def args(decl_string):
"""
returns list of template arguments
:type decl_string: `str`
:rtype: [`str`]
"""
return __THE_PARSER.args(decl_string)
def split(decl_string):
"""returns (name, [arguments] )"""
return __THE_PARSER.split(decl_string)
def split_recursive(decl_string):
"""returns [(name, [arguments])]"""
return __THE_PARSER.split_recursive(decl_string)
def join(name, args):
"""returns name< argument_1, argument_2, ..., argument_n >"""
return __THE_PARSER.join(name, args)
def normalize(decl_string):
"""returns `decl_string`, which contains "normalized" spaces
this functionality allows to implement comparison of 2 different string
which are actually same: x::y< z > and x::y<z>
"""
return __THE_PARSER.normalize(decl_string)
def normalize_name(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_name is None:
decl.cache.normalized_name = normalize(decl.name)
return decl.cache.normalized_name
def normalize_partial_name(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_partial_name is None:
decl.cache.normalized_partial_name = normalize(decl.partial_name)
return decl.cache.normalized_partial_name
def normalize_full_name_true(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_full_name_true is None:
decl.cache.normalized_full_name_true = normalize(
declaration_utils.full_name(decl, with_defaults=True))
return decl.cache.normalized_full_name_true
def normalize_full_name_false(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_full_name_false is None:
decl.cache.normalized_full_name_false = normalize(
declaration_utils.full_name(decl, with_defaults=False))
return decl.cache.normalized_full_name_false
|