class procedure_adjusted_callers_iterator

An iterator over the direct and indirect call sites ( point of kind point_kind.CALL_SITE or point_kind.INDIRECT_CALL) whose target is a particular procedure, taking into account any translations incurred by csonar_replace_*() calls and the FUNCTION_MAP configuration file variable.

Initialize with procedure.adjusted_callers().

Use as you would any other Python iterator. For example:

# set up procedure proc, then...
for e in proc.adjusted_callers():
    print('point: ', e)

procedure_adjusted_callers_iterator Details

class cs.procedure_adjusted_callers_iterator

An iterator over the direct and indirect call sites ( point of kind point_kind.CALL_SITE or point_kind.INDIRECT_CALL) whose target is a particular procedure, taking into account any translations incurred by csonar_replace_*() calls and the FUNCTION_MAP configuration file variable.

__eq__(other)

Iterator equality.

Parameters:other (procedure_adjusted_callers_iterator) –
Return type:bool
Returns:True if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> cu = next(c for c in project.current().compunits()
...             if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='bar')
>>> callers_iterA = proc.adjusted_callers()
>>> callers_iterB = proc.adjusted_callers()
>>> callers_iterA == callers_iterB
True
>>> for py in callers_iterA:
...     if pt.file_line()[1] > 30:  # if point is on line 30 or higher...
...         break
...
>>> callers_iterA == callers_iterB
False
__iter__()

Get the iterator object.

Return type:procedure_adjusted_callers_iterator
Returns:self.
>>> cu = next(c for c in project.current().compunits()
...             if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='bar')
>>> for pt in proc.adjusted_callers():  # iteration managed by procedure_adjusted_callers_iterator.__iter__()
...                                     # and procedure_adjusted_callers_iterator.__next__()
...     fl = pt.file_line()
...     print(fl[0].normalized_name().split('/')[-1], fl[1], pt.characters())
...
apitest.cpp 35 bar()
apitest.cpp 36 bar()
apitest.cpp 40 bar()
apitest.cpp 14 bar()
__ne__(other)

Iterator inequality.

Parameters:other (procedure_adjusted_callers_iterator) – The iterator to compare against.
Return type:bool
Returns:False if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> cu = next(c for c in project.current().compunits()
...             if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='bar')
>>> callers_iterA = proc.adjusted_callers()
>>> callers_iterB = proc.adjusted_callers()
>>> callers_iterA != callers_iterB
False
>>> for py in callers_iterA:
...     if pt.file_line()[1] > 30:  # if point is on line 30 or higher...
...         break
...
>>> callers_iterA != callers_iterB
True
__next__()

Iterator dereference operator.

Return type:

point

Returns:

The element at the current iterator position.

Raises:
  • Side effects: Modifies self.

The typical use is implicit:

>>> for item in myiter:
...   (do something to item)
>>> cu = next(c for c in project.current().compunits()
...             if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='bar')
>>> for pt in proc.adjusted_callers():  # iteration managed by procedure_adjusted_callers_iterator.__iter__()
...                                     # and procedure_adjusted_callers_iterator.__next__()
...     fl = pt.file_line()
...     print(fl[0].normalized_name().split('/')[-1], fl[1], pt.characters())
...
apitest.cpp 35 bar()
apitest.cpp 36 bar()
apitest.cpp 40 bar()
apitest.cpp 14 bar()
__repr__()

Get a representation of the iterator that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> foofn = next(p for p in project.current().procedures() if p.name()=='foo')
>>> it = foofn.adjusted_callers()
>>> repr(it)
'<cs.procedure_adjusted_callers_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> foofn = next(p for p in project.current().procedures() if p.name()=='foo')
>>> it = foofn.adjusted_callers()
>>> str(it)
'<cs.procedure_adjusted_callers_iterator begin>'
at_end()

Check: is the iterator at the end of the structure?

Return type:bool
Returns:True if the iterator is at the end of the structure (there are no more elements to iterate over), False otherwise.
>>> foofn = next(p for p in project.current().procedures() if p.name()=='foo')
>>> it = foofn.adjusted_callers()
>>> it.at_end()
True