From 5fb2460fd543755ce0ec7e5dc75d2f6df801079b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 18 Jun 2020 11:56:26 +0200 Subject: [PATCH] Merge fixes for kalyptus that were made in tdelibs/dcopidlng: + 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 + do not skip an empty class if it is declared with K_DCOP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit 3da067051cc259588363c88875374fd699c83a07) --- kalyptus/kalyptus | 28 +++++++++++++++++----------- kalyptus/kalyptusCxxToDcopIDL.pm | 23 ++++++++++++++++++++--- kalyptus/kdocAstUtil.pm | 8 +++++--- kalyptus/kdocParseDoc.pm | 12 ++++-------- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/kalyptus/kalyptus b/kalyptus/kalyptus index 5bc443b..a290161 100644 --- a/kalyptus/kalyptus +++ b/kalyptus/kalyptus @@ -557,7 +557,7 @@ LOOP: || $p =~ /^\s*Q_DECLARE_SHARED/ ); - push @includes_list, $1 if $p =~ /^#include\s+?\s*$/; + push @includes_list, $1 if $p =~ /^#include\s+[<"]?(.*?)[>"]?\s*$/; # remove all preprocessor macros if( $p =~ /^\s*#\s*(\w+)/ ) { @@ -1690,16 +1690,22 @@ sub makeParamList($$$) # Separate arg type from arg name, if the latter is specified if ( $arg =~ /(.*)\s+([\w_]+)\s*$/ || $arg =~ /(.*)\(\s*\*\s([\w_]+)\)\s*\((.*)\)\s*$/ ) { - if ( defined $3 ) { # function pointer - $argType = $1."(*)($3)"; - $argName = $2; - } else { - $argType = $1; - $argName = $2; - } - } else { # unnamed arg - or enum value - $argType = $arg if (!$isEnum); - $argName = $arg if ($isEnum); + if ( $1 eq "const" || $2 eq "long" || $2 eq "short" || $2 eq "int" || $2 eq "char" ) { + # const qualifier or long notation of numeric type + # without argument name + $argType = "$1 $2"; + } else { + $argType = $1; + $argName = $2; + } + if ( defined $3 ) { + # function pointer + $argType .= "(*)($3)"; + } + } else { + # unnamed arg - or enum value + $argType = $arg if (!$isEnum); + $argName = $arg if ($isEnum); } $argId++; diff --git a/kalyptus/kalyptusCxxToDcopIDL.pm b/kalyptus/kalyptusCxxToDcopIDL.pm index 5ff17c0..3dd00fc 100644 --- a/kalyptus/kalyptusCxxToDcopIDL.pm +++ b/kalyptus/kalyptusCxxToDcopIDL.pm @@ -230,7 +230,7 @@ sub preParseClass my( $classNode ) = @_; my $className = join( "::", kdocAstUtil::heritage($classNode) ); - if( $#{$classNode->{Kids}} < 0 || + if( ($#{$classNode->{Kids}} < 0 && !$classNode->{DcopExported}) || $classNode->{Access} eq "private" || $classNode->{Access} eq "protected" || # e.g. TQPixmap::TQPixmapData exists $classNode->{Tmpl} || @@ -685,8 +685,14 @@ sub generateMethod($$$) $argType =~ s/^\s*(.*?)\s*$/$1/; $argType =~ s//>/g; + $argType =~ s/(\W)\s+/$1/g; + $argType =~ s/\s+(\W)/$1/g; + $argType =~ s/\b(signed|unsigned|long|short)$/$1 int/; - $args .= " $argType$arg->{ArgName}\n"; + $args .= " "; + $args .= "$argType"; + $args .= "$arg->{ArgName}" if $arg->{ArgName} !~ /^$/; + $args .= "\n"; push @argTypeList, $argType; @@ -703,6 +709,13 @@ sub generateMethod($$$) my $qual = ""; $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=\"&\"" if $r_isRef; + my $this = $classNode->{BindingDerives} > 0 ? "this" : "xthis"; # We iterate as many times as we have default params @@ -714,8 +727,12 @@ sub generateMethod($$$) $xretCode .= coerce_type('x[0]', 'xret', $returnType, 1); } $returnType = "void" unless $returnType; + $returnType =~ s/^\s*(.*?)\s*$/$1/; $returnType =~ s//>/g; + $returnType =~ s/(\W)\s+/$1/g; + $returnType =~ s/\s+(\W)/$1/g; + $returnType =~ s/\b(signed|unsigned|long|short)$/$1 int/; my $methodCode = ""; @@ -739,7 +756,7 @@ sub generateMethod($$$) $methodCode .= " $doc\n"; } - $methodCode .= " $returnType\n"; + $methodCode .= " $returnType\n"; $methodCode .= " $name\n"; $methodCode .= "$args"; $methodCode .= " \n"; diff --git a/kalyptus/kdocAstUtil.pm b/kalyptus/kdocAstUtil.pm index 8c24430..d7586b9 100644 --- a/kalyptus/kdocAstUtil.pm +++ b/kalyptus/kdocAstUtil.pm @@ -361,10 +361,12 @@ ANITER: if( !defined $ref ) { # ancestor undefined - warn "warning: ", $node->{astNodeName}, - " inherits unknown class '", + if( $in->{astNodeName} ne "DCOPObject" + && $in->{astNodeName} ne "TQObject" ) { + warn "warning: ", $node->{astNodeName}, + " inherits unknown class '", $in->{astNodeName},"'\n"; - + } $parent->AddPropList( 'InBy', $node ); } else { diff --git a/kalyptus/kdocParseDoc.pm b/kalyptus/kdocParseDoc.pm index f28b4e5..befa8c5 100644 --- a/kalyptus/kdocParseDoc.pm +++ b/kalyptus/kdocParseDoc.pm @@ -60,15 +60,15 @@ PARSELOOP: next if !defined $text; $text =~ s#^\s*\*(?!\/)##; + if ( $text =~ m#\*/# ) { + $finished = 1; + $text = $`; + } # if ( $text =~ /^\s*<\/pre>/i ) { # flushProp(); # $inbounded = 0; # } if( $inbounded ) { - if ( $text =~ m#\*/# ) { - $finished = 1; - $text = $`; - } $buffer .= $text; next PARSELOOP; } @@ -165,10 +165,6 @@ PARSELOOP: docProp( "LibDoc" ); } else { - if ( $text =~ m#\*/# ) { - $finished = 1; - $text = $`; - } $buffer .= $text; } }