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

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: Address comments. 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..1c62f3ef87efbcc70212252c37e03651dd68e4f8 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 = set()
cpp_header_handlers_emitter = emitter.Emitter()
cpp_impl_handlers_emitter = emitter.Emitter()
class_name = 'Dart%s' % self._interface.id
@@ -77,6 +78,7 @@ class NativeImplementationSystem(System):
parameters.append('%s %s' % (argument_type_info.parameter_type(),
argument.id))
arguments.append(argument.id)
+ cpp_impl_includes |= set(argument_type_info.conversion_includes())
antonm 2012/03/01 15:44:50 or cpp_impl_includes.update(argument_type_info.con
cpp_header_handlers_emitter.Emit(
'\n'
@@ -107,6 +109,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),
INTERFACE=self._interface.id,
HANDLERS=cpp_impl_handlers_emitter.Fragments())
@@ -160,21 +163,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):
+ derived_sources_path = os.path.join(self._output_dir,
+ '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 impl_file in self._cpp_impl_files[i::partitions]:
+ path = os.path.relpath(impl_file, 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(derived_sources_path)
antonm 2012/03/01 15:44:50 cpp_all_in_one, cpp_all_in_one, la-la
+ 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()
@@ -248,7 +254,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
self._interface_type_info = GetIDLTypeInfoByName(self._interface.id)
self._members_emitter = emitter.Emitter()
self._cpp_declarations_emitter = emitter.Emitter()
- self._cpp_impl_includes = {}
+ self._cpp_impl_includes = set()
self._cpp_definitions_emitter = emitter.Emitter()
self._cpp_resolver_emitter = emitter.Emitter()
@@ -288,6 +294,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
' goto fail;\n'
' }\n'
' Document* document = domWindow->document();\n')
+ self._cpp_impl_includes.add('DOMWindow')
arguments.append('document')
create_function = 'createForJSConstructor'
if 'CallWith' in self._interface.ext_attrs:
@@ -336,17 +343,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),
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 +372,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())
@@ -583,10 +584,11 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
arguments.append('context')
elif call_with == 'ScriptArguments|CallStack':
raises_dart_exceptions = True
- self._cpp_impl_includes['ScriptArguments'] = 1
- self._cpp_impl_includes['ScriptCallStack'] = 1
- self._cpp_impl_includes['V8Proxy'] = 1
- self._cpp_impl_includes['v8'] = 1
+ self._cpp_impl_includes.add('DOMWindow')
+ self._cpp_impl_includes.add('ScriptArguments')
+ self._cpp_impl_includes.add('ScriptCallStack')
+ self._cpp_impl_includes.add('V8Proxy')
+ self._cpp_impl_includes.add('v8')
parameter_definitions_emitter.Emit(
' v8::HandleScope handleScope;\n'
' v8::Context::Scope scope(V8Proxy::mainWorldContext(DartUtilities::domWindowForCurrentIsolate()->frame()));\n'
@@ -675,7 +677,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
type_info = GetIDLTypeInfo(idl_argument.type)
(adapter_type, include_name) = type_info.parameter_adapter_info()
if include_name:
- self._cpp_impl_includes[include_name] = 1
+ self._cpp_impl_includes.add(include_name)
flags = ''
if (idl_argument.ext_attrs.get('Optional') == 'DefaultIsNullString' or
('Optional' in idl_argument.ext_attrs and 'Callback' in idl_argument.ext_attrs)):
@@ -724,7 +726,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
'onmouseup', 'onresize', 'onscroll', 'onunload']
if self._interface.id.startswith('SVG') and not attr.id in svg_exceptions:
namespace = 'SVGNames'
- self._cpp_impl_includes[namespace] = 1
+ self._cpp_impl_includes.add(namespace)
attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower()
return 'WebCore::%s::%sAttr' % (namespace, attribute_name)
@@ -739,8 +741,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
invocation_template = ' $FUNCTION_CALL;\n'
if idl_return_type and idl_return_type.id != 'void':
return_type_info = GetIDLTypeInfo(idl_return_type)
- if return_type_info.conversion_include():
- self._cpp_impl_includes[return_type_info.conversion_include()] = 1
+ self._cpp_impl_includes |= set(return_type_info.conversion_includes())
antonm 2012/03/01 15:44:50 ditto
# Generate C++ cast based on idl return type.
conversion_cast = return_type_info.conversion_cast('$FUNCTION_CALL')
@@ -786,7 +787,10 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
if 'ImplementedBy' in attributes:
arguments.insert(0, 'receiver')
- self._cpp_impl_includes[attributes['ImplementedBy']] = 1
+ self._cpp_impl_includes.add(attributes['ImplementedBy'])
return emitter.Format(invocation_template,
FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments)))
+
+def _GenerateCPPIncludes(includes):
+ return ''.join(['#include "%s.h"\n' % include for include in includes])
« no previous file with comments | « client/dom/scripts/generator.py ('k') | client/dom/templates/dom/native/cpp_callback_implementation.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698