dcopidlng fixes:

+ includes may use quotation marks
+ argument types can contain multiple words
+ avoid use long, short, int or char type as the argument name
+ avoid use type as the argument name if the const qualifier is used
+ use long notation of int types
+ the arguments can be nameless
+ return types can have qualifiers
+ do not warn on inherit of the DCOPObject and TQObject classes
+ the documentation comment does not have to end on a separate line

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/83/head
Slávek Banko 4 years ago
parent ef23612c56
commit 49614d38c9
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -439,7 +439,7 @@ LOOP:
|| $p =~ /^\s*KDOM_/ || $p =~ /^\s*KDOM_/
); );
push @includes_list, $1 if $p =~ /^#include\s+<?(.*?)>?\s*$/; push @includes_list, $1 if $p =~ /^#include\s+[<"]?(.*?)[>"]?\s*$/;
# remove all preprocessor macros # remove all preprocessor macros
if( $p =~ /^\s*#\s*(\w+)/ ) { if( $p =~ /^\s*#\s*(\w+)/ ) {
@ -1521,16 +1521,22 @@ sub makeParamList($$$)
# Separate arg type from arg name, if the latter is specified # Separate arg type from arg name, if the latter is specified
if ( $arg =~ /(.*)\s+([\w_]+)\s*$/ || $arg =~ /(.*)\(\s*\*\s([\w_]+)\)\s*\((.*)\)\s*$/ ) { if ( $arg =~ /(.*)\s+([\w_]+)\s*$/ || $arg =~ /(.*)\(\s*\*\s([\w_]+)\)\s*\((.*)\)\s*$/ ) {
if ( defined $3 ) { # function pointer if ( $1 eq "const" || $2 eq "long" || $2 eq "short" || $2 eq "int" || $2 eq "char" ) {
$argType = $1."(*)($3)"; # const qualifier or long notation of numeric type
$argName = $2; # without argument name
$argType = "$1 $2";
} else { } else {
$argType = $1; $argType = $1;
$argName = $2; $argName = $2;
} }
} else { # unnamed arg - or enum value if ( defined $3 ) {
# function pointer
$argType .= "(*)($3)";
}
} else {
# unnamed arg - or enum value
$argType = $arg if (!$isEnum); $argType = $arg if (!$isEnum);
$argName = $arg if ($isEnum); $argName = $arg if ($isEnum);
} }
$argId++; $argId++;

@ -161,18 +161,33 @@ sub generateMethod($$)
$argType =~ s/^\s*(.*?)\s*$/$1/; $argType =~ s/^\s*(.*?)\s*$/$1/;
$argType =~ s/</&lt;/g; $argType =~ s/</&lt;/g;
$argType =~ s/>/&gt;/g; $argType =~ s/>/&gt;/g;
$argType =~ s/\s//g; $argType =~ s/(\W)\s+/$1/g;
$argType =~ s/\s+(\W)/$1/g;
$args .= " <ARG><TYPE$typeAttrs>$argType</TYPE><NAME>$arg->{ArgName}</NAME></ARG>\n"; $argType =~ s/\b(signed|unsigned|long|short)$/$1 int/;
$args .= " ";
$args .= "<ARG><TYPE$typeAttrs>$argType</TYPE>";
$args .= "<NAME>$arg->{ArgName}</NAME>" if $arg->{ArgName} !~ /^$/;
$args .= "</ARG>\n";
} }
my $qual = ""; my $qual = "";
$qual .= " qual=\"const\"" if $flags =~ "c"; $qual .= " qual=\"const\"" if $flags =~ "c";
my $r_isConst = ($returnType =~ s/^\s*const\s*//);
my $r_isRef = ($returnType =~ s/&//);
my $retTypeAttrs = "";
$retTypeAttrs .= " qleft=\"const\"" if $r_isConst;
$retTypeAttrs .= " qright=\"&amp;\"" if $r_isRef;
$returnType = "void" unless $returnType; $returnType = "void" unless $returnType;
$returnType =~ s/^\s*(.*?)\s*$/$1/;
$returnType =~ s/</&lt;/g; $returnType =~ s/</&lt;/g;
$returnType =~ s/>/&gt;/g; $returnType =~ s/>/&gt;/g;
$returnType =~ s/^\s*const\s*//; $returnType =~ s/(\W)\s+/$1/g;
$returnType =~ s/\s+(\W)/$1/g;
$returnType =~ s/\b(signed|unsigned|long|short)$/$1 int/;
my $methodCode = ""; my $methodCode = "";
@ -182,7 +197,7 @@ sub generateMethod($$)
if (!$isConstructor) { if (!$isConstructor) {
$methodCode .= " <$tagType$tagAttr$qual>\n"; $methodCode .= " <$tagType$tagAttr$qual>\n";
$methodCode .= " <TYPE>$returnType</TYPE>\n"; $methodCode .= " <TYPE$retTypeAttrs>$returnType</TYPE>\n";
$methodCode .= " <NAME>$name</NAME>\n"; $methodCode .= " <NAME>$name</NAME>\n";
$methodCode .= "$args"; $methodCode .= "$args";
$methodCode .= " </$tagType>\n"; $methodCode .= " </$tagType>\n";

@ -152,10 +152,12 @@ ANITER:
if( !defined $ref ) { if( !defined $ref ) {
# ancestor undefined # ancestor undefined
warn "warning: ", $node->{astNodeName}, if( $in->{astNodeName} ne "DCOPObject"
" inherits unknown class '", && $in->{astNodeName} ne "TQObject" ) {
warn "warning: ", $node->{astNodeName},
" inherits unknown class '",
$in->{astNodeName},"'\n"; $in->{astNodeName},"'\n";
}
$parent->AddPropList( 'InBy', $node ); $parent->AddPropList( 'InBy', $node );
} }
else { else {

@ -60,15 +60,15 @@ PARSELOOP:
next if !defined $text; next if !defined $text;
$text =~ s#^\s*\*(?!\/)##; $text =~ s#^\s*\*(?!\/)##;
if ( $text =~ m#\*/# ) {
$finished = 1;
$text = $`;
}
# if ( $text =~ /^\s*<\/pre>/i ) { # if ( $text =~ /^\s*<\/pre>/i ) {
# flushProp(); # flushProp();
# $inbounded = 0; # $inbounded = 0;
# } # }
if( $inbounded ) { if( $inbounded ) {
if ( $text =~ m#\*/# ) {
$finished = 1;
$text = $`;
}
$buffer .= $text; $buffer .= $text;
next PARSELOOP; next PARSELOOP;
} }
@ -162,10 +162,6 @@ PARSELOOP:
docProp( "LibDoc" ); docProp( "LibDoc" );
} }
else { else {
if ( $text =~ m#\*/# ) {
$finished = 1;
$text = $`;
}
$buffer .= $text; $buffer .= $text;
} }
} }

Loading…
Cancel
Save