Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # | 1 # |
| 2 # KDOM IDL parser | 2 # KDOM IDL parser |
| 3 # | 3 # |
| 4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org> | 4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org> |
| 5 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 5 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 6 # | 6 # |
| 7 # This file is part of the KDE project | 7 # This file is part of the KDE project |
| 8 # | 8 # |
| 9 # This library is free software; you can redistribute it and/or | 9 # This library is free software; you can redistribute it and/or |
| 10 # modify it under the terms of the GNU Library General Public | 10 # modify it under the terms of the GNU Library General Public |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 $codeGenerator->GenerateModule($useDocument, $defines); | 108 $codeGenerator->GenerateModule($useDocument, $defines); |
| 109 | 109 |
| 110 my $classes = $useDocument->classes; | 110 my $classes = $useDocument->classes; |
| 111 foreach my $class (@$classes) { | 111 foreach my $class (@$classes) { |
| 112 print "Generating $useGenerator bindings code for IDL interface \"" . $c lass->name . "\"...\n" if $verbose; | 112 print "Generating $useGenerator bindings code for IDL interface \"" . $c lass->name . "\"...\n" if $verbose; |
| 113 $codeGenerator->GenerateInterface($class, $defines); | 113 $codeGenerator->GenerateInterface($class, $defines); |
| 114 $codeGenerator->finish(); | 114 $codeGenerator->finish(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 | |
| 119 sub FindParentsRecursively | |
| 120 { | |
| 121 my $object = shift; | |
| 122 my $dataNode = shift; | |
| 123 my @parents = ($dataNode->name); | |
| 124 foreach (@{$dataNode->parents}) { | |
| 125 my $interface = $object->StripModule($_); | |
| 126 | |
| 127 $endCondition = 0; | |
| 128 $foundFilename = ""; | |
| 129 foreach (@{$useDirectories}) { | |
| 130 $object->ScanDirectory("$interface.idl", $_, $_, 0) if ($foundFilename eq ""); | |
| 131 } | |
| 132 | |
| 133 if ($foundFilename ne "") { | |
| 134 print " | |> Parsing parent IDL \"$foundFilename\" for interface \"$int erface\"\n" if $verbose; | |
| 135 | |
| 136 # Step #2: Parse the found IDL file (in quiet mode). | |
| 137 my $parser = IDLParser->new(1); | |
| 138 my $document = $parser->ParseInheritance($foundFilename, $defines, $prepro cessor); | |
| 139 | |
| 140 foreach my $class (@{$document->classes}) { | |
| 141 @parents = (@parents, FindParentsRecursively($object, $class)); | |
| 142 } | |
| 143 } else { | |
| 144 die("Could NOT find specified parent interface \"$interface\"!\n") | |
| 145 } | |
| 146 } | |
| 147 return @parents; | |
| 148 } | |
| 149 | |
| 150 | |
| 118 sub AddMethodsConstantsAndAttributesFromParentClasses | 151 sub AddMethodsConstantsAndAttributesFromParentClasses |
| 119 { | 152 { |
| 120 # For the passed interface, recursively parse all parent | 153 # For the passed interface, recursively parse all parent |
| 121 # IDLs in order to find out all inherited properties/methods. | 154 # IDLs in order to find out all inherited properties/methods. |
| 122 | 155 |
| 123 my $object = shift; | 156 my $object = shift; |
| 124 my $dataNode = shift; | 157 my $dataNode = shift; |
| 125 | 158 |
| 126 my @parents = @{$dataNode->parents}; | 159 my @parents = @{$dataNode->parents}; |
| 127 my $parentsMax = @{$dataNode->parents}; | 160 my $parentsMax = @{$dataNode->parents}; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 # Internal Helper | 274 # Internal Helper |
| 242 sub ScanDirectory | 275 sub ScanDirectory |
| 243 { | 276 { |
| 244 my $object = shift; | 277 my $object = shift; |
| 245 | 278 |
| 246 my $interface = shift; | 279 my $interface = shift; |
| 247 my $directory = shift; | 280 my $directory = shift; |
| 248 my $useDirectory = shift; | 281 my $useDirectory = shift; |
| 249 my $reportAllFiles = shift; | 282 my $reportAllFiles = shift; |
| 250 | 283 |
| 284 print "Scanning interface " . $interface . " in " . $directory . "\n" if $ve rbose; | |
|
Mike Belshe
2008/09/23 00:36:13
Do we want this print statement? Or is this for d
Feng Qian
2008/09/23 21:46:04
For debugging purpose, the condition variable $ver
| |
| 285 | |
| 251 return if ($endCondition eq 1) and ($reportAllFiles eq 0); | 286 return if ($endCondition eq 1) and ($reportAllFiles eq 0); |
| 252 | 287 |
| 253 my $sourceRoot = $ENV{SOURCE_ROOT}; | 288 my $sourceRoot = $ENV{SOURCE_ROOT}; |
| 254 my $thisDir = $sourceRoot ? "$sourceRoot/$directory" : $directory; | 289 my $thisDir = $sourceRoot ? "$sourceRoot/$directory" : $directory; |
| 255 | 290 |
| 256 opendir(DIR, $thisDir) or die "[ERROR] Can't open directory $thisDir: \"$!\" \n"; | 291 opendir(DIR, $thisDir) or die "[ERROR] Can't open directory $thisDir: \"$!\" \n"; |
| 257 | 292 |
| 258 my @names = readdir(DIR) or die "[ERROR] Cant't read directory $thisDir \"$! \"\n"; | 293 my @names = readdir(DIR) or die "[ERROR] Cant't read directory $thisDir \"$! \"\n"; |
| 259 closedir(DIR); | 294 closedir(DIR); |
| 260 | 295 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 279 if ($reportAllFiles eq 0) { | 314 if ($reportAllFiles eq 0) { |
| 280 $endCondition = 1; | 315 $endCondition = 1; |
| 281 } else { | 316 } else { |
| 282 push(@foundFilenames, $foundFilename); | 317 push(@foundFilenames, $foundFilename); |
| 283 } | 318 } |
| 284 } | 319 } |
| 285 } | 320 } |
| 286 } | 321 } |
| 287 | 322 |
| 288 1; | 323 1; |
| OLD | NEW |