Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: Source/WebCore/dom/make_names.pl

Issue 8806015: Changes to support a second VM. (Closed) Base URL: svn://svn.chromium.org/dash/experimental/chrome/src/webkit-full
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 use File::Spec; 37 use File::Spec;
38 use IO::File; 38 use IO::File;
39 use InFilesParser; 39 use InFilesParser;
40 40
41 sub readTags($$); 41 sub readTags($$);
42 sub readAttrs($$); 42 sub readAttrs($$);
43 43
44 my $printFactory = 0; 44 my $printFactory = 0;
45 my $printWrapperFactory = 0; 45 my $printWrapperFactory = 0;
46 my $printWrapperFactoryV8 = 0; 46 my $printWrapperFactoryV8 = 0;
47 my $printWrapperFactoryDart = 0;
47 my $fontNamesIn = ""; 48 my $fontNamesIn = "";
48 my $tagsFile = ""; 49 my $tagsFile = "";
49 my $attrsFile = ""; 50 my $attrsFile = "";
50 my $outputDir = "."; 51 my $outputDir = ".";
51 my %parsedTags = (); 52 my %parsedTags = ();
52 my %parsedAttrs = (); 53 my %parsedAttrs = ();
53 my %enabledTags = (); 54 my %enabledTags = ();
54 my %enabledAttrs = (); 55 my %enabledAttrs = ();
55 my %allTags = (); 56 my %allTags = ();
56 my %allAttrs = (); 57 my %allAttrs = ();
(...skipping 16 matching lines...) Expand all
73 74
74 GetOptions( 75 GetOptions(
75 'tags=s' => \$tagsFile, 76 'tags=s' => \$tagsFile,
76 'attrs=s' => \$attrsFile, 77 'attrs=s' => \$attrsFile,
77 'factory' => \$printFactory, 78 'factory' => \$printFactory,
78 'outputDir=s' => \$outputDir, 79 'outputDir=s' => \$outputDir,
79 'extraDefines=s' => \$extraDefines, 80 'extraDefines=s' => \$extraDefines,
80 'preprocessor=s' => \$preprocessor, 81 'preprocessor=s' => \$preprocessor,
81 'wrapperFactory' => \$printWrapperFactory, 82 'wrapperFactory' => \$printWrapperFactory,
82 'wrapperFactoryV8' => \$printWrapperFactoryV8, 83 'wrapperFactoryV8' => \$printWrapperFactoryV8,
84 'wrapperFactoryDart' => \$printWrapperFactoryDart,
83 'fonts=s' => \$fontNamesIn 85 'fonts=s' => \$fontNamesIn
84 ); 86 );
85 87
86 mkpath($outputDir); 88 mkpath($outputDir);
87 89
88 if (length($fontNamesIn)) { 90 if (length($fontNamesIn)) {
89 my $names = new IO::File; 91 my $names = new IO::File;
90 my $familyNamesFileBase = "WebKitFontFamily"; 92 my $familyNamesFileBase = "WebKitFontFamily";
91 93
92 open($names, $fontNamesIn) or die "Failed to open file: $fontNamesIn"; 94 open($names, $fontNamesIn) or die "Failed to open file: $fontNamesIn";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory"; 154 my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory";
153 155
154 printNamesHeaderFile("$namesBasePath.h"); 156 printNamesHeaderFile("$namesBasePath.h");
155 printNamesCppFile("$namesBasePath.cpp"); 157 printNamesCppFile("$namesBasePath.cpp");
156 158
157 if ($printFactory) { 159 if ($printFactory) {
158 printFactoryCppFile("$factoryBasePath.cpp"); 160 printFactoryCppFile("$factoryBasePath.cpp");
159 printFactoryHeaderFile("$factoryBasePath.h"); 161 printFactoryHeaderFile("$factoryBasePath.h");
160 } 162 }
161 163
162 die "You cannot specify both --wrapperFactory and --wrapperFactoryV8" if $printW rapperFactory && $printWrapperFactoryV8; 164 my @wrapperFactoryTypes = ();
163 my $wrapperFactoryType = ""; 165 push(@wrapperFactoryTypes, "JS") if $printWrapperFactory;
164 if ($printWrapperFactory) { 166 push(@wrapperFactoryTypes, "V8") if $printWrapperFactoryV8;
165 $wrapperFactoryType = "JS"; 167 push(@wrapperFactoryTypes, "Dart") if $printWrapperFactoryDart;
166 } elsif ($printWrapperFactoryV8) {
167 $wrapperFactoryType = "V8";
168 }
169 168
170 if ($wrapperFactoryType) { 169 foreach my $wrapperFactoryType (@wrapperFactoryTypes) {
171 printWrapperFactoryCppFile($outputDir, $wrapperFactoryType, $wrapperFactoryF ileName); 170 printWrapperFactoryCppFile($outputDir, $wrapperFactoryType, $wrapperFactoryF ileName);
172 printWrapperFactoryHeaderFile($outputDir, $wrapperFactoryType, $wrapperFacto ryFileName); 171 printWrapperFactoryHeaderFile($outputDir, $wrapperFactoryType, $wrapperFacto ryFileName);
173 } 172 }
174 173
175 ### Hash initialization 174 ### Hash initialization
176 175
177 sub defaultTagPropertyHash 176 sub defaultTagPropertyHash
178 { 177 {
179 return ( 178 return (
180 'constructorNeedsCreatedByParser' => 0, 179 'constructorNeedsCreatedByParser' => 0,
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 print F <<END 1019 print F <<END
1021 static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespa ce}Element* element) 1020 static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespa ce}Element* element)
1022 { 1021 {
1023 return toV8(static_cast<${JSInterfaceName}*>(element)); 1022 return toV8(static_cast<${JSInterfaceName}*>(element));
1024 } 1023 }
1025 1024
1026 1025
1027 END 1026 END
1028 ; 1027 ;
1029 } 1028 }
1029 } elsif ($wrapperFactoryType eq "Dart") {
1030 # Hack for the media tags
1031 # FIXME: This should have been done via a CustomWrapper attribute an d a separate *Custom file.
1032 if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) {
1033 print F <<END
1034 static Dart_Handle create${JSInterfaceName}Wrapper($parameters{namespace}Element * element)
1035 {
1036 Settings* settings = element->document()->settings();
1037 if (!MediaPlayer::isAvailable() || (settings && !settings->isMediaEnabled()) )
1038 return toDartValue(element);
1039 return toDartValue(static_cast<${JSInterfaceName}*>(element));
1040 }
1041
1042 END
1043 ;
1044 } elsif (${JSInterfaceName} eq "HTMLElement") {
1045 print F <<END
1046 static Dart_Handle create${JSInterfaceName}Wrapper($parameters{namespace}Element * element)
1047 {
1048 return DartDOMWrapper::toDart<DartHTMLElement>(element);
1049 }
1050
1051 END
1052 ;
1053 } else {
1054 print F <<END
1055 static Dart_Handle create${JSInterfaceName}Wrapper($parameters{namespace}Element * element)
1056 {
1057 return toDartValue(static_cast<${JSInterfaceName}*>(element));
1058 }
1059
1060 END
1061 ;
1062 }
1030 } 1063 }
1031 1064
1032 if ($conditional) { 1065 if ($conditional) {
1033 print F "#endif\n\n"; 1066 print F "#endif\n\n";
1034 } 1067 }
1035 } 1068 }
1036 } 1069 }
1037 1070
1038 sub printWrapperFactoryCppFile 1071 sub printWrapperFactoryCppFile
1039 { 1072 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 using namespace JSC; 1108 using namespace JSC;
1076 END 1109 END
1077 ; 1110 ;
1078 } elsif ($wrapperFactoryType eq "V8") { 1111 } elsif ($wrapperFactoryType eq "V8") {
1079 print F <<END 1112 print F <<END
1080 #include "V8$parameters{namespace}Element.h" 1113 #include "V8$parameters{namespace}Element.h"
1081 1114
1082 #include <v8.h> 1115 #include <v8.h>
1083 END 1116 END
1084 ; 1117 ;
1118 } elsif ($wrapperFactoryType eq "Dart") {
1119 print F <<END
1120 #include "Dart$parameters{namespace}Element.h"
1121 END
1122 ;
1085 } 1123 }
1086 1124
1087 print F <<END 1125 print F <<END
1088 1126
1089 namespace WebCore { 1127 namespace WebCore {
1090 1128
1091 using namespace $parameters{namespace}Names; 1129 using namespace $parameters{namespace}Names;
1092 1130
1093 END 1131 END
1094 ; 1132 ;
1095 if ($wrapperFactoryType eq "JS") { 1133 if ($wrapperFactoryType eq "JS") {
1096 print F <<END 1134 print F <<END
1097 typedef JSDOMWrapper* (*Create$parameters{namespace}ElementWrapperFunction)(Exec State*, JSDOMGlobalObject*, PassRefPtr<$parameters{namespace}Element>); 1135 typedef JSDOMWrapper* (*Create$parameters{namespace}ElementWrapperFunction)(Exec State*, JSDOMGlobalObject*, PassRefPtr<$parameters{namespace}Element>);
1098 1136
1099 END 1137 END
1100 ; 1138 ;
1101 } elsif ($wrapperFactoryType eq "V8") { 1139 } elsif ($wrapperFactoryType eq "V8") {
1102 print F <<END 1140 print F <<END
1103 typedef v8::Handle<v8::Value> (*Create$parameters{namespace}ElementWrapperFuncti on)($parameters{namespace}Element*); 1141 typedef v8::Handle<v8::Value> (*Create$parameters{namespace}ElementWrapperFuncti on)($parameters{namespace}Element*);
1104 1142
1105 END 1143 END
1106 ; 1144 ;
1145 } elsif ($wrapperFactoryType eq "Dart") {
1146 print F <<END
1147 typedef Dart_Handle (*Create$parameters{namespace}ElementWrapperFunction)($param eters{namespace}Element*);
1148
1149 END
1150 ;
1107 } 1151 }
1108 1152
1109 printWrapperFunctions($F, $wrapperFactoryType); 1153 printWrapperFunctions($F, $wrapperFactoryType);
1110 1154
1111 if ($wrapperFactoryType eq "JS") { 1155 if ($wrapperFactoryType eq "JS") {
1112 print F <<END 1156 print F <<END
1113 JSDOMWrapper* createJS$parameters{namespace}Wrapper(ExecState* exec, JSDOMGlobal Object* globalObject, PassRefPtr<$parameters{namespace}Element> element) 1157 JSDOMWrapper* createJS$parameters{namespace}Wrapper(ExecState* exec, JSDOMGlobal Object* globalObject, PassRefPtr<$parameters{namespace}Element> element)
1114 { 1158 {
1115 typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementW rapperFunction> FunctionMap; 1159 typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementW rapperFunction> FunctionMap;
1116 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); 1160 DEFINE_STATIC_LOCAL(FunctionMap, map, ());
1117 if (map.isEmpty()) { 1161 if (map.isEmpty()) {
1118 END 1162 END
1119 ; 1163 ;
1120 } elsif ($wrapperFactoryType eq "V8") { 1164 } elsif ($wrapperFactoryType eq "V8") {
1121 print F <<END 1165 print F <<END
1122 v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespac e}Element* element, bool forceNewObject) 1166 v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespac e}Element* element, bool forceNewObject)
1123 { 1167 {
1124 typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementW rapperFunction> FunctionMap; 1168 typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementW rapperFunction> FunctionMap;
1125 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); 1169 DEFINE_STATIC_LOCAL(FunctionMap, map, ());
1126 if (map.isEmpty()) { 1170 if (map.isEmpty()) {
1127 END 1171 END
1128 ; 1172 ;
1173 } elsif ($wrapperFactoryType eq "Dart") {
1174 print F <<END
1175 Dart_Handle createDart$parameters{namespace}Wrapper($parameters{namespace}Elemen t* element)
1176 {
1177 typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementW rapperFunction> FunctionMap;
1178 DEFINE_STATIC_LOCAL(FunctionMap, map, ());
1179 if (map.isEmpty()) {
1180 END
1181 ;
1129 } 1182 }
1130 1183
1131 for my $tag (sort keys %enabledTags) { 1184 for my $tag (sort keys %enabledTags) {
1132 # Do not add the name to the map if it does not have a JS wrapper constr uctor or uses the default wrapper. 1185 # Do not add the name to the map if it does not have a JS wrapper constr uctor or uses the default wrapper.
1133 next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallb ackInterfaceName} eq $parameters{namespace} . "Element")); 1186 next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallb ackInterfaceName} eq $parameters{namespace} . "Element"));
1134 1187
1135 my $conditional = $enabledTags{$tag}{conditional}; 1188 my $conditional = $enabledTags{$tag}{conditional};
1136 if ($conditional) { 1189 if ($conditional) {
1137 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; 1190 my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")";
1138 print F "#if ${conditionalString}\n"; 1191 print F "#if ${conditionalString}\n";
(...skipping 18 matching lines...) Expand all
1157 return createWrapperFunction(exec, globalObject, element); 1210 return createWrapperFunction(exec, globalObject, element);
1158 return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceN ame}, element.get()); 1211 return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceN ame}, element.get());
1159 END 1212 END
1160 ; 1213 ;
1161 } elsif ($wrapperFactoryType eq "V8") { 1214 } elsif ($wrapperFactoryType eq "V8") {
1162 print F <<END 1215 print F <<END
1163 return createWrapperFunction(element); 1216 return createWrapperFunction(element);
1164 return V8$parameters{fallbackInterfaceName}::wrap(static_cast<$parameters{fa llbackInterfaceName}*>(element), forceNewObject); 1217 return V8$parameters{fallbackInterfaceName}::wrap(static_cast<$parameters{fa llbackInterfaceName}*>(element), forceNewObject);
1165 END 1218 END
1166 ; 1219 ;
1220 } elsif ($wrapperFactoryType eq "Dart") {
1221 print F <<END
1222 return createWrapperFunction(element);
1223 return toDartValue(static_cast<$parameters{fallbackInterfaceName}*>(element) );
1224 END
1225 ;
1167 } 1226 }
1168 print F <<END 1227 print F <<END
1169 } 1228 }
1170 1229
1171 } 1230 }
1172 1231
1173 END 1232 END
1174 ; 1233 ;
1175 1234
1176 print F "#endif\n" if $parameters{guardFactoryWith}; 1235 print F "#endif\n" if $parameters{guardFactoryWith};
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 #include <v8.h> 1277 #include <v8.h>
1219 1278
1220 namespace WebCore { 1279 namespace WebCore {
1221 1280
1222 class $parameters{namespace}Element; 1281 class $parameters{namespace}Element;
1223 1282
1224 v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{name space}Element*, bool); 1283 v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{name space}Element*, bool);
1225 } 1284 }
1226 END 1285 END
1227 ; 1286 ;
1287 } elsif ($wrapperFactoryType eq "Dart") {
1288 print F <<END
1289 #include "dart_api.h"
1290
1291 namespace WebCore {
1292
1293 class $parameters{namespace}Element;
1294
1295 Dart_Handle createDart$parameters{namespace}Wrapper($parameters{namespace}El ement*);
1296 }
1297 END
1298 ;
1228 } 1299 }
1229 1300
1230 print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFa ctoryWith}; 1301 print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFa ctoryWith};
1231 1302
1232 print F "#endif // $wrapperFactoryType$parameters{namespace}ElementWrapperFa ctory_h\n"; 1303 print F "#endif // $wrapperFactoryType$parameters{namespace}ElementWrapperFa ctory_h\n";
1233 1304
1234 close F; 1305 close F;
1235 } 1306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698