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

Unified Diff: client/dom/scripts/systemnative.py

Issue 9565006: Add missing includes (spotted while splitting cpp derived sources). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: client/dom/scripts/systemnative.py
diff --git a/client/dom/scripts/systemnative.py b/client/dom/scripts/systemnative.py
index ae75dbcd8e242f543647c188a025c78718820206..83205270ed053a302de731f9153082f7d31836cb 100644
--- a/client/dom/scripts/systemnative.py
+++ b/client/dom/scripts/systemnative.py
@@ -59,6 +59,7 @@ class NativeImplementationSystem(System):
dart_interface_path = self._FilePathForDartInterface(self._interface.id)
self._dom_public_files.append(dart_interface_path)
+ cpp_impl_includes = {}
cpp_header_handlers_emitter = emitter.Emitter()
cpp_impl_handlers_emitter = emitter.Emitter()
class_name = 'Dart%s' % self._interface.id
@@ -77,6 +78,8 @@ class NativeImplementationSystem(System):
parameters.append('%s %s' % (argument_type_info.parameter_type(),
argument.id))
arguments.append(argument.id)
+ if argument_type_info.conversion_include():
+ cpp_impl_includes[argument_type_info.conversion_include()] = 1
antonm 2012/03/01 14:25:31 why it's map? should we assign 1 or None?
podivilov 2012/03/01 15:36:56 Done.
cpp_header_handlers_emitter.Emit(
'\n'
@@ -107,6 +110,7 @@ class NativeImplementationSystem(System):
cpp_impl_emitter = self._emitters.FileEmitter(cpp_impl_path)
cpp_impl_emitter.Emit(
self._templates.Load('cpp_callback_implementation.template'),
+ INCLUDES=_GenerateCPPIncludes(cpp_impl_includes.keys()),
INTERFACE=self._interface.id,
HANDLERS=cpp_impl_handlers_emitter.Fragments())
@@ -160,21 +164,24 @@ class NativeImplementationSystem(System):
INCLUDES=includes_emitter.Fragments(),
RESOLVER_BODY=resolver_body_emitter.Fragments())
- # Generate DartDerivedSourcesAll.cpp
- cpp_all_in_one_path = os.path.join(self._output_dir,
- 'DartDerivedSourcesAll.cpp')
+ # Generate DartDerivedSourcesXX.cpp.
+ partitions = 20 # FIXME: this should be configurable.
+ sources_count = len(self._cpp_impl_files)
+ for i in range(0, partitions):
+ cpp_all_in_one_path = os.path.join(self._output_dir,
antonm 2012/03/01 14:25:31 cpp_all_in_one is now misleading
+ 'DartDerivedSources%02i.cpp' % (i + 1))
- includes_emitter = emitter.Emitter()
- for file in self._cpp_impl_files:
- path = os.path.relpath(file, os.path.dirname(cpp_all_in_one_path))
- includes_emitter.Emit('#include "$PATH"\n', PATH=path)
+ includes_emitter = emitter.Emitter()
+ for j in range(i * sources_count / partitions, (i + 1) * sources_count / partitions):
antonm 2012/03/01 14:25:31 for impl_file in self._cpp_impl_files[i * sources_
podivilov 2012/03/01 15:36:56 nice!
+ path = os.path.relpath(self._cpp_impl_files[j], os.path.dirname(cpp_all_in_one_path))
+ includes_emitter.Emit('#include "$PATH"\n', PATH=path)
- cpp_all_in_one_emitter = self._emitters.FileEmitter(cpp_all_in_one_path)
- cpp_all_in_one_emitter.Emit(
- self._templates.Load('cpp_all_in_one.template'),
- INCLUDES=includes_emitter.Fragments())
+ cpp_all_in_one_emitter = self._emitters.FileEmitter(cpp_all_in_one_path)
+ cpp_all_in_one_emitter.Emit(
+ self._templates.Load('cpp_all_in_one.template'),
+ INCLUDES=includes_emitter.Fragments())
- # Generate DartResolver.cpp
+ # Generate DartResolver.cpp.
cpp_resolver_path = os.path.join(self._output_dir, 'DartResolver.cpp')
includes_emitter = emitter.Emitter()
@@ -288,6 +295,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
' goto fail;\n'
' }\n'
' Document* document = domWindow->document();\n')
+ self._cpp_impl_includes['DOMWindow'] = 1
arguments.append('document')
create_function = 'createForJSConstructor'
if 'CallWith' in self._interface.ext_attrs:
@@ -336,17 +344,12 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
self._cpp_impl_emitter.Emit(
self._templates.Load('cpp_implementation.template'),
INTERFACE=self._interface.id,
- INCLUDES=''.join(['#include "%s.h"\n' %
- k for k in self._cpp_impl_includes.keys()]),
+ INCLUDES=_GenerateCPPIncludes(self._cpp_impl_includes.keys()),
CALLBACKS=self._cpp_definitions_emitter.Fragments(),
RESOLVER=self._cpp_resolver_emitter.Fragments())
def _GenerateCppHeader(self):
- webcore_include = self._interface_type_info.webcore_include()
- if webcore_include:
- webcore_include = '#include "%s.h"\n' % webcore_include
- else:
- webcore_include = ''
+ webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_includes())
if ('CustomToJS' in self._interface.ext_attrs or
'CustomToJSObject' in self._interface.ext_attrs or
@@ -370,8 +373,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
self._cpp_header_emitter.Emit(
self._templates.Load('cpp_header.template'),
INTERFACE=self._interface.id,
- WEBCORE_INCLUDE=webcore_include,
- ADDITIONAL_INCLUDES='',
+ WEBCORE_INCLUDES=webcore_includes,
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
TO_DART_VALUE=to_dart_value_emitter.Fragments(),
DECLARATIONS=self._cpp_declarations_emitter.Fragments())
@@ -790,3 +792,6 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
return emitter.Format(invocation_template,
FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments)))
+
+def _GenerateCPPIncludes(includes):
+ return ''.join(['#include "%s.h"\n' % i for i in includes])
antonm 2012/03/01 14:25:31 nit: i is usually for index :)
podivilov 2012/03/01 15:36:56 Done.

Powered by Google App Engine
This is Rietveld 408576698