Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Side by Side Diff: Source/bindings/scripts/v8_dictionary.py

Issue 409373002: IDL: Binding code generation for dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Generate template contexts of dictionaries for both v8 bindings and
6 implementation classes that are used by blink's core/modules.
7 """
8
9 import operator
10 from v8_globals import includes
11 import v8_types
12 import v8_utilities
13
14
15 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.
16 'bindings/core/v8/V8Binding.h',
17 'platform/heap/Handle.h',
18 ])
19
20 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.
21 # FIXME: Remove this, http://crbug.com/321462
22 'bindings/core/v8/Dictionary.h',
23 ])
24
25
26 def setter_name_for_dictionary_member(member):
27 return 'set%s' % v8_utilities.capitalize(member.name)
28
29
30 def has_name_for_dictionary_member(member):
31 return 'has%s' % v8_utilities.capitalize(member.name)
32
33
34 # Context for V8 bindings
35
36
haraken 2014/07/23 15:49:01 Unnecessary empty lines.
bashi 2014/07/25 01:59:02 Done.
37 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.
38 includes.clear()
39 includes.update(DICTIONARY_CPP_INCLUDES_V8)
40 return {
41 'cpp_class': v8_utilities.cpp_name(dictionary),
42 'header_includes': set(DICTIONARY_H_INCLUDES_V8),
43 'members': [member_context_v8(member)
44 for member in sorted(dictionary.members,
45 key=operator.attrgetter('name'))],
46 'v8_class': v8_utilities.v8_class_name(dictionary),
47 }
48
49
50 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.
51 idl_type = member.idl_type
52 idl_type.add_includes_for_type()
53
54 def default_values():
55 if not member.default_value:
56 return None, None
57 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;
58 return None, 'v8::Null(isolate)'
59 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.
60 v8_default_value = idl_type.cpp_value_to_v8_value(
61 cpp_value=default_value, isolate='isolate',
62 creation_context='creationContext',
63 extended_attributes=member.extended_attributes)
64 return default_value, v8_default_value
65
66 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.
67
68 return {
69 'cpp_type': idl_type.cpp_type,
70 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
71 cpp_value='impl->%s()' % member.name, isolate='isolate',
72 creation_context='creationContext',
73 extended_attributes=member.extended_attributes),
74 'default_value': default_value,
75 'has_name': has_name_for_dictionary_member(member),
76 'name': member.name,
77 'setter_name': setter_name_for_dictionary_member(member),
78 'v8_default_value': v8_default_value,
79 'v8_type': v8_types.v8_type(idl_type.base_type),
80 }
81
82 # FIXME: Implement context for impl class.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698