]> mj.ucw.cz Git - libucw.git/commitdiff
Doc. system: add support for typedefs
authorMichal Vaner <vorner@ucw.cz>
Sun, 14 Sep 2008 15:45:58 +0000 (17:45 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sun, 14 Sep 2008 15:45:58 +0000 (17:45 +0200)
And a little cleanup/code compression at the occasion.

build/doc-defs
build/doc-extract

index b0c5a5e8810d5f2c3da8a7f3654be0ae470b50b2..c3b683aeea9adcb1e4722efaee54d56bf4d1b451 100755 (executable)
@@ -23,21 +23,22 @@ while( defined( my $line = <> ) ) {
        push @dump, [ split /,/, $line, 5 ];
 }
 
-my %groups = (
-       'enum' => 0,
-       'struct' => 1,
-       'fun' => 2,
-       'var' => 3,
-       'def' => 4
+my @types = (
+       [ 'enum', 'Enumerations' ],
+       [ 'struct', 'Structures' ],
+       [ 'type', 'Types' ],
+       [ 'fun', 'Functions' ],
+       [ 'var', 'Variables' ],
+       [ 'def', 'Preprocessor definitions' ]
 );
 
-my %heads = (
-       'enum' => 'Enums',
-       'struct' => 'Structs',
-       'fun' => 'Functions',
-       'var' => 'Variables',
-       'def' => 'Preprocessor definitions'
-);
+my( $index, %groups, %heads ) = ( 0 );
+
+foreach( @types ) {
+       my( $name, $value ) = @{$_};
+       $groups{$name} = ++ $index;
+       $heads{$name} = $value;
+}
 
 my $lasttype = '';
 
index db713095563e2b6069001871df130f1a73f0307b..dd01f4c42b7735c16709b224ee36f54bdb480e1e 100755 (executable)
@@ -24,19 +24,20 @@ if( defined $defdump ) {
 
 sub detect( $ ) {
         ( $_ ) = @_;
-       return( 'struct', 1, $1, "typedef struct { ... } $1;" ) if( /^\s*typedef\s+struct\s*{.*}\s*(\w+)\s*;\s*$/s );
-       return( 'enum', 1, $1, "typedef enum { ... } $1;" ) if( /^\s*typedef\s+enum\s*{.*}\s*(\w+)\s*;\s*$/s );
+       return( 'struct', 1, $1, "typedef struct { ... } $1;" ) if /^\s*typedef\s+struct\s*{.*}\s*(\w+)\s*;\s*$/s;
+       return( 'enum', 1, $1, "typedef enum { ... } $1;" ) if /^\s*typedef\s+enum\s*{.*}\s*(\w+)\s*;\s*$/s;
         my $l = length;
         s/\n.*//s;
-        return( 'struct', 0, $1, $_ ) if( /struct\s+(\w+)\s+{/ );
-        return( 'enum', 0, $1, $_ ) if( /enum\s+(\w+)\s+{/ );
+        return( 'struct', 0, $1, $_ ) if /struct\s+(\w+)\s+{/;
+        return( 'enum', 0, $1, $_ ) if /enum\s+(\w+)\s+{/;
         if( $l > length ) {
                 warn( "Unknown statement $_\n" );
                 return( '', 0, $_, $_ );
         }
-        return( 'def', 0, $1, $_ ) if( /#define\s+(\w+)/ );
-        return( 'fun', 1, $2, $1 ) if( /^(.*?(\w+)\([^{]*\)[^{]*)/ );
-        return( 'var', 1, $1, $_ ) if( /\s(\w+);/ );
+        return( 'def', 0, $1, $_ ) if /#define\s+(\w+)/;
+        return( 'fun', 1, $2, $1 ) if /^(.*?(\w+)\([^{]*\)[^{]*)/;
+       return( 'type', 1, $1, $_ ) if /^\s*typedef.*?(\w+);/;
+        return( 'var', 1, $1, $_ ) if /\s(\w+);/;
         warn( "Unknown statement $_\n" );
         return( '', 0, $_, $_ );
 }