This file is indexed.

/usr/lib/python3/dist-packages/pygccxml/declarations/declaration.py is in python3-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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# 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

"""
Defines :class:`pygccxml.declarations.declaration_t` class - all declarations
base class.

"""

from . import declaration_utils
from . import algorithms_cache
from .. import utils


class declaration_t(object):
    """
    Base class for all classes that represent a C++ declaration.

    """

    def __init__(
            self,
            name='',
            location=None,
            is_artificial=False,
            mangled=None,
            demangled=None,
            attributes=None):
        self._name = name
        self._location = location
        self._is_artificial = is_artificial
        self._mangled = mangled
        self._demangled = demangled
        self._attributes = attributes
        self._parent = None
        self._cache = algorithms_cache.declaration_algs_cache_t()
        # Kept for retrocompatibility. Use utils.xml_generator instead
        self._compiler = None
        self._partial_name = None
        self._decorated_name = None

    def __str__(self):
        """
        Default __str__ method.

        This version just returns the decl_string and the class.
        Derived classes may override this method to provide more detailed
        information.

        A __str__ method for a declaration should always provide enough
        information so that it uniquely identifies the declaration and
        the user is able to find the declaration in his source code.

        """

        name = self.decl_string
        if name[:2] == "::":
            name = name[2:]
        # Append the declaration class
        cls = self.__class__.__name__
        if cls[-2:] == "_t":
            cls = cls[:-2]
        cls = cls.replace('_', ' ')

        return "%s [%s]" % (name, cls)

    def _get__cmp__items(self):
        """
        Implementation detail.

        """
        # Every derived class should implement this method. This method should
        # return a list of items, that should be compared.

        print(
            '_get__cmp__items not implemented for class ',
            self.__class__.__name__)

        raise NotImplemented()

    def _get__cmp__data(self):
        """
        Implementation detail.

        """
        if self._cache.cmp_data is None:
            cmp_data = [
                declaration_utils.declaration_path(self.parent),
                self.name,
                self.location]
            cmp_data.extend(self._get__cmp__items())
            self._cache.cmp_data = cmp_data

        return self._cache.cmp_data

    def __eq__(self, other):
        """
        This function will return true, if both declarations refers to the same
        object.
        This function could be implemented in terms of _get__cmp__data, but in
        this case it will downgrade performance. self.mangled property is not
        compared, because it could be changed from one compilation time to an
        other.

        """

        if not isinstance(other, self.__class__):
            return False
        return self.name == other.name \
            and self.location == other.location \
            and declaration_utils.declaration_path(self.parent) \
            == declaration_utils.declaration_path(other.parent)

    def __hash__(self):
        return (hash(self.__class__) ^
                hash(self.name) ^
                hash(self.location))

    def __ne__(self, other):
        """
        Return not self.__eq__( other ).

        """

        return not self.__eq__(other)

    def __lt__(self, other):
        """
        .. code-block:: python

           if not isinstance( other, self.__class__ ):
               return self.__class__.__name__ < other.__class__.__name__
           return self._get__cmp__data() < other._get__cmp__data()

        """

        if not isinstance(other, self.__class__):
            return self.__class__.__name__ < other.__class__.__name__
        return self._get__cmp__data() < other._get__cmp__data()

    def _get_name_impl(self):
        return self._name

    def _on_rename(self):
        """
        Placeholder method, is redefined in child class.

        """

        pass

    @property
    def name(self):
        """
        Declaration name
           @type: str

        """

        return self._get_name_impl()

    @name.setter
    def name(self, new_name):
        previous_name = self._name
        self._name = new_name
        self._partial_name = None
        self.cache.reset_name_based()
        if previous_name:
            # There was a reset of the name
            self._on_rename()

    def _get_partial_name_impl(self):
        return self.name

    @property
    def partial_name(self):
        """
        Declaration name, without template default arguments.

        Right now std containers is the only classes that support this
        functionality.

        """

        if None is self._partial_name:
            self._partial_name = self._get_partial_name_impl()

        return self._partial_name

    @property
    def parent(self):
        """
        Reference to parent declaration.

           @type: declaration_t

        """

        return self._parent

    @parent.setter
    def parent(self, new_parent):
        if new_parent:
            assert(isinstance(new_parent, declaration_t))

        self._parent = new_parent

    @property
    def top_parent(self):
        """
        Reference to top parent declaration.

           @type: declaration_t

        """

        parent = self.parent
        me = self
        while True:
            if not parent:
                return me
            else:
                me = parent
                parent = me.parent

    @property
    def location(self):
        """
        Location of the declaration within source file

           @type: :class:`location_t`

        """

        return self._location

    @location.setter
    def location(self, new_location):
        self._location = new_location

    @property
    def is_artificial(self):
        """
        Describes whether declaration is compiler generated or not

           @type: bool

        """

        return self._is_artificial

    @is_artificial.setter
    def is_artificial(self, new_artificial):
        self._is_artificial = new_artificial

    def get_mangled_name(self):
        return self._mangled

    @property
    def mangled(self):
        """
        Unique declaration name generated by the compiler.

        For GCCXML, you can get the mangled name for all the declarations.
        When using CastXML, calling mangled is only allowed on functions
        and variables. For other declarations it will raise an exception.

        :return: the mangled name
        :rtype: str

        """

        if "GCC" in utils.xml_generator:
            return self.get_mangled_name()
        elif "CastXML" in utils.xml_generator:
            raise Exception(
                "Mangled name is not available with CastXML for all " +
                "declarations: you can get the mangled name only " +
                "for functions and variable declarations.")

    @mangled.setter
    def mangled(self, mangled):
        self._mangled = mangled

    @property
    def demangled(self):
        """
        Declaration name, reconstructed from GCCXML generated unique name.

           @type: str

        """
        if "GCC" in utils.xml_generator:
            return self._demangled
        elif "CastXML" in utils.xml_generator:
            raise Exception("Demangled name is not available with CastXML.")

    @demangled.setter
    def demangled(self, demangled):
        self._demangled = demangled

    @property
    def decorated_name(self):
        """
        Unique declaration name extracted from a binary file
        ( .map, .dll, .so, etc ).

           @type: str

        """

        return self._decorated_name

    @decorated_name.setter
    def decorated_name(self, decorated_name):
        self._decorated_name = decorated_name

    @property
    def attributes(self):
        """
        GCCXML attributes, set using __attribute__((gccxml("...")))

           @type: str

        """

        return self._attributes

    @attributes.setter
    def attributes(self, attributes):
        self._attributes = attributes

    def create_decl_string(self, with_defaults=True):
        return declaration_utils.full_name(self, with_defaults)

    @property
    def decl_string(self):
        """
        Declaration full name.

        """

        return self.create_decl_string()

    @property
    def partial_decl_string(self):
        """
        Declaration full name.

        """

        return self.create_decl_string(with_defaults=False)

    @property
    def cache(self):
        """
        Implementation detail.

        Reference to instance of :class:`algorithms_cache_t` class.

        """

        return self._cache

    def i_depend_on_them(self, recursive=True):
        """
        Return list of all types and declarations the declaration depends on

        """

        print(self)
        raise NotImplementedError()