diff options
author | Timothy Pearson <[email protected]> | 2012-01-01 19:19:07 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-01-01 19:19:07 -0600 |
commit | cf5706eb5adbe5858d87118d200e233abfa1271f (patch) | |
tree | 9c4da2dc3e403f2cdfa2cf8d632098a12fdad2e4 /kalyptus/kalyptus | |
parent | 795a0355a40293affc7164507e918440d4a828d6 (diff) | |
download | libtqt-perl-cf5706eb5adbe5858d87118d200e233abfa1271f.tar.gz libtqt-perl-cf5706eb5adbe5858d87118d200e233abfa1271f.zip |
Update embedded kalyptus installation
Diffstat (limited to 'kalyptus/kalyptus')
-rw-r--r-- | kalyptus/kalyptus | 345 |
1 files changed, 268 insertions, 77 deletions
diff --git a/kalyptus/kalyptus b/kalyptus/kalyptus index 6cdc12d..15e7a27 100644 --- a/kalyptus/kalyptus +++ b/kalyptus/kalyptus @@ -1,8 +1,8 @@ -#!/usr/bin/perl -I/Users/duke/src/kde/kdebindings/kalyptus +#!/usr/bin/perl # KDOC -- C++ and CORBA IDL interface documentation tool. # Sirtaj Singh Kang <[email protected]>, Jan 1999. -# $Id: kalyptus,v 1.9 2003/08/31 15:35:11 germaingarand Exp $ +# $Id$ # All files in this project are distributed under the GNU General # Public License. This is Free Software. @@ -22,12 +22,12 @@ use kdocParseDoc; use vars qw/ %rootNodes $declNodeType @includes_list %options @formats_wanted $allow_k_dcop_accessors @includeclasses $includeclasses $skipInternal %defines $defines $match_qt_defines - $libdir $libname $outputdir @libs $parse_global_space $striphpath $doPrivate $readstdin - $Version $quiet $debug $debuggen $parseonly $currentfile $cSourceNode $exe + $libdir $libname $outputdir @libs $parse_global_space $qt_embedded $qt4 $striphpath $doPrivate $readstdin + $Version $tquiet $debug $debuggen $parseonly $currentfile $cSourceNode $exe %formats %flagnames @allowed_k_dcop_accesors $allowed_k_dcop_accesors_re $rootNode @classStack $cNode $globalSpaceClassName $lastLine $docNode @includes $cpp $defcppcmd $cppcmd $docincluded - $inExtern %stats %definitions @inputqueue @codeqobject /; + $inExtern $inNamespace %stats %definitions @inputqueue @codeqobject @qt4_codeqobject @qte_codeqobject /; ## globals @@ -52,7 +52,7 @@ $includeclasses = ""; $doPrivate = 0; $Version = "0.9"; -$quiet = 0; +$tquiet = 0; $debug = 0; $debuggen = 0; $parseonly = 0; @@ -82,11 +82,36 @@ public: private: CODE +@qt4_codeqobject = split "\n", <<CODE; +public: + static const TQMetaObject staticMetaObject; + virtual const TQMetaObject *metaObject() const; + virtual void *qt_metacast(const char *); + static inline TQString tr(const char *s, const char *c = 0) + { return staticMetaObject.tr(s, c); } + virtual int qt_metacall(TQMetaObject::Call, int, void **); +private: +CODE + +@qte_codeqobject = split "\n", <<CODE; +public: + TQMetaObject *metaObject() const { + return staticMetaObject(); + } + const char *className() const; + static TQMetaObject* staticMetaObject(); + static TQString tr( const char *, const char * = 0 ); +protected: + void initMetaObject(); +private: +CODE + # Supported formats -%formats = ( "java" => "kalyptusCxxToJava", "c" => "kalyptusCxxToC", - "objc" => "kalyptusCxxToObjc", "dcopidl" => "kalyptusCxxToDcopIDL", - "smoke" => "kalyptusCxxToSmoke", "csharp" => "kalyptusCxxToCSharp", - "ECMA" => "kalyptusCxxToECMA", "swig" => "kalyptusCxxToSwig" ); +%formats = ( "java" => "kalyptusCxxToJava", "jni" => "kalyptusCxxToJNI", + "dcopidl" => "kalyptusCxxToDcopIDL", + "smoke" => "kalyptusCxxToSmoke", "csharp" => "kalyptusCxxToCSharp", "kimono" => "kalyptusCxxToKimono", + "ECMA" => "kalyptusCxxToECMA", "swig" => "kalyptusCxxToSwig", + "KDOMECMA" => "kalyptusKDOMEcma"); # these are for expansion of method flags %flagnames = ( v => 'virtual', 's' => 'static', p => 'pure', @@ -104,22 +129,23 @@ $allowed_k_dcop_accesors_re = join("|", @allowed_k_dcop_accesors); _STYLE_PLATINUM => '', _STYLE_SGI => '', _STYLE_WINDOWS => '', - TQT_STATIC_CONST => 'static const', - TTQ_EXPORT => '', - TTQ_REFCOUNT => '', + QT_STATIC_CONST => 'static const', + Q_EXPORT => '', + Q_EXPORT_CODECS_BIG5 => '', + Q_REFCOUNT => '', TQM_EXPORT_CANVAS => '', TQM_EXPORT_DNS => '', TQM_EXPORT_ICONVIEW => '', TQM_EXPORT_NETWORK => '', TQM_EXPORT_SQL => '', TQM_EXPORT_WORKSPACE => '', - TQT_NO_REMOTE => 'TQT_NO_REMOTE', - TQT_ACCESSIBILITY_SUPPORT => 'TQT_ACCESSIBILITY_SUPPORT', - TTQ_WS_X11 => 'TTQ_WS_X11', - TTQ_DISABLE_COPY => 'TTQ_DISABLE_COPY', - TTQ_WS_TQWS => 'undef', - TTQ_WS_MAC => 'undef', - TTQ_OBJECT => <<'CODE', + QT_NO_REMOTE => 'QT_NO_REMOTE', + QT_ACCESSIBILITY_SUPPORT => 'QT_ACCESSIBILITY_SUPPORT', + Q_WS_X11 => 'Q_WS_X11', + Q_DISABLE_COPY => 'Q_DISABLE_COPY', + Q_WS_QWS => 'undef', + Q_WS_MAC => 'undef', + Q_OBJECT => <<'CODE', public: virtual TQMetaObject *metaObject() const; virtual const char *className() const; @@ -164,6 +190,8 @@ GetOptions( \%options, "xref|l=s", \@libs, "classes|c=s", \@includeclasses, "globspace", \$parse_global_space, + "qte", \$qt_embedded, + "qt4", \$qt4, "allow_k_dcop_accessors", \$allow_k_dcop_accessors, "cpp|P", \$cpp, @@ -173,7 +201,7 @@ GetOptions( \%options, "define=s", \%defines, # define a single preprocessing symbol "defines=s", \$defines, # file containing preprocessing symbols, one per line - "quiet|q", \$quiet, + "tquiet|q", \$tquiet, "debug|D", \$debug, # debug the parsing "debuggen", \$debuggen, # debug the file generation "parse-only", \$parseonly ) @@ -193,7 +221,7 @@ else { if ($#includeclasses>=0) { $includeclasses = join (" ", @includeclasses); - print "Using Classes: $includeclasses\n" unless $quiet; + print "Using Classes: $includeclasses\n" unless $tquiet; } if ( $#includes >= 0 && !$cpp ) { @@ -222,13 +250,13 @@ if( $defines ) } } -# Check the %defines hash for TQT_* symbols and compile the corresponding RE +# Check the %defines hash for QT_* symbols and compile the corresponding RE # Otherwise, compile the default ones. Used for filtering in readCxxLine. -if ( my @qt_defines = map { ($_=~m/^TQT_(.*)/)[0] } keys %defines) +if ( my @qt_defines = map { ($_=~m/^QT_(.*)/)[0] } keys %defines) { - my $regexp = "m/^#\\s*ifn?def\\s+TQT_(?:" . join('|', map { "\$qt_defines[$_]" } 0..$#qt_defines).")/o"; + my $regexp = "m/^#\\s*ifn?def\\s+QT_(?:" . join('|', map { "\$qt_defines[$_]" } 0..$#qt_defines).")/o"; $match_qt_defines = eval "sub { my \$s=shift; - \$s=~/^#\\s*if(n)?def/ || return 0; + \$s=~/^#\\s*if(n)?def\\s+QT_/ || return 0; if(!\$1) { return \$s=~$regexp ? 0:1 } else { return \$s=~$regexp ? 1:0 } }"; @@ -236,18 +264,18 @@ if ( my @qt_defines = map { ($_=~m/^TQT_(.*)/)[0] } keys %defines) } else { - $match_qt_defines = eval q� + $match_qt_defines = eval q{ sub { my $s = shift; - $s =~ m/^\#\s*ifndef\s+TQT_NO_(?:REMOTE| # not in the default compile options + $s =~ m/^\#\s*ifndef\s+QT_NO_(?:REMOTE| # not in the default compile options NIS| # ... XINERAMA| IMAGEIO_(?:MNG|JPEG)| STYLE_(?:MAC|INTERLACE|COMPACT) )/x; } - �; + }; die if $@; } # Check if there any files to process. @@ -302,7 +330,7 @@ sub readLibraries require kdocLib; foreach my $lib ( @libs ) { - print "$exe: reading lib: $lib\n" unless $quiet; + print "$exe: reading lib: $lib\n" unless $tquiet; my $relpath = exists $options{url} ? $options{url} : $outputdir; @@ -334,11 +362,11 @@ sub parseFiles || croak "Can't preprocess $currentfile"; } else { - open( INPUT, "$currentfile" ) + open( INPUT, "tqt-replace-stream $currentfile |" ) || croak "Can't read from $currentfile"; } - print STDERR "$exe: processing $currentfile\n" unless $quiet; + print STDERR "$exe: processing $currentfile\n" unless $tquiet; # reset vars $rootNode = getRoot( $lang ); @@ -356,6 +384,7 @@ sub parseFiles @classStack = (); $cNode = $rootNode; $inExtern = 0; + $inNamespace = 0; # parse my $k = undef; @@ -386,7 +415,7 @@ sub writeDocumentation require $pack.".pm"; print STDERR "Generating bindings for $format ", - "language...\n" unless $quiet; + "language...\n" unless $tquiet; my $f = "$pack\::writeDoc"; &$f( $libname, $node, $outputdir, \%options ); @@ -425,7 +454,7 @@ sub readSourceLine =head2 readCxxLine Reads a C++ source line, skipping comments, blank lines, - preprocessor tokens and the TTQ_OBJECT macro + preprocessor tokens and the Q_OBJECT macro =cut @@ -453,12 +482,31 @@ LOOP: } } - if ( $p =~ /^\s*TTQ_OBJECT/ ) { - push @inputqueue, @codeqobject; + if ( $p =~ /^\s*Q_OBJECT/ ) { + if ($qt_embedded) { + push @inputqueue, @qte_codeqobject; + } elsif ($qt4) { + push @inputqueue, @qt4_codeqobject; + } else { + push @inputqueue, @codeqobject; + } next; } # Hack, waiting for real handling of preprocessor defines - $p =~ s/TQT_STATIC_CONST/static const/; + $p =~ s/QT_MODULE\(\w+\)//; + $p =~ s/QT_STATIC_CONST/static const/; + $p =~ s/QT_WEAK_SYMBOL//; + $p =~ s/QT_MOC_COMPAT//; + $p =~ s/Q_EXPORT_CODECS_BIG5//; + $p =~ s/QT_COMPAT / /; + $p =~ s/Q_DISABLE_COPY\((\w+)\)/$1(const $1 &);\n$1 &operator=(const $1 &);/; + $p =~ s/TQWIDGETSIZE_MAX/32767/; # Qt/E uses this #define as an enum value - yuck! + $p =~ s/Q_SIGNALS/signals/; + $p =~ s/ASYNC/void/; + $p =~ s/[A-Z_]*_EXPORT_DEPRECATED//; + $p =~ s/[A-Z_]*_EXPORT\s/ /; + $p =~ s/EXPORT_DOCKCLASS//; + $p =~ s/DLL_IMP_EXP_KMDICLASS//; $p =~ s/KSVG_GET/KJS::Value get();/; $p =~ s/KSVG_BASECLASS_GET/KJS::Value get();/; $p =~ s/KSVG_BRIDGE/KJS::ObjectImp *bridge();/; @@ -469,20 +517,44 @@ LOOP: if ( $p =~ m/KSVG_DEFINE_PROTOTYPE\((\w+)\)/ ) { push @inputqueue, split('\n',"namespace KSVG {\nclass $1 {\n};\n};"); } + # Bother the same again for KDOM :/ + $p =~ s/KDOM_GET/KJS::Value get();/; + $p =~ s/KDOM_BASECLASS_GET/KJS::Value get();/; + $p =~ s/KDOM_FORWARDGET/KJS::Value getforward();/; + $p =~ s/KDOM_PUT/bool put();/; + $p =~ s/KDOM_FORWARDPUT/bool putforward();/; + $p =~ s/KDOM_BASECLASS/virtual KJS::Value cache();/; + $p =~ s/KDOM_CAST/KJS::Value cast();/; + if ( $p =~ m/KDOM_DEFINE_PROTOTYPE\((\w+)\)/ ) { + push @inputqueue, split('\n',"namespace KDOM {\nclass $1 {\n};\n};"); + } + next if ( $p =~ /^\s*$/s ); # blank lines -# || $p =~ /^\s*TTQ_OBJECT/ # TQObject macro +# || $p =~ /^\s*Q_OBJECT/ # TQObject macro # ); # - next if ( $p =~ /^\s*TTQ_ENUMS/ # ignore TTQ_ENUMS - || $p =~ /^\s*TTQ_PROPERTY/ # and TTQ_PROPERTY - || $p =~ /^\s*TTQ_OVERRIDE/ # and TTQ_OVERRIDE - || $p =~ /^\s*TTQ_SETS/ - || $p =~ /^\s*TTQ_DUMMY_COMPARISON_OPERATOR/ + next if ( $p =~ /^\s*Q_ENUMS/ # ignore Q_ENUMS + || $p =~ /^\s*TQ_OBJECT/ # and TQ_OBJECT + || $p =~ /^\s*Q_FLAGS/ # and Q_FLAGS + || $p =~ /^\s*Q_DECLARE_FLAGS/ # and Q_DECLARE_FLAGS + || ( !$qt4 && $p =~ /^\s*Q_PROPERTY/ ) # and Q_PROPERTY + || $p =~ /^\s*TQDOC_PROPERTY/ + || $p =~ /^\s*Q_GADGET/ + || $p =~ /^\s*Q_OVERRIDE/ # and Q_OVERRIDE + || $p =~ /^\s*Q_SETS/ + || $p =~ /^\s*Q_DUMMY_COMPARISON_OPERATOR/ || $p =~ /^\s*K_SYCOCATYPE/ # and K_SYCOCA stuff || $p =~ /^\s*K_SYCOCAFACTORY/ # || $p =~ /^\s*KSVG_/ # and KSVG stuff ;) + || $p =~ /^\s*KDOM_/ # and KDOM stuff :( + || $p =~ /^\s*Q_DECLARE_FLAGS/ + || $p =~ /^\s*Q_DECLARE_OPERATORS_FOR_FLAGS/ + || $p =~ /^\s*Q_DECLARE_PRIVATE/ + || $p =~ /^\s*Q_DECLARE_TYPEINFO/ + || $p =~ /^\s*Q_PRIVATE_SLOT/ + || $p =~ /^\s*Q_DECLARE_SHARED/ ); push @includes_list, $1 if $p =~ /^#include\s+<?(.*?)>?\s*$/; @@ -503,14 +575,31 @@ LOOP: else { # Skip platform-specific stuff, or #if 0 stuff # or #else of something we parsed (e.g. for TQKeySequence) - if ( $p =~ m/^#\s*ifdef\s*TTQ_WS_/ or - $p =~ m/^#\s*if\s+defined\(TTQ_WS_/ or - $p =~ m/^#\s*if\s+defined\(TTQ_OS_/ or - $p =~ m/^#\s*if\s+defined\(TTQ_CC_/ or - $p =~ m/^#\s*if\s+defined\(TQT_THREAD_SUPPORT/ or + if ( $p =~ m/^#\s*ifdef\s*Q_WS_/ or + $p =~ m/^#\s*if\s+defined\(Q_WS_/ or + ($p =~ m/^#\s*ifdef\s+_WS_QWS_/ and $qt_embedded) or + ($p =~ m/^#\s*ifndef\s+QT_NO_MIMECLIPBOARD/ and $qt_embedded) or + ($p =~ m/^#\s*if\s+defined\(_WS_X11_/ and $qt_embedded) or + ($p =~ m/^#\s*if\s+defined\(Q_WS_X11_/ and $qt_embedded) or + ($p =~ m/^#\s*if\s+defined\(Q_WS_WIN_/ and $qt_embedded) or + ($p =~ m/^#\s*if\s+defined\(_WS_MAC_/ and $qt_embedded) or + ($p =~ m/^#\s*if\s+defined\(Q_INCOMPATIBLE_3_0_ADDONS/ and $qt_embedded) or + $p =~ m/^#\s*ifndef\s+QT_NO_STL/ or + $p =~ m/^#\s*if\s+defined\s*\(Q_OS_/ or + $p =~ m/^#\s*if\s+defined\(Q_CC_/ or + $p =~ m/^#\s*if\s+defined\(QT_THREAD_SUPPORT/ or $p =~ m/^#\s*else/ or - $p =~ m/^#\s*if\s+defined\(TTQ_FULL_TEMPLATE_INSTANTIATION/ or + $p =~ m/^#\s*if\s+defined\(Q_FULL_TEMPLATE_INSTANTIATION/ or + $p =~ m/^#\s*ifdef\s+QT_WORKSPACE_WINDOWMODE/ or + $p =~ m/^#\s*ifdef\s+QT_COMPAT/ or + $p =~ m/^#\s*if\s+defined\s*\(?QT_COMPAT/ or $p =~ m/^#\s*ifdef\s+CONTAINER_CUSTOM_WIDGETS/ or + $p =~ m/^#\s*ifdef\s+QT3_SUPPORT/ or + $p =~ m/^#\s*ifdef\s+Q_MOC_RUN/ or + $p =~ m/^#\s*if\s+defined\s*\(QT3_SUPPORT/ or + $p =~ m/^#\s*if\s+defined\s*\(qdoc/ or + $p =~ m/^#\s*ifndef\s+QT_NO_MEMBER_TEMPLATES/ or + $p =~ m/^#if\s*!defined\(Q_NO_USING_KEYWORD\)/ or &$match_qt_defines( $p ) or $p =~ m/^#\s*if\s+0\s+/ ) { my $if_depth = 1; @@ -519,7 +608,7 @@ LOOP: last if !defined $p; $if_depth++ if $p =~ m/^#\s*if/; $if_depth-- if $p =~ m/^#\s*endif/; - # Exit at #else in the #ifdef TQT_NO_ACCEL/#else/#endif case + # Exit at #else in the #ifdef QT_NO_ACCEL/#else/#endif case last if $if_depth == 1 && $p =~ m/^#\s*else\s/; #ignore elif for now print "Skipping ifdef'ed line: $p" if $debug; @@ -638,6 +727,9 @@ sub readDecl $declNodeType = "c"; return $l; } + elsif ( $l =~ /Q_PROPERTY/ ) { # property + return $l; + } do { $decl .= $l; @@ -694,7 +786,11 @@ sub identifyDecl my $newNode = undef; my $skipBlock = 0; - + my $isDeprecated = 0; + + if ( $decl =~ s/KDE_DEPRECATED// ) { + $isDeprecated = 1; + } # Doc comment if ( $declNodeType eq "c" ) { $docNode = kdocParseDoc::newDocComment( $decl ); @@ -713,7 +809,12 @@ sub identifyDecl elsif ( $declNodeType eq "k" ) { $cNode->AddProp( "DcopExported", 1 ); } + # properties + elsif ( $decl =~ s/Q_PROPERTY// ) { + print "Property: <$1>\n" if $debug; + $newNode = newProperty( $decl ); + } # Typedef struct/class elsif ( $decl =~ /^\s*typedef \s+(struct|union|class|enum) @@ -737,8 +838,8 @@ sub identifyDecl # Typedef elsif ( $decl =~ /^\s*typedef\s+ (?:typename\s+)? # `typename' keyword - (.*?\s*[\*&]?) # type - \s+([-\w_\:]+) # name + (.*?\s*[\*&>]?) # type + \s*([-\w_\:]+) # name \s*((?:\[[-\w_\:<>\s]*\])*) # array \s*[{;]\s*$/xs ) { @@ -758,15 +859,16 @@ sub identifyDecl # Class/Struct elsif ( $decl =~ /^\s*((?:template\s*<.*>)?) # 1 template \s*(class|struct|union|namespace) # 2 struct type + (?:\s*TQ[A-Z_]*EXPORT[A-Z_]*)? (?:\s*Q[A-Z_]*EXPORT[A-Z_]*)? - (?:\s*TTQ_PACKED)? - (?:\s*TTQ_REFCOUNT)? + (?:\s*Q_PACKED)? + (?:\s*Q_REFCOUNT)? \s+([\w_]+ # 3 name (?:<[\w_ :,]+?>)? # maybe explicit template # (eat chars between <> non-hungry) (?:::[\w_]+)* # maybe nested ) - (.*?) # 4 inheritance + ([^\(]*?) # 4 inheritance ([;{])/xs ) { # 5 rest print "Class: [$1]\n\t[$2]\n\t[$3]\n\t[$4]\n\t[$5]\n" if $debug; @@ -781,7 +883,14 @@ sub identifyDecl } } - + if ($ntype eq 'namespace') { + if ($decl =~ /}/) { + return 0; + } + # Set a flag to indicate we're in a multi-line namespace declaration + $inNamespace = 1; + } + my @inherits = (); $tmpl =~ s/<(.*)>/$1/ if $tmpl ne ""; @@ -793,7 +902,15 @@ sub identifyDecl } $newNode = newClass( $tmpl, $ntype, - $name, $endtag, @inherits ); + $name, $endtag, $isDeprecated, @inherits ); + + if ($decl =~ /};/) { + # If the declaration was all on one line ending with a '};', + # then pop the new node + $cNode = pop @classStack; + print "end decl: popped $cNode->{astNodeName}\n" + if $debug; + } } # IDL compound node elsif( $decl =~ /^\s*(module|interface|exception) # struct type @@ -819,9 +936,10 @@ sub identifyDecl $newNode = newIDLstruct( $type, $name, $fwd, $complete, @in ); } # Method - elsif ( $decl =~ /^\s*([^=]+?(?:operator\s*(?:\(\)|.?=)\s*)?) # ret+nm + elsif ( $decl =~ /^\s*(?:(?:class|struct)\s*)?([^=]+?(?:operator\s*(?:\(\)|.?=)\s*)?) # ret+nm \( (.*?) \) # parameters \s*((?:const)?)\s* + (?:throw\s*\(.*?\))? \s*((?:=\s*0(?:L?))?)\s* # Pureness. is "0L" allowed? \s*[;{]+/xs ) { # rest @@ -836,16 +954,17 @@ sub identifyDecl my $const = $3 eq "" ? 0 : 1; my $pure = $4 eq "" ? 0 : 1; $tpn =~ s/\s+/ /g; + $tpn =~ s/operator\s+([^\w])/operator$1/g; $params =~ s/\s+/ /g; print "Method: R+N:[$tpn]\n\tP:[$params]\n\t[$const]\n" if $debug; if ( $tpn =~ /((?:\w+\s*::\s*)?operator.*?)\s*$/ # operator - || $tpn =~ /((?:\w*\s*::\s*~?)?[-\w:]+)\s*$/ ) { # normal + || $tpn =~ /((?:\w*\s*::\s*~?)?[-\w:]+)\s*$/ ) { # normal my $name = $1; $tpn = $`; $newNode = newMethod( $tpn, $name, - $params, $const, $pure ); + $params, $const, $pure, $isDeprecated ); } $skipBlock = 1; # FIXME check end token before doing this! @@ -877,8 +996,10 @@ sub identifyDecl my $val = $4; my $end = $5; - if ( $type !~ /^friend\s+class\s*/ ) { - print "Var: [$name] type: [$type$arr] val: [$val]\n" + $type =~ s/\s+/ /g; + + if ( $type !~ /^friend\s+class\s*/ && $type.$name ne "struct" ) { + print "Var: [$name] type: [$type$arr] val: [$val]\n" if $debug; $newNode = newVar( $type.$arr, $name, $val ); @@ -931,12 +1052,11 @@ sub identifyDecl $skipBlock = 1 if $end eq '{'; } # end of an "extern" block - elsif ( $decl =~ /^\s*}\s*$/ ) { + elsif ( $decl =~ /^\s*}\s*$/ && $inExtern ) { $inExtern = 0; } # end of an in-block declaration - elsif ( $decl =~ /^\s*}\s*(.*?)\s*;\s*$/ ) { - + elsif ( $decl =~ /^\s*}\s*(.*?)\s*;\s*$/ || ($decl =~ /^\s*}\s*$/ && $inNamespace) ) { if ( $cNode->{astNodeName} eq "--" ) { # structure typedefs should have no name preassigned. # If they do, then the name in @@ -950,6 +1070,11 @@ sub identifyDecl $siblings->{ $1 } = $cNode; } + # C++ namespaces end with a '}', and not '};' like classes + if ($decl =~ /^\s*}\s*$/ ) { + $inNamespace = 0; + } + if ( $#classStack < 0 ) { confess "close decl found, but no class in stack!" ; $cNode = $rootNode; @@ -966,9 +1091,13 @@ sub identifyDecl $skipBlock = 1; } # explicit template instantiation, or friend template - elsif ( $decl =~ /(template|friend)\s+class\s+(?:Q[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) { + elsif ( $decl =~ /(template|friend)\s+class\s+(?:TQ[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) { # Nothing to be done with those. } + # explicit template instantiation, or friend template + elsif ( $decl =~ /(template|friend)\s+class\s+(?:Q[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) { + # Nothing to be done with those (same as above, but for QT not TQT). + } else { ## decl is unidentified. @@ -1060,13 +1189,15 @@ sub initEnum ($name = $end) if $name eq "" && $end ne ""; $params =~ s#\s+# #sg; # no newlines + $params =~ s#\s*/\*([^\*]/|\*[^/]|[^\*/])*\*/##g; # strip out comments $params = $1 if $params =~ /^\s*{?(.*)}/; + $params =~ s/,\s*$/ /; print "$name params: [$params]\n" if $debug; - my ( $node ) = Ast::New( $name ); $node->AddProp( "NodeType", "enum" ); $node->AddProp( "Params", $params ); + $node->AddProp( "Source", $cSourceNode ); makeParamList( $node, $params, 1 ); # Adds the ParamList property containing the list of param nodes kdocAstUtil::attachChild( $cNode, $node ); @@ -1125,7 +1256,7 @@ sub newIDLstruct =head2 newClass - Parameters: tmplArgs, cNodeType, name, endTag, @inheritlist + Parameters: tmplArgs, cNodeType, name, endTag, isDeprecated, @inheritlist Handles a class declaration (also fwd decls). @@ -1133,7 +1264,7 @@ sub newIDLstruct sub newClass { - my( $tmplArgs, $cNodeType, $name, $endTag ) = @_; + my( $tmplArgs, $cNodeType, $name, $endTag, $isDeprecated ) = @_; my $access = "private"; $access = "public" if $cNodeType ne "class"; @@ -1150,6 +1281,8 @@ sub newClass $node->AddProp( "KidAccess", $access ); kdocAstUtil::attachChild( $cNode, $node ); } + # Discard any doc comment against a forward decl + undef $docNode; return $node; } @@ -1160,17 +1293,23 @@ sub newClass $node->AddProp( "NodeType", $cNodeType ); $node->AddProp( "Compound", 1 ); $node->AddProp( "Source", $cSourceNode ); + + if ($cNodeType eq 'namespace') { + $node->AddPropList( "Sources", $cSourceNode ); + } $node->AddProp( "KidAccess", $access ); $node->AddProp( "Tmpl", $tmplArgs ) unless $tmplArgs eq ""; + $node->AddProp( "Deprecated", $isDeprecated ); + if ( !defined $oldnode ) { kdocAstUtil::attachChild( $cNode, $node ); } # inheritance - foreach my $ances ( splice (@_, 4) ) { + foreach my $ances ( splice (@_, 5) ) { my $type = ""; my $name = $ances; my $intmpl = undef; @@ -1323,7 +1462,7 @@ sub newTypedefComp =head2 newMethod - Parameters: retType, name, params, const, pure? + Parameters: retType, name, params, const, pure?, deprecated? Handles a new method declaration or definition. @@ -1334,7 +1473,7 @@ my $theSourceNode = $cSourceNode; sub newMethod { - my ( $retType, $name, $params, $const, $pure ) = @_; + my ( $retType, $name, $params, $const, $pure, $deprecated ) = @_; my $parent = $cNode; my $class; @@ -1405,9 +1544,12 @@ sub newMethod $opsNode->AddProp( "KidAccess", "public" ); kdocAstUtil::attachChild( $cNode, $opsNode ); } + # Add a special 'Source' property for methods in global space + $cNode->AddProp( "Source", $theSourceNode ); + unless( $theSourceNode == $cSourceNode ) { $theSourceNode = $cSourceNode; - $opsNode->AddPropList( "Sources", $theSourceNode ); # sources are scattered across TQt + $opsNode->AddPropList( "Sources", $theSourceNode ); # sources are scattered across Qt } $parent = $opsNode; } @@ -1434,6 +1576,11 @@ sub newMethod $retType =~ s/virtual//g; } + if( $retType =~ /explicit\s*/ ) { + $flags .= "t"; + $retType =~ s/explicit\s*//g; + } + print "\n" if $flags ne "" && $debug; if ( !defined $parent->{KidAccess} ) { @@ -1458,11 +1605,14 @@ sub newMethod $flags .= "n"; } + $retType =~ s/TQM?_EXPORT[_A-Z]*\s*//; $retType =~ s/QM?_EXPORT[_A-Z]*\s*//; $retType =~ s/inline\s+//; $retType =~ s/extern\s+//; $retType =~ s/^\s*//g; $retType =~ s/\s*$//g; + $retType =~ s/^class\s/ /; # Remove redundant class forward decln's + $retType =~ s/<class\s/</; # node @@ -1472,10 +1622,13 @@ sub newMethod $node->AddProp( "ReturnType", $retType ); $node->AddProp( "Params", $params ); # The raw string with the whole param list makeParamList( $node, $params, 0 ); # Adds the ParamList property containing the list of param nodes + + $node->AddProp( "Deprecated", $deprecated ); $parent->AddProp( "Pure", 1 ) if $pure; kdocAstUtil::attachChild( $parent, $node ); + return $node; } @@ -1505,7 +1658,8 @@ sub makeParamList($$$) { my ( $methodNode, $params, $isEnum ) = @_; $params =~ s/\s+/ /g; # normalize multiple spaces/tabs into a single one - $params =~ s/\s*([,\*\&])\s*/$1 /g; # normalize spaces before and after *, & and ',' + $params =~ s/\s*([\*\&])\s*/$1 /g; # normalize spaces before and after *, & + $params =~ s/\s*(,)([^'\s])\s*/$1 $2/g; # And after ',', but not if inside single quotes $params =~ s/^\s*void\s*$//; # foo(void) ==> foo() $params =~ s/^\s*$//; # Make sure the property always exists, makes iteration over it easier @@ -1520,12 +1674,19 @@ sub makeParamList($$$) my $defaultparam; $arg =~ s/\s*([^\s].*[^\s])\s*/$1/; # stripWhiteSpace $arg =~ s/(\w+)\[\]/\* $1/; # Turn [] array into * + $arg =~ s/^class //; # Remove any redundant 'class' forward decln's - # The RE below reads as: = ( string constant or char + # The RE below reads as: = ( string constant or char or cast to numeric literal # or some word/number, with optional bitwise shifts, OR'ed or +'ed flags, and/or function call ). - if ( $arg =~ s/\s*=\s*(("[^\"]*")|(\'.\')|(([-\w:~]*)\s*([<>\|\+-]*\s*\w*\s*)*(\([^(]*\))?))// ) { + if ( $arg =~ s/\s*=\s*(("[^\"]*")|\([^)]*\)\s*[\+-]?\s*[0-9]+|(\'.\')|(([-\w:~]*)\s*([<>\|\+-]*\s*[\w:._]*\s*)*(\([^(]*\))?))// ) { $defaultparam = $1; } + + if (defined $defaultparam && $isEnum) { + # Remove any casts in enum values, for example this in kfileitem.h: + # 'enum { Unknown = (mode_t) - 1 };' + $defaultparam =~ s/\([^\)]+\)(.*[0-9].*)/$1/; + } # Separate arg type from arg name, if the latter is specified if ( $arg =~ /(.*)\s+([\w_]+)\s*$/ || $arg =~ /(.*)\(\s*\*\s([\w_]+)\)\s*\((.*)\)\s*$/ ) { @@ -1611,6 +1772,36 @@ sub newVar return $node; } +=head2 newProperty + + Parameters: property + + Handles a property + +=cut + +sub newProperty +{ + my ( $property ) = @_; + + $property =~ s/^\s+|\s+$//g; + my @items = split(/ /,$property); + + do { + my ( $node ) = Ast::New( $items[1] ); + + $node->AddProp( "NodeType", "property" ); + $node->AddProp( "type", $items[0] ); + $node->AddProp( "READ", $items[3] ); + $node->AddProp( "WRITE", $items[5] ); + $node->AddProp( "NOTIFY", $items[7] ); + + $cNode->{KidAccess} = "public"; + kdocAstUtil::attachChild( $cNode, $node ); + return $node; + + } if defined $items[1]; +} =head2 show_usage |