Eliminate the old non blink code paths from idl generation

During the transition to the dart:html dart:blink split, we needed to support generating the old style and the new style.  This CL eliminates the code paths for the old style generation now that they're no longer needed.

BUG=
R=efortuna@google.com

Review URL: https://codereview.chromium.org//450693005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39005 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
leafp@google.com 2014-08-07 20:04:18 +00:00
parent b8ab793a1b
commit 445e8fda3d
11 changed files with 134 additions and 236 deletions

View file

@ -51,8 +51,7 @@ def LoadDatabase(database_dir, use_database_cache):
return common_database
def GenerateFromDatabase(common_database, dart2js_output_dir,
dartium_output_dir, update_dom_metadata=False,
dart_use_blink=False):
dartium_output_dir, update_dom_metadata=False):
current_dir = os.path.dirname(__file__)
auxiliary_dir = os.path.join(current_dir, '..', 'src')
template_dir = os.path.join(current_dir, '..', 'templates')
@ -102,8 +101,7 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
template_paths = ['html/dart2js', 'html/impl', 'html/interface', '']
template_loader = TemplateLoader(template_dir,
template_paths,
{'DARTIUM': False, 'DART2JS': True,
'DART_USE_BLINK' : False})
{'DARTIUM': False, 'DART2JS': True})
backend_options = GeneratorOptions(
template_loader, webkit_database, type_registry, renamer,
metadata)
@ -121,8 +119,7 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
template_paths = ['html/dartium', 'html/impl', 'html/interface', '']
template_loader = TemplateLoader(template_dir,
template_paths,
{'DARTIUM': True, 'DART2JS': False,
'DART_USE_BLINK' : dart_use_blink})
{'DARTIUM': True, 'DART2JS': False})
backend_options = GeneratorOptions(
template_loader, webkit_database, type_registry, renamer,
metadata)
@ -135,7 +132,7 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
auxiliary_dir)
backend_factory = lambda interface:\
DartiumBackend(interface, native_library_emitter,
cpp_library_emitter, backend_options, dart_use_blink)
cpp_library_emitter, backend_options)
dart_libraries = DartLibraries(
HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir)
RunGenerator(dart_libraries, dart_output_dir,
@ -186,10 +183,6 @@ def main():
action='store', type='string',
default=None,
help='Directory to put the generated files')
parser.add_option('--use-blink', dest='dart_use_blink',
action='store_true',
default=False,
help='''Delegate all native calls to dart:blink''')
parser.add_option('--use-database-cache', dest='use_database_cache',
action='store_true',
default=False,
@ -225,7 +218,7 @@ def main():
# Load the previously generated database.
database = LoadDatabase(database_dir, options.use_database_cache)
GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir,
options.update_dom_metadata, options.dart_use_blink)
options.update_dom_metadata)
if 'htmldart2js' in systems:
_logger.info('Generating dart2js single files.')

View file

@ -46,9 +46,9 @@ fi
if [[ $CACHED ]] ; then
reset &&
./dartdomgenerator.py --use-database-cache --systems="$SYSTEMS" \
--update-dom-metadata --use-blink
--update-dom-metadata
else
reset &&
./dartdomgenerator.py --rebuild --parallel --systems="$SYSTEMS" \
--update-dom-metadata --use-blink
--update-dom-metadata
fi

View file

@ -37,8 +37,6 @@ _custom_factories = [
class HtmlDartGenerator(object):
def __init__(self, interface, options, dart_use_blink):
# This goes away after the Chrome 35 roll (or whenever we commit to the
# dart:blink refactor)
self._dart_use_blink = dart_use_blink
self._database = options.database
self._interface = interface

View file

@ -415,8 +415,8 @@ class DartiumBackend(HtmlDartGenerator):
"""Generates Dart implementation for one DOM IDL interface."""
def __init__(self, interface, native_library_emitter,
cpp_library_emitter, options, dart_use_blink):
super(DartiumBackend, self).__init__(interface, options, dart_use_blink)
cpp_library_emitter, options):
super(DartiumBackend, self).__init__(interface, options, True)
self._interface = interface
self._cpp_library_emitter = cpp_library_emitter
@ -626,13 +626,12 @@ class DartiumBackend(HtmlDartGenerator):
' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INTERFACE_NAME)>(args);\n'
'}\n',
INTERFACE_NAME=self._interface.id);
if self._dart_use_blink:
self._native_class_emitter = self._native_library_emitter.Emit(
'\n'
'class $INTERFACE_NAME {'
'$!METHODS'
'}\n',
INTERFACE_NAME=DeriveBlinkClassName(self._interface.id))
self._native_class_emitter = self._native_library_emitter.Emit(
'\n'
'class $INTERFACE_NAME {'
'$!METHODS'
'}\n',
INTERFACE_NAME=DeriveBlinkClassName(self._interface.id))
def _EmitConstructorInfrastructure(self,
constructor_info, cpp_prefix, cpp_suffix, factory_method_name,
@ -641,63 +640,47 @@ class DartiumBackend(HtmlDartGenerator):
constructor_callback_cpp_name = cpp_prefix + cpp_suffix
if arguments is None:
if self._dart_use_blink:
arguments = constructor_info.idl_args[0]
argument_count = len(arguments)
else:
argument_count = len(constructor_info.param_infos)
arguments = constructor_info.idl_args[0]
argument_count = len(arguments)
else:
argument_count = len(arguments)
argument_count = len(arguments)
typed_formals = constructor_info.ParametersAsArgumentList(argument_count)
parameters = constructor_info.ParametersAsStringOfVariables(argument_count)
interface_name = self._interface_type_info.interface_name()
if self._dart_use_blink:
type_ids = [p.type.id for p in arguments[:argument_count]]
type_ids = [p.type.id for p in arguments[:argument_count]]
constructor_callback_id = \
DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids, self._database, is_custom)
# First we emit the toplevel function
dart_native_name = \
self.DeriveNativeName(constructor_callback_cpp_name)
if constructor_callback_id in _cpp_resolver_string_map:
constructor_callback_id = \
DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids, self._database, is_custom)
else:
constructor_callback_id = self._interface.id + '_' + constructor_callback_cpp_name
_cpp_resolver_string_map[constructor_callback_id]
self._native_class_emitter.Emit(
'\n'
' static $FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n',
FACTORY_METHOD_NAME=dart_native_name,
PARAMETERS=parameters,
ID=constructor_callback_id)
if self._dart_use_blink:
# First we emit the toplevel function
dart_native_name = \
self.DeriveNativeName(constructor_callback_cpp_name)
if constructor_callback_id in _cpp_resolver_string_map:
constructor_callback_id = \
_cpp_resolver_string_map[constructor_callback_id]
self._native_class_emitter.Emit(
'\n'
' static $FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n',
FACTORY_METHOD_NAME=dart_native_name,
PARAMETERS=parameters,
ID=constructor_callback_id)
# Then we emit the impedance matching wrapper to call out to the
# toplevel wrapper
if not emit_to_native:
toplevel_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
self._members_emitter.Emit(
'\n @DocsEditable()\n'
' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => '
'$TOPLEVEL_NAME($OUTPARAMETERS);\n',
INTERFACE_NAME=self._interface_type_info.interface_name(),
FACTORY_METHOD_NAME=factory_method_name,
PARAMETERS=typed_formals,
TOPLEVEL_NAME=toplevel_name,
OUTPARAMETERS=parameters)
else:
# Then we emit the impedance matching wrapper to call out to the
# toplevel wrapper
if not emit_to_native:
toplevel_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
self._members_emitter.Emit(
'\n @DocsEditable()\n'
' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) '
'native "$ID";\n',
' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => '
'$TOPLEVEL_NAME($OUTPARAMETERS);\n',
INTERFACE_NAME=self._interface_type_info.interface_name(),
FACTORY_METHOD_NAME=factory_method_name,
PARAMETERS=typed_formals,
ID=constructor_callback_id)
TOPLEVEL_NAME=toplevel_name,
OUTPARAMETERS=parameters)
self._cpp_resolver_emitter.Emit(
' if (name == "$ID")\n'
@ -740,7 +723,7 @@ class DartiumBackend(HtmlDartGenerator):
constructor_callback_cpp_name = name + 'constructorCallback'
self._EmitConstructorInfrastructure(
constructor_info, name, 'constructorCallback', name, arguments,
emit_to_native=self._dart_use_blink,
emit_to_native=True,
is_custom=False)
ext_attrs = self._interface.ext_attrs
@ -1082,56 +1065,41 @@ class DartiumBackend(HtmlDartGenerator):
elif self._HasExplicitIndexedGetter():
self._EmitExplicitIndexedGetter(dart_element_type)
else:
if self._dart_use_blink:
is_custom = any((op.id == 'item' and 'Custom' in op.ext_attrs) for op in self._interface.operations)
dart_native_name = \
self.DeriveNativeName("NativeIndexed", "Getter")
# First emit a toplevel function to do the native call
# Calls to this are emitted elsewhere,
is_custom = any((op.id == 'item' and 'Custom' in op.ext_attrs) for op in self._interface.operations)
dart_native_name = \
self.DeriveNativeName("NativeIndexed", "Getter")
# First emit a toplevel function to do the native call
# Calls to this are emitted elsewhere,
resolver_string = \
DeriveResolverString(self._interface.id, "item", "Callback",
["unsigned long"], self._database, is_custom)
if resolver_string in _cpp_resolver_string_map:
resolver_string = \
DeriveResolverString(self._interface.id, "item", "Callback",
["unsigned long"], self._database, is_custom)
if resolver_string in _cpp_resolver_string_map:
resolver_string = \
_cpp_resolver_string_map[resolver_string]
self._native_class_emitter.Emit(
'\n'
' static $(DART_NATIVE_NAME)(mthis, index) '
'native "$(RESOLVER_STRING)";\n',
DART_NATIVE_NAME = dart_native_name,
RESOLVER_STRING=resolver_string)
_cpp_resolver_string_map[resolver_string]
self._native_class_emitter.Emit(
'\n'
' static $(DART_NATIVE_NAME)(mthis, index) '
'native "$(RESOLVER_STRING)";\n',
DART_NATIVE_NAME = dart_native_name,
RESOLVER_STRING=resolver_string)
# Emit the method which calls the toplevel function, along with
# the [] operator.
dart_qualified_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
self._members_emitter.Emit(
'\n'
' $TYPE operator[](int index) {\n'
' if (index < 0 || index >= length)\n'
' throw new RangeError.range(index, 0, length);\n'
' return $(DART_NATIVE_NAME)(this, index);\n'
' }\n\n'
' $TYPE _nativeIndexedGetter(int index) =>'
' $(DART_NATIVE_NAME)(this, index);\n',
DART_NATIVE_NAME=dart_qualified_name,
TYPE=self.SecureOutputType(element_type),
INTERFACE=self._interface.id)
else:
# Emit the method which calls the toplevel function, along with
# the [] operator.
self._members_emitter.Emit(
'\n'
' $TYPE operator[](int index) {\n'
' if (index < 0 || index >= length)\n'
' throw new RangeError.range(index, 0, length);\n'
' return _nativeIndexedGetter(index);\n'
' }\n'
' $TYPE _nativeIndexedGetter(int index)'
' native "$(INTERFACE)_item_Callback";\n',
TYPE=self.SecureOutputType(element_type),
INTERFACE=self._interface.id)
# Emit the method which calls the toplevel function, along with
# the [] operator.
dart_qualified_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
self._members_emitter.Emit(
'\n'
' $TYPE operator[](int index) {\n'
' if (index < 0 || index >= length)\n'
' throw new RangeError.range(index, 0, length);\n'
' return $(DART_NATIVE_NAME)(this, index);\n'
' }\n\n'
' $TYPE _nativeIndexedGetter(int index) =>'
' $(DART_NATIVE_NAME)(this, index);\n',
DART_NATIVE_NAME=dart_qualified_name,
TYPE=self.SecureOutputType(element_type),
INTERFACE=self._interface.id)
if self._HasNativeIndexSetter():
self._EmitNativeIndexSetter(dart_element_type)
@ -1226,14 +1194,11 @@ class DartiumBackend(HtmlDartGenerator):
argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos)
native_suffix = 'Callback'
auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix)
if self._dart_use_blink:
type_ids = [argument.type.id
for argument in operation.arguments[:len(info.param_infos)]]
resolver_string = \
DeriveResolverString(self._interface.id, operation.id,
native_suffix, type_ids, self._database, is_custom)
else:
resolver_string = None
type_ids = [argument.type.id
for argument in operation.arguments[:len(info.param_infos)]]
resolver_string = \
DeriveResolverString(self._interface.id, operation.id,
native_suffix, type_ids, self._database, is_custom)
cpp_callback_name = self._GenerateNativeBinding(
info.name, argument_count, dart_declaration,
info.IsStatic(), return_type, parameters,
@ -1255,35 +1220,25 @@ class DartiumBackend(HtmlDartGenerator):
return_type = self.SecureOutputType(operation.type.id)
native_suffix = 'Callback'
is_custom = 'Custom' in operation.ext_attrs
if self._dart_use_blink:
base_name = '_%s_%s' % (operation.id, version)
overload_base_name = \
self.DeriveNativeName(base_name, native_suffix)
overload_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
overload_base_name)
static = True
if not operation.is_static:
actuals = ['this'] + actuals
formals = ['mthis'] + formals
actuals_s = ", ".join(actuals)
formals_s = ", ".join(formals)
dart_declaration = '%s(%s)' % (
base_name, formals_s)
type_ids = [argument.type.id
for argument in operation.arguments[:argument_count]]
resolver_string = \
DeriveResolverString(self._interface.id, operation.id,
native_suffix, type_ids, self._database, is_custom)
else:
base_name = '_%s_%s' % (operation.id, version)
overload_name = base_name
static = operation.is_static
dart_declaration = '%s%s %s(%s)' % (
'static ' if static else '',
return_type,
overload_name, actuals_s)
resolver_string = None
base_name = '_%s_%s' % (operation.id, version)
overload_base_name = \
self.DeriveNativeName(base_name, native_suffix)
overload_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
overload_base_name)
static = True
if not operation.is_static:
actuals = ['this'] + actuals
formals = ['mthis'] + formals
actuals_s = ", ".join(actuals)
formals_s = ", ".join(formals)
dart_declaration = '%s(%s)' % (
base_name, formals_s)
type_ids = [argument.type.id
for argument in operation.arguments[:argument_count]]
resolver_string = \
DeriveResolverString(self._interface.id, operation.id,
native_suffix, type_ids, self._database, is_custom)
call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s)
auto_scope_setup = \
@ -1292,7 +1247,7 @@ class DartiumBackend(HtmlDartGenerator):
base_name, (0 if static else 1) + argument_count,
dart_declaration, static, return_type, formals,
native_suffix, is_custom, auto_scope_setup, emit_metadata=False,
emit_to_native=self._dart_use_blink, resolver_string=resolver_string)
emit_to_native=True, resolver_string=resolver_string)
if not is_custom:
self._GenerateOperationNativeCallback(operation,
operation.arguments[:argument_count], cpp_callback_name,
@ -1494,21 +1449,13 @@ class DartiumBackend(HtmlDartGenerator):
' Document& document = *domWindow->document();\n')
if needs_receiver:
if self._dart_use_blink:
body_emitter.Emit(
' $WEBCORE_CLASS_NAME* receiver = '
'DartDOMWrapper::receiverChecked<Dart$INTERFACE>(args, exception);\n'
' if (exception)\n'
' goto fail;\n',
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
INTERFACE=self._interface.id)
else:
body_emitter.Emit(
' $WEBCORE_CLASS_NAME* receiver = '
'DartDOMWrapper::receiver< $WEBCORE_CLASS_NAME >(args);\n'
' if (exception)\n'
' goto fail;\n',
WEBCORE_CLASS_NAME=self._interface_type_info.native_type())
body_emitter.Emit(
' $WEBCORE_CLASS_NAME* receiver = '
'DartDOMWrapper::receiverChecked<Dart$INTERFACE>(args, exception);\n'
' if (exception)\n'
' goto fail;\n',
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
INTERFACE=self._interface.id)
if requires_stack_info:
self._cpp_impl_includes.add('"ScriptArguments.h"')
@ -1712,47 +1659,38 @@ class DartiumBackend(HtmlDartGenerator):
native_binding = resolver_string
else:
native_binding_id = self._interface.id
if self._dart_use_blink:
native_binding_id = TypeIdToBlinkName(native_binding_id, self._database)
native_binding_id = TypeIdToBlinkName(native_binding_id, self._database)
native_binding = \
'%s_%s_%s' % (native_binding_id, idl_name, native_suffix)
if self._dart_use_blink:
if not static:
formals = ", ".join(['mthis'] + parameters)
actuals = ", ".join(['this'] + parameters)
else:
formals = ", ".join(parameters)
actuals = ", ".join(parameters)
if native_binding in _cpp_resolver_string_map:
native_binding = \
_cpp_resolver_string_map[native_binding]
self._native_class_emitter.Emit(
'\n'
' static $DART_NAME($FORMALS) native "$NATIVE_BINDING";\n',
DART_NAME=dart_native_name,
FORMALS=formals,
NATIVE_BINDING=native_binding)
if not emit_to_native:
caller_emitter = self._members_emitter
full_dart_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
caller_emitter.Emit(
'\n'
' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n',
METADATA=metadata,
DART_DECLARATION=dart_declaration,
DART_NAME=full_dart_name,
ACTUALS=actuals)
if not static:
formals = ", ".join(['mthis'] + parameters)
actuals = ", ".join(['this'] + parameters)
else:
self._members_emitter.Emit(
formals = ", ".join(parameters)
actuals = ", ".join(parameters)
if native_binding in _cpp_resolver_string_map:
native_binding = \
_cpp_resolver_string_map[native_binding]
self._native_class_emitter.Emit(
'\n'
' static $DART_NAME($FORMALS) native "$NATIVE_BINDING";\n',
DART_NAME=dart_native_name,
FORMALS=formals,
NATIVE_BINDING=native_binding)
if not emit_to_native:
caller_emitter = self._members_emitter
full_dart_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
dart_native_name)
caller_emitter.Emit(
'\n'
' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n',
' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n',
METADATA=metadata,
DART_DECLARATION=dart_declaration,
NATIVE_BINDING=native_binding)
DART_NAME=full_dart_name,
ACTUALS=actuals)
cpp_callback_name = '%s%s' % (idl_name, native_suffix)
self._cpp_resolver_emitter.Emit(

View file

@ -14,6 +14,4 @@
/// [Chrome APIs Documentation](http://developer.chrome.com/extensions/api_index.html)
library _chrome;
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif

View file

@ -56,9 +56,7 @@ import 'dart:svg' show Matrix;
import 'dart:svg' show SvgSvgElement;
import 'dart:web_audio' as web_audio;
import 'dart:web_audio' show web_audioBlinkMap;
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
export 'dart:math' show Rectangle, Point;
@ -91,11 +89,7 @@ part '$AUXILIARY_DIR/dartium_Platform.dart';
part '$AUXILIARY_DIR/dartium_WrappedEvent.dart';
part '$AUXILIARY_DIR/shared_html.dart';
$if DART_USE_BLINK
part '$AUXILIARY_DIR/html_native_DOMImplementation.dart';
$else
part '$AUXILIARY_DIR/native_DOMImplementation.dart';
$endif
Window _window;
@ -144,7 +138,6 @@ Future<Isolate> spawnDomUri(Uri uri, List<String> args, message) {
// TODO(17738): Plumb arguments and return value through.
return _Utils.spawnDomUri(uri.toString());
}
$if DART_USE_BLINK
// FIXME: Can we make this private?
final htmlBlinkMap = {
'_HistoryCrossFrame': () => _HistoryCrossFrame,
@ -248,5 +241,3 @@ Type _getSvgType(String key) {
}
return null;
}
$endif

View file

@ -11,9 +11,7 @@ import 'dart:async';
import 'dart:html';
import 'dart:html_common';
import 'dart:nativewrappers';
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
$!GENERATED_DART_FILES
@ -35,9 +33,7 @@ class _KeyRangeFactoryProvider {
[bool lowerOpen = false, bool upperOpen = false]) =>
KeyRange.bound_(lower, upper, lowerOpen, upperOpen);
}
$if DART_USE_BLINK
// FIXME: Can we make this private?
final indexed_dbBlinkMap = {
$!TYPE_MAP
};
$endif

View file

@ -9,16 +9,12 @@ import 'dart:_internal' hide deprecated;
import 'dart:html';
import 'dart:html_common';
import 'dart:nativewrappers';
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
part '$AUXILIARY_DIR/shared_SVGFactoryProviders.dart';
$!GENERATED_DART_FILES
$if DART_USE_BLINK
// FIXME: Can we make this private?
final svgBlinkMap = {
$!TYPE_MAP
};
$endif

View file

@ -10,14 +10,10 @@ import 'dart:html';
import 'dart:html_common';
import 'dart:nativewrappers';
import 'dart:typed_data';
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
$!GENERATED_DART_FILES
$if DART_USE_BLINK
// FIXME: Can we make this private?
final web_audioBlinkMap = {
$!TYPE_MAP
};
$endif

View file

@ -10,16 +10,12 @@ import 'dart:html';
import 'dart:html_common';
import 'dart:nativewrappers';
import 'dart:typed_data';
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
part '$AUXILIARY_DIR/WebGLConstants.dart';
$!GENERATED_DART_FILES
$if DART_USE_BLINK
// FIXME: Can we make this private?
final web_glBlinkMap = {
$!TYPE_MAP
};
$endif

View file

@ -20,14 +20,10 @@ import 'dart:_internal' hide deprecated;
import 'dart:html';
import 'dart:html_common';
import 'dart:nativewrappers';
$if DART_USE_BLINK
import 'dart:_blink' as _blink;
$endif
$!GENERATED_DART_FILES
$if DART_USE_BLINK
// FIXME: Can we make this private?
final web_sqlBlinkMap = {
$!TYPE_MAP
};
$endif