Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
finish the s/smurf/popping/ renaming
[simgrid.git] / src / simix / simcalls.py
index 4e8963f..ad1435e 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())       
@@ -163,7 +163,7 @@ inline static %s simcall_BODY_%s(%s) {
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
       SIMIX_process_yield(self);
     } else {
-      SIMIX_simcall_enter(&self->simcall, 0);
+      SIMIX_simcall_handle(&self->simcall, 0);
     }    
     %s
   }'''%(self.res.ret()
@@ -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,52 +237,41 @@ 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('popping_accessors.h')
+  handle(fd, Simcall.accessors, simcalls, simcalls_dict)
+  fd.close()
+
+  ###
+  ### smx_popping_enum.c
+  ###
+  fd = header("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("popping_generated.c")
   
   fd.write('#include "smx_private.h"\n');
   fd.write('#ifdef HAVE_MC\n');
   fd.write('#include "mc/mc_private.h"\n');
   fd.write('#endif\n');
   fd.write('\n');
-  fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_smurf);\n\n');
+  fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n');
   
   fd.write('/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n')
   fd.write('const char* simcall_names[] = {\n')
@@ -298,7 +287,7 @@ NUM_SIMCALLS
   fd.write(' * \n')
   fd.write(' * This function is generated from src/simix/simcalls.in\n')
   fd.write(' */\n');
-  fd.write('void SIMIX_simcall_enter(smx_simcall_t simcall, int value) {\n');
+  fd.write('void SIMIX_simcall_handle(smx_simcall_t simcall, int value) {\n');
   fd.write('  XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));\n');
   fd.write('  SIMCALL_SET_MC_VALUE(simcall, value);\n');
   fd.write('  if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP)\n');
@@ -321,4 +310,12 @@ NUM_SIMCALLS
   
   fd.close()
   
-  write('smx_popping_bodies.c', Simcall.body, simcalls, simcalls_dict)
+  ###
+  ### smx_popping_bodies.c
+  ###
+  fd = header('popping_bodies.c')
+  fd.write('#include "smx_private.h"\n')
+  fd.write('#include "mc/mc_interface.h"\n')
+  fd.write('#include "xbt/ex.h"\n')
+  handle(fd, Simcall.body, simcalls, simcalls_dict)
+  fd.close()