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

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

Issue 24156003: Revert IDL compiler build flow to Perl, rename 'deprecated' (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 """Generate template values for attributes."""
30
31 import v8_types
32 import v8_utilities
33 from v8_utilities import cpp_method_name, generate_conditional_string, uncapital ize
34
35
36 def generate_attributes(interface):
37 def generate_attribute(attribute):
38 attribute_contents, attribute_includes = generate_attribute_and_includes (attribute)
39 includes.update(attribute_includes)
40 return attribute_contents
41
42 includes = set()
43 contents = generate_attributes_common(interface)
44 contents['attributes'] = [generate_attribute(attribute) for attribute in int erface.attributes]
45 return contents, includes
46
47
48 def generate_attributes_common(interface):
49 attributes = interface.attributes
50 v8_class_name = v8_utilities.v8_class_name(interface)
51 return {
52 # Size 0 constant array is not allowed in VC++
53 'number_of_attributes': 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class_name if attributes else '0',
54 'attribute_templates': '%sAttributes' % v8_class_name if attributes else '0',
55 }
56
57
58 def generate_attribute_and_includes(attribute):
59 idl_type = attribute.data_type
60 # FIXME: need to check should_keep_attribute_alive, but for now sufficient
61 # to check if primitive.
62 should_keep_attribute_alive = not v8_types.primitive_type(idl_type)
63 if should_keep_attribute_alive:
64 return_v8_value_statement = None # unused
65 includes = v8_types.includes_for_type(idl_type)
66 includes.add('bindings/v8/V8HiddenPropertyName.h')
67 else:
68 cpp_value = 'imp->%s()' % uncapitalize(attribute.name)
69 return_v8_value_statement = v8_types.v8_set_return_value(idl_type, cpp_v alue, callback_info='info')
70 includes = []
71 contents = {
72 'name': attribute.name,
73 'conditional_string': generate_conditional_string(attribute),
74 'cpp_method_name': cpp_method_name(attribute),
75 'cpp_type': v8_types.cpp_type(idl_type, pointer_type='RefPtr'),
76 'should_keep_attribute_alive': should_keep_attribute_alive,
77 'return_v8_value_statement': return_v8_value_statement,
78 'v8_type': v8_types.v8_type(idl_type),
79 }
80 return contents, includes
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_utilities.py ('k') | Source/bindings/scripts/v8_callback_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698