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

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

Issue 10702202: Introduce TypeRegistry class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 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 side-by-side diff with in-line comments
Download patch
« lib/dom/scripts/dartgenerator.py ('K') | « lib/dom/scripts/systeminterface.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index d98fa585c0ef22a2c7d2ba11c317d03539f9639b..a5d279066fb7a01a4545ad594b16cb317b0fa414 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -15,13 +15,12 @@ from systemhtml import HtmlSystemShared
class NativeImplementationSystem(systembase.System):
- def __init__(self, templates, database, emitters, output_dir, auxiliary_dir):
- super(NativeImplementationSystem, self).__init__(
- templates, database, emitters, output_dir)
+ def __init__(self, options, auxiliary_dir):
+ super(NativeImplementationSystem, self).__init__(options)
self._auxiliary_dir = auxiliary_dir
self._cpp_header_files = []
self._cpp_impl_files = []
- self._html_system = HtmlSystemShared(database)
+ self._html_system = HtmlSystemShared(self._database)
def ImplementationGenerator(self, interface):
return NativeImplementationGenerator(self, interface)
@@ -47,13 +46,13 @@ class NativeImplementationSystem(systembase.System):
parameters = []
arguments = []
for argument in operation.arguments:
- argument_type_info = GetIDLTypeInfo(argument.type.id)
+ argument_type_info = self._type_registry.TypeInfo(argument.type.id)
parameters.append('%s %s' % (argument_type_info.parameter_type(),
argument.id))
arguments.append(argument_type_info.to_dart_conversion(argument.id))
cpp_impl_includes |= set(argument_type_info.conversion_includes())
- native_return_type = GetIDLTypeInfo(operation.type.id).native_type()
+ native_return_type = self._type_registry.TypeInfo(operation.type.id).native_type()
cpp_header_handlers_emitter.Emit(
'\n'
' virtual $TYPE handleEvent($PARAMETERS);\n',
@@ -212,7 +211,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
self._cpp_header_emitter = emitter.Emitter()
self._cpp_impl_emitter = emitter.Emitter()
- self._interface_type_info = GetIDLTypeInfo(self._interface.id)
+ self._interface_type_info = self._TypeInfo(self._interface.id)
self._members_emitter = emitter.Emitter()
self._cpp_declarations_emitter = emitter.Emitter()
self._cpp_impl_includes = set()
@@ -487,7 +486,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
self._AddSetter(attribute, html_name)
def _AddGetter(self, attr, html_name):
- type_info = GetIDLTypeInfo(attr.type.id)
+ type_info = self._TypeInfo(attr.type.id)
dart_declaration = '%s get %s()' % (self._DartType(attr.type.id), html_name)
is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs
cpp_callback_name = self._GenerateNativeBinding(attr.id, 1,
@@ -501,7 +500,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
raises_exceptions = raises_exceptions or attr.get_raises
if 'Reflect' in attr.ext_attrs:
- webcore_function_name = GetIDLTypeInfo(attr.type.id).webcore_getter_name()
+ webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name()
if 'URL' in attr.ext_attrs:
if 'NonEmpty' in attr.ext_attrs:
webcore_function_name = 'getNonEmptyURLAttribute'
@@ -525,7 +524,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
True, invocation, raises_exceptions=raises_exceptions)
def _AddSetter(self, attr, html_name):
- type_info = GetIDLTypeInfo(attr.type.id)
+ type_info = self._TypeInfo(attr.type.id)
dart_declaration = 'void set %s(%s)' % (html_name, self._DartType(attr.type.id))
is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext_attrs)
cpp_callback_name = self._GenerateNativeBinding(attr.id, 2,
@@ -538,7 +537,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
self._GenerateCallWithHandling(attr, parameter_definitions_emitter, arguments)
if 'Reflect' in attr.ext_attrs:
- webcore_function_name = GetIDLTypeInfo(attr.type.id).webcore_setter_name()
+ webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name()
arguments.append(self._GenerateWebCoreReflectionAttributeName(attr))
else:
webcore_function_name = re.sub(r'^(xml(?=[A-Z])|\w)',
@@ -862,7 +861,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
def _GenerateToNative(self, emitter, idl_node, index,
argument_name=None):
"""idl_node is IDLArgument or IDLAttribute."""
- type_info = GetIDLTypeInfo(idl_node.type.id)
+ type_info = self._TypeInfo(idl_node.type.id)
self._cpp_impl_includes |= set(type_info.to_native_includes())
argument_name = argument_name or idl_node.id
handle = 'Dart_GetNativeArgument(args, %i)' % index
@@ -916,7 +915,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
idl_return_type, attributes, raises_dom_exceptions):
invocation_template = ' $FUNCTION_CALL;\n'
if idl_return_type != 'void':
- return_type_info = GetIDLTypeInfo(idl_return_type)
+ return_type_info = self._TypeInfo(idl_return_type)
self._cpp_impl_includes |= set(return_type_info.conversion_includes())
# Generate to Dart conversion of C++ value.
@@ -946,6 +945,9 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
return emitter.Format(invocation_template,
FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments)))
+ def _TypeInfo(self, type_name):
+ return self._system._type_registry.TypeInfo(type_name)
+
def _GenerateCPPIncludes(includes):
return ''.join(['#include %s\n' % include for include in sorted(includes)])
« lib/dom/scripts/dartgenerator.py ('K') | « lib/dom/scripts/systeminterface.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698