[CodeGeneratorJS] Standalone dictionaries have misplaced build guards
https://bugs.webkit.org/show_bug.cgi?id=163881
Patch by Zan Dobersek <zdobersek@igalia.com> on 2016-10-24
Reviewed by Chris Dumez.
Build guards that are generated from the Conditional attribute
on WebIDL dictionary declarations properly guard the relevant
convertDictionary() functions for WebIDL files that also specify
interfaces. But for standalone dictionaries these build guards
should guard the complete header and implementation files, much
like this is done for files that originate from interfaces or
callbacks.
Before this patch, guarding a standalone dictionary resulted in
malformed output because GenerateHeaderContentHeader() and
GenerateImplementationContentHeader() functions both generated
the #if macro that would guard the whole file, but
GenerateDictionary{Header,Implementation}() didn't generate the
closing #endif.
CodeGeneratorJS.pm now passes the conditional string, if any,
to GenerateDictionary{Header,Implementation}Content() functions
in case of a non-standalone dictionary. Otherwise, the
conditional string, if any, is used to guard the complete
header and implementation files.
Generator tests are updated to cover various build guard
combinations on dictionaries in TestObj.idl, and the standalone
dictionary WebIDL file now has a Conditional attribute to check
that the build guards cover complete generated header and
implementation files.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryHeaderContent):
(GenerateDictionariesHeaderContent):
(GenerateDictionaryImplementationContent):
(GenerateDictionariesImplementationContent):
(GenerateDictionaryHeader):
(GenerateDictionaryImplementation):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::convertDictionary<TestObj::ConditionalDictionaryA>):
(WebCore::convertDictionary<TestObj::ConditionalDictionaryB>):
(WebCore::convertDictionary<TestObj::ConditionalDictionaryC>):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.h:
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/TestStandaloneDictionary.idl:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@207766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
index 0b4ea8d..6418775 100644
--- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
+++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
@@ -184,5 +184,23 @@
template<> TestObj::ChildDictionary convertDictionary<TestObj::ChildDictionary>(JSC::ExecState&, JSC::JSValue);
+#if ENABLE(Condition1)
+
+template<> TestObj::ConditionalDictionaryA convertDictionary<TestObj::ConditionalDictionaryA>(JSC::ExecState&, JSC::JSValue);
+
+#endif
+
+#if ENABLE(Condition1) && ENABLE(Condition2)
+
+template<> TestObj::ConditionalDictionaryB convertDictionary<TestObj::ConditionalDictionaryB>(JSC::ExecState&, JSC::JSValue);
+
+#endif
+
+#if ENABLE(Condition1) || ENABLE(Condition2)
+
+template<> TestObj::ConditionalDictionaryC convertDictionary<TestObj::ConditionalDictionaryC>(JSC::ExecState&, JSC::JSValue);
+
+#endif
+
} // namespace WebCore