Commit ba7d5c7e authored by mahesh.kk@samsung.com's avatar mahesh.kk@samsung.com

Add support in generate scripts to handle Conditional

WEB_AUDIO and SVG_FONTS conditions in tagName files were 
handled by generate scripts and this CL adds the support. 
This fix was also needed to build without SVG_FONTS enabled.

Review URL: https://codereview.chromium.org/330093002

git-svn-id: svn://svn.chromium.org/blink/trunk@176249 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b4ff3562
...@@ -40,6 +40,7 @@ from make_qualified_names import MakeQualifiedNamesWriter ...@@ -40,6 +40,7 @@ from make_qualified_names import MakeQualifiedNamesWriter
class MakeElementFactoryWriter(MakeQualifiedNamesWriter): class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{ defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{
'JSInterfaceName': None, 'JSInterfaceName': None,
'Conditional': None,
'constructorNeedsCreatedByParser': None, 'constructorNeedsCreatedByParser': None,
'constructorNeedsFormElement': None, 'constructorNeedsFormElement': None,
'contextConditional': None, 'contextConditional': None,
......
...@@ -22,9 +22,7 @@ def _symbol(tag): ...@@ -22,9 +22,7 @@ def _symbol(tag):
class MakeElementTypeHelpersWriter(in_generator.Writer): class MakeElementTypeHelpersWriter(in_generator.Writer):
defaults = { defaults = {
'interfaceName': None, 'Conditional': None,
'noConstructor': None,
'noTypeHelpers': None,
'ImplementedAs': None, 'ImplementedAs': None,
'JSInterfaceName': None, 'JSInterfaceName': None,
'constructorNeedsCreatedByParser': None, 'constructorNeedsCreatedByParser': None,
...@@ -32,17 +30,20 @@ class MakeElementTypeHelpersWriter(in_generator.Writer): ...@@ -32,17 +30,20 @@ class MakeElementTypeHelpersWriter(in_generator.Writer):
'contextConditional': None, 'contextConditional': None,
'interfaceName': None, 'interfaceName': None,
'noConstructor': None, 'noConstructor': None,
'noConstructor': None,
'noTypeHelpers': None,
'runtimeEnabled': None, 'runtimeEnabled': None,
} }
default_parameters = { default_parameters = {
'attrsNullNamespace': None, 'attrsNullNamespace': None,
'fallbackInterfaceName': '',
'namespace': '', 'namespace': '',
'namespacePrefix': '', 'namespacePrefix': '',
'namespaceURI': '', 'namespaceURI': '',
'fallbackInterfaceName': '',
'fallbackJSInterfaceName': '', 'fallbackJSInterfaceName': '',
} }
filters = { filters = {
'enable_conditional': name_utilities.enable_conditional_if_endif,
'hash': hasher.hash, 'hash': hasher.hash,
'symbol': _symbol, 'symbol': _symbol,
} }
......
...@@ -46,17 +46,18 @@ def _symbol(entry): ...@@ -46,17 +46,18 @@ def _symbol(entry):
class MakeNamesWriter(in_generator.Writer): class MakeNamesWriter(in_generator.Writer):
defaults = { defaults = {
'Conditional': None, # FIXME: Add support for Conditional. 'Conditional': None, # FIXME: Add support for Conditional.
'RuntimeEnabled': None, # What should we do for runtime-enabled features?
'ImplementedAs': None, 'ImplementedAs': None,
'RuntimeEnabled': None, # What should we do for runtime-enabled features?
'Symbol': None, 'Symbol': None,
} }
default_parameters = { default_parameters = {
'export': '',
'namespace': '', 'namespace': '',
'suffix': '', 'suffix': '',
'export': '',
} }
filters = { filters = {
'cpp_name': name_utilities.cpp_name, 'cpp_name': name_utilities.cpp_name,
'enable_conditional': name_utilities.enable_conditional_if_endif,
'hash': hasher.hash, 'hash': hasher.hash,
'script_name': name_utilities.script_name, 'script_name': name_utilities.script_name,
'symbol': _symbol, 'symbol': _symbol,
......
...@@ -55,8 +55,9 @@ class MakeQualifiedNamesWriter(in_generator.Writer): ...@@ -55,8 +55,9 @@ class MakeQualifiedNamesWriter(in_generator.Writer):
} }
filters = { filters = {
'hash': hasher.hash, 'hash': hasher.hash,
'to_macro_style': name_utilities.to_macro_style, 'enable_conditional': name_utilities.enable_conditional_if_endif,
'symbol': _symbol, 'symbol': _symbol,
'to_macro_style': name_utilities.to_macro_style,
} }
def __init__(self, in_file_paths): def __init__(self, in_file_paths):
......
...@@ -35,6 +35,7 @@ typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; ...@@ -35,6 +35,7 @@ typedef HashMap<AtomicString, ConstructorFunction> FunctionMap;
static FunctionMap* g_constructors = 0; static FunctionMap* g_constructors = 0;
{% for tag in tags|sort if not tag.noConstructor %} {% for tag in tags|sort if not tag.noConstructor %}
{% filter enable_conditional(tag.Conditional) %}
static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor( static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor(
Document& document, Document& document,
{% if namespace == 'HTML' %} {% if namespace == 'HTML' %}
...@@ -57,6 +58,7 @@ static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor( ...@@ -57,6 +58,7 @@ static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor(
{%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%} {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%}
); );
} }
{% endfilter %}
{% endfor %} {% endfor %}
struct Create{{namespace}}FunctionMapData { struct Create{{namespace}}FunctionMapData {
...@@ -68,9 +70,13 @@ static void create{{namespace}}FunctionMap() ...@@ -68,9 +70,13 @@ static void create{{namespace}}FunctionMap()
{ {
ASSERT(!g_constructors); ASSERT(!g_constructors);
g_constructors = new FunctionMap; g_constructors = new FunctionMap;
// Empty array initializer lists are illegal [dcl.init.aggr] and will not
// compile in MSVC. If tags list is empty, add check to skip this.
static const Create{{namespace}}FunctionMapData data[] = { static const Create{{namespace}}FunctionMapData data[] = {
{% for tag in tags|sort if not tag.noConstructor %} {% for tag in tags|sort if not tag.noConstructor %}
{% filter enable_conditional(tag.Conditional) %}
{ {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, { {{tag|symbol}}Tag, {{tag|symbol}}Constructor },
{% endfilter %}
{% endfor %} {% endfor %}
}; };
for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace WebCore { namespace WebCore {
// Type checking. // Type checking.
{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
{% filter enable_conditional(tag.Conditional) %}
class {{tag.interface}}; class {{tag.interface}};
void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time. void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time.
void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time. void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time.
...@@ -51,13 +52,15 @@ template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& ...@@ -51,13 +52,15 @@ template <> inline bool isElementOfType<const {{tag.interface}}>(const Element&
{% if namespace == "HTML" %} {% if namespace == "HTML" %}
template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLElement& element) { return is{{tag.interface}}(element); } template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLElement& element) { return is{{tag.interface}}(element); }
{% endif %} {% endif %}
{% endfilter %}
{% endfor %} {% endfor %}
// Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the
// casting functions above. reinterpret_cast would be unsafe due to multiple inheritence. // casting functions above. reinterpret_cast would be unsafe due to multiple inheritence.
{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
{% filter enable_conditional(tag.Conditional) %}
#define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x) #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x)
{% endfilter %}
{% endfor %} {% endfor %}
} // WebCore } // WebCore
......
...@@ -31,6 +31,7 @@ static v8::Handle<v8::Object> create{{namespace}}ElementWrapper({{namespace}}Ele ...@@ -31,6 +31,7 @@ static v8::Handle<v8::Object> create{{namespace}}ElementWrapper({{namespace}}Ele
return v8::Handle<v8::Object>(); return v8::Handle<v8::Object>();
} }
{% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('js_interface') %} {% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('js_interface') %}
{% filter enable_conditional(list[0].Conditional) %}
static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{ {
{% if list[0].contextConditional %} {% if list[0].contextConditional %}
...@@ -43,6 +44,7 @@ static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element ...@@ -43,6 +44,7 @@ static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element
{% endif %} {% endif %}
return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolate); return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolate);
} }
{% endfilter %}
{% endfor %} {% endfor %}
v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
...@@ -51,7 +53,9 @@ v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* elemen ...@@ -51,7 +53,9 @@ v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* elemen
DEFINE_STATIC_LOCAL(FunctionMap, map, ()); DEFINE_STATIC_LOCAL(FunctionMap, map, ());
if (map.isEmpty()) { if (map.isEmpty()) {
{% for tag in tags|sort %} {% for tag in tags|sort %}
{% filter enable_conditional(tag.Conditional) %}
map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}}Wrapper); map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}}Wrapper);
{% endfilter %}
{% endfor %} {% endfor %}
} }
...@@ -78,7 +82,9 @@ const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString ...@@ -78,7 +82,9 @@ const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString
// FIXME: This seems wrong. We should list every interface here, not // FIXME: This seems wrong. We should list every interface here, not
// just the ones that have specialized JavaScript interfaces. // just the ones that have specialized JavaScript interfaces.
{% for tag in tags|sort if tag.has_js_interface %} {% for tag in tags|sort if tag.has_js_interface %}
{% filter enable_conditional(tag.Conditional) %}
map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::wrapperTypeInfo); map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::wrapperTypeInfo);
{% endfilter %}
{% endfor %} {% endfor %}
} }
......
...@@ -17,22 +17,28 @@ namespace {{namespace}}Names { ...@@ -17,22 +17,28 @@ namespace {{namespace}}Names {
using namespace WTF; using namespace WTF;
{% for entry in entries|sort %} {% for entry in entries|sort %}
{% filter enable_conditional(entry.Conditional) %}
{% if export %} {% if export %}
DEFINE_GLOBAL(AtomicString, {{entry|symbol}}Storage) DEFINE_GLOBAL(AtomicString, {{entry|symbol}}Storage)
{{export}} const AtomicString& {{entry|symbol}} = *reinterpret_cast<const AtomicString*>(&{{entry|symbol}}Storage); {{export}} const AtomicString& {{entry|symbol}} = *reinterpret_cast<const AtomicString*>(&{{entry|symbol}}Storage);
{% else %} {% else %}
DEFINE_GLOBAL(AtomicString, {{entry|symbol}}) DEFINE_GLOBAL(AtomicString, {{entry|symbol}})
{% endif %} {% endif %}
{% endfilter %}
{% endfor %} {% endfor %}
void init{{suffix}}() void init{{suffix}}()
{ {
{% for entry in entries|sort %} {% for entry in entries|sort %}
{% filter enable_conditional(entry.Conditional) %}
StringImpl* {{entry|symbol}}Impl = StringImpl::createStatic("{{entry|cpp_name}}", {{entry|cpp_name|length}}, {{entry|cpp_name|hash}}); StringImpl* {{entry|symbol}}Impl = StringImpl::createStatic("{{entry|cpp_name}}", {{entry|cpp_name|length}}, {{entry|cpp_name|hash}});
{% endfilter %}
{% endfor %} {% endfor %}
{% for entry in entries|sort %} {% for entry in entries|sort %}
{% filter enable_conditional(entry.Conditional) %}
new ((void*)&{{entry|symbol}}) AtomicString({{entry|symbol}}Impl); new ((void*)&{{entry|symbol}}) AtomicString({{entry|symbol}}Impl);
{% endfilter %}
{% endfor %} {% endfor %}
} }
......
...@@ -19,11 +19,13 @@ namespace {{namespace}}Names { ...@@ -19,11 +19,13 @@ namespace {{namespace}}Names {
#ifndef {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS #ifndef {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS
{% for entry in entries|sort %} {% for entry in entries|sort %}
{% filter enable_conditional(entry.Conditional) %}
{% if export %} {% if export %}
{{export}} extern const WTF::AtomicString& {{entry|symbol}}; {{export}} extern const WTF::AtomicString& {{entry|symbol}};
{% else %} {% else %}
extern const WTF::AtomicString {{entry|symbol}}; extern const WTF::AtomicString {{entry|symbol}};
{% endif %} {% endif %}
{% endfilter %}
{% endfor %} {% endfor %}
#endif // {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS #endif // {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS
......
...@@ -4,11 +4,9 @@ fallbackInterfaceName="SVGUnknownElement" ...@@ -4,11 +4,9 @@ fallbackInterfaceName="SVGUnknownElement"
fallbackJSInterfaceName="SVGElement" fallbackJSInterfaceName="SVGElement"
a a
#if ENABLE_SVG_FONTS altGlyph Conditional=SVG_FONTS
altGlyph altGlyphDef Conditional=SVG_FONTS
altGlyphDef altGlyphItem Conditional=SVG_FONTS
altGlyphItem
#endif
animate noTypeHelpers animate noTypeHelpers
animateColor interfaceName=SVGUnknownElement, JSInterfaceName=SVGElement, noConstructor animateColor interfaceName=SVGUnknownElement, JSInterfaceName=SVGElement, noConstructor
animateMotion animateMotion
...@@ -47,30 +45,24 @@ feSpotLight ...@@ -47,30 +45,24 @@ feSpotLight
feTile feTile
feTurbulence feTurbulence
filter filter
#if ENABLE_SVG_FONTS font Conditional=SVG_FONTS
font font-face Conditional=SVG_FONTS
font-face font-face-format Conditional=SVG_FONTS
font-face-format font-face-name Conditional=SVG_FONTS
font-face-name font-face-src Conditional=SVG_FONTS
font-face-src font-face-uri Conditional=SVG_FONTS
font-face-uri
#endif
foreignObject foreignObject
g g
#if ENABLE_SVG_FONTS glyph Conditional=SVG_FONTS
glyph glyphRef Conditional=SVG_FONTS
glyphRef hkern Conditional=SVG_FONTS, interfaceName=SVGHKernElement
hkern interfaceName=SVGHKernElement
#endif
image image
line line
linearGradient linearGradient
marker marker
mask mask
metadata metadata
#if ENABLE_SVG_FONTS missing-glyph Conditional=SVG_FONTS
missing-glyph
#endif
mpath interfaceName=SVGMPathElement mpath interfaceName=SVGMPathElement
path path
pattern pattern
...@@ -90,6 +82,4 @@ title ...@@ -90,6 +82,4 @@ title
tspan interfaceName=SVGTSpanElement tspan interfaceName=SVGTSpanElement
use use
view view
#if ENABLE_SVG_FONTS vkern Conditional=SVG_FONTS, interfaceName=SVGVKernElement
vkern interfaceName=SVGVKernElement
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment