提交 7c0d7e87 编写于 作者: M Mauro Carvalho Chehab 提交者: Jonathan Corbet

scripts: kernel-doc: handle nested struct function arguments

Function arguments are different than usual ones. So, an
special logic is needed in order to handle such arguments
on nested structs.
Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: NJonathan Corbet <corbet@lwn.net>
上级 151c468b
...@@ -1041,10 +1041,23 @@ sub dump_struct($$) { ...@@ -1041,10 +1041,23 @@ sub dump_struct($$) {
$id =~ s/^\*+//; $id =~ s/^\*+//;
foreach my $arg (split /;/, $content) { foreach my $arg (split /;/, $content) {
next if ($arg =~ m/^\s*$/); next if ($arg =~ m/^\s*$/);
if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
# pointer-to-function
my $type = $1;
my $name = $2;
my $extra = $3;
next if (!$name);
if ($id =~ m/^\s*$/) {
# anonymous struct/union
$newmember .= "$type$name$extra;";
} else {
$newmember .= "$type$id.$name$extra;";
}
} else {
my $type = $arg; my $type = $arg;
my $name = $arg; my $name = $arg;
$type =~ s/\s\S+$//; $type =~ s/\s\S+$//;
$name =~ s/.*\s//; $name =~ s/.*\s+//;
$name =~ s/[:\[].*//; $name =~ s/[:\[].*//;
$name =~ s/^\*+//; $name =~ s/^\*+//;
next if (($name =~ m/^\s*$/)); next if (($name =~ m/^\s*$/));
...@@ -1055,6 +1068,7 @@ sub dump_struct($$) { ...@@ -1055,6 +1068,7 @@ sub dump_struct($$) {
$newmember .= "$type $id.$name;"; $newmember .= "$type $id.$name;";
} }
} }
}
$members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/; $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
$cont = 1; $cont = 1;
}; };
...@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) { ...@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) {
} elsif ($arg =~ m/\(.+\)\s*\(/) { } elsif ($arg =~ m/\(.+\)\s*\(/) {
# pointer-to-function # pointer-to-function
$arg =~ tr/#/,/; $arg =~ tr/#/,/;
$arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/; $arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/;
$param = $1; $param = $1;
$type = $arg; $type = $arg;
$type =~ s/([^\(]+\(\*?)\s*$param/$1/; $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册