Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Public Attributes | List of all members
miasm2.jitter.jitload.CallbackHandler Class Reference
+ Inheritance diagram for miasm2.jitter.jitload.CallbackHandler:
+ Collaboration diagram for miasm2.jitter.jitload.CallbackHandler:

Public Member Functions

def __init__
 
def add_callback
 
def set_callback
 
def get_callbacks
 
def remove_callback
 
def has_callbacks
 
def call_callbacks
 
def __call__
 

Public Attributes

 callbacks
 

Detailed Description

Definition at line 75 of file jitload.py.

Constructor & Destructor Documentation

def miasm2.jitter.jitload.CallbackHandler.__init__ (   self)

Definition at line 79 of file jitload.py.

79 
80  def __init__(self):
81  self.callbacks = {} # Key -> [callback list]

Member Function Documentation

def miasm2.jitter.jitload.CallbackHandler.__call__ (   self,
  name,
  args 
)

Definition at line 131 of file jitload.py.

132  def __call__(self, name, *args):
133  "Wrapper for call_callbacks"
134  return self.call_callbacks(name, *args)
135 

+ Here is the call graph for this function:

def miasm2.jitter.jitload.CallbackHandler.add_callback (   self,
  name,
  callback 
)
Add a callback to the key @name, iff the @callback isn't already
assigned to it

Definition at line 82 of file jitload.py.

82 
83  def add_callback(self, name, callback):
84  """Add a callback to the key @name, iff the @callback isn't already
85  assigned to it"""
86  if callback not in self.callbacks.get(name, []):
87  self.callbacks[name] = self.callbacks.get(name, []) + [callback]
def miasm2.jitter.jitload.CallbackHandler.call_callbacks (   self,
  name,
  args 
)
Call callbacks associated to key 'name' with arguments args. While
callbacks return True, continue with next callback.
Iterator on other results.

Definition at line 119 of file jitload.py.

120  def call_callbacks(self, name, *args):
121  """Call callbacks associated to key 'name' with arguments args. While
122  callbacks return True, continue with next callback.
123  Iterator on other results."""
124 
125  res = True
126 
127  for c in self.get_callbacks(name):
128  res = c(*args)
129  if res is not True:
130  yield res
tuple c
Definition: ir2C.py:23

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.jitter.jitload.CallbackHandler.get_callbacks (   self,
  name 
)

Definition at line 92 of file jitload.py.

92 
93  def get_callbacks(self, name):
94  "Return the list of callbacks associated to key 'name'"
95  return self.callbacks.get(name, [])

+ Here is the caller graph for this function:

def miasm2.jitter.jitload.CallbackHandler.has_callbacks (   self,
  name 
)

Definition at line 116 of file jitload.py.

117  def has_callbacks(self, name):
118  return name in self.callbacks
def miasm2.jitter.jitload.CallbackHandler.remove_callback (   self,
  callback 
)
Remove the callback from the list.
Return the list of empty keys (removed)

Definition at line 96 of file jitload.py.

96 
97  def remove_callback(self, callback):
98  """Remove the callback from the list.
99  Return the list of empty keys (removed)"""
100 
101  to_check = set()
102  for key, cb_list in self.callbacks.items():
103  try:
104  cb_list.remove(callback)
105  to_check.add(key)
106  except ValueError:
107  pass
108 
109  empty_keys = []
110  for key in to_check:
111  if len(self.callbacks[key]) == 0:
112  empty_keys.append(key)
113  del(self.callbacks[key])
114 
115  return empty_keys
def miasm2.jitter.jitload.CallbackHandler.set_callback (   self,
  name,
  args 
)

Definition at line 88 of file jitload.py.

88 
89  def set_callback(self, name, *args):
90  "Set the list of callback for key 'name'"
91  self.callbacks[name] = list(args)

Member Data Documentation

miasm2.jitter.jitload.CallbackHandler.callbacks

Definition at line 80 of file jitload.py.


The documentation for this class was generated from the following file: