2006-05-17 Anders Carlsson <acarlsson@apple.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2006 23:27:11 +0000 (23:27 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2006 23:27:11 +0000 (23:27 +0000)
        Reviewed by Darin.

        * DerivedSources.make:
        Conditionally generate the SVG and XPath related files based on the value of
        FEATURE_DEFINES. Also, pass FEATURE_DEFINES TO THE BINDINGS GENERATOR.

        * WebCore.xcodeproj/project.pbxproj:
        Add FEATURE_DEFINES as a toplevel build setting and set it to "SVG_SUPPORT XPATH_SUPPORT"
        to keep SVG and XPath support turned on. Add FEATURE_DEFINES to the CPP defines.

        * bindings/js/kjs_binding.cpp:
        (KJS::setDOMException):
        Add #ifdefs around the XPath code.

        * bindings/scripts/CodeGeneratorJS.pm:
        Add "Conditional" extended attribute for interfaces. If this is set, the generated code will be
        surrounded by an #if.

        * bindings/scripts/IDLParser.pm:
        Pass the define flags on to the preprocessor.

        * bindings/scripts/generate-bindings.pl:
        Add a --defines property and pass it on to the parser.

        * css/cssstyleselector.h:
        Add DeprecatedString.h include.

        * dom/Document.idl:
        Put back #if around the XPath functions

        * page/DOMWindow.idl:
        Put #if around the XPath constructors

        * xpath/XPathEvaluator.idl:
        * xpath/XPathExpression.idl:
        * xpath/XPathNSResolver.cpp:
        * xpath/XPathNSResolver.idl:
        * xpath/XPathNamespace.cpp:
        * xpath/XPathResult.idl:
        Add "Conditional=XPATH" to all interfaces.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14423 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/kjs_binding.cpp
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/IDLParser.pm
WebCore/bindings/scripts/generate-bindings.pl
WebCore/css/cssstyleselector.h
WebCore/dom/Document.idl
WebCore/page/DOMWindow.idl
WebCore/xpath/XPathEvaluator.idl
WebCore/xpath/XPathExpression.idl
WebCore/xpath/XPathNSResolver.cpp
WebCore/xpath/XPathNSResolver.idl
WebCore/xpath/XPathNamespace.cpp
WebCore/xpath/XPathResult.idl

index 33aa930c2185b0aff8b2eba12294d87c60d00273..a4cc0cf2e975f697617fee75d668fcdb3ecf61b2 100644 (file)
@@ -1,3 +1,46 @@
+2006-05-17  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        * DerivedSources.make:
+        Conditionally generate the SVG and XPath related files based on the value of 
+        FEATURE_DEFINES. Also, pass FEATURE_DEFINES TO THE BINDINGS GENERATOR.
+        
+        * WebCore.xcodeproj/project.pbxproj:
+        Add FEATURE_DEFINES as a toplevel build setting and set it to "SVG_SUPPORT XPATH_SUPPORT"
+        to keep SVG and XPath support turned on. Add FEATURE_DEFINES to the CPP defines.
+        
+        * bindings/js/kjs_binding.cpp:
+        (KJS::setDOMException):
+        Add #ifdefs around the XPath code.
+        
+        * bindings/scripts/CodeGeneratorJS.pm:
+        Add "Conditional" extended attribute for interfaces. If this is set, the generated code will be
+        surrounded by an #if.
+        
+        * bindings/scripts/IDLParser.pm:
+        Pass the define flags on to the preprocessor.
+        
+        * bindings/scripts/generate-bindings.pl:
+        Add a --defines property and pass it on to the parser.
+        
+        * css/cssstyleselector.h:
+        Add DeprecatedString.h include.
+        
+        * dom/Document.idl:
+        Put back #if around the XPath functions
+        
+        * page/DOMWindow.idl:
+        Put #if around the XPath constructors
+        
+        * xpath/XPathEvaluator.idl:
+        * xpath/XPathExpression.idl:
+        * xpath/XPathNSResolver.cpp:
+        * xpath/XPathNSResolver.idl:
+        * xpath/XPathNamespace.cpp:
+        * xpath/XPathResult.idl:
+        Add "Conditional=XPATH" to all interfaces.
+        
 2006-05-16  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders.
index 39922191fd8660a0db5b193d509b080b6dce0a9a..72d694ce776790b4ea5b8cbe3c78eb9a512035b6 100644 (file)
@@ -146,13 +146,18 @@ CSSGrammar.cpp : css/CSSGrammar.y
        rm -f CSSGrammar.cpp.h CSSGrammar.hpp
 
 # XPath grammar
-
-XPathGrammar.cpp : xpath/impl/XPathGrammar.y
+ifeq ($(findstring XPATH_SUPPORT,$(FEATURE_DEFINES)), XPATH_SUPPORT)
+XPathGrammar.cpp : xpath/impl/XPathGrammar.y $(PROJECT_FILE)
        bison -d -p xpathyy $< -o $@
        touch XPathGrammar.cpp.h
        touch XPathGrammar.hpp
        cat XPathGrammar.cpp.h XPathGrammar.hpp > XPathGrammar.h
        rm -f XPathGrammar.cpp.h XPathGrammar.hpp
+else
+XPathGrammar.cpp : $(PROJECT_FILE)
+       echo > XPathGrammar.cpp
+       echo > XPathGrammar.h
+endif
 
 # user agent style sheets
 
@@ -172,8 +177,9 @@ CharsetData.cpp : platform/make-charset-table.pl platform/character-sets.txt $(E
 %Table.cpp: %.cpp $(CREATE_HASH_TABLE)
        $(CREATE_HASH_TABLE) $< > $@
 
-# SVG tag and attribute names
+ifeq ($(findstring SVG_SUPPORT,$(FEATURE_DEFINES)), SVG_SUPPORT)
 
+# SVG tag and attribute names
 SVGNames.cpp : ksvg2/scripts/make_names.pl ksvg2/svg/svgtags.in ksvg2/svg/svgattrs.in
        $< --tags $(WebCore)/ksvg2/svg/svgtags.in --attrs $(WebCore)/ksvg2/svg/svgattrs.in \
             --namespace SVG --cppNamespace WebCore --namespaceURI "http://www.w3.org/2000/svg" --factory --attrsNullNamespace --output .
@@ -196,6 +202,22 @@ ksvgcssvalues.h : ksvg2/scripts/cssmakevalues css/CSSValueKeywords.in ksvg2/css/
        perl -ne 'print lc' $(WebCore)/ksvg2/css/CSSValueKeywords.in > ksvgcssvalues.in
        $(WebCore)/ksvg2/scripts/cssmakevalues -n SVG -f ksvgcssvalues.in
 
+else
+
+SVGNames.cpp :
+       echo > SVGNames.cpp
+
+XLinkNames.cpp :
+       echo > XLinkNames.cpp
+       
+ksvgcssproperties.h :
+       echo > ksvgcssproperties.h
+
+ksvgcssvalues.h :
+       echo > ksvgcssvalues.h
+
+endif
+
 # new-style JavaScript bindings
 
 JS_BINDINGS_SCRIPTS = \
@@ -207,4 +229,4 @@ JS_BINDINGS_SCRIPTS = \
 #
 
 JS%.h : %.idl $(JS_BINDINGS_SCRIPTS)
-       perl -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/generate-bindings.pl --generator JS --include dom --include html --include xpath --outputdir  . $<
+       perl -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/generate-bindings.pl --defines "$(FEATURE_DEFINES)" --generator JS --include dom --include html --include xpath --outputdir  . $<
index 461bd806284bcd1bcfbee61929d143025839e48c..8cb1c001af759a3ffbcf72acd1497d92557524e8 100644 (file)
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "if [ \"${BUILD_STYLE}\" = \"Release\" -o \"${BUILD_STYLE}\" = \"Debug\" ] ; then\n    export CREATE_HASH_TABLE=\"${BUILT_PRODUCTS_DIR}/JavaScriptCore.framework/PrivateHeaders/create_hash_table\"\nelse\n    export CREATE_HASH_TABLE=\"${NEXT_ROOT}${SYSTEM_LIBRARY_DIR}/Frameworks/WebKit.framework/Versions/A/Frameworks/JavaScriptCore.framework/PrivateHeaders/create_hash_table\"\nfi\n\nmkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\"\ncd \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\"\n\nexport WebCore=\"${SRCROOT}\"\n\nexport ENCODINGS_FILE=\"${WebCore}/platform/mac/mac-encodings.txt\"\nexport ENCODINGS_PREFIX=\"kCFStringEncoding\"\n\nmake -f \"$WebCore/DerivedSources.make\"\n";
+                       shellScript = "if [ \"${BUILD_STYLE}\" = \"Release\" -o \"${BUILD_STYLE}\" = \"Debug\" ] ; then\n    export CREATE_HASH_TABLE=\"${BUILT_PRODUCTS_DIR}/JavaScriptCore.framework/PrivateHeaders/create_hash_table\"\nelse\n    export CREATE_HASH_TABLE=\"${NEXT_ROOT}${SYSTEM_LIBRARY_DIR}/Frameworks/WebKit.framework/Versions/A/Frameworks/JavaScriptCore.framework/PrivateHeaders/create_hash_table\"\nfi\n\nmkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\"\ncd \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\"\n\nexport WebCore=\"${SRCROOT}\"\n\nexport ENCODINGS_FILE=\"${WebCore}/platform/mac/mac-encodings.txt\"\nexport ENCODINGS_PREFIX=\"kCFStringEncoding\"\n\nif [ \"${ACTION}\" = \"build\" ]; then\n\tmake -f \"$WebCore/DerivedSources.make\"\nfi\n";
                };
 /* End PBXShellScriptBuildPhase section */
 
                                GCC_PREFIX_HEADER = WebCorePrefix.h;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(DEBUG_DEFINES)",
-                                       SVG_SUPPORT,
-                                       XPATH_SUPPORT,
+                                       "$(FEATURE_DEFINES)",
                                );
                                HEADER_SEARCH_PATHS = (
                                        ForwardingHeaders,
                                GCC_PREFIX_HEADER = WebCorePrefix.h;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(DEBUG_DEFINES)",
-                                       SVG_SUPPORT,
-                                       XPATH_SUPPORT,
+                                       "$(FEATURE_DEFINES)",
                                );
                                HEADER_SEARCH_PATHS = (
                                        ForwardingHeaders,
                                GCC_PREFIX_HEADER = WebCorePrefix.h;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(DEBUG_DEFINES)",
-                                       SVG_SUPPORT,
-                                       XPATH_SUPPORT,
+                                       "$(FEATURE_DEFINES)",
                                );
                                HEADER_SEARCH_PATHS = (
                                        ForwardingHeaders,
                149C284408902B11008A9EFC /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               FEATURE_DEFINES = "SVG_SUPPORT XPATH_SUPPORT";
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
                                GCC_ENABLE_CPP_RTTI = NO;
                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
                149C284508902B11008A9EFC /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               FEATURE_DEFINES = "SVG_SUPPORT XPATH_SUPPORT";
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
                                GCC_ENABLE_CPP_RTTI = NO;
                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
                149C284708902B11008A9EFC /* Production */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               FEATURE_DEFINES = "SVG_SUPPORT XPATH_SUPPORT";
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
                                GCC_ENABLE_CPP_RTTI = NO;
                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
index 3af9528e3033a0721f38a797c41e0d6897af5270..6cef30f91f3c53418a31eb13c2d49d63a5c05c97 100644 (file)
@@ -299,10 +299,12 @@ static const char * const eventExceptionNames[] = {
     "UNSPECIFIED_EVENT_TYPE_ERR"
 };
 
+#if XPATH_SUPPORT
 static const char * const xpathExceptionNames[] = {
     "INVALID_EXPRESSION_ERR",
     "TYPE_ERR"
 };
+#endif
 
 void setDOMException(ExecState* exec, ExceptionCode ec)
 {
@@ -328,6 +330,7 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     nameIndex = code;
     nameTable = eventExceptionNames;
     nameTableSize = sizeof(eventExceptionNames) / sizeof(eventExceptionNames[0]);
+#if XPATH_SUPPORT
   } else if (code >= XPathExceptionOffset && code <= XPathExceptionMax) {
     type = "DOM XPath";
     // XPath exception codes start with 51 and we don't want 51 empty elements in the name array
@@ -335,6 +338,7 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     code -= XPathExceptionOffset;
     nameTable = xpathExceptionNames;
     nameTableSize = sizeof(xpathExceptionNames) / sizeof(xpathExceptionNames[0]);
+#endif
   } else {
     nameIndex = code;
     nameTable = exceptionNames;
index aed26ac712c14cbf9766dcb70a290a6ed9c3af79..9010ea134f5cd943672dbb12bed35ab6203f576d 100644 (file)
@@ -192,6 +192,7 @@ sub GenerateHeader
   my $hasRealParent = @{$dataNode->parents} > 0;
   my $hasParent = $hasLegacyParent || $hasRealParent;
   my $parentClassName = GetParentClassName($dataNode);
+  my $conditional = $dataNode->extendedAttributes->{"Conditional"};
   
   # - Add default header template
   @headerContent = split("\r", $headerTemplate);
@@ -200,6 +201,8 @@ sub GenerateHeader
   push(@headerContent, "\n#ifndef $className" . "_H");
   push(@headerContent, "\n#define $className" . "_H\n\n");
   
+  push(@headerContent, "#if ${conditional}_SUPPORT\n\n") if $conditional;
+  
   if (exists $dataNode->extendedAttributes->{"LegacyParent"}) {
     push(@headerContent, GetLegacyHeaderIncludes($dataNode->extendedAttributes->{"LegacyParent"}));
   } else {
@@ -359,7 +362,11 @@ sub GenerateHeader
   }
   push(@headerContent, "};\n\n");
   
-  push(@headerContent, "}\n\n#endif\n");
+  push(@headerContent, "}\n\n");
+
+  push(@headerContent, "#endif // ${conditional}_SUPPORT\n\n") if $conditional;
+  
+  push(@headerContent, "#endif\n");
 }
 
 sub GenerateImplementation
@@ -375,14 +382,17 @@ sub GenerateImplementation
   my $hasRealParent = @{$dataNode->parents} > 0;
   my $hasParent = $hasLegacyParent || $hasRealParent;
   my $parentClassName = GetParentClassName($dataNode);
+  my $conditional = $dataNode->extendedAttributes->{"Conditional"};
   
   # - Add default header template
   @implContentHeader = split("\r", $headerTemplate);
   push(@implContentHeader, "\n");
-  push(@implContentHeader,, "#include \"config.h\"\n");
+  push(@implContentHeader,, "#include \"config.h\"\n\n");
+  
+  push(@implContentHeader, "#if ${conditional}_SUPPORT\n\n") if $conditional;
+  
   push(@implContentHeader, "#include \"$className.h\"\n\n");
 
-
   AddIncludesForType($interfaceName);
 
   @implContent = ();
@@ -752,6 +762,8 @@ sub GenerateImplementation
   }
 
   push(@implContent, "\n}\n");
+    
+  push(@implContent, "\n#endif // ${conditional}_SUPPORT\n") if $conditional;
 }
 
 sub GetNativeType
index 15d93d0aadd809ec846edb6512b288173d4294be..e1d34b401de36fd34bef05e1a6d7399b8fd92dd4 100644 (file)
@@ -59,9 +59,12 @@ sub Parse
 {
   my $object = shift;
   my $fileName = shift;
-
+  my $defines = shift;
+  
   print " | *** Starting to parse $fileName...\n |\n" if(!$beQuiet);
-  open FILE, "-|", "/usr/bin/gcc", "-E", "-P", "-x", "c++", $fileName or die "Could not open $fileName";
+
+  open FILE, "-|", "/usr/bin/gcc", "-E", "-P", "-x", "c++", 
+      (map { "-D$_" } split(/ /, $defines)), $fileName or die "Could not open $fileName";
   my @documentContent = <FILE>;
   close FILE;
 
index f4f37b8d44f47df20798fa69d09e3ea3b0d954f9..c709df38db53bc79e07f94fd664b8b7dd527a645 100755 (executable)
@@ -40,10 +40,12 @@ use CodeGenerator;
 my @idlDirectories;
 my $outputDirectory;
 my $generator;
+my $defines;
 
 GetOptions('include=s@' => \@idlDirectories,
            'outputdir=s' => \$outputDirectory,
-           'generator=s' => \$generator);
+           'generator=s' => \$generator,
+                  'defines=s' => \$defines);
 
 my $idlFile = $ARGV[0];
 
@@ -52,12 +54,12 @@ die('Must specify IDL search path.') unless @idlDirectories;
 die('Must specify generator') unless defined($generator);
 die('Must specify input file.') unless defined($idlFile);
 die('Must specify output directory.') unless defined($outputDirectory);
+die('Must specify defines') unless defined($defines);
 
 
 # Parse the given IDL file.
 my $parser = IDLParser->new(1);
-       
-my $document = $parser->Parse($idlFile);
+my $document = $parser->Parse($idlFile, $defines);
        
 # Generate desired output for given IDL file.
 my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory);
index 7c84976fbb9a2cbe4ecdebe2c443fae7cca52a63..245c86b2b114085ca54bb05a735267697431154c 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef CSS_cssstyleselector_h_
 #define CSS_cssstyleselector_h_
 
+#include "DeprecatedString.h"
 #include "render_style.h"
 
 class KHTMLSettings;
index 02870d533a02a007bb758fe51c498fce67da2c77..9381b9e22b48f9c06e5e6e0f7d3c73443cd1c3df 100644 (file)
@@ -114,6 +114,7 @@ module core {
         Node adoptNode(in Node source)
             raises (DOMException);
 
+#if XPATH_SUPPORT
         // DOM Level 3 XPath (XPathEvaluator interface)
         XPathExpression createExpression(in DOMString expression,
                                          in XPathNSResolver resolver)
@@ -127,6 +128,7 @@ module core {
                              in unsigned short type,
                              in XPathResult inResult)
             raises(DOMException);
+#endif
 
         // Common extensions
 
index c21e991c8eccd6753d8a06fb612a225f21cbe1c1..7ad620f48a55908684811ee01570af0ffe33a1c9 100644 (file)
@@ -59,9 +59,11 @@ module window {
         // Mozilla has a separate XMLDocument object for XML documents. 
         // We just use Document for this.
         attribute DocumentConstructor XMLDocument;
-
+        
+#if XPATH_SUPPORT
         attribute XPathEvaluatorConstructor XPathEvaluator;
         attribute XPathResultConstructor XPathResult;
+#endif
     };
 
 }
index 56ccae608ad39f7b97b81d9320dd7a8d4fab264f..2ab0c798993d4de21e27bc83d8dbe84d5c8fa5fa 100644 (file)
@@ -18,8 +18,7 @@
  */
 
 module xpath {
-
-    interface [GenerateConstructor, CanBeConstructed] XPathEvaluator {
+    interface [GenerateConstructor, CanBeConstructed, Conditional=XPATH] XPathEvaluator {
         XPathExpression createExpression(in DOMString expression,
                                          in XPathNSResolver resolver)
             raises(core::DOMException);
index 80052c46f80d73ec02503abd8491d51a6e697399..5082aad92ac2d478891324e34d8524671a5e6e82 100644 (file)
@@ -19,7 +19,7 @@
 
 module xpath {
 
-    interface XPathExpression {
+    interface [Conditional=XPATH] XPathExpression {
         XPathResult evaluate(in Node contextNode, 
                              in unsigned short type, 
                              in XPathResult inResult)
index 3d1631b3b5dae776670eef19404549c5318abaf7..61eec4953dd7beba406ec31f18852fad3287fe7b 100644 (file)
@@ -47,7 +47,6 @@ String XPathNSResolver::lookupNamespaceURI(const String& prefix)
     return m_node ? m_node->lookupNamespaceURI(prefix) : String();
 }
 
-#endif // XPATH_SUPPORT
-
 }
 
+#endif // XPATH_SUPPORT
index 084719d5e080425bec9a88c8655d8b95b298f50b..408384e5a98907ec582a7f341e7ddd39ce243c43 100644 (file)
@@ -19,7 +19,7 @@
 
 module xpath {
 
-    interface XPathNSResolver {
+    interface [Conditional=XPATH] XPathNSResolver {
         DOMString lookupNamespaceURI(in DOMString prefix);
     };
 }
index 071c1fa2d191eaff90be12054d52ff81782d1e72..d9df00843887b1e68e8df9a0a8b07e4d0bf6e5a0 100644 (file)
@@ -79,7 +79,7 @@ Node::NodeType XPathNamespace::nodeType() const
     return Node::XPATH_NAMESPACE_NODE;
 }
 
-#endif // XPATH_SUPPORT
-
 }
 
+#endif // XPATH_SUPPORT
+
index b79b0d52b2d3a78daad81dae74c971d0d3347073..53370fdd1ea72cec41b6b9879c594733093468dd 100644 (file)
@@ -19,7 +19,7 @@
 
 module xpath {
 
-    interface [GenerateConstructor] XPathResult {
+    interface [GenerateConstructor, Conditional=XPATH] XPathResult {
         const unsigned short ANY_TYPE                       = 0;
         const unsigned short NUMBER_TYPE                    = 1;
         const unsigned short STRING_TYPE                    = 2;