generate tommath_class.h with astyle format
(refactor with heredoc)
This commit is contained in:
		
							parent
							
								
									f89cda034b
								
							
						
					
					
						commit
						e2cd147a46
					
				
							
								
								
									
										57
									
								
								dep.pl
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								dep.pl
									
									
									
									
									
								
							| @ -9,7 +9,18 @@ my %deplist; | ||||
| 
 | ||||
| #open class file and write preamble  | ||||
| open(my $class, '>', 'tommath_class.h') or die "Couldn't open tommath_class.h for writing\n"; | ||||
| print {$class} "#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))\n#if defined(LTM2)\n#define LTM3\n#endif\n#if defined(LTM1)\n#define LTM2\n#endif\n#define LTM1\n\n#if defined(LTM_ALL)\n"; | ||||
| print {$class} << 'EOS'; | ||||
| #if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) | ||||
| #if defined(LTM2) | ||||
| #   define LTM3 | ||||
| #endif | ||||
| #if defined(LTM1) | ||||
| #   define LTM2 | ||||
| #endif | ||||
| #define LTM1 | ||||
| 
 | ||||
| #if defined(LTM_ALL) | ||||
| EOS | ||||
| 
 | ||||
| foreach my $filename (glob 'bn*.c') { | ||||
|    my $define = $filename; | ||||
| @ -19,7 +30,9 @@ foreach my $filename (glob 'bn*.c') { | ||||
|    # convert filename to upper case so we can use it as a define | ||||
|    $define =~ tr/[a-z]/[A-Z]/; | ||||
|    $define =~ tr/\./_/; | ||||
|    print {$class} "#define $define\n"; | ||||
|    print {$class} << "EOS"; | ||||
| #   define $define | ||||
| EOS | ||||
| 
 | ||||
|    # now copy text and apply #ifdef as required  | ||||
|    my $apply = 0; | ||||
| @ -31,7 +44,11 @@ foreach my $filename (glob 'bn*.c') { | ||||
|    if ($line =~ /include/) { | ||||
|       print {$out} $line; | ||||
|    } else { | ||||
|       print {$out} "#include <tommath.h>\n#ifdef $define\n$line"; | ||||
|       print {$out} << "EOS"; | ||||
| #include <tommath.h> | ||||
| #ifdef $define | ||||
| $line | ||||
| EOS | ||||
|       $apply = 1; | ||||
|    } | ||||
|    while (<$src>) { | ||||
| @ -40,7 +57,9 @@ foreach my $filename (glob 'bn*.c') { | ||||
|       } | ||||
|    } | ||||
|    if ($apply == 1) { | ||||
|       print {$out} "#endif\n"; | ||||
|       print {$out} << 'EOS'; | ||||
| #endif | ||||
| EOS | ||||
|    } | ||||
|    close $src; | ||||
|    close $out; | ||||
| @ -48,7 +67,10 @@ foreach my $filename (glob 'bn*.c') { | ||||
|    unlink $filename; | ||||
|    rename 'tmp', $filename; | ||||
| } | ||||
| print {$class} "#endif\n\n"; | ||||
| print {$class} << 'EOS'; | ||||
| #endif | ||||
| 
 | ||||
| EOS | ||||
| 
 | ||||
| # now do classes  | ||||
| 
 | ||||
| @ -59,7 +81,9 @@ foreach my $filename (glob 'bn*.c') { | ||||
|    $filename =~ tr/[a-z]/[A-Z]/; | ||||
|    $filename =~ tr/\./_/; | ||||
| 
 | ||||
|    print {$class} "#if defined($filename)\n"; | ||||
|    print {$class} << "EOS"; | ||||
| #if defined($filename) | ||||
| EOS | ||||
|    my $list = $filename; | ||||
| 
 | ||||
|    # scan for mp_* and make classes | ||||
| @ -74,7 +98,9 @@ foreach my $filename (glob 'bn*.c') { | ||||
|              $a =~ tr/[a-z]/[A-Z]/; | ||||
|              $a = 'BN_' . $a . '_C'; | ||||
|              if (!($list =~ /$a/)) { | ||||
|                 print {$class} "   #define $a\n"; | ||||
|                 print {$class} << "EOS"; | ||||
| #   define $a | ||||
| EOS | ||||
|              } | ||||
|              $list = $list . ',' . $a; | ||||
|           } | ||||
| @ -82,11 +108,24 @@ foreach my $filename (glob 'bn*.c') { | ||||
|    } | ||||
|    $deplist{$filename} = $list; | ||||
| 
 | ||||
|    print {$class} "#endif\n\n"; | ||||
|    print {$class} << 'EOS'; | ||||
| #endif | ||||
| 
 | ||||
| EOS | ||||
|    close $src; | ||||
| } | ||||
| 
 | ||||
| print {$class} "#ifdef LTM3\n#define LTM_LAST\n#endif\n#include <tommath_superclass.h>\n#include <tommath_class.h>\n#else\n#define LTM_LAST\n#endif\n"; | ||||
| print {$class} << 'EOS'; | ||||
| #ifdef LTM3 | ||||
| #   define LTM_LAST | ||||
| #endif | ||||
| 
 | ||||
| #include <tommath_superclass.h> | ||||
| #include <tommath_class.h> | ||||
| #else | ||||
| #   define LTM_LAST | ||||
| #endif | ||||
| EOS | ||||
| close $class; | ||||
| 
 | ||||
| #now let's make a cool call graph...  | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user