The patch file cached_patches.dart generated from C++ with special dartium switch --enable-blink-features=dartGenCachedPatches

TBR=jacobr@google.com,alanknight@google.com

Review URL: https://codereview.chromium.org/1898163002 .
This commit is contained in:
Terry Lucas 2016-04-19 08:32:50 -07:00
parent 5e3b3f8d50
commit e8fd9f5c1f
6 changed files with 43 additions and 67 deletions

View file

@ -7,7 +7,8 @@
library cached_patches;
var cached_patches = {"dart:html": ["dart:html", "dart:html_js_interop_patch.dart", """import 'dart:js' as js_library;
var cached_patches = {
"dart:html": ["dart:html", "dart:html_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -4048,7 +4049,8 @@ class _XMLHttpRequestProgressEventImpl extends _XMLHttpRequestProgressEvent impl
toString() => super.toString();
}
"""],"dart:indexed_db": ["dart:indexed_db", "dart:indexed_db_js_interop_patch.dart", """import 'dart:js' as js_library;
"""],
"dart:indexed_db": ["dart:indexed_db", "dart:indexed_db_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -4156,7 +4158,8 @@ class VersionChangeEventImpl extends VersionChangeEvent implements js_library.JS
toString() => super.toString();
}
"""],"dart:web_gl": ["dart:web_gl", "dart:web_gl_js_interop_patch.dart", """import 'dart:js' as js_library;
"""],
"dart:web_gl": ["dart:web_gl", "dart:web_gl_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -4552,7 +4555,8 @@ class _WebGLRenderingContextBaseImpl extends _WebGLRenderingContextBase implemen
toString() => super.toString();
}
"""],"dart:web_sql": ["dart:web_sql", "dart:web_sql_js_interop_patch.dart", """import 'dart:js' as js_library;
"""],
"dart:web_sql": ["dart:web_sql", "dart:web_sql_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -4606,7 +4610,8 @@ class SqlTransactionImpl extends SqlTransaction implements js_library.JSObjectIn
toString() => super.toString();
}
"""],"dart:svg": ["dart:svg", "dart:svg_js_interop_patch.dart", """import 'dart:js' as js_library;
"""],
"dart:svg": ["dart:svg", "dart:svg_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -5758,7 +5763,8 @@ class _SVGMPathElementImpl extends _SVGMPathElement implements js_library.JSObje
toString() => super.toString();
}
"""],"dart:web_audio": ["dart:web_audio", "dart:web_audio_js_interop_patch.dart", """import 'dart:js' as js_library;
"""],
"dart:web_audio": ["dart:web_audio", "dart:web_audio_js_interop_patch.dart", """import 'dart:js' as js_library;
/**
* Placeholder object for cases where we need to determine exactly how many
@ -6019,5 +6025,7 @@ class WaveShaperNodeImpl extends WaveShaperNode implements js_library.JSObjectIn
toString() => super.toString();
}
"""],};
"""],
};
// END_OF_CACHED_PATCHES

View file

@ -282,48 +282,6 @@ void _registerJsInterfaces(List<Type> classes) {
_finalizeJsInterfaces() native "Js_finalizeJsInterfaces";
// Create the files for the generated Dart files from IDLs. These only change
// when browser's Dart files change (dart:*).
@Deprecated("Internal Use Only")
String createCachedPatchesFile() {
var patches = _generateInteropPatchFiles(['dart:html',
'dart:indexed_db',
'dart:web_gl',
'dart:web_sql',
'dart:svg',
'dart:web_audio']);
var sb = new StringBuffer();
sb.write("""
// START_OF_CACHED_PATCHES
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// DO NOT EDIT GENERATED FILE.
library cached_patches;
var cached_patches = {""");
for (var baseIndex = 0; baseIndex < patches.length; baseIndex += 3) {
var uri = patches[baseIndex + 0];
var uri_js_interop = patches[baseIndex + 1];
var source = patches[baseIndex + 2];
if (uri != 'dart:js') {
sb.write('"$uri": ["$uri", "$uri_js_interop", """$source"""],');
}
}
sb.write("""};
// END_OF_CACHED_PATCHES
""");
return "$sb";
}
String _getJsName(mirrors.DeclarationMirror mirror) {
if (_atJsType != null) {
for (var annotation in mirror.metadata) {
@ -499,19 +457,23 @@ bool _isExternal(mirrors.MethodMirror mirror) {
return false;
}
List<String> _generateExternalMethods(List<String> libraryPaths) {
List<String> _generateExternalMethods(List<String> libraryPaths, bool useCachedPatches) {
var staticCodegen = <String>[];
if (libraryPaths.length == 0) {
mirrors.currentMirrorSystem().libraries.forEach((uri, library) {
var library_name = "${uri.scheme}:${uri.path}";
if (cached_patches.containsKey(library_name)) {
if (useCachedPatches && cached_patches.containsKey(library_name)) {
// Use the pre-generated patch files for DOM dart:nnnn libraries.
var patch = cached_patches[library_name];
staticCodegen.addAll(patch);
} else if (_hasJsName(library)) {
// Library marked with @JS
_generateLibraryCodegen(uri, library, staticCodegen);
} else if (!useCachedPatches) {
// Can't use the cached patches file, instead this is a signal to generate
// the patches for this file.
_generateLibraryCodegen(uri, library, staticCodegen);
}
}); // End of library foreach
} else {
@ -676,8 +638,11 @@ var _atJsType = -1;
* Generates part files defining source code for JSObjectImpl, all DOM classes
* classes. This codegen is needed so that type checks for all registered
* JavaScript interop classes pass.
* If genCachedPatches is true then the patch files don't exist this is a special
* signal to generate and emit the patches to stdout to be captured and put into
* the file sdk/lib/js/dartium/cached_patches.dart
*/
List<String> _generateInteropPatchFiles(List<String> libraryPaths) {
List<String> _generateInteropPatchFiles(List<String> libraryPaths, genCachedPatches) {
// Cache the @JS Type.
if (_atJsType == -1) {
var uri = new Uri(scheme: "package", path: "js/js.dart");
@ -692,7 +657,7 @@ List<String> _generateInteropPatchFiles(List<String> libraryPaths) {
}
}
var ret = _generateExternalMethods(libraryPaths);
var ret = _generateExternalMethods(libraryPaths, genCachedPatches ? false : true);
var libraryPrefixes = new Map<mirrors.LibraryMirror, String>();
var prefixNames = new Set<String>();
var sb = new StringBuffer();

View file

@ -2,12 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "dart:js" as js;
void main() {
try {
var cached_files = js.createCachedPatchesFile();
print("$cached_files");
print("Generated Patches");
} catch (e) {
var workedElem = document.querySelector("#worked");
var failedElem = document.querySelector("#failed");

View file

@ -5,14 +5,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div {
<style>
div {
background: #ffffff;
text-align: center;
width: 50%;
margin: 10% 10% 25% 25%;
}
div#worked {
border: 5px solid green;
color: green;
@ -23,7 +23,7 @@
color: red;
}
.cached_file_done {
.cached_file_done {
font-family: arial;
font-size: 24pt;
}
@ -33,12 +33,12 @@
font-size: 16pt;
vertical-align: text-bottom;
}
</style>
</style>
<script async type="application/dart" src="generate_cached_patches.dart"></script>
<script async src="packages/browser/dart.js"></script>
</head>
<body>
<body>
<div id=worked>
<span class=cached_file_done>Close Dartium</span><br/><br/>
<span class=cached_file_done>File: </span>

View file

@ -13,25 +13,31 @@ set -x
# other systems. My habit is to run:
#
# ./go.sh
#
# 1. After running go.sh libraries in sdk/lib may change.
# 2. Build Dartium.
# 3. Run this script and sdk/lib/js/dartium/cached_patches will be created.
# 4. Rebuild Dartium.
# 5. Commit files in sdk/lib
#
# NOTE: If the Dart files generated from the IDLs may cause major changes which
# could cause the patch files to fail (missing classes, etc). If this
# happens delete the contents of the sdk/lib/js/dartium/cached_patches.dart
# build Dartium, run this script and build Dartium again with the newly
# generated patches.
LOCATION_DARTIUM="../../../out/Release"
DARTIUM="$LOCATION_DARTIUM"
DART_APP_LOCATION="file://"$PWD"/generate_app/generate_cached_patches.html"
DARTIUM_ARGS=" --user-data-dir=out --disable-web-security --no-sandbox --enable-logging=stderr"
DARTIUM_ARGS=" --user-data-dir=out --disable-web-security --no-sandbox --enable-blink-features=dartGenCachedPatches"
CACHED_PATCHES_FILE=""$PWD"/../../sdk/lib/js/dartium/cached_patches.dart"
if [[ "$1" != "" ]] ; then
DARTIM="$1"
fi
cmd=""$DARTIUM"/chrome "$DARTIUM_ARGS" "$DART_APP_LOCATION" 3>&1 1>&2- 2>&3 | \
cmd=""$DARTIUM"/chrome "$DARTIUM_ARGS" "$DART_APP_LOCATION" |
(sed -n '/START_OF_CACHED_PATCHES/,/END_OF_CACHED_PATCHES/p') > "$CACHED_PATCHES_FILE""
reset && eval "${cmd}"

View file

@ -9,7 +9,7 @@ execfile(os.path.join(path, 'src', 'dart', 'tools', 'deps', 'dartium.deps', 'DEP
vars.update({
"dartium_chromium_commit": "d70bedf071e56a6bb1d8ad0df8ece98745e0401a",
"dartium_webkit_commit": "b4483b1ace5b28b4678cf132087db9cd9e18deb6",
"dartium_webkit_commit": "a0bee58b8a55333175dad90e31a9becd3f4447de",
"chromium_base_revision": "338390",
# We use mirrors of all github repos to guarantee reproducibility and