Chromium Code Reviews| Index: Source/bindings/scripts/v8_dictionary.py |
| diff --git a/Source/bindings/scripts/v8_dictionary.py b/Source/bindings/scripts/v8_dictionary.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5cb273a9dfc841d0ac6ef1f0d2d96c809f04c5a3 |
| --- /dev/null |
| +++ b/Source/bindings/scripts/v8_dictionary.py |
| @@ -0,0 +1,82 @@ |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Generate template contexts of dictionaries for both v8 bindings and |
| +implementation classes that are used by blink's core/modules. |
| +""" |
| + |
| +import operator |
| +from v8_globals import includes |
| +import v8_types |
| +import v8_utilities |
| + |
| + |
| +DICTIONARY_H_INCLUDES_V8 = frozenset([ |
|
haraken
2014/07/23 15:49:01
DICTIONARY_H_INCLUDES_V8 => DICTIONARY_H_INCLUDES
bashi
2014/07/25 01:59:02
Done.
|
| + 'bindings/core/v8/V8Binding.h', |
| + 'platform/heap/Handle.h', |
| +]) |
| + |
| +DICTIONARY_CPP_INCLUDES_V8 = frozenset([ |
|
haraken
2014/07/23 15:49:01
DICTIONARY_CPP_INCLUDES_V8 => DICTIONARY_CPP_INCLU
bashi
2014/07/25 01:59:02
Done.
|
| + # FIXME: Remove this, http://crbug.com/321462 |
| + 'bindings/core/v8/Dictionary.h', |
| +]) |
| + |
| + |
| +def setter_name_for_dictionary_member(member): |
| + return 'set%s' % v8_utilities.capitalize(member.name) |
| + |
| + |
| +def has_name_for_dictionary_member(member): |
| + return 'has%s' % v8_utilities.capitalize(member.name) |
| + |
| + |
| +# Context for V8 bindings |
| + |
| + |
|
haraken
2014/07/23 15:49:01
Unnecessary empty lines.
bashi
2014/07/25 01:59:02
Done.
|
| +def dictionary_context_v8(dictionary): |
|
haraken
2014/07/23 15:49:01
dictionary_context_v8 => dictionary_context ?
I t
bashi
2014/07/25 01:59:02
Done.
|
| + includes.clear() |
| + includes.update(DICTIONARY_CPP_INCLUDES_V8) |
| + return { |
| + 'cpp_class': v8_utilities.cpp_name(dictionary), |
| + 'header_includes': set(DICTIONARY_H_INCLUDES_V8), |
| + 'members': [member_context_v8(member) |
| + for member in sorted(dictionary.members, |
| + key=operator.attrgetter('name'))], |
| + 'v8_class': v8_utilities.v8_class_name(dictionary), |
| + } |
| + |
| + |
| +def member_context_v8(member): |
|
haraken
2014/07/23 15:49:01
member_context_v8 => member_context ?
bashi
2014/07/25 01:59:02
Done.
|
| + idl_type = member.idl_type |
| + idl_type.add_includes_for_type() |
| + |
| + def default_values(): |
| + if not member.default_value: |
| + return None, None |
| + if member.default_value.is_null: |
|
haraken
2014/07/23 15:49:01
Just help me understand: When do we hit this branc
bashi
2014/07/25 01:59:02
dictionary {
double? doubleOrNullMember = null;
|
| + return None, 'v8::Null(isolate)' |
| + default_value = str(member.default_value) |
|
haraken
2014/07/23 15:49:01
default_value => cpp_default_value
bashi
2014/07/25 01:59:02
Done.
|
| + v8_default_value = idl_type.cpp_value_to_v8_value( |
| + cpp_value=default_value, isolate='isolate', |
| + creation_context='creationContext', |
| + extended_attributes=member.extended_attributes) |
| + return default_value, v8_default_value |
| + |
| + default_value, v8_default_value = default_values() |
|
haraken
2014/07/23 15:49:01
decalut_value => cpp_decault_value
bashi
2014/07/25 01:59:02
Done.
|
| + |
| + return { |
| + 'cpp_type': idl_type.cpp_type, |
| + 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
| + cpp_value='impl->%s()' % member.name, isolate='isolate', |
| + creation_context='creationContext', |
| + extended_attributes=member.extended_attributes), |
| + 'default_value': default_value, |
| + 'has_name': has_name_for_dictionary_member(member), |
| + 'name': member.name, |
| + 'setter_name': setter_name_for_dictionary_member(member), |
| + 'v8_default_value': v8_default_value, |
| + 'v8_type': v8_types.v8_type(idl_type.base_type), |
| + } |
| + |
| +# FIXME: Implement context for impl class. |