| OLD | NEW |
| 1 #!/usr/bin/perl -w | 1 #!/usr/bin/perl -w |
| 2 | 2 |
| 3 # Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved. | 3 # Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved. |
| 4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org> | 4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org> |
| 5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmob
ile.com/) | 5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmob
ile.com/) |
| 6 # Copyright (C) 2011 Ericsson AB. All rights reserved. | 6 # Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 7 # | 7 # |
| 8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
| 9 # modification, are permitted provided that the following conditions | 9 # modification, are permitted provided that the following conditions |
| 10 # are met: | 10 # are met: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (length($attrsFile)) { | 108 if (length($attrsFile)) { |
| 109 %allAttrs = %{readAttrs($attrsFile, 0)}; | 109 %allAttrs = %{readAttrs($attrsFile, 0)}; |
| 110 %enabledAttrs = %{readAttrs($attrsFile, 1)}; | 110 %enabledAttrs = %{readAttrs($attrsFile, 1)}; |
| 111 namesToStrings(\%allAttrs, \%allStrings); | 111 namesToStrings(\%allAttrs, \%allStrings); |
| 112 } | 112 } |
| 113 | 113 |
| 114 die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $par
ameters{namespace}; | 114 die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $par
ameters{namespace}; |
| 115 die "You must specify a namespaceURI (e.g. http://www.w3.org/2000/svg)" unless $
parameters{namespaceURI}; | 115 die "You must specify a namespaceURI (e.g. http://www.w3.org/2000/svg)" unless $
parameters{namespaceURI}; |
| 116 | 116 |
| 117 $parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespa
cePrefix}; | 117 $parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespa
cePrefix}; |
| 118 $parameters{fallbackJSInterfaceName} = $parameters{fallbackInterfaceName} unless
$parameters{fallbackJSInterfaceName}; |
| 118 | 119 |
| 119 my $namesBasePath = "$outputDir/$parameters{namespace}Names"; | 120 my $namesBasePath = "$outputDir/$parameters{namespace}Names"; |
| 120 my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory"; | 121 my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory"; |
| 121 my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory"; | 122 my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory"; |
| 122 | 123 |
| 123 printNamesHeaderFile("$namesBasePath.h"); | 124 printNamesHeaderFile("$namesBasePath.h"); |
| 124 printNamesCppFile("$namesBasePath.cpp"); | 125 printNamesCppFile("$namesBasePath.cpp"); |
| 125 | 126 |
| 126 if ($printFactory) { | 127 if ($printFactory) { |
| 127 printFactoryCppFile("$factoryBasePath.cpp"); | 128 printFactoryCppFile("$factoryBasePath.cpp"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 152 | 153 |
| 153 sub defaultParametersHash | 154 sub defaultParametersHash |
| 154 { | 155 { |
| 155 return ( | 156 return ( |
| 156 'namespace' => '', | 157 'namespace' => '', |
| 157 'namespacePrefix' => '', | 158 'namespacePrefix' => '', |
| 158 'namespaceURI' => '', | 159 'namespaceURI' => '', |
| 159 'guardFactoryWith' => '', | 160 'guardFactoryWith' => '', |
| 160 'tagsNullNamespace' => 0, | 161 'tagsNullNamespace' => 0, |
| 161 'attrsNullNamespace' => 0, | 162 'attrsNullNamespace' => 0, |
| 162 'fallbackInterfaceName' => '' | 163 'fallbackInterfaceName' => '', |
| 164 'fallbackJSInterfaceName' => '' |
| 163 ); | 165 ); |
| 164 } | 166 } |
| 165 | 167 |
| 166 sub defaultInterfaceName | 168 sub defaultInterfaceName |
| 167 { | 169 { |
| 168 die "No namespace found" if !$parameters{namespace}; | 170 die "No namespace found" if !$parameters{namespace}; |
| 169 return $parameters{namespace} . upperCaseName($_[0]) . "Element" | 171 return $parameters{namespace} . upperCaseName($_[0]) . "Element" |
| 170 } | 172 } |
| 171 | 173 |
| 172 ### Parsing handlers | 174 ### Parsing handlers |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName}; | 685 my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName}; |
| 684 next if defined($tagsSeen{$JSInterfaceName}) || usesDefaultJSWrapper($ta
gName); | 686 next if defined($tagsSeen{$JSInterfaceName}) || usesDefaultJSWrapper($ta
gName); |
| 685 if ($enabledTags{$tagName}{conditional}) { | 687 if ($enabledTags{$tagName}{conditional}) { |
| 686 # We skip feature-define-specific #includes here since we handle the
m separately. | 688 # We skip feature-define-specific #includes here since we handle the
m separately. |
| 687 next; | 689 next; |
| 688 } | 690 } |
| 689 $tagsSeen{$JSInterfaceName} = 1; | 691 $tagsSeen{$JSInterfaceName} = 1; |
| 690 | 692 |
| 691 print F "#include \"V8${JSInterfaceName}.h\"\n"; | 693 print F "#include \"V8${JSInterfaceName}.h\"\n"; |
| 692 } | 694 } |
| 693 print F "#include \"V8$parameters{fallbackInterfaceName}.h\"\n"; | 695 print F "#include \"V8$parameters{fallbackJSInterfaceName}.h\"\n"; |
| 694 } | 696 } |
| 695 | 697 |
| 696 sub printElementIncludes | 698 sub printElementIncludes |
| 697 { | 699 { |
| 698 my $F = shift; | 700 my $F = shift; |
| 699 | 701 |
| 700 my %tagsSeen; | 702 my %tagsSeen; |
| 701 for my $tagName (sort keys %enabledTags) { | 703 for my $tagName (sort keys %enabledTags) { |
| 702 my $interfaceName = $enabledTags{$tagName}{interfaceName}; | 704 my $interfaceName = $enabledTags{$tagName}{interfaceName}; |
| 703 next if defined($tagsSeen{$interfaceName}); | 705 next if defined($tagsSeen{$interfaceName}); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 } | 961 } |
| 960 | 962 |
| 961 sub printWrapperFunctions | 963 sub printWrapperFunctions |
| 962 { | 964 { |
| 963 my $F = shift; | 965 my $F = shift; |
| 964 | 966 |
| 965 my %tagsSeen; | 967 my %tagsSeen; |
| 966 for my $tagName (sort keys %enabledTags) { | 968 for my $tagName (sort keys %enabledTags) { |
| 967 # Avoid defining the same wrapper method twice. | 969 # Avoid defining the same wrapper method twice. |
| 968 my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName}; | 970 my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName}; |
| 969 next if defined($tagsSeen{$JSInterfaceName}) || (usesDefaultJSWrapper($t
agName) && ($parameters{fallbackInterfaceName} eq $parameters{namespace} . "Elem
ent")); | 971 next if defined($tagsSeen{$JSInterfaceName}) || (usesDefaultJSWrapper($t
agName) && ($parameters{fallbackJSInterfaceName} eq $parameters{namespace} . "El
ement")); |
| 970 $tagsSeen{$JSInterfaceName} = 1; | 972 $tagsSeen{$JSInterfaceName} = 1; |
| 971 | 973 |
| 972 my $conditional = $enabledTags{$tagName}{conditional}; | 974 my $conditional = $enabledTags{$tagName}{conditional}; |
| 973 if ($conditional) { | 975 if ($conditional) { |
| 974 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/,
$conditional)) . ")"; | 976 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/,
$conditional)) . ")"; |
| 975 print F "#if ${conditionalString}\n\n"; | 977 print F "#if ${conditionalString}\n\n"; |
| 976 } | 978 } |
| 977 | 979 |
| 978 if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { | 980 if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { |
| 979 print F <<END | 981 print F <<END |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 v8::Handle<v8::Object> createV8$parameters{namespace}Wrapper($parameters{namespa
ce}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolat
e) | 1091 v8::Handle<v8::Object> createV8$parameters{namespace}Wrapper($parameters{namespa
ce}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolat
e) |
| 1090 { | 1092 { |
| 1091 typedef HashMap<WTF::StringImpl*, Create$parameters{namespace}ElementWrapper
Function> FunctionMap; | 1093 typedef HashMap<WTF::StringImpl*, Create$parameters{namespace}ElementWrapper
Function> FunctionMap; |
| 1092 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); | 1094 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); |
| 1093 if (map.isEmpty()) { | 1095 if (map.isEmpty()) { |
| 1094 END | 1096 END |
| 1095 ; | 1097 ; |
| 1096 | 1098 |
| 1097 for my $tag (sort keys %enabledTags) { | 1099 for my $tag (sort keys %enabledTags) { |
| 1098 # Do not add the name to the map if it does not have a JS wrapper constr
uctor or uses the default wrapper. | 1100 # Do not add the name to the map if it does not have a JS wrapper constr
uctor or uses the default wrapper. |
| 1099 next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallb
ackInterfaceName} eq $parameters{namespace} . "Element")); | 1101 next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallb
ackJSInterfaceName} eq $parameters{namespace} . "Element")); |
| 1100 | 1102 |
| 1101 my $conditional = $enabledTags{$tag}{conditional}; | 1103 my $conditional = $enabledTags{$tag}{conditional}; |
| 1102 if ($conditional) { | 1104 if ($conditional) { |
| 1103 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/,
$conditional)) . ")"; | 1105 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/,
$conditional)) . ")"; |
| 1104 print F "#if ${conditionalString}\n"; | 1106 print F "#if ${conditionalString}\n"; |
| 1105 } | 1107 } |
| 1106 | 1108 |
| 1107 my $ucTag = $enabledTags{$tag}{JSInterfaceName}; | 1109 my $ucTag = $enabledTags{$tag}{JSInterfaceName}; |
| 1108 print F " map.set(${tag}Tag.localName().impl(), create${ucTag}Wrap
per);\n"; | 1110 print F " map.set(${tag}Tag.localName().impl(), create${ucTag}Wrap
per);\n"; |
| 1109 | 1111 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 | 1198 |
| 1197 printLicenseHeader($F); | 1199 printLicenseHeader($F); |
| 1198 | 1200 |
| 1199 print F "#ifndef V8$parameters{namespace}ElementWrapperFactory_h\n"; | 1201 print F "#ifndef V8$parameters{namespace}ElementWrapperFactory_h\n"; |
| 1200 print F "#define V8$parameters{namespace}ElementWrapperFactory_h\n\n"; | 1202 print F "#define V8$parameters{namespace}ElementWrapperFactory_h\n\n"; |
| 1201 | 1203 |
| 1202 print F "#if $parameters{guardFactoryWith}\n" if $parameters{guardFactoryWit
h}; | 1204 print F "#if $parameters{guardFactoryWith}\n" if $parameters{guardFactoryWit
h}; |
| 1203 | 1205 |
| 1204 print F <<END | 1206 print F <<END |
| 1205 #include <V8$parameters{namespace}Element.h> | 1207 #include <V8$parameters{namespace}Element.h> |
| 1206 #include <V8$parameters{fallbackInterfaceName}.h> | 1208 #include <V8$parameters{fallbackJSInterfaceName}.h> |
| 1207 #include <v8.h> | 1209 #include <v8.h> |
| 1208 | 1210 |
| 1209 namespace WebCore { | 1211 namespace WebCore { |
| 1210 | 1212 |
| 1211 class $parameters{namespace}Element; | 1213 class $parameters{namespace}Element; |
| 1212 | 1214 |
| 1213 const QualifiedName* find$parameters{namespace}TagNameOfV8Type(const Wrapper
TypeInfo*); | 1215 const QualifiedName* find$parameters{namespace}TagNameOfV8Type(const Wrapper
TypeInfo*); |
| 1214 v8::Handle<v8::Object> createV8$parameters{namespace}Wrapper($parameters{nam
espace}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*); | 1216 v8::Handle<v8::Object> createV8$parameters{namespace}Wrapper($parameters{nam
espace}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*); |
| 1215 inline v8::Handle<v8::Object> createV8$parameters{namespace}DirectWrapper($p
arameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8
::Isolate* isolate) | 1217 inline v8::Handle<v8::Object> createV8$parameters{namespace}DirectWrapper($p
arameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8
::Isolate* isolate) |
| 1216 { | 1218 { |
| 1217 return V8$parameters{namespace}Element::createWrapper(element, creationC
ontext, isolate); | 1219 return V8$parameters{namespace}Element::createWrapper(element, creationC
ontext, isolate); |
| 1218 } | 1220 } |
| 1219 inline v8::Handle<v8::Object> createV8$parameters{namespace}FallbackWrapper(
$parameters{fallbackInterfaceName}* element, v8::Handle<v8::Object> creationCont
ext, v8::Isolate* isolate) | 1221 inline v8::Handle<v8::Object> createV8$parameters{namespace}FallbackWrapper(
$parameters{fallbackJSInterfaceName}* element, v8::Handle<v8::Object> creationCo
ntext, v8::Isolate* isolate) |
| 1220 { | 1222 { |
| 1221 return V8$parameters{fallbackInterfaceName}::createWrapper(element, crea
tionContext, isolate); | 1223 return V8$parameters{fallbackJSInterfaceName}::createWrapper(element, cr
eationContext, isolate); |
| 1222 } | 1224 } |
| 1223 } | 1225 } |
| 1224 END | 1226 END |
| 1225 ; | 1227 ; |
| 1226 print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFa
ctoryWith}; | 1228 print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFa
ctoryWith}; |
| 1227 | 1229 |
| 1228 print F "#endif // V8$parameters{namespace}ElementWrapperFactory_h\n"; | 1230 print F "#endif // V8$parameters{namespace}ElementWrapperFactory_h\n"; |
| 1229 | 1231 |
| 1230 close F; | 1232 close F; |
| 1231 } | 1233 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1278 |
| 1277 while ( my ($name, $identifier) = each %parameters ) { | 1279 while ( my ($name, $identifier) = each %parameters ) { |
| 1278 print F " new ((void*)&$name) AtomicString(${name}Impl);\n"; | 1280 print F " new ((void*)&$name) AtomicString(${name}Impl);\n"; |
| 1279 } | 1281 } |
| 1280 | 1282 |
| 1281 print F "}\n}\n}\n"; | 1283 print F "}\n}\n}\n"; |
| 1282 close F; | 1284 close F; |
| 1283 exit 0; | 1285 exit 0; |
| 1284 } | 1286 } |
| 1285 | 1287 |
| OLD | NEW |