[Kde-bindings] KDE/kdebindings/kalyptus
Richard Dale
rdale at foton.es
Fri May 16 16:57:58 UTC 2008
On Friday 16 May 2008 14:47:52 Arno Rehn wrote:
> SVN commit 808387 by arnorehn:
>
> * Fixed enums being marked as t_voidp if the containing
> classes weren't preparsed.
> * Added the kalyptus module for generating lists of classes.
>
> CCMAIL: kde-bindings at kde.org
>
>
>
> A kalyptusCxxToClasslist.pm
> M +21 -1 kalyptusCxxToSmoke.pm
>
>
> --- trunk/KDE/kdebindings/kalyptus/kalyptusCxxToSmoke.pm #808386:808387
> @@ -448,7 +448,8 @@
> return;
> }
> # return if the class is not in the current module or an ancestor of a
> class in the module - return if (defined($excludeClasses{$className}) &&
> !isAncestorOfModuleClass($className) && $className ne 'QMetaObject'); # &&
> $className ne 'Qt'); + return if (defined($excludeClasses{$className}) &&
> !isAncestorOfModuleClass($className) + && $className ne
> 'QMetaObject' && !defined($externClasses{$className})); # && $className ne
> 'Qt'); $externClasses{$className} = 1 if
> defined($excludeClasses{$className});
>
> my $signalCount = 0;
> @@ -1846,6 +1847,10 @@
> # For instance, if $type was Q_UINT16&, realType will be ushort
> $allTypes{$type}{realType} = applyTypeDef( $realType );
> $realType = $allTypes{$type}{realType};
> + if ($realType =~ /(.*)::/) {
> + my $c = $1;
> + $externClasses{$c} = 1 if defined($excludeClasses{$c});
> + }
> $externClasses{$realType} = 1 if defined($excludeClasses{$realType});
>
> # In the first phase we only create entries into allTypes.
> @@ -2247,6 +2252,8 @@
> }
> # First write the name
> print OUT "\t{ \"$type\", ";
> + my $retried;
> +retry:
> # Then write the classId (and find out the typeid at the same time)
> if(exists $classidx{$realType}) { # this one first, we want t_class for
> QBlah* $typeId = 't_class';
> @@ -2284,6 +2291,19 @@
> if ( $skippedClasses{$realType} ) {
> # print STDERR "$realType has been skipped, using t_voidp for it\n";
> } else {
> + # If we have an enum in a class that has not been preparsed
> + # because it is not needed in any other way, try to find the node
> + # and preparse it now. Then jump to the beginning and test again.
> + if(!$retried && $realType =~ /(.*)::/) {
> + $retried = 1;
> + my $c = $1;
> + my $cnode = kdocAstUtil::findRef( $rootnode, "$c" );
> + if ($cnode) {
> + preParseClass($cnode);
> + # ugly, but the easiest way without copying all the code again
> + goto retry;
> + }
> + }
> unless( $realType =~ /</ ) { # Don't warn for template stuff...
> print STDERR "$realType isn't a known type (type=$type)\n";
> }
I've been thinking about this and looking at the code too, and it is quite
tricky. I'm not sure if this test is quite right - won't it trap nested
classes as well as enums?
if(!$retried && $realType =~ /(.*)::/) {
I thought seemed like we need another pass after preprocessing the classes. In
the first pass we register all types on all classes, and remove this
condition:
return if (defined($excludeClasses{$className}) &&
!isAncestorOfModuleClass($className) && $className ne 'QMetaObject')
In the second pass, any types which are used by methods which are either in
the classes in the current module, or are in virtual methods from classes
outside the module that are inherited, are marked as 'used' in the registered
types table. Then we remove any types that aren't marked 'used' after the
second pass. But maybe your version will amount to the same.
-- Richard
More information about the Kde-bindings
mailing list