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

Side by Side Diff: Source/bindings/scripts/unstable/code_generator_v8.py

Issue 24867002: Add static attributes to IDL compiler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 2 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
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 module_path, module_name = os.path.split(__file__) 46 module_path, module_name = os.path.split(__file__)
47 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir, os.pardir) 47 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir, os.pardir)
48 # Insert at front to override system libraries, and after path[0] == script dir 48 # Insert at front to override system libraries, and after path[0] == script dir
49 sys.path.insert(1, third_party) 49 sys.path.insert(1, third_party)
50 import jinja2 50 import jinja2
51 51
52 templates_dir = os.path.join(module_path, os.pardir, os.pardir, 'templates') 52 templates_dir = os.path.join(module_path, os.pardir, os.pardir, 'templates')
53 53
54 import v8_callback_interface 54 import v8_callback_interface
55 import v8_interface 55 import v8_interface
56 from v8_utilities import cpp_class_name, generate_conditional_string, v8_class_n ame 56 from v8_utilities import cpp_implemented_as_name, generate_conditional_string, v 8_class_name
57 57
58 58
59 class CodeGeneratorV8: 59 class CodeGeneratorV8:
60 def __init__(self, definitions, interface_name, output_directory, relative_d ir_posix, idl_directories, verbose=False): 60 def __init__(self, definitions, interface_name, output_directory, relative_d ir_posix, idl_directories, verbose=False):
61 self.idl_definitions = definitions 61 self.idl_definitions = definitions
62 self.interface_name = interface_name 62 self.interface_name = interface_name
63 self.idl_directories = idl_directories 63 self.idl_directories = idl_directories
64 self.output_directory = output_directory 64 self.output_directory = output_directory
65 self.verbose = verbose 65 self.verbose = verbose
66 # FIXME: remove definitions check when remove write_dummy_header_and_cpp 66 # FIXME: remove definitions check when remove write_dummy_header_and_cpp
(...skipping 12 matching lines...) Expand all
79 cpp_template_filename = 'interface.cpp' 79 cpp_template_filename = 'interface.cpp'
80 self.generate_contents = v8_interface.generate_interface 80 self.generate_contents = v8_interface.generate_interface
81 jinja_env = jinja2.Environment( 81 jinja_env = jinja2.Environment(
82 loader=jinja2.FileSystemLoader(templates_dir), 82 loader=jinja2.FileSystemLoader(templates_dir),
83 keep_trailing_newline=True, # newline-terminate generated files 83 keep_trailing_newline=True, # newline-terminate generated files
84 lstrip_blocks=True, # so can indent control flow tags 84 lstrip_blocks=True, # so can indent control flow tags
85 trim_blocks=True) 85 trim_blocks=True)
86 self.header_template = jinja_env.get_template(header_template_filename) 86 self.header_template = jinja_env.get_template(header_template_filename)
87 self.cpp_template = jinja_env.get_template(cpp_template_filename) 87 self.cpp_template = jinja_env.get_template(cpp_template_filename)
88 88
89 class_name = cpp_class_name(self.interface) 89 class_name = cpp_implemented_as_name(self.interface)
90 self.include_for_cpp_class = posixpath.join(relative_dir_posix, class_na me + '.h') 90 self.include_for_cpp_class = posixpath.join(relative_dir_posix, class_na me + '.h')
91 91
92 def write_dummy_header_and_cpp(self): 92 def write_dummy_header_and_cpp(self):
93 # FIXME: fix GYP so these files aren't needed and remove this method 93 # FIXME: fix GYP so these files aren't needed and remove this method
94 target_interface_name = self.interface_name 94 target_interface_name = self.interface_name
95 header_basename = 'V8%s.h' % target_interface_name 95 header_basename = 'V8%s.h' % target_interface_name
96 cpp_basename = 'V8%s.cpp' % target_interface_name 96 cpp_basename = 'V8%s.cpp' % target_interface_name
97 contents = """/* 97 contents = """/*
98 This file is generated just to tell build scripts that {header_basename} and 98 This file is generated just to tell build scripts that {header_basename} and
99 {cpp_basename} are created for {target_interface_name}.idl, and thus 99 {cpp_basename} are created for {target_interface_name}.idl, and thus
(...skipping 17 matching lines...) Expand all
117 self.write_file(header_basename, header_file_text) 117 self.write_file(header_basename, header_file_text)
118 118
119 cpp_basename = v8_class_name(interface) + '.cpp' 119 cpp_basename = v8_class_name(interface) + '.cpp'
120 cpp_file_text = self.cpp_template.render(template_contents) 120 cpp_file_text = self.cpp_template.render(template_contents)
121 self.write_file(cpp_basename, cpp_file_text) 121 self.write_file(cpp_basename, cpp_file_text)
122 122
123 def write_file(self, basename, file_text): 123 def write_file(self, basename, file_text):
124 filename = os.path.join(self.output_directory, basename) 124 filename = os.path.join(self.output_directory, basename)
125 with open(filename, 'w') as output_file: 125 with open(filename, 'w') as output_file:
126 output_file.write(file_text) 126 output_file.write(file_text)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.pm ('k') | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698