| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/perl -w | |
| 2 | |
| 3 # Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved. | |
| 4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org> | |
| 5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmob
ile.com/) | |
| 6 # Copyright (C) 2011 Ericsson AB. All rights reserved. | |
| 7 # Copyright (C) 2011 Google, Inc. All rights reserved. | |
| 8 # | |
| 9 # Redistribution and use in source and binary forms, with or without | |
| 10 # modification, are permitted provided that the following conditions | |
| 11 # are met: | |
| 12 # | |
| 13 # 1. Redistributions of source code must retain the above copyright | |
| 14 # notice, this list of conditions and the following disclaimer. | |
| 15 # 2. Redistributions in binary form must reproduce the above copyright | |
| 16 # notice, this list of conditions and the following disclaimer in the | |
| 17 # documentation and/or other materials provided with the distribution. | |
| 18 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
| 19 # its contributors may be used to endorse or promote products derived | |
| 20 # from this software without specific prior written permission. | |
| 21 # | |
| 22 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 23 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 24 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 25 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 26 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 27 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 29 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 32 | |
| 33 use strict; | |
| 34 | |
| 35 use InFilesCompiler; | |
| 36 | |
| 37 my %defaultParameters = ( | |
| 38 'namespace' => 0 | |
| 39 ); | |
| 40 | |
| 41 sub defaultItemFactory | |
| 42 { | |
| 43 return ( | |
| 44 'ImplementedAs' => 0, | |
| 45 'implementedAs' => 0, | |
| 46 'Conditional' => 0, | |
| 47 'runtimeConditional' => 0, | |
| 48 'EnabledAtRuntime' => 0 | |
| 49 ); | |
| 50 } | |
| 51 | |
| 52 my $InCompiler = InFilesCompiler->new(\%defaultParameters, \&defaultItemFactory)
; | |
| 53 | |
| 54 my $outputDir = $InCompiler->initializeFromCommandLine(); | |
| 55 $InCompiler->compile(\&generateCode); | |
| 56 | |
| 57 sub generateCode() | |
| 58 { | |
| 59 my $parsedParametersRef = shift; | |
| 60 my $parsedItemsRef = shift; | |
| 61 | |
| 62 generateHeadersHeader($parsedParametersRef, $parsedItemsRef); | |
| 63 } | |
| 64 | |
| 65 sub generateHeadersHeader() | |
| 66 { | |
| 67 my $parsedParametersRef = shift; | |
| 68 my $parsedItemsRef = shift; | |
| 69 my %parsedParameters = %{ $parsedParametersRef }; | |
| 70 my %parsedItems = %{ $parsedItemsRef }; | |
| 71 | |
| 72 my $F; | |
| 73 my $namespace = $parsedParameters{"namespace"}; | |
| 74 my $outputFile = "$outputDir/Dart${namespace}Headers.h"; | |
| 75 | |
| 76 open F, ">$outputFile" or die "Failed to open file: $!"; | |
| 77 | |
| 78 print F $InCompiler->license(); | |
| 79 | |
| 80 print F "#ifndef Dart${namespace}Headers_h\n"; | |
| 81 print F "#define Dart${namespace}Headers_h\n"; | |
| 82 print F "\n"; | |
| 83 | |
| 84 my %includedInterfaces = (); | |
| 85 | |
| 86 for my $itemName (sort keys %parsedItems) { | |
| 87 my $conditional = $parsedItems{$itemName}{"Conditional"}; | |
| 88 my $interfaceName = $InCompiler->interfaceForItem($itemName); | |
| 89 my $implementedAs = $parsedItems{$itemName}{"implementedAs"}; | |
| 90 | |
| 91 # FIXME: Egregious hack to drop these names until we move to python. | |
| 92 next if (index($interfaceName, "Events") != -1); | |
| 93 | |
| 94 next if defined($includedInterfaces{$interfaceName}); | |
| 95 $includedInterfaces{$interfaceName} = 1; | |
| 96 | |
| 97 print F "#if " . $InCompiler->conditionalStringFromAttributeValue($condi
tional) . "\n" if $conditional; | |
| 98 if ($interfaceName eq "WebKitTransitionEvent") { | |
| 99 print F "#include \"Dart$implementedAs.h\"\n"; | |
| 100 } else { | |
| 101 print F "#include \"Dart$interfaceName.h\"\n"; | |
| 102 } | |
| 103 print F "#endif\n" if $conditional; | |
| 104 } | |
| 105 | |
| 106 print F "\n"; | |
| 107 print F "#endif // Dart${namespace}Headers_h\n"; | |
| 108 | |
| 109 close F; | |
| 110 } | |
| OLD | NEW |