Add actions

Provide tooling to enable specification of pre-implemented actions
to perform after a signal match.

Add a default 'noop' action to be used when an action isn't specified.

Change-Id: I8d3b1ef2cfc26771322820be931a61bba3ad8d94
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/pimgen.py b/pimgen.py
index 8350d3a..37819d3 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -38,10 +38,11 @@
 
 
 class MatchRender(object):
-    def __init__(self, name, signature, fltr):
+    def __init__(self, name, signature, fltr, action):
         self.name = valid_c_name_pattern.sub('_', name).lower()
         self.signature = signature
         self.fltr = fltr
+        self.action = action
 
         if self.name in all_names:
             raise RuntimeError('The name "%s" is not unique.' % name)
@@ -61,6 +62,9 @@
             fd.write('            %s' % s)
         fd.write(',\n')
         self.fltr(fd)
+        fd.write(',\n')
+        self.action(fd)
+        fd.write('\n')
         fd.write('        ),\n')
         fd.write('    },\n')
 
@@ -90,7 +94,13 @@
             fd.write(buf)
             fd.write(')')
 
-        fd.write('\n')
+
+class ActionRender(FilterRender):
+    namespace = 'actions'
+    default = 'noop'
+
+    def __init__(self, action):
+        FilterRender.__init__(self, action)
 
 
 class MatchEventParse(object):
@@ -98,12 +108,14 @@
         self.name = match['name']
         self.signature = match['signature']
         self.fltr = match.get('filter')
+        self.action = match.get('action')
 
     def __call__(self):
         return MatchRender(
             self.name,
             self.signature,
-            FilterRender(self.fltr))
+            FilterRender(self.fltr),
+            ActionRender(self.action))
 
 
 class EventsParse(object):