class procedure_callers_iterator¶
Iterator over the call sites ( point of kind point_kind.CALL_SITE) whose target is a particular procedure.
Initialize with procedure.callers().
Use as you would any other Python iterator. For example:
# set up procedure proc, then...
for e in proc.callers():
print('point: ', e)
procedure_callers_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
procedure_callers_iterator Details¶
-
class
cs.procedure_callers_iterator¶ Iterator over the call sites (
pointof kindpoint_kind.CALL_SITE) whose target is a particular procedure.-
__eq__(other)¶ Iterator equality.
Parameters: other ( procedure_callers_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare 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') >>> c_iterA = proc.callers() >>> c_iterB = proc.callers() >>> c_iterA == c_iterB True >>> for p in c_iterA: ... if p.get_procedure().name() == 'bar': ... break ... >>> c_iterA == c_iterB False
-
__iter__()¶ Get the iterator object.
Return type: procedure_callers_iteratorReturns: 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 p in proc.callers(): # iteration is managed by procedure_callers_iterator.__iter__() ... # and procedure_callers_iterator.__next__() ... print(p.get_procedure()) ... foo foo foo bar
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( procedure_callers_iterator) – The iterator to compare against.Return type: bool Returns: Falseif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare 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') >>> c_iterA = proc.callers() >>> c_iterB = proc.callers() >>> c_iterA != c_iterB False >>> for p in c_iterA: ... if p.get_procedure().name() == 'bar': ... break ... >>> c_iterA != c_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: pointReturns: The element at the current iterator position. Raises: StopIteration- 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 p in proc.callers(): # iteration is managed by procedure_callers_iterator.__iter__() ... # and procedure_callers_iterator.__next__() ... print(p.get_procedure()) ... foo foo foo bar
- Side effects: Modifies
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> callers = proc.callers() >>> repr(callers)
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> callers = proc.callers() >>> str(callers) '<cs.procedure_callers_iterator begin>'
-
at_end()¶ Check: is the iterator at the end of the structure?
Return type: bool Returns: Trueif the iterator is at the end of the structure (there are no more elements to iterate over),Falseotherwise.>>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> callers = proc.callers() >>> callers.at_end() True
-