[hipl-commit] [tiny] Rev 3746: Removed typedef in generated header files and pretty printing for init functions.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 30 Mar 2010 18:58:10 +0300

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: 30/03/2010 at 18:58:10
Revision: 3746
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Removed typedef in generated header files and pretty printing for init 
functions.
  
  The typedef pt2Function was removed. Instead the function pointer arrays
  are defined intuitionally.
  
  The init function definition is printed with line breaks after each 
  function pointer.

Modified:
  M  process_modules.py

=== modified file 'process_modules.py'
--- process_modules.py  2010-03-30 15:23:13 +0000
+++ process_modules.py  2010-03-30 15:54:55 +0000
@@ -192,9 +192,8 @@
                     for current in includes[current_app]:
                         hdr_file.write('\n#include \"' + current + '\"')
 
-                    hdr_file.write('\n\ntypedef int (*pt2Function)(void);\n')
-                    hdr_file.write('\nconst int num_modules_' + current_app + 
' = ')
-                    hdr_file.write(num_modules + ';\n')
+                    hdr_file.write('\n\nconst int num_modules_' + current_app)
+                    hdr_file.write(' = ' + num_modules + ';\n')
                     hdr_file.write('\nconst int num_required_modules_' + 
current_app + ' = ')
                     hdr_file.write(str(len(required_modules)) + ';\n')
                     hdr_file.write('\nconst char *modules_' + current_app + 
'[')
@@ -216,18 +215,22 @@
                         first_loop = False
                     hdr_file.write('};')
 
-                    hdr_file.write('\n\nstatic const pt2Function ' + 
current_app)
-                    hdr_file.write('_init_functions[' + num_modules + '] = {')
+                    hdr_file.write('\n\n')
+                    init_function_string = 'static int (*' + current_app
+                    init_function_string += '_init_functions[' + num_modules
+                    init_function_string += '])(void) = {'
+                    hdr_file.write(init_function_string)
 
                     first_loop = True
                     for function in init_functions[current_app]:
                         if first_loop != True:
-                            hdr_file.write(', ')
+                            hdr_file.write(',\n')
+                            for i in range(len(init_function_string)):
+                                hdr_file.write(' ')
                         hdr_file.write('&' + function)
                         first_loop = False
                     hdr_file.write('};')
                 else:
-                    hdr_file.write('\n\ntypedef int (*pt2Function)(void);\n')
                     hdr_file.write('\nconst int num_modules_' + current_app + 
' = 0;')
                     hdr_file.write('\n\nconst char *modules_' + current_app)
                     hdr_file.write('[0] = {};')
@@ -235,8 +238,7 @@
                     hdr_file.write(current_app + ' = 0;')
                     hdr_file.write('\n\nconst char *required_modules_')
                     hdr_file.write(current_app + '[0] = {};')
-                    hdr_file.write('\n\nstatic const pt2Function ' + 
current_app)
-                    hdr_file.write('_init_functions[0] = {};')
+                    hdr_file.write('\n\n' + init_function_string + '};')
 
                 hdr_file.write('\n\n#endif /* ' + app_string + ' */\n')
                 print '|    created file: ' + hdr_file_path

Other related posts:

  • » [hipl-commit] [tiny] Rev 3746: Removed typedef in generated header files and pretty printing for init functions. - Tim Just