2008-05-08 Julien Chaffraix <jchaffraix@webkit.org>
+ Reviewed by Eric.
+
+ Bug 18916: make_names.pl --factory needs to support custom c++ guard
+
+ Add --guardFactoryWith to handle the cpp guard around generated factories.
+
+ * DerivedSources.make: Set the guardFactoryWith variable for SVG factory.
+ * GNUmakefile.am: Ditto.
+ * WebCore.pro: Ditto.
+ * dom/make_names.pl: Add guardFactoryWith option.
+
+2008-05-08 Julien Chaffraix <jchaffraix@webkit.org>
+
Reviewed by Adam Roben.
wx & Gtk build fix.
SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
perl $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(SVG_FLAGS)" \
- --namespace SVG --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output .
+ --namespace SVG --guardFactoryWith "ENABLE(SVG)" --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output .
else
SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
perl $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in \
- --namespace SVG --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output .
+ --namespace SVG --guardFactoryWith "ENABLE(SVG)" --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output .
endif
if SVG_FLAGS
DerivedSources/SVGElementFactory.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in
$(PERL) $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(SVG_FEATURES)" \
- --namespace SVG --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output $(GENSOURCES)
+ --namespace SVG --guardFactoryWith "ENABLE(SVG)" --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output $(GENSOURCES)
else
DerivedSources/SVGElementFactory.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in
- $(PERL) $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --namespace SVG --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output $(GENSOURCES)
+ $(PERL) $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --namespace SVG --guardFactoryWith "ENABLE(SVG)" --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output $(GENSOURCES)
endif # SVG_FLAGS
# GENERATOR 5-C:
svgnames_a.output = $$GENERATED_SOURCES_DIR/SVGNames.cpp
- svgnames_a.commands = perl $$PWD/dom/make_names.pl --tags $$PWD/svg/svgtags.in --attrs $$PWD/svg/svgattrs.in --extraDefines \"$${DEFINES}\" --namespace SVG --cppNamespace WebCore --namespaceURI 'http://www.w3.org/2000/svg' --factory --attrsNullNamespace --preprocessor \"$${QMAKE_MOC} -E\" --output $$GENERATED_SOURCES_DIR
+ svgnames_a.commands = perl $$PWD/dom/make_names.pl --tags $$PWD/svg/svgtags.in --attrs $$PWD/svg/svgattrs.in --extraDefines \"$${DEFINES}\" --namespace SVG --guardFactoryWith \"ENABLE(SVG)\" --cppNamespace WebCore --namespaceURI 'http://www.w3.org/2000/svg' --factory --attrsNullNamespace --preprocessor \"$${QMAKE_MOC} -E\" --output $$GENERATED_SOURCES_DIR
svgnames_a.input = SVG_NAMES
svgnames_a.dependency_type = TYPE_C
svgnames_a.CONFIG = target_predeps
my $attrsNullNamespace = 0;
my $extraDefines = 0;
my $preprocessor = "/usr/bin/gcc -E -P -x c++";
+my $guardFactoryWith = 0;
GetOptions('tags=s' => \$tagsFile,
'attrs=s' => \$attrsFile,
'tagsNullNamespace' => \$tagsNullNamespace,
'attrsNullNamespace' => \$attrsNullNamespace,
'extraDefines=s' => \$extraDefines,
- 'preprocessor=s' => \$preprocessor);
+ 'preprocessor=s' => \$preprocessor,
+ 'guardFactoryWith=s' => \$guardFactoryWith);
die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $namespace;
die "You must specify a namespaceURI (e.g. http://www.w3.org/2000/svg)" unless $namespaceURI;
sub printConstructors
{
my ($F, @names) = @_;
- print F "#if ENABLE(SVG)\n";
+ print F "#if $guardFactoryWith\n" if $guardFactoryWith;
for my $name (@names) {
my $upperCase = upperCaseName($name);
print F " return new ${namespace}${upperCase}Element(${name}Tag, doc);\n";
print F "}\n\n";
}
- print F "#endif\n";
+ print F "#endif\n" if $guardFactoryWith;
}
sub printFunctionInits
printConstructors($F, @tags);
+print F "#if $guardFactoryWith\n" if $guardFactoryWith;
+
print F <<END
-#if ENABLE(SVG)
static inline void createFunctionMapIfNecessary()
{
if (gFunctionMap)
printFunctionInits($F, @tags);
-print F <<END
-}
-#endif
+print F "}\n";
+print F "#endif\n\n" if $guardFactoryWith;
+print F <<END
${namespace}Element *${namespace}ElementFactory::create${namespace}Element(const QualifiedName& qName, Document* doc, bool createdByParser)
{
-#if ENABLE(SVG)
+END
+;
+
+print F "#if $guardFactoryWith\n" if $guardFactoryWith;
+
+print F <<END
// Don't make elements without a document
if (!doc)
return 0;
return func(doc, createdByParser);
return new ${namespace}Element(qName, doc);
+END
+;
+
+if ($guardFactoryWith) {
+
+print F <<END
#else
return 0;
#endif
+END
+;
+
+}
+
+print F <<END
}
} // namespace