kernel-doc (701b3a3c0ac42630f74a5efba8545d61ac0e3293) kernel-doc (673bb2dfc36488abfdbbfc2ce2631204eaf682f2)
1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
3
4use warnings;
5use strict;
6
7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##

--- 1048 unchanged lines hidden (view full) ---

1057sub dump_union($$) {
1058 dump_struct(@_);
1059}
1060
1061sub dump_struct($$) {
1062 my $x = shift;
1063 my $file = shift;
1064
1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
3
4use warnings;
5use strict;
6
7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##

--- 1048 unchanged lines hidden (view full) ---

1057sub dump_union($$) {
1058 dump_struct(@_);
1059}
1060
1061sub dump_struct($$) {
1062 my $x = shift;
1063 my $file = shift;
1064
1065 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
1065 if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) {
1066 my $decl_type = $1;
1067 $declaration_name = $2;
1068 my $members = $3;
1069
1070 # ignore members marked private:
1071 $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;
1072 $members =~ s/\/\*\s*private:.*//gosi;
1073 # strip comments:

--- 69 unchanged lines hidden (view full) ---

1143 $newmember .= "$type $name; ";
1144 } else {
1145 $newmember .= "$type $id.$name; ";
1146 }
1147 }
1148 }
1149 }
1150 }
1066 my $decl_type = $1;
1067 $declaration_name = $2;
1068 my $members = $3;
1069
1070 # ignore members marked private:
1071 $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;
1072 $members =~ s/\/\*\s*private:.*//gosi;
1073 # strip comments:

--- 69 unchanged lines hidden (view full) ---

1143 $newmember .= "$type $name; ";
1144 } else {
1145 $newmember .= "$type $id.$name; ";
1146 }
1147 }
1148 }
1149 }
1150 }
1151 $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)}([^\{\}\;]*)\;/$newmember/;
1151 $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/$newmember/;
1152 }
1153
1154 # Ignore other nested elements, like enums
1152 }
1153
1154 # Ignore other nested elements, like enums
1155 $members =~ s/(\{[^\{\}]*})//g;
1155 $members =~ s/(\{[^\{\}]*\})//g;
1156
1157 create_parameterlist($members, ';', $file, $declaration_name);
1158 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
1159
1160 # Adjust declaration for better display
1156
1157 create_parameterlist($members, ';', $file, $declaration_name);
1158 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
1159
1160 # Adjust declaration for better display
1161 $declaration =~ s/([{;])/$1\n/g;
1162 $declaration =~ s/}\s+;/};/g;
1161 $declaration =~ s/([\{;])/$1\n/g;
1162 $declaration =~ s/\}\s+;/};/g;
1163 # Better handle inlined enums
1163 # Better handle inlined enums
1164 do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/);
1164 do {} while ($declaration =~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/);
1165
1166 my @def_args = split /\n/, $declaration;
1167 my $level = 1;
1168 $declaration = "";
1169 foreach my $clause (@def_args) {
1170 $clause =~ s/^\s+//;
1171 $clause =~ s/\s+$//;
1172 $clause =~ s/\s+/ /;
1173 next if (!$clause);
1165
1166 my @def_args = split /\n/, $declaration;
1167 my $level = 1;
1168 $declaration = "";
1169 foreach my $clause (@def_args) {
1170 $clause =~ s/^\s+//;
1171 $clause =~ s/\s+$//;
1172 $clause =~ s/\s+/ /;
1173 next if (!$clause);
1174 $level-- if ($clause =~ m/(})/ && $level > 1);
1174 $level-- if ($clause =~ m/(\})/ && $level > 1);
1175 if (!($clause =~ m/^\s*#/)) {
1176 $declaration .= "\t" x $level;
1177 }
1178 $declaration .= "\t" . $clause . "\n";
1175 if (!($clause =~ m/^\s*#/)) {
1176 $declaration .= "\t" x $level;
1177 }
1178 $declaration .= "\t" . $clause . "\n";
1179 $level++ if ($clause =~ m/(\{)/ && !($clause =~m/}/));
1179 $level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
1180 }
1181 output_declaration($declaration_name,
1182 'struct',
1183 {'struct' => $declaration_name,
1184 'module' => $modulename,
1185 'definition' => $declaration,
1186 'parameterlist' => \@parameterlist,
1187 'parameterdescs' => \%parameterdescs,

--- 51 unchanged lines hidden (view full) ---

1239sub dump_enum($$) {
1240 my $x = shift;
1241 my $file = shift;
1242
1243 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1244 # strip #define macros inside enums
1245 $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
1246
1180 }
1181 output_declaration($declaration_name,
1182 'struct',
1183 {'struct' => $declaration_name,
1184 'module' => $modulename,
1185 'definition' => $declaration,
1186 'parameterlist' => \@parameterlist,
1187 'parameterdescs' => \%parameterdescs,

--- 51 unchanged lines hidden (view full) ---

1239sub dump_enum($$) {
1240 my $x = shift;
1241 my $file = shift;
1242
1243 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1244 # strip #define macros inside enums
1245 $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
1246
1247 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1247 if ($x =~ /enum\s+(\w+)\s*\{(.*)\}/) {
1248 $declaration_name = $1;
1249 my $members = $2;
1250 my %_members;
1251
1252 $members =~ s/\s+$//;
1253
1254 foreach my $arg (split ',', $members) {
1255 $arg =~ s/^\s*(\w+).*/$1/;

--- 524 unchanged lines hidden (view full) ---

1780 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1781
1782 if ($x =~ /^#/) {
1783 # To distinguish preprocessor directive from regular declaration later.
1784 $x .= ";";
1785 }
1786
1787 while (1) {
1248 $declaration_name = $1;
1249 my $members = $2;
1250 my %_members;
1251
1252 $members =~ s/\s+$//;
1253
1254 foreach my $arg (split ',', $members) {
1255 $arg =~ s/^\s*(\w+).*/$1/;

--- 524 unchanged lines hidden (view full) ---

1780 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1781
1782 if ($x =~ /^#/) {
1783 # To distinguish preprocessor directive from regular declaration later.
1784 $x .= ";";
1785 }
1786
1787 while (1) {
1788 if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1788 if ( $x =~ /([^\{\};]*)([\{\};])(.*)/ ) {
1789 if( length $prototype ) {
1790 $prototype .= " "
1791 }
1792 $prototype .= $1 . $2;
1793 ($2 eq '{') && $brcount++;
1794 ($2 eq '}') && $brcount--;
1795 if (($2 eq ';') && ($brcount == 0)) {
1796 dump_declaration($prototype, $file);

--- 426 unchanged lines hidden ---
1789 if( length $prototype ) {
1790 $prototype .= " "
1791 }
1792 $prototype .= $1 . $2;
1793 ($2 eq '{') && $brcount++;
1794 ($2 eq '}') && $brcount--;
1795 if (($2 eq ';') && ($brcount == 0)) {
1796 dump_declaration($prototype, $file);

--- 426 unchanged lines hidden ---