Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in the popping generator
[simgrid.git] / src / simix / simcalls.py
index 4e8963f..da4df73 100755 (executable)
@@ -101,7 +101,7 @@ class Simcall(object):
     return True
 
   def enum(self):
-    return 'SIMCALL_%s,'%(self.name.upper())
+    return '  SIMCALL_%s,'%(self.name.upper())
 
   def string(self):
     return '[SIMCALL_%s] = "SIMCALL_%s",'%(self.name.upper(), self.name.upper())       
@@ -200,7 +200,8 @@ def parse(fn):
       resdi.append(sim)
   return simcalls, simcalls_guarded
 
-def header(fd):
+def header(name):
+    fd = open(name, 'w')
     fd.write('/**********************************************************************/\n')
     fd.write('/* File generated by src/simix/simcalls.py from src/simix/simcalls.in */\n')
     fd.write('/*                                                                    */\n')
@@ -208,6 +209,13 @@ def header(fd):
     fd.write('/*                                                                    */\n')
     fd.write('/* change simcalls specification in src/simix/simcalls.in             */\n')  
     fd.write('/**********************************************************************/\n\n')
+    fd.write('/*\n')
+    fd.write(' * Note that the name comes from http://en.wikipedia.org/wiki/Popping\n') 
+    fd.write(' * Indeed, the control flow is doing a strange dance in there.\n')
+    fd.write(' *\n')
+    fd.write(' * That\'s not about http://en.wikipedia.org/wiki/Poop, despite the odor :)\n')
+    fd.write(' */\n\n')
+    return fd
 
 def handle(fd,func, simcalls, guarded_simcalls):
     fd.write('\n'.join(func(simcall) for simcall in simcalls))
@@ -216,14 +224,6 @@ def handle(fd,func, simcalls, guarded_simcalls):
         fd.write('\n'.join(func(simcall) for simcall in list))
         fd.write('\n#endif\n')
 
-def write(fn, func, simcalls, scd,pre="",post=""):
-    fd = open(fn, 'w')
-    header(fd)
-    fd.write(pre)
-    handle(fd, func, simcalls, scd)
-    fd.write(post)
-    fd.close()
-
 if __name__=='__main__':
   import sys
   simcalls, simcalls_dict = parse('simcalls.in')
@@ -237,45 +237,34 @@ if __name__=='__main__':
   #  print ("Some checks fail!")
   #  sys.exit(1)
 
-  write('smx_popping_accessors.h', Simcall.accessors, simcalls, simcalls_dict)
-  
-  
-  fd = open("smx_popping_enum.h", 'w')
-  header(fd)
-  fd.write("""
-/*
- * Note that the name comes from http://en.wikipedia.org/wiki/Popping 
- * Indeed, the control flow is doing a strange dance in there.
- *
- * That\'s not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
- */
-
-/**
- * @brief All possible simcalls.
- */
-typedef enum {
-SIMCALL_NONE,
-  """)
+  ###
+  ### smx_popping_accessors.c
+  ###
+  fd = header('smx_popping_accessors.h')
+  handle(fd, Simcall.accessors, simcalls, simcalls_dict)
+  fd.close()
+
+  ###
+  ### smx_popping_enum.c
+  ###
+  fd = header("smx_popping_enum.h")
+  fd.write('/**\n')
+  fd.write(' * @brief All possible simcalls.\n')
+  fd.write(' */\n')
+  fd.write('typedef enum {\n')
+  fd.write('  SIMCALL_NONE,\n')
   
   handle(fd, Simcall.enum, simcalls, simcalls_dict)
   
-  fd.write("""
-NUM_SIMCALLS
-} e_smx_simcall_t;
-  """)
-
-  
+  fd.write('  NUM_SIMCALLS\n')
+  fd.write('} e_smx_simcall_t;\n')
   fd.close()
 
+  ###
+  ### smx_popping_generated.c
+  ###
   
-  fd = open("smx_popping_generated.c", 'w')
-  header(fd)
-  fd.write('/*\n')
-  fd.write(' * Note that the name comes from http://en.wikipedia.org/wiki/Popping \n')
-  fd.write(' * Indeed, the control flow is doing a strange dance in there.\n')
-  fd.write(' *\n')
-  fd.write(' * That\'s not about http://en.wikipedia.org/wiki/Poop, despite the odor :)\n')
-  fd.write(' */\n\n')
+  fd = header("smx_popping_generated.c")
   
   fd.write('#include "smx_private.h"\n');
   fd.write('#ifdef HAVE_MC\n');
@@ -321,4 +310,9 @@ NUM_SIMCALLS
   
   fd.close()
   
-  write('smx_popping_bodies.c', Simcall.body, simcalls, simcalls_dict)
+  ###
+  ### smx_popping_bodies.c
+  ###
+  fd = header('smx_popping_bodies.c')
+  handle(fd, Simcall.body, simcalls, simcalls_dict)
+  fd.close()