mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Format all files under tools and utils directory.
BUG= R=terry@google.com Review-Url: https://codereview.chromium.org/2827793002 .
This commit is contained in:
parent
b00a85231e
commit
119b2d58ce
|
@ -12,7 +12,7 @@
|
|||
// typical usage would be as follows:
|
||||
//
|
||||
// dart
|
||||
// --package-root=<build dir>/packages \
|
||||
// --package-root=<build dir>/packages \
|
||||
// ../../tools/addlatexhash.dart dartLangSpec.tex out.tex hash.txt
|
||||
//
|
||||
// This will produce a normalized variant out.tex of the language
|
||||
|
@ -35,9 +35,9 @@ import 'package:utf/utf.dart';
|
|||
// Normalization of the text: removal or normalization of parts that
|
||||
// do not affect the output from latex, such as white space.
|
||||
|
||||
final commentRE = new RegExp(r"[^\\]%.*"); // NB: . does not match \n.
|
||||
final commentRE = new RegExp(r"[^\\]%.*"); // NB: . does not match \n.
|
||||
final whitespaceAllRE = new RegExp(r"^\s+$");
|
||||
final whitespaceRE = new RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
|
||||
final whitespaceRE = new RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
|
||||
|
||||
/// Removes [match]ing part of [line], adjusting that part with the
|
||||
/// given [startOffset] and [endOffset], bounded to be valid indices
|
||||
|
@ -55,9 +55,7 @@ cutMatch(line, match, {startOffset: 0, endOffset: 0, glue: ""}) {
|
|||
|
||||
cutRegexp(line, re, {startOffset: 0, endOffset: 0, glue: ""}) {
|
||||
return cutMatch(line, re.firstMatch(line),
|
||||
startOffset: startOffset,
|
||||
endOffset: endOffset,
|
||||
glue: glue);
|
||||
startOffset: startOffset, endOffset: endOffset, glue: glue);
|
||||
}
|
||||
|
||||
/// Removes the rest of [line] starting from the beginning of the
|
||||
|
@ -114,8 +112,8 @@ normalizeWhitespace(line) {
|
|||
/// lines as white-space-only when they occur in white-space-only
|
||||
/// line blocks.
|
||||
multilineNormalize(lines) {
|
||||
var afterBlankLines = false; // Does [line] succeed >0 empty lines?
|
||||
var afterCommentLines = false; // Does [line] succeed >0 commentOnly lines?
|
||||
var afterBlankLines = false; // Does [line] succeed >0 empty lines?
|
||||
var afterCommentLines = false; // Does [line] succeed >0 commentOnly lines?
|
||||
var newLines = new List();
|
||||
for (var line in lines) {
|
||||
if (afterBlankLines && afterCommentLines) {
|
||||
|
@ -181,7 +179,7 @@ sispNormalize(line) => stripComment(line);
|
|||
// Managing fragments with significant spacing.
|
||||
|
||||
final dartCodeBeginRE = new RegExp(r"^\s*\\begin\s*\{dartCode\}");
|
||||
final dartCodeEndRE = new RegExp (r"^\s*\\end\s*\{dartCode\}");
|
||||
final dartCodeEndRE = new RegExp(r"^\s*\\end\s*\{dartCode\}");
|
||||
|
||||
/// Recognizes beginning of dartCode block.
|
||||
sispIsDartBegin(line) => line.contains(dartCodeBeginRE);
|
||||
|
@ -272,7 +270,6 @@ abstract class HashEvent {
|
|||
}
|
||||
|
||||
class HashMarkerEvent extends HashEvent {
|
||||
|
||||
// Line number of first line in block that gets hashed.
|
||||
var startLineNumber;
|
||||
|
||||
|
@ -286,7 +283,10 @@ class HashMarkerEvent extends HashEvent {
|
|||
|
||||
HashMarkerEvent(this.startLineNumber);
|
||||
|
||||
setEndLineNumber(n) { endLineNumber = n; }
|
||||
setEndLineNumber(n) {
|
||||
endLineNumber = n;
|
||||
}
|
||||
|
||||
getStartLineNumber() => startLineNumber;
|
||||
}
|
||||
|
||||
|
@ -331,13 +331,16 @@ class HashAnalyzer {
|
|||
|
||||
sectioningPrefix() {
|
||||
switch (pendingSectioning) {
|
||||
case PENDING_IS_SECTION: return "sec:";
|
||||
case PENDING_IS_SUBSECTION: return "subsec:";
|
||||
case PENDING_IS_SUBSUBSECTION: return "subsubsec:";
|
||||
case PENDING_IS_PARAGRAPH: return "par:";
|
||||
case PENDING_IS_SECTION:
|
||||
return "sec:";
|
||||
case PENDING_IS_SUBSECTION:
|
||||
return "subsec:";
|
||||
case PENDING_IS_SUBSUBSECTION:
|
||||
return "subsubsec:";
|
||||
case PENDING_IS_PARAGRAPH:
|
||||
return "par:";
|
||||
case PENDING_IS_NONE:
|
||||
throw
|
||||
"\\LMHash{..} should only be used after a sectioning command " +
|
||||
throw "\\LMHash{..} should only be used after a sectioning command " +
|
||||
"(\\section, \\subsection, \\subsubsection, \\paragraph)";
|
||||
default:
|
||||
// set of PENDING_IS_.. was extended, but updates here omitted
|
||||
|
@ -393,13 +396,13 @@ findHashEvents(lines) {
|
|||
/// (i.e., nested {..} blocks are handled), but it may break if '{' is
|
||||
/// made an active character etc.etc.
|
||||
removeCommand(line, cmdName, startIndex) {
|
||||
const BACKSLASH = 92; // char code for '\\'.
|
||||
const BRACE_BEGIN = 123; // char code for '{'.
|
||||
const BRACE_END = 125; // char code for '}'.
|
||||
const BACKSLASH = 92; // char code for '\\'.
|
||||
const BRACE_BEGIN = 123; // char code for '{'.
|
||||
const BRACE_END = 125; // char code for '}'.
|
||||
|
||||
var blockStartIndex = startIndex + cmdName.length + 1;
|
||||
while (blockStartIndex < line.length &&
|
||||
line.codeUnitAt(blockStartIndex) != BRACE_BEGIN) {
|
||||
line.codeUnitAt(blockStartIndex) != BRACE_BEGIN) {
|
||||
blockStartIndex++;
|
||||
}
|
||||
blockStartIndex++;
|
||||
|
@ -408,8 +411,8 @@ removeCommand(line, cmdName, startIndex) {
|
|||
}
|
||||
// [blockStartIndex] has index just after '{'.
|
||||
|
||||
var afterEscape = false; // Is true iff [index] is just after '{'.
|
||||
var braceLevel = 1; // Have seen so many '{'s minus so many '}'s.
|
||||
var afterEscape = false; // Is true iff [index] is just after '{'.
|
||||
var braceLevel = 1; // Have seen so many '{'s minus so many '}'s.
|
||||
|
||||
for (var index = blockStartIndex; index < line.length; index++) {
|
||||
switch (line.codeUnitAt(index)) {
|
||||
|
@ -478,11 +481,11 @@ cleanupLine(line) => cutRegexp(line, commentRE, startOffset: 1).trimRight();
|
|||
/// a hash block terminator is encountered or [nextIndex] reached (if so,
|
||||
/// the line lines[nextIndex] itself is not included); each line is cleaned
|
||||
/// up using [cleanupLine], and " " is inserted between the lines gathered.
|
||||
gatherLines(lines, startIndex, nextIndex) =>
|
||||
lines.getRange(startIndex, nextIndex)
|
||||
.takeWhile(isntHashBlockTerminator)
|
||||
.map(cleanupLine)
|
||||
.join(" ");
|
||||
gatherLines(lines, startIndex, nextIndex) => lines
|
||||
.getRange(startIndex, nextIndex)
|
||||
.takeWhile(isntHashBlockTerminator)
|
||||
.map(cleanupLine)
|
||||
.join(" ");
|
||||
|
||||
/// Computes the hash value for the line block starting at [startIndex]
|
||||
/// in [lines], stopping just before [nextIndex]. SIDE EFFECT:
|
||||
|
@ -496,10 +499,7 @@ computeHashValue(lines, startIndex, nextIndex, listSink) {
|
|||
}
|
||||
|
||||
computeHashString(lines, startIndex, nextIndex, listSink) =>
|
||||
hex.encode(computeHashValue(lines,
|
||||
startIndex,
|
||||
nextIndex,
|
||||
listSink));
|
||||
hex.encode(computeHashValue(lines, startIndex, nextIndex, listSink));
|
||||
|
||||
/// Computes and adds hashes to \LMHash{} lines in [lines] (which
|
||||
/// must be on the line numbers specified in [hashEvents]), and emits
|
||||
|
@ -523,7 +523,7 @@ addHashMarks(lines, hashEvents, listSink) {
|
|||
}
|
||||
|
||||
/// Transforms LaTeX input to LaTeX output plus hash value list file.
|
||||
main ([args]) {
|
||||
main([args]) {
|
||||
if (args.length != 3) {
|
||||
print("Usage: addlatexhash.dart <input-file> <output-file> <list-file>");
|
||||
throw "Received ${args.length} arguments, expected three";
|
||||
|
|
|
@ -67,12 +67,18 @@ class Config {
|
|||
/// Defines the percent of classes that are dynamically instantiated.
|
||||
final int instantiateClassesPercent;
|
||||
|
||||
Config({this.nbClasses, this.nbMethodsPerClass,
|
||||
this.shareCommonSuperclass, this.sameMethodNames,
|
||||
this.shouldPrintInMethod, this.nbWhileLoopsInBody,
|
||||
this.shouldWrapProgram, this.shouldEmitCallAllMethods,
|
||||
this.shouldEmitInstantiatePreviousMethod,
|
||||
this.fakeInstantiateClass, this.instantiateClassesPercent});
|
||||
Config(
|
||||
{this.nbClasses,
|
||||
this.nbMethodsPerClass,
|
||||
this.shareCommonSuperclass,
|
||||
this.sameMethodNames,
|
||||
this.shouldPrintInMethod,
|
||||
this.nbWhileLoopsInBody,
|
||||
this.shouldWrapProgram,
|
||||
this.shouldEmitCallAllMethods,
|
||||
this.shouldEmitInstantiatePreviousMethod,
|
||||
this.fakeInstantiateClass,
|
||||
this.instantiateClassesPercent});
|
||||
}
|
||||
|
||||
String get d8Path {
|
||||
|
@ -180,12 +186,12 @@ abstract class ClassGenerator {
|
|||
String buildFileName(String filePrefix, String extension) {
|
||||
// TODO(floitsch): store other config info in the file name.
|
||||
return "$filePrefix.$nbClasses.$nbMethodsPerClass."
|
||||
"$instantiateClassesPercent.$description.$extension";
|
||||
"$instantiateClassesPercent.$description.$extension";
|
||||
}
|
||||
|
||||
String writeFile(String filePrefix) {
|
||||
buffer.clear();
|
||||
emitClasses(); // Output is stored in `buffer`.
|
||||
emitClasses(); // Output is stored in `buffer`.
|
||||
|
||||
String fileName = buildFileName(filePrefix, fileExtension);
|
||||
new File(fileName).writeAsStringSync(buffer.toString());
|
||||
|
@ -303,20 +309,15 @@ abstract class JavaScriptClassGenerator extends ClassGenerator {
|
|||
String get fileExtension => "js";
|
||||
}
|
||||
|
||||
enum PrototypeApproach {
|
||||
tmpFunction,
|
||||
internalProto,
|
||||
objectCreate
|
||||
}
|
||||
enum PrototypeApproach { tmpFunction, internalProto, objectCreate }
|
||||
|
||||
class PlainJavaScriptClassGenerator extends JavaScriptClassGenerator {
|
||||
final PrototypeApproach prototypeApproach;
|
||||
final bool shouldInlineInherit;
|
||||
final bool useMethodsObject;
|
||||
|
||||
PlainJavaScriptClassGenerator(Config config,
|
||||
{this.prototypeApproach,
|
||||
this.shouldInlineInherit,
|
||||
this.useMethodsObject})
|
||||
{this.prototypeApproach, this.shouldInlineInherit, this.useMethodsObject})
|
||||
: super(config) {
|
||||
if (prototypeApproach == null) {
|
||||
throw "Must provide prototype approach";
|
||||
|
@ -383,7 +384,6 @@ class PlainJavaScriptClassGenerator extends JavaScriptClassGenerator {
|
|||
}
|
||||
}
|
||||
''');
|
||||
|
||||
} else {
|
||||
writeln('''
|
||||
function inherit(cls, sup) {
|
||||
|
@ -448,7 +448,7 @@ class PlainJavaScriptClassGenerator extends JavaScriptClassGenerator {
|
|||
}
|
||||
|
||||
void emitMethod(int classId, String methodName, Function bodyEmitter,
|
||||
{bool emitArgument: true}) {
|
||||
{bool emitArgument: true}) {
|
||||
String argumentString = emitArgument ? argumentName : "";
|
||||
if (useMethodsObject) {
|
||||
writeln("$methodName: function($argumentString)");
|
||||
|
@ -476,15 +476,13 @@ class PlainJavaScriptClassGenerator extends JavaScriptClassGenerator {
|
|||
methodIds.add(j);
|
||||
}
|
||||
if (shouldEmitCallAllMethods) {
|
||||
emitMethod(classId,
|
||||
callOtherMethodsName,
|
||||
emitMethod(classId, callOtherMethodsName,
|
||||
() => emitCallOtherMethodsBody(methodIds, classId));
|
||||
}
|
||||
if (shouldEmitInstantiatePreviousMethod) {
|
||||
emitMethod(classId,
|
||||
instantiatePreviousMethodName,
|
||||
emitMethod(classId, instantiatePreviousMethodName,
|
||||
() => emitInstantiatePrevious(classId),
|
||||
emitArgument: false);
|
||||
emitArgument: false);
|
||||
}
|
||||
if (useMethodsObject) {
|
||||
writeln("};");
|
||||
|
@ -639,9 +637,8 @@ class DartClassGenerator extends ClassGenerator {
|
|||
}
|
||||
print("compiling");
|
||||
print("dart2jsPath: $dart2jsPath");
|
||||
ProcessResult result =
|
||||
await Process.run(dart2jsPath, [dartFile, "--out=$outFile"],
|
||||
environment: env);
|
||||
ProcessResult result = await Process
|
||||
.run(dart2jsPath, [dartFile, "--out=$outFile"], environment: env);
|
||||
if (result.exitCode != 0) {
|
||||
print("compilation failed");
|
||||
print(result.stdout);
|
||||
|
@ -652,7 +649,7 @@ class DartClassGenerator extends ClassGenerator {
|
|||
return outFile;
|
||||
}
|
||||
|
||||
Future measureDart(String filePrefix, { bool useSnapshot: false }) async {
|
||||
Future measureDart(String filePrefix, {bool useSnapshot: false}) async {
|
||||
String dartFile = writeFile(filePrefix);
|
||||
String command = Platform.executable;
|
||||
Stopwatch watch = new Stopwatch();
|
||||
|
@ -663,7 +660,7 @@ class DartClassGenerator extends ClassGenerator {
|
|||
print("creating snapshot");
|
||||
measuring = new File("${dir.path}/measuring.snapshot").path;
|
||||
ProcessResult result =
|
||||
await Process.run(command, ["--snapshot=$measuring", dartFile]);
|
||||
await Process.run(command, ["--snapshot=$measuring", dartFile]);
|
||||
if (result.exitCode != 0) {
|
||||
print("snapshot creation failed");
|
||||
print(result.stdout);
|
||||
|
@ -720,8 +717,7 @@ main(List<String> arguments) async {
|
|||
nbWhileLoopsInBody: 1,
|
||||
shouldWrapProgram: true,
|
||||
shouldEmitCallAllMethods: true,
|
||||
shouldEmitInstantiatePreviousMethod: true
|
||||
);
|
||||
shouldEmitInstantiatePreviousMethod: true);
|
||||
|
||||
var plain = new PlainJavaScriptClassGenerator(config,
|
||||
prototypeApproach: PrototypeApproach.tmpFunction,
|
||||
|
|
|
@ -71,7 +71,7 @@ void startServer() {
|
|||
Directory directory = new Directory(root);
|
||||
if (!directory.existsSync()) {
|
||||
print("Directory '$root' does not exist. "
|
||||
"Run 'pub build' to generate the output.");
|
||||
"Run 'pub build' to generate the output.");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -80,10 +80,10 @@ void startServer() {
|
|||
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, port).then((server) {
|
||||
port = server.port;
|
||||
print("Source mapping server is running on "
|
||||
"'http://${server.address.address}:$port/'");
|
||||
"'http://${server.address.address}:$port/'");
|
||||
Router router = new Router(server)
|
||||
..serve('/file').listen(handleFile)
|
||||
..serve('/map').listen(handleSourceMapFile);
|
||||
..serve('/file').listen(handleFile)
|
||||
..serve('/map').listen(handleSourceMapFile);
|
||||
|
||||
// Set up default handler. This will serve files from our 'build'
|
||||
// directory. Disable jail root, as packages are local symlinks.
|
||||
|
@ -133,4 +133,4 @@ startBrowser(String url) {
|
|||
print(result.stderr);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ Future getMap() {
|
|||
Completer c = new Completer();
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
httpRequest
|
||||
..open('GET', '/map')
|
||||
..onLoadEnd.listen((_) => c.complete(httpRequest.responseText))
|
||||
..send('');
|
||||
..open('GET', '/map')
|
||||
..onLoadEnd.listen((_) => c.complete(httpRequest.responseText))
|
||||
..send('');
|
||||
return c.future;
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ Future fetchFile(String path) {
|
|||
HttpRequest httpRequest = new HttpRequest();
|
||||
sourceFileName.text = path;
|
||||
httpRequest
|
||||
..open('GET', path)
|
||||
..onLoadEnd.listen((_) => c.complete(httpRequest.responseText))
|
||||
..send('');
|
||||
..open('GET', path)
|
||||
..onLoadEnd.listen((_) => c.complete(httpRequest.responseText))
|
||||
..send('');
|
||||
return c.future;
|
||||
}
|
||||
|
||||
|
@ -55,18 +55,18 @@ displaySource(String filename, List<String> source, TargetEntry entry) {
|
|||
String id = nameId == null ? null : sourceMap.names[nameId];
|
||||
selectedSource.children.clear();
|
||||
SpanElement marker = new SpanElement()
|
||||
..className = "marker"
|
||||
..appendText("*");
|
||||
..className = "marker"
|
||||
..appendText("*");
|
||||
for (int pos = 0; pos < source.length; pos++) {
|
||||
String l = source[pos];
|
||||
if (pos != line) {
|
||||
selectedSource.children.add(l.isEmpty ? new BRElement() : new DivElement()
|
||||
..appendText(l));
|
||||
..appendText(l));
|
||||
} else {
|
||||
selectedSource.children.add(new DivElement()
|
||||
..appendText(l.substring(0, column))
|
||||
..children.add(marker)
|
||||
..appendText(l.substring(column)));
|
||||
..appendText(l.substring(0, column))
|
||||
..children.add(marker)
|
||||
..appendText(l.substring(column)));
|
||||
}
|
||||
}
|
||||
sourceFileName.text = filename;
|
||||
|
@ -106,8 +106,8 @@ void highlightSelectedSpan(TargetEntry entry, TargetLineEntry lineEntry) {
|
|||
String sourceName = source.substring(source.lastIndexOf('/') + 1);
|
||||
String sourcePoint =
|
||||
'Source: Line ${entry.sourceLine} Col. ${entry.sourceColumn}';
|
||||
sourcePoint +=
|
||||
entry.sourceNameId == null ? ''
|
||||
sourcePoint += entry.sourceNameId == null
|
||||
? ''
|
||||
: ' (${sourceMap.names[entry.sourceNameId]})';
|
||||
sourcePoint += ' in $sourceName';
|
||||
selectedOutputSpan.children.add(getTextElement(targetSpan));
|
||||
|
@ -122,21 +122,21 @@ void highlightSelectedSpan(TargetEntry entry, TargetLineEntry lineEntry) {
|
|||
String highlightColor = "#99ff99";
|
||||
highlightedMapEntry = targetEntryMap[entry];
|
||||
highlightedMapEntry[0]
|
||||
..scrollIntoView()
|
||||
..style.backgroundColor = highlightColor;
|
||||
..scrollIntoView()
|
||||
..style.backgroundColor = highlightColor;
|
||||
highlightedMapEntry[1]
|
||||
..scrollIntoView()
|
||||
..style.backgroundColor = highlightColor;
|
||||
..scrollIntoView()
|
||||
..style.backgroundColor = highlightColor;
|
||||
highlightedMapEntry[1].onMouseOver.listen((e) {
|
||||
selectedOutputSpan.style.zIndex = "2";
|
||||
selectedOutputSpan.style.visibility = "visible";
|
||||
selectedOutputSpan.style.top = "${decodedMap.offsetTo(document.body).y +
|
||||
decodedMap.clientHeight - 20}px";
|
||||
selectedOutputSpan.style.left = "${decodedMap.offsetTo(document.body).x}px";
|
||||
selectedOutputSpan.style.width= "${decodedMap.clientWidth}px";
|
||||
selectedOutputSpan.style.width = "${decodedMap.clientWidth}px";
|
||||
});
|
||||
|
||||
highlightedMapEntry[1].onMouseOut.listen( (e) {
|
||||
highlightedMapEntry[1].onMouseOut.listen((e) {
|
||||
selectedOutputSpan.style.visibility = "hidden";
|
||||
});
|
||||
|
||||
|
@ -149,19 +149,19 @@ void loadSource(TargetEntry entry) {
|
|||
}
|
||||
|
||||
String source = sourceMap.urls[entry.sourceUrlId];
|
||||
fetchFile(new Uri(path: "/file",
|
||||
queryParameters: {"path": source}).toString()).then((text)
|
||||
=> displaySource(source, text.split("\n"), entry));
|
||||
fetchFile(
|
||||
new Uri(path: "/file", queryParameters: {"path": source}).toString())
|
||||
.then((text) => displaySource(source, text.split("\n"), entry));
|
||||
selectedSource.text = "loading";
|
||||
}
|
||||
|
||||
SpanElement createSpan(String content, TargetEntry entry,
|
||||
TargetLineEntry lineEntry) {
|
||||
return new SpanElement()
|
||||
SpanElement createSpan(
|
||||
String content, TargetEntry entry, TargetLineEntry lineEntry) {
|
||||
return new SpanElement()
|
||||
..addEventListener('click', (e) {
|
||||
loadSource(entry);
|
||||
highlightSelectedSpan(entry, lineEntry);
|
||||
}, false)
|
||||
loadSource(entry);
|
||||
highlightSelectedSpan(entry, lineEntry);
|
||||
}, false)
|
||||
..className = "range${entry.sourceUrlId % 4}"
|
||||
..appendText(content);
|
||||
}
|
||||
|
@ -182,14 +182,14 @@ Element getTextElement(String text) {
|
|||
|
||||
addTargetLine(int lineNumber, String content, TargetLineEntry lineEntry) {
|
||||
if (content.isEmpty) {
|
||||
generatedOutput.children.add(new DivElement()
|
||||
..children.add(getLineNumberElement(lineNumber)));
|
||||
generatedOutput.children
|
||||
.add(new DivElement()..children.add(getLineNumberElement(lineNumber)));
|
||||
return;
|
||||
}
|
||||
if (lineEntry == null) {
|
||||
generatedOutput.children.add(new DivElement()
|
||||
..children.add(getLineNumberElement(lineNumber))
|
||||
..children.add(getTextElement(content)));
|
||||
..children.add(getLineNumberElement(lineNumber))
|
||||
..children.add(getTextElement(content)));
|
||||
return;
|
||||
}
|
||||
DivElement div = new DivElement();
|
||||
|
@ -232,8 +232,8 @@ void displayTargetSource() {
|
|||
int linesIndex = 0;
|
||||
for (int line = 0; line < target.length; line++) {
|
||||
TargetLineEntry entry = null;
|
||||
if (linesIndex < targetLines.length
|
||||
&& targetLines[linesIndex].line == line) {
|
||||
if (linesIndex < targetLines.length &&
|
||||
targetLines[linesIndex].line == line) {
|
||||
entry = targetLines[linesIndex];
|
||||
linesIndex++;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ String getMappedData(String mapFileContent) {
|
|||
// Source map contains mapping information in this format:
|
||||
// "mappings": "A;A,yC;"
|
||||
List<String> mapEntry = mapFileContent.split('mappings');
|
||||
return mapEntry[mapEntry.length-1].split('"')[2];
|
||||
return mapEntry[mapEntry.length - 1].split('"')[2];
|
||||
}
|
||||
|
||||
SpanElement createMapSpan(String segment) {
|
||||
|
@ -257,9 +257,10 @@ SpanElement createMapSpan(String segment) {
|
|||
}
|
||||
|
||||
SpanElement createDecodedMapSpan(TargetEntry entry) {
|
||||
return new SpanElement()..text = '(${entry.column}, ${entry.sourceUrlId},'
|
||||
' ${entry.sourceLine},'
|
||||
' ${entry.sourceColumn})';
|
||||
return new SpanElement()
|
||||
..text = '(${entry.column}, ${entry.sourceUrlId},'
|
||||
' ${entry.sourceLine},'
|
||||
' ${entry.sourceColumn})';
|
||||
}
|
||||
|
||||
displayMap(String mapFileContent) {
|
||||
|
@ -302,9 +303,8 @@ displayMap(String mapFileContent) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
Future load(String q) => fetchFile(new Uri(path: "/file", queryParameters: {
|
||||
"path": q
|
||||
}).toString());
|
||||
Future load(String q) => fetchFile(
|
||||
new Uri(path: "/file", queryParameters: {"path": q}).toString());
|
||||
|
||||
getMap().then((mapFileName) {
|
||||
load(mapFileName).then((mapFileContent) {
|
||||
|
@ -320,4 +320,4 @@ void main() {
|
|||
});
|
||||
|
||||
sourceFileName.text = "<source not selected>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,17 @@ import 'dart:io';
|
|||
|
||||
Future downloadFile(Uri url, String destination) {
|
||||
var client = new HttpClient();
|
||||
return client.getUrl(url)
|
||||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
if (response.statusCode != HttpStatus.OK) {
|
||||
throw new Exception("Http status code (${response.statusCode}) "
|
||||
"was not 200. Aborting.");
|
||||
}
|
||||
var sink = new File(destination).openWrite();
|
||||
return response.pipe(sink).then((_) {
|
||||
client.close();
|
||||
return client
|
||||
.getUrl(url)
|
||||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
if (response.statusCode != HttpStatus.OK) {
|
||||
throw new Exception("Http status code (${response.statusCode}) "
|
||||
"was not 200. Aborting.");
|
||||
}
|
||||
var sink = new File(destination).openWrite();
|
||||
return response.pipe(sink).then((_) {
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,4 +12,3 @@ void main() {
|
|||
failedElem.style.visibility = 'inline';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,8 @@ final String lib_uri = Platform.script.resolve('../../../../sdk').toString();
|
|||
main() {
|
||||
print('Converting HTML docs from $lib_uri to $json_path.');
|
||||
|
||||
convert(lib_uri, json_path)
|
||||
.then((bool anyErrors) {
|
||||
print('Converted HTML docs ${anyErrors ? "with": "without"}'
|
||||
convert(lib_uri, json_path).then((bool anyErrors) {
|
||||
print('Converted HTML docs ${anyErrors ? "with": "without"}'
|
||||
' errors.');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,12 +20,14 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
|
||||
/// The various HTML libraries.
|
||||
const List<String> HTML_LIBRARY_NAMES = const ['dart:html',
|
||||
'dart:indexed_db',
|
||||
'dart:svg',
|
||||
'dart:web_audio',
|
||||
'dart:web_gl',
|
||||
'dart:web_sql'];
|
||||
const List<String> HTML_LIBRARY_NAMES = const [
|
||||
'dart:html',
|
||||
'dart:indexed_db',
|
||||
'dart:svg',
|
||||
'dart:web_audio',
|
||||
'dart:web_gl',
|
||||
'dart:web_sql'
|
||||
];
|
||||
/**
|
||||
* Converts the libraries in [HTML_LIBRARY_NAMES] to a json file at [jsonPath]
|
||||
* given the library path at [libUri].
|
||||
|
@ -59,10 +61,10 @@ Future<bool> convert(String libUri, String jsonPath) {
|
|||
}
|
||||
|
||||
return analyze(paths, libUri, options: ['--preserve-comments'])
|
||||
.then((MirrorSystem mirrors) {
|
||||
var convertedJson = _generateJsonFromLibraries(mirrors);
|
||||
return _exportJsonToFile(convertedJson, jsonPath);
|
||||
});
|
||||
.then((MirrorSystem mirrors) {
|
||||
var convertedJson = _generateJsonFromLibraries(mirrors);
|
||||
return _exportJsonToFile(convertedJson, jsonPath);
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> _exportJsonToFile(Map convertedJson, String jsonPath) {
|
||||
|
@ -81,25 +83,26 @@ Map _generateJsonFromLibraries(MirrorSystem mirrors) {
|
|||
var convertedJson = {};
|
||||
|
||||
// Sort the libraries by name (not key).
|
||||
var sortedLibraries = new List<LibraryMirror>.from(
|
||||
mirrors.libraries.values.where(
|
||||
(e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
|
||||
..sort((x, y) =>
|
||||
x.uri.toString().toUpperCase().compareTo(
|
||||
y.uri.toString().toUpperCase()));
|
||||
var sortedLibraries = new List<LibraryMirror>.from(mirrors.libraries.values
|
||||
.where((e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
|
||||
..sort((x, y) => x.uri
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.compareTo(y.uri.toString().toUpperCase()));
|
||||
|
||||
for (LibraryMirror libMirror in sortedLibraries) {
|
||||
print('Extracting documentation from ${libMirror.simpleName}.');
|
||||
|
||||
var libraryJson = {};
|
||||
var sortedClasses = _sortAndFilterMirrors(
|
||||
classesOf(libMirror.declarations).toList(), ignoreDocsEditable: true);
|
||||
classesOf(libMirror.declarations).toList(),
|
||||
ignoreDocsEditable: true);
|
||||
|
||||
for (ClassMirror classMirror in sortedClasses) {
|
||||
print(' class: $classMirror');
|
||||
var classJson = {};
|
||||
var sortedMembers = _sortAndFilterMirrors(
|
||||
membersOf(classMirror.declarations).toList());
|
||||
var sortedMembers =
|
||||
_sortAndFilterMirrors(membersOf(classMirror.declarations).toList());
|
||||
|
||||
var membersJson = {};
|
||||
for (var memberMirror in sortedMembers) {
|
||||
|
@ -120,26 +123,23 @@ Map _generateJsonFromLibraries(MirrorSystem mirrors) {
|
|||
}
|
||||
|
||||
// Only include the comment if DocsEditable is set.
|
||||
var classComment = _splitCommentsByNewline(
|
||||
computeUntrimmedCommentAsList(classMirror));
|
||||
var classComment =
|
||||
_splitCommentsByNewline(computeUntrimmedCommentAsList(classMirror));
|
||||
if (!classComment.isEmpty &&
|
||||
findMetadata(classMirror.metadata, 'DocsEditable') != null) {
|
||||
classJson.putIfAbsent('comment', () => classComment);
|
||||
}
|
||||
if (!membersJson.isEmpty) {
|
||||
classJson.putIfAbsent('members', () =>
|
||||
membersJson);
|
||||
classJson.putIfAbsent('members', () => membersJson);
|
||||
}
|
||||
|
||||
if (!classJson.isEmpty) {
|
||||
libraryJson.putIfAbsent(domNames(classMirror)[0], () =>
|
||||
classJson);
|
||||
libraryJson.putIfAbsent(domNames(classMirror)[0], () => classJson);
|
||||
}
|
||||
}
|
||||
|
||||
if (!libraryJson.isEmpty) {
|
||||
convertedJson.putIfAbsent(nameOf(libMirror), () =>
|
||||
libraryJson);
|
||||
convertedJson.putIfAbsent(nameOf(libMirror), () => libraryJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,17 +153,17 @@ Map _generateJsonFromLibraries(MirrorSystem mirrors) {
|
|||
/// members are generated.
|
||||
List<DeclarationMirror> _sortAndFilterMirrors(List<DeclarationMirror> mirrors,
|
||||
{ignoreDocsEditable: false}) {
|
||||
|
||||
var filteredMirrors = mirrors.where((DeclarationMirror c) =>
|
||||
!domNames(c).isEmpty &&
|
||||
!displayName(c).startsWith('_') &&
|
||||
(!ignoreDocsEditable ? (findMetadata(c.metadata, 'DocsEditable') != null)
|
||||
: true))
|
||||
var filteredMirrors = mirrors
|
||||
.where((DeclarationMirror c) =>
|
||||
!domNames(c).isEmpty &&
|
||||
!displayName(c).startsWith('_') &&
|
||||
(!ignoreDocsEditable
|
||||
? (findMetadata(c.metadata, 'DocsEditable') != null)
|
||||
: true))
|
||||
.toList();
|
||||
|
||||
filteredMirrors.sort((x, y) =>
|
||||
domNames(x)[0].toUpperCase().compareTo(
|
||||
domNames(y)[0].toUpperCase()));
|
||||
domNames(x)[0].toUpperCase().compareTo(domNames(y)[0].toUpperCase()));
|
||||
|
||||
return filteredMirrors;
|
||||
}
|
||||
|
|
|
@ -40,19 +40,21 @@ main() {
|
|||
if (testJson.existsSync()) testJson.deleteSync();
|
||||
assert(!testJson.existsSync());
|
||||
|
||||
expect(convert(lib_uri, testJsonPath)
|
||||
.then((bool anyErrors) {
|
||||
expect(anyErrors, isFalse);
|
||||
expect(
|
||||
convert(lib_uri, testJsonPath).then((bool anyErrors) {
|
||||
expect(anyErrors, isFalse);
|
||||
|
||||
// We should have a file now.
|
||||
expect(testJson.existsSync(), isTrue);
|
||||
// We should have a file now.
|
||||
expect(testJson.existsSync(), isTrue);
|
||||
|
||||
// Ensure that there's nothing different between the new JSON and old.
|
||||
expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync()));
|
||||
// Ensure that there's nothing different between the new JSON and old.
|
||||
expect(testJson.readAsStringSync(),
|
||||
equals(oldJson.readAsStringSync()));
|
||||
|
||||
// Ensure that the old JSON file didn't actually change.
|
||||
expect(oldJsonModified, equals(oldJson.lastModifiedSync()));
|
||||
}), completes);
|
||||
// Ensure that the old JSON file didn't actually change.
|
||||
expect(oldJsonModified, equals(oldJson.lastModifiedSync()));
|
||||
}),
|
||||
completes);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,24 +4,23 @@
|
|||
|
||||
List sorted(Iterable input, [compare, key]) {
|
||||
comparator(compare, key) {
|
||||
if (compare == null && key == null)
|
||||
return (a, b) => a.compareTo(b);
|
||||
if (compare == null)
|
||||
return (a, b) => key(a).compareTo(key(b));
|
||||
if (key == null)
|
||||
return compare;
|
||||
if (compare == null && key == null) return (a, b) => a.compareTo(b);
|
||||
if (compare == null) return (a, b) => key(a).compareTo(key(b));
|
||||
if (key == null) return compare;
|
||||
return (a, b) => compare(key(a), key(b));
|
||||
}
|
||||
|
||||
List copy = new List.from(input);
|
||||
copy.sort(comparator(compare, key));
|
||||
return copy;
|
||||
}
|
||||
|
||||
render(idl_node, [indent_str=' ']) {
|
||||
render(idl_node, [indent_str = ' ']) {
|
||||
var output = [''];
|
||||
var indent_stack = [];
|
||||
|
||||
indented(action) { // TODO: revert to indented(action()) {
|
||||
// TODO: revert to indented(action()) {
|
||||
indented(action) {
|
||||
indent_stack.add(indent_str);
|
||||
action();
|
||||
indent_stack.removeLast();
|
||||
|
@ -48,8 +47,7 @@ render(idl_node, [indent_str=' ']) {
|
|||
if (node == null) {
|
||||
return;
|
||||
} else if (node is String) {
|
||||
if (output.last.endsWith('\n'))
|
||||
output.addAll(indent_stack);
|
||||
if (output.last.endsWith('\n')) output.addAll(indent_stack);
|
||||
output.add(node);
|
||||
} else if (node is List) {
|
||||
var separator = null;
|
||||
|
@ -66,32 +64,33 @@ render(idl_node, [indent_str=' ']) {
|
|||
w(node.extAttrs);
|
||||
wln('module ${node.id} {');
|
||||
indented(() {
|
||||
w(node.interfaces);
|
||||
w(node.typedefs);
|
||||
});
|
||||
w(node.interfaces);
|
||||
w(node.typedefs);
|
||||
});
|
||||
wln('};');
|
||||
} else if (node is IDLInterface) {
|
||||
w(node.annotations);
|
||||
w(node.extAttrs);
|
||||
w('interface ${node.id}');
|
||||
indented(() {
|
||||
if (!node.parents.isEmpty) {
|
||||
wln(' :');
|
||||
w(node.parents, ',\n');
|
||||
if (!node.parents.isEmpty) {
|
||||
wln(' :');
|
||||
w(node.parents, ',\n');
|
||||
}
|
||||
wln(' {');
|
||||
section(list, comment) {
|
||||
if (list != null && !list.isEmpty) {
|
||||
wln();
|
||||
wln(comment);
|
||||
w(sort(list));
|
||||
}
|
||||
wln(' {');
|
||||
section(list, comment) {
|
||||
if (list != null && !list.isEmpty) {
|
||||
wln();
|
||||
wln(comment);
|
||||
w(sort(list));
|
||||
}
|
||||
}
|
||||
section(node.constants, '/* Constants */');
|
||||
section(node.attributes, '/* Attributes */');
|
||||
section(node.operations, '/* Operations */');
|
||||
section(node.snippets, '/* Snippets */');
|
||||
});
|
||||
}
|
||||
|
||||
section(node.constants, '/* Constants */');
|
||||
section(node.attributes, '/* Attributes */');
|
||||
section(node.operations, '/* Operations */');
|
||||
section(node.snippets, '/* Snippets */');
|
||||
});
|
||||
wln('};');
|
||||
} else if (node is IDLParentInterface) {
|
||||
w(node.annotations);
|
||||
|
@ -116,7 +115,7 @@ render(idl_node, [indent_str=' ']) {
|
|||
w(' ');
|
||||
}
|
||||
} else if (node is IDLExtAttrs) {
|
||||
if(!node.map.isEmpty) {
|
||||
if (!node.map.isEmpty) {
|
||||
w('[');
|
||||
var sep = null;
|
||||
for (var name in sorted(node.map.keys)) {
|
||||
|
@ -160,8 +159,7 @@ render(idl_node, [indent_str=' ']) {
|
|||
} else if (node is IDLArgument) {
|
||||
w(node.extAttrs);
|
||||
w('in ');
|
||||
if (node.isOptional)
|
||||
w('optional ');
|
||||
if (node.isOptional) w('optional ');
|
||||
w('${node.type.id} ${node.id}');
|
||||
} else if (node is IDLExtAttrFunctionValue) {
|
||||
w(node.name);
|
||||
|
|
|
@ -10,7 +10,9 @@ abstract class _AttributeMap implements Map<String, String> {
|
|||
_AttributeMap(this._element);
|
||||
|
||||
void addAll(Map<String, String> other) {
|
||||
other.forEach((k, v) { this[k] = v; });
|
||||
other.forEach((k, v) {
|
||||
this[k] = v;
|
||||
});
|
||||
}
|
||||
|
||||
bool containsValue(Object value) {
|
||||
|
@ -90,8 +92,7 @@ abstract class _AttributeMap implements Map<String, String> {
|
|||
* Wrapper to expose [Element.attributes] as a typed map.
|
||||
*/
|
||||
class _ElementAttributeMap extends _AttributeMap {
|
||||
|
||||
_ElementAttributeMap(Element element): super(element);
|
||||
_ElementAttributeMap(Element element) : super(element);
|
||||
|
||||
bool containsKey(Object key) {
|
||||
return _element._hasAttribute(key);
|
||||
|
@ -125,10 +126,9 @@ class _ElementAttributeMap extends _AttributeMap {
|
|||
* Wrapper to expose namespaced attributes as a typed map.
|
||||
*/
|
||||
class _NamespacedAttributeMap extends _AttributeMap {
|
||||
|
||||
final String _namespace;
|
||||
|
||||
_NamespacedAttributeMap(Element element, this._namespace): super(element);
|
||||
_NamespacedAttributeMap(Element element, this._namespace) : super(element);
|
||||
|
||||
bool containsKey(Object key) {
|
||||
return _element._hasAttributeNS(_namespace, key);
|
||||
|
@ -158,13 +158,11 @@ class _NamespacedAttributeMap extends _AttributeMap {
|
|||
bool _matches(Node node) => node._namespaceUri == _namespace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a Map abstraction on top of data-* attributes, similar to the
|
||||
* dataSet in the old DOM.
|
||||
*/
|
||||
class _DataAttributeMap implements Map<String, String> {
|
||||
|
||||
final Map<String, String> _attributes;
|
||||
|
||||
_DataAttributeMap(this._attributes);
|
||||
|
@ -172,7 +170,9 @@ class _DataAttributeMap implements Map<String, String> {
|
|||
// interface Map
|
||||
|
||||
void addAll(Map<String, String> other) {
|
||||
other.forEach((k, v) { this[k] = v; });
|
||||
other.forEach((k, v) {
|
||||
this[k] = v;
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Use lazy iterator when it is available on Map.
|
||||
|
@ -187,7 +187,7 @@ class _DataAttributeMap implements Map<String, String> {
|
|||
}
|
||||
|
||||
String putIfAbsent(String key, String ifAbsent()) =>
|
||||
_attributes.putIfAbsent(_attr(key), ifAbsent);
|
||||
_attributes.putIfAbsent(_attr(key), ifAbsent);
|
||||
|
||||
String remove(Object key) => _attributes.remove(_attr(key));
|
||||
|
||||
|
|
|
@ -139,7 +139,8 @@ abstract class WindowBase implements EventTarget {
|
|||
* * [Cross-document messaging](https://html.spec.whatwg.org/multipage/comms.html#web-messaging)
|
||||
* from WHATWG.
|
||||
*/
|
||||
void postMessage(var message, String targetOrigin, [List<MessagePort> messagePorts]);
|
||||
void postMessage(var message, String targetOrigin,
|
||||
[List<MessagePort> messagePorts]);
|
||||
}
|
||||
|
||||
abstract class LocationBase {
|
||||
|
|
|
@ -6,7 +6,6 @@ part of html;
|
|||
|
||||
/** A Set that stores the CSS class names for an element. */
|
||||
abstract class CssClassSet implements Set<String> {
|
||||
|
||||
/**
|
||||
* Adds the class [value] to the element if it is not on it, removes it if it
|
||||
* is.
|
||||
|
|
|
@ -9,14 +9,13 @@ part of html;
|
|||
* [box model](http://www.w3.org/TR/CSS2/box.html).
|
||||
*/
|
||||
class _ContentCssRect extends CssRect {
|
||||
|
||||
_ContentCssRect(Element element) : super(element);
|
||||
|
||||
num get height => _element.offsetHeight +
|
||||
_addOrSubtractToBoxModel(_HEIGHT, _CONTENT);
|
||||
num get height =>
|
||||
_element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _CONTENT);
|
||||
|
||||
num get width => _element.offsetWidth +
|
||||
_addOrSubtractToBoxModel(_WIDTH, _CONTENT);
|
||||
num get width =>
|
||||
_element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _CONTENT);
|
||||
|
||||
/**
|
||||
* Set the height to `newHeight`.
|
||||
|
@ -59,9 +58,11 @@ class _ContentCssRect extends CssRect {
|
|||
}
|
||||
}
|
||||
|
||||
num get left => _element.getBoundingClientRect().left -
|
||||
num get left =>
|
||||
_element.getBoundingClientRect().left -
|
||||
_addOrSubtractToBoxModel(['left'], _CONTENT);
|
||||
num get top => _element.getBoundingClientRect().top -
|
||||
num get top =>
|
||||
_element.getBoundingClientRect().top -
|
||||
_addOrSubtractToBoxModel(['top'], _CONTENT);
|
||||
}
|
||||
|
||||
|
@ -106,14 +107,16 @@ class _ContentCssListRect extends _ContentCssRect {
|
|||
*/
|
||||
class _PaddingCssRect extends CssRect {
|
||||
_PaddingCssRect(element) : super(element);
|
||||
num get height => _element.offsetHeight +
|
||||
_addOrSubtractToBoxModel(_HEIGHT, _PADDING);
|
||||
num get width => _element.offsetWidth +
|
||||
_addOrSubtractToBoxModel(_WIDTH, _PADDING);
|
||||
num get height =>
|
||||
_element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _PADDING);
|
||||
num get width =>
|
||||
_element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _PADDING);
|
||||
|
||||
num get left => _element.getBoundingClientRect().left -
|
||||
num get left =>
|
||||
_element.getBoundingClientRect().left -
|
||||
_addOrSubtractToBoxModel(['left'], _PADDING);
|
||||
num get top => _element.getBoundingClientRect().top -
|
||||
num get top =>
|
||||
_element.getBoundingClientRect().top -
|
||||
_addOrSubtractToBoxModel(['top'], _PADDING);
|
||||
}
|
||||
|
||||
|
@ -138,14 +141,16 @@ class _BorderCssRect extends CssRect {
|
|||
*/
|
||||
class _MarginCssRect extends CssRect {
|
||||
_MarginCssRect(element) : super(element);
|
||||
num get height => _element.offsetHeight +
|
||||
_addOrSubtractToBoxModel(_HEIGHT, _MARGIN);
|
||||
num get height =>
|
||||
_element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _MARGIN);
|
||||
num get width =>
|
||||
_element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _MARGIN);
|
||||
|
||||
num get left => _element.getBoundingClientRect().left -
|
||||
num get left =>
|
||||
_element.getBoundingClientRect().left -
|
||||
_addOrSubtractToBoxModel(['left'], _MARGIN);
|
||||
num get top => _element.getBoundingClientRect().top -
|
||||
num get top =>
|
||||
_element.getBoundingClientRect().top -
|
||||
_addOrSubtractToBoxModel(['top'], _MARGIN);
|
||||
}
|
||||
|
||||
|
@ -225,8 +230,8 @@ abstract class CssRect implements Rectangle<num> {
|
|||
* to augmentingMeasurement, we may need to add or subtract margin, padding,
|
||||
* or border values, depending on the measurement we're trying to obtain.
|
||||
*/
|
||||
num _addOrSubtractToBoxModel(List<String> dimensions,
|
||||
String augmentingMeasurement) {
|
||||
num _addOrSubtractToBoxModel(
|
||||
List<String> dimensions, String augmentingMeasurement) {
|
||||
// getComputedStyle always returns pixel values (hence, computed), so we're
|
||||
// always dealing with pixels in this method.
|
||||
var styles = _element.getComputedStyle();
|
||||
|
@ -237,22 +242,25 @@ abstract class CssRect implements Rectangle<num> {
|
|||
// The border-box and default box model both exclude margin in the regular
|
||||
// height/width calculation, so add it if we want it for this measurement.
|
||||
if (augmentingMeasurement == _MARGIN) {
|
||||
val += new Dimension.css(styles.getPropertyValue(
|
||||
'$augmentingMeasurement-$measurement')).value;
|
||||
val += new Dimension.css(
|
||||
styles.getPropertyValue('$augmentingMeasurement-$measurement'))
|
||||
.value;
|
||||
}
|
||||
|
||||
// The border-box includes padding and border, so remove it if we want
|
||||
// just the content itself.
|
||||
if (augmentingMeasurement == _CONTENT) {
|
||||
val -= new Dimension.css(
|
||||
styles.getPropertyValue('${_PADDING}-$measurement')).value;
|
||||
val -= new Dimension.css(
|
||||
styles.getPropertyValue('${_PADDING}-$measurement'))
|
||||
.value;
|
||||
}
|
||||
|
||||
// At this point, we don't wan't to augment with border or margin,
|
||||
// so remove border.
|
||||
if (augmentingMeasurement != _MARGIN) {
|
||||
val -= new Dimension.css(styles.getPropertyValue(
|
||||
'border-${measurement}-width')).value;
|
||||
val -= new Dimension.css(
|
||||
styles.getPropertyValue('border-${measurement}-width'))
|
||||
.value;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
|
@ -271,13 +279,15 @@ abstract class CssRect implements Rectangle<num> {
|
|||
}
|
||||
|
||||
bool operator ==(other) {
|
||||
if (other is !Rectangle) return false;
|
||||
return left == other.left && top == other.top && right == other.right &&
|
||||
if (other is! Rectangle) return false;
|
||||
return left == other.left &&
|
||||
top == other.top &&
|
||||
right == other.right &&
|
||||
bottom == other.bottom;
|
||||
}
|
||||
|
||||
int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode,
|
||||
right.hashCode, bottom.hashCode);
|
||||
int get hashCode => _JenkinsSmiHash.hash4(
|
||||
left.hashCode, top.hashCode, right.hashCode, bottom.hashCode);
|
||||
|
||||
/**
|
||||
* Computes the intersection of `this` and [other].
|
||||
|
@ -303,7 +313,6 @@ abstract class CssRect implements Rectangle<num> {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if `this` intersects [other].
|
||||
*/
|
||||
|
@ -332,9 +341,9 @@ abstract class CssRect implements Rectangle<num> {
|
|||
*/
|
||||
bool containsRectangle(Rectangle<num> another) {
|
||||
return left <= another.left &&
|
||||
left + width >= another.left + another.width &&
|
||||
top <= another.top &&
|
||||
top + height >= another.top + another.height;
|
||||
left + width >= another.left + another.width &&
|
||||
top <= another.top &&
|
||||
top + height >= another.top + another.height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,17 +351,17 @@ abstract class CssRect implements Rectangle<num> {
|
|||
*/
|
||||
bool containsPoint(Point<num> another) {
|
||||
return another.x >= left &&
|
||||
another.x <= left + width &&
|
||||
another.y >= top &&
|
||||
another.y <= top + height;
|
||||
another.x <= left + width &&
|
||||
another.y >= top &&
|
||||
another.y <= top + height;
|
||||
}
|
||||
|
||||
Point<num> get topLeft => new Point<num>(this.left, this.top);
|
||||
Point<num> get topRight => new Point<num>(this.left + this.width, this.top);
|
||||
Point<num> get bottomRight => new Point<num>(this.left + this.width,
|
||||
this.top + this.height);
|
||||
Point<num> get bottomLeft => new Point<num>(this.left,
|
||||
this.top + this.height);
|
||||
Point<num> get bottomRight =>
|
||||
new Point<num>(this.left + this.width, this.top + this.height);
|
||||
Point<num> get bottomLeft =>
|
||||
new Point<num>(this.left, this.top + this.height);
|
||||
}
|
||||
|
||||
final _HEIGHT = ['top', 'bottom'];
|
||||
|
|
|
@ -66,8 +66,8 @@ class Dimension {
|
|||
_unit = cssValue.substring(cssValue.length - 2);
|
||||
}
|
||||
if (cssValue.contains('.')) {
|
||||
_value = double.parse(cssValue.substring(0,
|
||||
cssValue.length - _unit.length));
|
||||
_value =
|
||||
double.parse(cssValue.substring(0, cssValue.length - _unit.length));
|
||||
} else {
|
||||
_value = int.parse(cssValue.substring(0, cssValue.length - _unit.length));
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class EventStreamProvider<T extends Event> {
|
|||
* [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventListener)
|
||||
*/
|
||||
Stream<T> forTarget(EventTarget e, {bool useCapture: false}) =>
|
||||
new _EventStream<T>(e, _eventType, useCapture);
|
||||
new _EventStream<T>(e, _eventType, useCapture);
|
||||
|
||||
/**
|
||||
* Gets an [ElementEventStream] for this event type, on the specified element.
|
||||
|
@ -129,16 +129,14 @@ class _EventStream<T extends Event> extends Stream<T> {
|
|||
_EventStream(this._target, this._eventType, this._useCapture);
|
||||
|
||||
// DOM events are inherently multi-subscribers.
|
||||
Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)})
|
||||
=> this;
|
||||
Stream<T> asBroadcastStream(
|
||||
{void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)}) =>
|
||||
this;
|
||||
bool get isBroadcast => true;
|
||||
|
||||
StreamSubscription<T> listen(void onData(T event),
|
||||
{ Function onError,
|
||||
void onDone(),
|
||||
bool cancelOnError}) {
|
||||
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
return new _EventStreamSubscription<T>(
|
||||
this._target, this._eventType, onData, this._useCapture);
|
||||
}
|
||||
|
@ -155,18 +153,18 @@ bool _matchesWithAncestors(Event event, String selector) {
|
|||
*/
|
||||
class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
|
||||
implements ElementStream<T> {
|
||||
_ElementEventStreamImpl(target, eventType, useCapture) :
|
||||
super(target, eventType, useCapture);
|
||||
_ElementEventStreamImpl(target, eventType, useCapture)
|
||||
: super(target, eventType, useCapture);
|
||||
|
||||
Stream<T> matches(String selector) => this.where(
|
||||
(event) => _matchesWithAncestors(event, selector)).map((e) {
|
||||
Stream<T> matches(String selector) =>
|
||||
this.where((event) => _matchesWithAncestors(event, selector)).map((e) {
|
||||
e._selector = selector;
|
||||
return e;
|
||||
});
|
||||
|
||||
StreamSubscription<T> capture(void onData(T event)) =>
|
||||
new _EventStreamSubscription<T>(
|
||||
this._target, this._eventType, onData, true);
|
||||
new _EventStreamSubscription<T>(
|
||||
this._target, this._eventType, onData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,23 +180,21 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
|
|||
_ElementListEventStreamImpl(
|
||||
this._targetList, this._eventType, this._useCapture);
|
||||
|
||||
Stream<T> matches(String selector) => this.where(
|
||||
(event) => _matchesWithAncestors(event, selector)).map((e) {
|
||||
Stream<T> matches(String selector) =>
|
||||
this.where((event) => _matchesWithAncestors(event, selector)).map((e) {
|
||||
e._selector = selector;
|
||||
return e;
|
||||
});
|
||||
|
||||
// Delegate all regular Stream behavior to a wrapped Stream.
|
||||
StreamSubscription<T> listen(void onData(T event),
|
||||
{ Function onError,
|
||||
void onDone(),
|
||||
bool cancelOnError}) {
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
var pool = new _StreamPool<T>.broadcast();
|
||||
for (var target in _targetList) {
|
||||
pool.add(new _EventStream<T>(target, _eventType, _useCapture));
|
||||
}
|
||||
return pool.stream.listen(onData, onError: onError, onDone: onDone,
|
||||
cancelOnError: cancelOnError);
|
||||
return pool.stream.listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
StreamSubscription<T> capture(void onData(T event)) {
|
||||
|
@ -209,9 +205,10 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
|
|||
return pool.stream.listen(onData);
|
||||
}
|
||||
|
||||
Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)})
|
||||
=> this;
|
||||
Stream<T> asBroadcastStream(
|
||||
{void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)}) =>
|
||||
this;
|
||||
bool get isBroadcast => true;
|
||||
}
|
||||
|
||||
|
@ -235,12 +232,11 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
|
|||
// use a more general listener, without causing as much slowdown for things
|
||||
// which are typed correctly. But this currently runs afoul of restrictions
|
||||
// on is checks for compatibility with the VM.
|
||||
_EventStreamSubscription(this._target, this._eventType, void onData(T event),
|
||||
this._useCapture) :
|
||||
_onData = onData == null
|
||||
? null
|
||||
: _wrapZone/*<Event, dynamic>*/((e) => (onData as dynamic)(e))
|
||||
{
|
||||
_EventStreamSubscription(
|
||||
this._target, this._eventType, void onData(T event), this._useCapture)
|
||||
: _onData = onData == null
|
||||
? null
|
||||
: _wrapZone/*<Event, dynamic>*/((e) => (onData as dynamic)(e)) {
|
||||
_tryResume();
|
||||
}
|
||||
|
||||
|
@ -334,16 +330,15 @@ class _CustomEventStreamImpl<T extends Event> extends Stream<T>
|
|||
|
||||
// Delegate all regular Stream behavior to our wrapped Stream.
|
||||
StreamSubscription<T> listen(void onData(T event),
|
||||
{ Function onError,
|
||||
void onDone(),
|
||||
bool cancelOnError}) {
|
||||
return _streamController.stream.listen(onData, onError: onError,
|
||||
onDone: onDone, cancelOnError: cancelOnError);
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
return _streamController.stream.listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)})
|
||||
=> _streamController.stream;
|
||||
Stream<T> asBroadcastStream(
|
||||
{void onListen(StreamSubscription<T> subscription),
|
||||
void onCancel(StreamSubscription<T> subscription)}) =>
|
||||
_streamController.stream;
|
||||
|
||||
bool get isBroadcast => true;
|
||||
|
||||
|
@ -383,8 +378,8 @@ class _StreamPool<T> {
|
|||
* regardless of whether [stream] has any subscribers.
|
||||
*/
|
||||
_StreamPool.broadcast() {
|
||||
_controller = new StreamController<T>.broadcast(sync: true,
|
||||
onCancel: close);
|
||||
_controller =
|
||||
new StreamController<T>.broadcast(sync: true, onCancel: close);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -402,8 +397,7 @@ class _StreamPool<T> {
|
|||
void add(Stream<T> stream) {
|
||||
if (_subscriptions.containsKey(stream)) return;
|
||||
_subscriptions[stream] = stream.listen(_controller.add,
|
||||
onError: _controller.addError,
|
||||
onDone: () => remove(stream));
|
||||
onError: _controller.addError, onDone: () => remove(stream));
|
||||
}
|
||||
|
||||
/** Removes [stream] as a member of this pool. */
|
||||
|
@ -428,7 +422,6 @@ class _StreamPool<T> {
|
|||
*/
|
||||
class _CustomEventStreamProvider<T extends Event>
|
||||
implements EventStreamProvider<T> {
|
||||
|
||||
final _eventTypeGetter;
|
||||
const _CustomEventStreamProvider(this._eventTypeGetter);
|
||||
|
||||
|
@ -440,9 +433,9 @@ class _CustomEventStreamProvider<T extends Event>
|
|||
return new _ElementEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture);
|
||||
}
|
||||
|
||||
ElementStream<T> _forElementList(ElementList e,
|
||||
{bool useCapture: false}) {
|
||||
return new _ElementListEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture);
|
||||
ElementStream<T> _forElementList(ElementList e, {bool useCapture: false}) {
|
||||
return new _ElementListEventStreamImpl<T>(
|
||||
e, _eventTypeGetter(e), useCapture);
|
||||
}
|
||||
|
||||
String getEventType(EventTarget target) {
|
||||
|
|
|
@ -17,7 +17,6 @@ part of dart.dom.html;
|
|||
* * <https://code.google.com/p/google-caja/wiki/CajaWhitelists>
|
||||
*/
|
||||
class _Html5NodeValidator implements NodeValidator {
|
||||
|
||||
static final Set<String> _allowedElements = new Set.from([
|
||||
'A',
|
||||
'ABBR',
|
||||
|
@ -410,8 +409,7 @@ class _Html5NodeValidator implements NodeValidator {
|
|||
* [uriPolicy] is null then a default UriPolicy will be used.
|
||||
*/
|
||||
_Html5NodeValidator({UriPolicy uriPolicy})
|
||||
:uriPolicy = uriPolicy != null ? uriPolicy : new UriPolicy() {
|
||||
|
||||
: uriPolicy = uriPolicy != null ? uriPolicy : new UriPolicy() {
|
||||
if (_attributeValidators.isEmpty) {
|
||||
for (var attr in _standardAttributes) {
|
||||
_attributeValidators[attr] = _standardAttributeValidator;
|
||||
|
|
|
@ -216,13 +216,24 @@ abstract class KeyCode {
|
|||
return true;
|
||||
}
|
||||
|
||||
return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS
|
||||
|| keyCode == NUM_MINUS || keyCode == NUM_PERIOD ||
|
||||
keyCode == NUM_DIVISION || keyCode == SEMICOLON ||
|
||||
keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS ||
|
||||
keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD ||
|
||||
keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE ||
|
||||
keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH ||
|
||||
return (keyCode == SPACE ||
|
||||
keyCode == QUESTION_MARK ||
|
||||
keyCode == NUM_PLUS ||
|
||||
keyCode == NUM_MINUS ||
|
||||
keyCode == NUM_PERIOD ||
|
||||
keyCode == NUM_DIVISION ||
|
||||
keyCode == SEMICOLON ||
|
||||
keyCode == FF_SEMICOLON ||
|
||||
keyCode == DASH ||
|
||||
keyCode == EQUALS ||
|
||||
keyCode == FF_EQUALS ||
|
||||
keyCode == COMMA ||
|
||||
keyCode == PERIOD ||
|
||||
keyCode == SLASH ||
|
||||
keyCode == APOSTROPHE ||
|
||||
keyCode == SINGLE_QUOTE ||
|
||||
keyCode == OPEN_SQUARE_BRACKET ||
|
||||
keyCode == BACKSLASH ||
|
||||
keyCode == CLOSE_SQUARE_BRACKET);
|
||||
}
|
||||
|
||||
|
@ -234,49 +245,86 @@ abstract class KeyCode {
|
|||
* follow the DOM3 spec.
|
||||
*/
|
||||
static String _convertKeyCodeToKeyName(int keyCode) {
|
||||
switch(keyCode) {
|
||||
case KeyCode.ALT: return _KeyName.ALT;
|
||||
case KeyCode.BACKSPACE: return _KeyName.BACKSPACE;
|
||||
case KeyCode.CAPS_LOCK: return _KeyName.CAPS_LOCK;
|
||||
case KeyCode.CTRL: return _KeyName.CONTROL;
|
||||
case KeyCode.DELETE: return _KeyName.DEL;
|
||||
case KeyCode.DOWN: return _KeyName.DOWN;
|
||||
case KeyCode.END: return _KeyName.END;
|
||||
case KeyCode.ENTER: return _KeyName.ENTER;
|
||||
case KeyCode.ESC: return _KeyName.ESC;
|
||||
case KeyCode.F1: return _KeyName.F1;
|
||||
case KeyCode.F2: return _KeyName.F2;
|
||||
case KeyCode.F3: return _KeyName.F3;
|
||||
case KeyCode.F4: return _KeyName.F4;
|
||||
case KeyCode.F5: return _KeyName.F5;
|
||||
case KeyCode.F6: return _KeyName.F6;
|
||||
case KeyCode.F7: return _KeyName.F7;
|
||||
case KeyCode.F8: return _KeyName.F8;
|
||||
case KeyCode.F9: return _KeyName.F9;
|
||||
case KeyCode.F10: return _KeyName.F10;
|
||||
case KeyCode.F11: return _KeyName.F11;
|
||||
case KeyCode.F12: return _KeyName.F12;
|
||||
case KeyCode.HOME: return _KeyName.HOME;
|
||||
case KeyCode.INSERT: return _KeyName.INSERT;
|
||||
case KeyCode.LEFT: return _KeyName.LEFT;
|
||||
case KeyCode.META: return _KeyName.META;
|
||||
case KeyCode.NUMLOCK: return _KeyName.NUM_LOCK;
|
||||
case KeyCode.PAGE_DOWN: return _KeyName.PAGE_DOWN;
|
||||
case KeyCode.PAGE_UP: return _KeyName.PAGE_UP;
|
||||
case KeyCode.PAUSE: return _KeyName.PAUSE;
|
||||
case KeyCode.PRINT_SCREEN: return _KeyName.PRINT_SCREEN;
|
||||
case KeyCode.RIGHT: return _KeyName.RIGHT;
|
||||
case KeyCode.SCROLL_LOCK: return _KeyName.SCROLL;
|
||||
case KeyCode.SHIFT: return _KeyName.SHIFT;
|
||||
case KeyCode.SPACE: return _KeyName.SPACEBAR;
|
||||
case KeyCode.TAB: return _KeyName.TAB;
|
||||
case KeyCode.UP: return _KeyName.UP;
|
||||
switch (keyCode) {
|
||||
case KeyCode.ALT:
|
||||
return _KeyName.ALT;
|
||||
case KeyCode.BACKSPACE:
|
||||
return _KeyName.BACKSPACE;
|
||||
case KeyCode.CAPS_LOCK:
|
||||
return _KeyName.CAPS_LOCK;
|
||||
case KeyCode.CTRL:
|
||||
return _KeyName.CONTROL;
|
||||
case KeyCode.DELETE:
|
||||
return _KeyName.DEL;
|
||||
case KeyCode.DOWN:
|
||||
return _KeyName.DOWN;
|
||||
case KeyCode.END:
|
||||
return _KeyName.END;
|
||||
case KeyCode.ENTER:
|
||||
return _KeyName.ENTER;
|
||||
case KeyCode.ESC:
|
||||
return _KeyName.ESC;
|
||||
case KeyCode.F1:
|
||||
return _KeyName.F1;
|
||||
case KeyCode.F2:
|
||||
return _KeyName.F2;
|
||||
case KeyCode.F3:
|
||||
return _KeyName.F3;
|
||||
case KeyCode.F4:
|
||||
return _KeyName.F4;
|
||||
case KeyCode.F5:
|
||||
return _KeyName.F5;
|
||||
case KeyCode.F6:
|
||||
return _KeyName.F6;
|
||||
case KeyCode.F7:
|
||||
return _KeyName.F7;
|
||||
case KeyCode.F8:
|
||||
return _KeyName.F8;
|
||||
case KeyCode.F9:
|
||||
return _KeyName.F9;
|
||||
case KeyCode.F10:
|
||||
return _KeyName.F10;
|
||||
case KeyCode.F11:
|
||||
return _KeyName.F11;
|
||||
case KeyCode.F12:
|
||||
return _KeyName.F12;
|
||||
case KeyCode.HOME:
|
||||
return _KeyName.HOME;
|
||||
case KeyCode.INSERT:
|
||||
return _KeyName.INSERT;
|
||||
case KeyCode.LEFT:
|
||||
return _KeyName.LEFT;
|
||||
case KeyCode.META:
|
||||
return _KeyName.META;
|
||||
case KeyCode.NUMLOCK:
|
||||
return _KeyName.NUM_LOCK;
|
||||
case KeyCode.PAGE_DOWN:
|
||||
return _KeyName.PAGE_DOWN;
|
||||
case KeyCode.PAGE_UP:
|
||||
return _KeyName.PAGE_UP;
|
||||
case KeyCode.PAUSE:
|
||||
return _KeyName.PAUSE;
|
||||
case KeyCode.PRINT_SCREEN:
|
||||
return _KeyName.PRINT_SCREEN;
|
||||
case KeyCode.RIGHT:
|
||||
return _KeyName.RIGHT;
|
||||
case KeyCode.SCROLL_LOCK:
|
||||
return _KeyName.SCROLL;
|
||||
case KeyCode.SHIFT:
|
||||
return _KeyName.SHIFT;
|
||||
case KeyCode.SPACE:
|
||||
return _KeyName.SPACEBAR;
|
||||
case KeyCode.TAB:
|
||||
return _KeyName.TAB;
|
||||
case KeyCode.UP:
|
||||
return _KeyName.UP;
|
||||
case KeyCode.WIN_IME:
|
||||
case KeyCode.WIN_KEY:
|
||||
case KeyCode.WIN_KEY_LEFT:
|
||||
case KeyCode.WIN_KEY_RIGHT:
|
||||
return _KeyName.WIN;
|
||||
default: return _KeyName.UNIDENTIFIED;
|
||||
default:
|
||||
return _KeyName.UNIDENTIFIED;
|
||||
}
|
||||
return _KeyName.UNIDENTIFIED;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ part of html;
|
|||
* KeyboardEvent.getKeyLocation.
|
||||
*/
|
||||
abstract class KeyLocation {
|
||||
|
||||
/**
|
||||
* The event key is not distinguished as the left or right version
|
||||
* of the key, and did not originate from the numeric keypad (or did not
|
||||
|
|
|
@ -10,7 +10,6 @@ part of html;
|
|||
* unicode mapping.
|
||||
*/
|
||||
abstract class _KeyName {
|
||||
|
||||
/** The Accept (Commit, OK) key */
|
||||
static const String ACCEPT = "Accept";
|
||||
|
||||
|
@ -117,7 +116,7 @@ abstract class _KeyName {
|
|||
static const String ENTER = "Enter";
|
||||
|
||||
/** The Erase EOF key */
|
||||
static const String ERASE_EOF= "EraseEof";
|
||||
static const String ERASE_EOF = "EraseEof";
|
||||
|
||||
/** The Execute key */
|
||||
static const String EXECUTE = "Execute";
|
||||
|
@ -485,7 +484,7 @@ abstract class _KeyName {
|
|||
* The Combining Katakana-Hiragana Semi-Voiced Sound Mark (Dead Semivoiced
|
||||
* Sound) key
|
||||
*/
|
||||
static const String DEC_SEMIVOICED_SOUND= "DeadSemivoicedSound";
|
||||
static const String DEC_SEMIVOICED_SOUND = "DeadSemivoicedSound";
|
||||
|
||||
/**
|
||||
* Key value used when an implementation is unable to identify another key
|
||||
|
|
|
@ -66,8 +66,8 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
/** Return a stream for KeyEvents for the specified target. */
|
||||
// Note: this actually functions like a factory constructor.
|
||||
CustomStream<KeyEvent> forTarget(EventTarget e, {bool useCapture: false}) {
|
||||
var handler = new _KeyboardEventHandler.initializeAllEventListeners(
|
||||
_type, e);
|
||||
var handler =
|
||||
new _KeyboardEventHandler.initializeAllEventListeners(_type, e);
|
||||
return handler._stream;
|
||||
}
|
||||
|
||||
|
@ -75,22 +75,26 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
* General constructor, performs basic initialization for our improved
|
||||
* KeyboardEvent controller.
|
||||
*/
|
||||
_KeyboardEventHandler(this._type):
|
||||
_stream = new _CustomKeyEventStreamImpl('event'), _target = null,
|
||||
super(_EVENT_TYPE);
|
||||
_KeyboardEventHandler(this._type)
|
||||
: _stream = new _CustomKeyEventStreamImpl('event'),
|
||||
_target = null,
|
||||
super(_EVENT_TYPE);
|
||||
|
||||
/**
|
||||
* Hook up all event listeners under the covers so we can estimate keycodes
|
||||
* and charcodes when they are not provided.
|
||||
*/
|
||||
_KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) :
|
||||
super(_EVENT_TYPE) {
|
||||
Element.keyDownEvent.forTarget(_target, useCapture: true).listen(
|
||||
processKeyDown);
|
||||
Element.keyPressEvent.forTarget(_target, useCapture: true).listen(
|
||||
processKeyPress);
|
||||
Element.keyUpEvent.forTarget(_target, useCapture: true).listen(
|
||||
processKeyUp);
|
||||
_KeyboardEventHandler.initializeAllEventListeners(this._type, this._target)
|
||||
: super(_EVENT_TYPE) {
|
||||
Element.keyDownEvent
|
||||
.forTarget(_target, useCapture: true)
|
||||
.listen(processKeyDown);
|
||||
Element.keyPressEvent
|
||||
.forTarget(_target, useCapture: true)
|
||||
.listen(processKeyPress);
|
||||
Element.keyUpEvent
|
||||
.forTarget(_target, useCapture: true)
|
||||
.listen(processKeyUp);
|
||||
_stream = new _CustomKeyEventStreamImpl(_type);
|
||||
}
|
||||
|
||||
|
@ -112,9 +116,11 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
if (prevEvent._shadowCharCode == event.charCode) {
|
||||
return prevEvent.keyCode;
|
||||
}
|
||||
if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".codeUnits[0]
|
||||
&& event.charCode <= "Z".codeUnits[0] && event.charCode +
|
||||
_ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) {
|
||||
if ((event.shiftKey || _capsLockOn) &&
|
||||
event.charCode >= "A".codeUnits[0] &&
|
||||
event.charCode <= "Z".codeUnits[0] &&
|
||||
event.charCode + _ROMAN_ALPHABET_OFFSET ==
|
||||
prevEvent._shadowCharCode) {
|
||||
return prevEvent.keyCode;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +134,8 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
* keypress events.
|
||||
*/
|
||||
int _findCharCodeKeyDown(KeyboardEvent event) {
|
||||
if (event.keyLocation == 3) { // Numpad keys.
|
||||
if (event.keyLocation == 3) {
|
||||
// Numpad keys.
|
||||
switch (event.keyCode) {
|
||||
case KeyCode.NUM_ZERO:
|
||||
// Even though this function returns _charCodes_, for some cases the
|
||||
|
@ -170,7 +177,7 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
// keyCode locations and other information during the keyPress event.
|
||||
return event.keyCode + _ROMAN_ALPHABET_OFFSET;
|
||||
}
|
||||
switch(event.keyCode) {
|
||||
switch (event.keyCode) {
|
||||
case KeyCode.SEMICOLON:
|
||||
return KeyCode.FF_SEMICOLON;
|
||||
case KeyCode.EQUALS:
|
||||
|
@ -217,23 +224,28 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
// Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress.
|
||||
if (!event.shiftKey &&
|
||||
(_keyDownList.last.keyCode == KeyCode.CTRL ||
|
||||
_keyDownList.last.keyCode == KeyCode.ALT ||
|
||||
Device.userAgent.contains('Mac') &&
|
||||
_keyDownList.last.keyCode == KeyCode.META)) {
|
||||
_keyDownList.last.keyCode == KeyCode.ALT ||
|
||||
Device.userAgent.contains('Mac') &&
|
||||
_keyDownList.last.keyCode == KeyCode.META)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some keys with Ctrl/Shift do not issue keypress in WebKit.
|
||||
if (Device.isWebKit && event.ctrlKey && event.shiftKey && (
|
||||
event.keyCode == KeyCode.BACKSLASH ||
|
||||
event.keyCode == KeyCode.OPEN_SQUARE_BRACKET ||
|
||||
event.keyCode == KeyCode.CLOSE_SQUARE_BRACKET ||
|
||||
event.keyCode == KeyCode.TILDE ||
|
||||
event.keyCode == KeyCode.SEMICOLON || event.keyCode == KeyCode.DASH ||
|
||||
event.keyCode == KeyCode.EQUALS || event.keyCode == KeyCode.COMMA ||
|
||||
event.keyCode == KeyCode.PERIOD || event.keyCode == KeyCode.SLASH ||
|
||||
event.keyCode == KeyCode.APOSTROPHE ||
|
||||
event.keyCode == KeyCode.SINGLE_QUOTE)) {
|
||||
if (Device.isWebKit &&
|
||||
event.ctrlKey &&
|
||||
event.shiftKey &&
|
||||
(event.keyCode == KeyCode.BACKSLASH ||
|
||||
event.keyCode == KeyCode.OPEN_SQUARE_BRACKET ||
|
||||
event.keyCode == KeyCode.CLOSE_SQUARE_BRACKET ||
|
||||
event.keyCode == KeyCode.TILDE ||
|
||||
event.keyCode == KeyCode.SEMICOLON ||
|
||||
event.keyCode == KeyCode.DASH ||
|
||||
event.keyCode == KeyCode.EQUALS ||
|
||||
event.keyCode == KeyCode.COMMA ||
|
||||
event.keyCode == KeyCode.PERIOD ||
|
||||
event.keyCode == KeyCode.SLASH ||
|
||||
event.keyCode == KeyCode.APOSTROPHE ||
|
||||
event.keyCode == KeyCode.SINGLE_QUOTE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -255,7 +267,7 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
int _normalizeKeyCodes(KeyboardEvent event) {
|
||||
// Note: This may change once we get input about non-US keyboards.
|
||||
if (Device.isFirefox) {
|
||||
switch(event.keyCode) {
|
||||
switch (event.keyCode) {
|
||||
case KeyCode.FF_EQUALS:
|
||||
return KeyCode.EQUALS;
|
||||
case KeyCode.FF_SEMICOLON:
|
||||
|
@ -276,9 +288,10 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
// we reset the state.
|
||||
if (_keyDownList.length > 0 &&
|
||||
(_keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey ||
|
||||
_keyDownList.last.keyCode == KeyCode.ALT && !e.altKey ||
|
||||
Device.userAgent.contains('Mac') &&
|
||||
_keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) {
|
||||
_keyDownList.last.keyCode == KeyCode.ALT && !e.altKey ||
|
||||
Device.userAgent.contains('Mac') &&
|
||||
_keyDownList.last.keyCode == KeyCode.META &&
|
||||
!e.metaKey)) {
|
||||
_keyDownList.clear();
|
||||
}
|
||||
|
||||
|
@ -289,7 +302,8 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
// as much information as possible on keypress about keycode and also
|
||||
// charCode.
|
||||
event._shadowCharCode = _findCharCodeKeyDown(event);
|
||||
if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode &&
|
||||
if (_keyDownList.length > 0 &&
|
||||
event.keyCode != _keyDownList.last.keyCode &&
|
||||
!_firesKeyPressEvent(event)) {
|
||||
// Some browsers have quirks not firing keypress events where all other
|
||||
// browsers do. This makes them more consistent.
|
||||
|
@ -350,7 +364,6 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Records KeyboardEvents that occur on a particular element, and provides a
|
||||
* stream of outgoing KeyEvents with cross-browser consistent keyCode and
|
||||
|
@ -367,7 +380,6 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
|||
* possible. Bugs welcome!
|
||||
*/
|
||||
class KeyboardEventStream {
|
||||
|
||||
/** Named constructor to produce a stream for onKeyPress events. */
|
||||
static CustomStream<KeyEvent> onKeyPress(EventTarget target) =>
|
||||
new _KeyboardEventHandler('keypress').forTarget(target);
|
||||
|
|
|
@ -154,9 +154,9 @@ class NodeValidatorBuilder implements NodeValidator {
|
|||
Iterable<String> uriAttributes}) {
|
||||
var tagNameUpper = tagName.toUpperCase();
|
||||
var attrs = attributes
|
||||
?.map /*<String>*/ ((name) => '$tagNameUpper::${name.toLowerCase()}');
|
||||
?.map/*<String>*/((name) => '$tagNameUpper::${name.toLowerCase()}');
|
||||
var uriAttrs = uriAttributes
|
||||
?.map /*<String>*/ ((name) => '$tagNameUpper::${name.toLowerCase()}');
|
||||
?.map/*<String>*/((name) => '$tagNameUpper::${name.toLowerCase()}');
|
||||
if (uriPolicy == null) {
|
||||
uriPolicy = new UriPolicy();
|
||||
}
|
||||
|
@ -180,9 +180,9 @@ class NodeValidatorBuilder implements NodeValidator {
|
|||
var baseNameUpper = baseName.toUpperCase();
|
||||
var tagNameUpper = tagName.toUpperCase();
|
||||
var attrs = attributes
|
||||
?.map /*<String>*/ ((name) => '$baseNameUpper::${name.toLowerCase()}');
|
||||
?.map/*<String>*/((name) => '$baseNameUpper::${name.toLowerCase()}');
|
||||
var uriAttrs = uriAttributes
|
||||
?.map /*<String>*/ ((name) => '$baseNameUpper::${name.toLowerCase()}');
|
||||
?.map/*<String>*/((name) => '$baseNameUpper::${name.toLowerCase()}');
|
||||
if (uriPolicy == null) {
|
||||
uriPolicy = new UriPolicy();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
part of dart.dom.html;
|
||||
|
||||
|
||||
/**
|
||||
* Interface used to validate that only accepted elements and attributes are
|
||||
* allowed while parsing HTML strings into DOM nodes.
|
||||
|
@ -14,7 +13,6 @@ part of dart.dom.html;
|
|||
* implementing validation rules.
|
||||
*/
|
||||
abstract class NodeValidator {
|
||||
|
||||
/**
|
||||
* Construct a default NodeValidator which only accepts whitelisted HTML5
|
||||
* elements and attributes.
|
||||
|
@ -52,7 +50,6 @@ abstract class NodeValidator {
|
|||
* tree sanitization.
|
||||
*/
|
||||
abstract class NodeTreeSanitizer {
|
||||
|
||||
/**
|
||||
* Constructs a default tree sanitizer which will remove all elements and
|
||||
* attributes which are not allowed by the provided validator.
|
||||
|
@ -125,15 +122,14 @@ class _SameOriginUriPolicy implements UriPolicy {
|
|||
_hiddenAnchor.href = uri;
|
||||
// IE leaves an empty hostname for same-origin URIs.
|
||||
return (_hiddenAnchor.hostname == _loc.hostname &&
|
||||
_hiddenAnchor.port == _loc.port &&
|
||||
_hiddenAnchor.protocol == _loc.protocol) ||
|
||||
_hiddenAnchor.port == _loc.port &&
|
||||
_hiddenAnchor.protocol == _loc.protocol) ||
|
||||
(_hiddenAnchor.hostname == '' &&
|
||||
_hiddenAnchor.port == '' &&
|
||||
(_hiddenAnchor.protocol == ':' || _hiddenAnchor.protocol == ''));
|
||||
_hiddenAnchor.port == '' &&
|
||||
(_hiddenAnchor.protocol == ':' || _hiddenAnchor.protocol == ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _ThrowsNodeValidator implements NodeValidator {
|
||||
final NodeValidator validator;
|
||||
|
||||
|
@ -148,12 +144,12 @@ class _ThrowsNodeValidator implements NodeValidator {
|
|||
|
||||
bool allowsAttribute(Element element, String attributeName, String value) {
|
||||
if (!validator.allowsAttribute(element, attributeName, value)) {
|
||||
throw new ArgumentError('${Element._safeTagName(element)}[$attributeName="$value"]');
|
||||
throw new ArgumentError(
|
||||
'${Element._safeTagName(element)}[$attributeName="$value"]');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Standard tree sanitizer which validates a node tree against the provided
|
||||
* validator and removes any nodes or attributes which are not allowed.
|
||||
|
@ -185,6 +181,7 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
|||
child = nextChild;
|
||||
}
|
||||
}
|
||||
|
||||
walk(node, null);
|
||||
}
|
||||
|
||||
|
@ -225,19 +222,23 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
|||
// On IE, erratically, the hasCorruptedAttributes test can return false,
|
||||
// even though it clearly is corrupted. A separate copy of the test
|
||||
// inlining just the basic check seems to help.
|
||||
corrupted = corruptedTest1 ? true : Element._hasCorruptedAttributesAdditionalCheck(element);
|
||||
} catch(e) {}
|
||||
corrupted = corruptedTest1
|
||||
? true
|
||||
: Element._hasCorruptedAttributesAdditionalCheck(element);
|
||||
} catch (e) {}
|
||||
var elementText = 'element unprintable';
|
||||
try {
|
||||
elementText = element.toString();
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
try {
|
||||
var elementTagName = Element._safeTagName(element);
|
||||
_sanitizeElement(element, parent, corrupted, elementText, elementTagName,
|
||||
attrs, isAttr);
|
||||
} on ArgumentError { // Thrown by _ThrowsNodeValidator
|
||||
} on ArgumentError {
|
||||
// Thrown by _ThrowsNodeValidator
|
||||
rethrow;
|
||||
} catch(e) { // Unexpected exception sanitizing -> remove
|
||||
} catch (e) {
|
||||
// Unexpected exception sanitizing -> remove
|
||||
_removeNode(element, parent);
|
||||
window.console.warn('Removing corrupted element $elementText');
|
||||
}
|
||||
|
@ -249,15 +250,14 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
|||
void _sanitizeElement(Element element, Node parent, bool corrupted,
|
||||
String text, String tag, Map attrs, String isAttr) {
|
||||
if (false != corrupted) {
|
||||
_removeNode(element, parent);
|
||||
window.console.warn(
|
||||
'Removing element due to corrupted attributes on <$text>');
|
||||
return;
|
||||
_removeNode(element, parent);
|
||||
window.console
|
||||
.warn('Removing element due to corrupted attributes on <$text>');
|
||||
return;
|
||||
}
|
||||
if (!validator.allowsElement(element)) {
|
||||
_removeNode(element, parent);
|
||||
window.console.warn(
|
||||
'Removing disallowed element <$tag> from $parent');
|
||||
window.console.warn('Removing disallowed element <$tag> from $parent');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,8 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
|||
var keys = attrs.keys.toList();
|
||||
for (var i = attrs.length - 1; i >= 0; --i) {
|
||||
var name = keys[i];
|
||||
if (!validator.allowsAttribute(element, name.toLowerCase(),
|
||||
attrs[name])) {
|
||||
if (!validator.allowsAttribute(
|
||||
element, name.toLowerCase(), attrs[name])) {
|
||||
window.console.warn('Removing disallowed attribute '
|
||||
'<$tag $name="${attrs[name]}">');
|
||||
attrs.remove(name);
|
||||
|
@ -286,7 +286,7 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
|||
if (element is TemplateElement) {
|
||||
TemplateElement template = element;
|
||||
sanitizeTree(template.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Sanitize the node and its children recursively.
|
||||
|
|
|
@ -41,7 +41,8 @@ const int COLOR_BUFFER_BIT = RenderingContext.COLOR_BUFFER_BIT;
|
|||
const int COLOR_CLEAR_VALUE = RenderingContext.COLOR_CLEAR_VALUE;
|
||||
const int COLOR_WRITEMASK = RenderingContext.COLOR_WRITEMASK;
|
||||
const int COMPILE_STATUS = RenderingContext.COMPILE_STATUS;
|
||||
const int COMPRESSED_TEXTURE_FORMATS = RenderingContext.COMPRESSED_TEXTURE_FORMATS;
|
||||
const int COMPRESSED_TEXTURE_FORMATS =
|
||||
RenderingContext.COMPRESSED_TEXTURE_FORMATS;
|
||||
const int CONSTANT_ALPHA = RenderingContext.CONSTANT_ALPHA;
|
||||
const int CONSTANT_COLOR = RenderingContext.CONSTANT_COLOR;
|
||||
const int CONTEXT_LOST_WEBGL = RenderingContext.CONTEXT_LOST_WEBGL;
|
||||
|
@ -71,7 +72,8 @@ const int DST_ALPHA = RenderingContext.DST_ALPHA;
|
|||
const int DST_COLOR = RenderingContext.DST_COLOR;
|
||||
const int DYNAMIC_DRAW = RenderingContext.DYNAMIC_DRAW;
|
||||
const int ELEMENT_ARRAY_BUFFER = RenderingContext.ELEMENT_ARRAY_BUFFER;
|
||||
const int ELEMENT_ARRAY_BUFFER_BINDING = RenderingContext.ELEMENT_ARRAY_BUFFER_BINDING;
|
||||
const int ELEMENT_ARRAY_BUFFER_BINDING =
|
||||
RenderingContext.ELEMENT_ARRAY_BUFFER_BINDING;
|
||||
const int EQUAL = RenderingContext.EQUAL;
|
||||
const int FASTEST = RenderingContext.FASTEST;
|
||||
const int FLOAT = RenderingContext.FLOAT;
|
||||
|
@ -83,15 +85,22 @@ const int FLOAT_VEC3 = RenderingContext.FLOAT_VEC3;
|
|||
const int FLOAT_VEC4 = RenderingContext.FLOAT_VEC4;
|
||||
const int FRAGMENT_SHADER = RenderingContext.FRAGMENT_SHADER;
|
||||
const int FRAMEBUFFER = RenderingContext.FRAMEBUFFER;
|
||||
const int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = RenderingContext.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
|
||||
const int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = RenderingContext.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
|
||||
const int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = RenderingContext.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
|
||||
const int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = RenderingContext.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
|
||||
const int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME =
|
||||
RenderingContext.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
|
||||
const int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE =
|
||||
RenderingContext.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
|
||||
const int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE =
|
||||
RenderingContext.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
|
||||
const int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL =
|
||||
RenderingContext.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
|
||||
const int FRAMEBUFFER_BINDING = RenderingContext.FRAMEBUFFER_BINDING;
|
||||
const int FRAMEBUFFER_COMPLETE = RenderingContext.FRAMEBUFFER_COMPLETE;
|
||||
const int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = RenderingContext.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
const int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = RenderingContext.FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
||||
const int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = RenderingContext.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
||||
const int FRAMEBUFFER_INCOMPLETE_ATTACHMENT =
|
||||
RenderingContext.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
const int FRAMEBUFFER_INCOMPLETE_DIMENSIONS =
|
||||
RenderingContext.FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
||||
const int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT =
|
||||
RenderingContext.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
||||
const int FRAMEBUFFER_UNSUPPORTED = RenderingContext.FRAMEBUFFER_UNSUPPORTED;
|
||||
const int FRONT = RenderingContext.FRONT;
|
||||
const int FRONT_AND_BACK = RenderingContext.FRONT_AND_BACK;
|
||||
|
@ -113,7 +122,8 @@ const int INT_VEC2 = RenderingContext.INT_VEC2;
|
|||
const int INT_VEC3 = RenderingContext.INT_VEC3;
|
||||
const int INT_VEC4 = RenderingContext.INT_VEC4;
|
||||
const int INVALID_ENUM = RenderingContext.INVALID_ENUM;
|
||||
const int INVALID_FRAMEBUFFER_OPERATION = RenderingContext.INVALID_FRAMEBUFFER_OPERATION;
|
||||
const int INVALID_FRAMEBUFFER_OPERATION =
|
||||
RenderingContext.INVALID_FRAMEBUFFER_OPERATION;
|
||||
const int INVALID_OPERATION = RenderingContext.INVALID_OPERATION;
|
||||
const int INVALID_VALUE = RenderingContext.INVALID_VALUE;
|
||||
const int INVERT = RenderingContext.INVERT;
|
||||
|
@ -132,16 +142,21 @@ const int LOW_FLOAT = RenderingContext.LOW_FLOAT;
|
|||
const int LOW_INT = RenderingContext.LOW_INT;
|
||||
const int LUMINANCE = RenderingContext.LUMINANCE;
|
||||
const int LUMINANCE_ALPHA = RenderingContext.LUMINANCE_ALPHA;
|
||||
const int MAX_COMBINED_TEXTURE_IMAGE_UNITS = RenderingContext.MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
||||
const int MAX_CUBE_MAP_TEXTURE_SIZE = RenderingContext.MAX_CUBE_MAP_TEXTURE_SIZE;
|
||||
const int MAX_FRAGMENT_UNIFORM_VECTORS = RenderingContext.MAX_FRAGMENT_UNIFORM_VECTORS;
|
||||
const int MAX_COMBINED_TEXTURE_IMAGE_UNITS =
|
||||
RenderingContext.MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
||||
const int MAX_CUBE_MAP_TEXTURE_SIZE =
|
||||
RenderingContext.MAX_CUBE_MAP_TEXTURE_SIZE;
|
||||
const int MAX_FRAGMENT_UNIFORM_VECTORS =
|
||||
RenderingContext.MAX_FRAGMENT_UNIFORM_VECTORS;
|
||||
const int MAX_RENDERBUFFER_SIZE = RenderingContext.MAX_RENDERBUFFER_SIZE;
|
||||
const int MAX_TEXTURE_IMAGE_UNITS = RenderingContext.MAX_TEXTURE_IMAGE_UNITS;
|
||||
const int MAX_TEXTURE_SIZE = RenderingContext.MAX_TEXTURE_SIZE;
|
||||
const int MAX_VARYING_VECTORS = RenderingContext.MAX_VARYING_VECTORS;
|
||||
const int MAX_VERTEX_ATTRIBS = RenderingContext.MAX_VERTEX_ATTRIBS;
|
||||
const int MAX_VERTEX_TEXTURE_IMAGE_UNITS = RenderingContext.MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
||||
const int MAX_VERTEX_UNIFORM_VECTORS = RenderingContext.MAX_VERTEX_UNIFORM_VECTORS;
|
||||
const int MAX_VERTEX_TEXTURE_IMAGE_UNITS =
|
||||
RenderingContext.MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
||||
const int MAX_VERTEX_UNIFORM_VECTORS =
|
||||
RenderingContext.MAX_VERTEX_UNIFORM_VECTORS;
|
||||
const int MAX_VIEWPORT_DIMS = RenderingContext.MAX_VIEWPORT_DIMS;
|
||||
const int MEDIUM_FLOAT = RenderingContext.MEDIUM_FLOAT;
|
||||
const int MEDIUM_INT = RenderingContext.MEDIUM_INT;
|
||||
|
@ -175,9 +190,11 @@ const int RENDERBUFFER_BLUE_SIZE = RenderingContext.RENDERBUFFER_BLUE_SIZE;
|
|||
const int RENDERBUFFER_DEPTH_SIZE = RenderingContext.RENDERBUFFER_DEPTH_SIZE;
|
||||
const int RENDERBUFFER_GREEN_SIZE = RenderingContext.RENDERBUFFER_GREEN_SIZE;
|
||||
const int RENDERBUFFER_HEIGHT = RenderingContext.RENDERBUFFER_HEIGHT;
|
||||
const int RENDERBUFFER_INTERNAL_FORMAT = RenderingContext.RENDERBUFFER_INTERNAL_FORMAT;
|
||||
const int RENDERBUFFER_INTERNAL_FORMAT =
|
||||
RenderingContext.RENDERBUFFER_INTERNAL_FORMAT;
|
||||
const int RENDERBUFFER_RED_SIZE = RenderingContext.RENDERBUFFER_RED_SIZE;
|
||||
const int RENDERBUFFER_STENCIL_SIZE = RenderingContext.RENDERBUFFER_STENCIL_SIZE;
|
||||
const int RENDERBUFFER_STENCIL_SIZE =
|
||||
RenderingContext.RENDERBUFFER_STENCIL_SIZE;
|
||||
const int RENDERBUFFER_WIDTH = RenderingContext.RENDERBUFFER_WIDTH;
|
||||
const int RENDERER = RenderingContext.RENDERER;
|
||||
const int REPEAT = RenderingContext.REPEAT;
|
||||
|
@ -207,8 +224,10 @@ const int STATIC_DRAW = RenderingContext.STATIC_DRAW;
|
|||
const int STENCIL_ATTACHMENT = RenderingContext.STENCIL_ATTACHMENT;
|
||||
const int STENCIL_BACK_FAIL = RenderingContext.STENCIL_BACK_FAIL;
|
||||
const int STENCIL_BACK_FUNC = RenderingContext.STENCIL_BACK_FUNC;
|
||||
const int STENCIL_BACK_PASS_DEPTH_FAIL = RenderingContext.STENCIL_BACK_PASS_DEPTH_FAIL;
|
||||
const int STENCIL_BACK_PASS_DEPTH_PASS = RenderingContext.STENCIL_BACK_PASS_DEPTH_PASS;
|
||||
const int STENCIL_BACK_PASS_DEPTH_FAIL =
|
||||
RenderingContext.STENCIL_BACK_PASS_DEPTH_FAIL;
|
||||
const int STENCIL_BACK_PASS_DEPTH_PASS =
|
||||
RenderingContext.STENCIL_BACK_PASS_DEPTH_PASS;
|
||||
const int STENCIL_BACK_REF = RenderingContext.STENCIL_BACK_REF;
|
||||
const int STENCIL_BACK_VALUE_MASK = RenderingContext.STENCIL_BACK_VALUE_MASK;
|
||||
const int STENCIL_BACK_WRITEMASK = RenderingContext.STENCIL_BACK_WRITEMASK;
|
||||
|
@ -264,12 +283,18 @@ const int TEXTURE_2D = RenderingContext.TEXTURE_2D;
|
|||
const int TEXTURE_BINDING_2D = RenderingContext.TEXTURE_BINDING_2D;
|
||||
const int TEXTURE_BINDING_CUBE_MAP = RenderingContext.TEXTURE_BINDING_CUBE_MAP;
|
||||
const int TEXTURE_CUBE_MAP = RenderingContext.TEXTURE_CUBE_MAP;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_X = RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_X;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_Y = RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_Y;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_Z = RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_Z;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_X = RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_Y = RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_Y;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_Z = RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_Z;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_X =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_X;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_Y =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_Y;
|
||||
const int TEXTURE_CUBE_MAP_NEGATIVE_Z =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_NEGATIVE_Z;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_X =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_Y =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_Y;
|
||||
const int TEXTURE_CUBE_MAP_POSITIVE_Z =
|
||||
RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_Z;
|
||||
const int TEXTURE_MAG_FILTER = RenderingContext.TEXTURE_MAG_FILTER;
|
||||
const int TEXTURE_MIN_FILTER = RenderingContext.TEXTURE_MIN_FILTER;
|
||||
const int TEXTURE_WRAP_S = RenderingContext.TEXTURE_WRAP_S;
|
||||
|
@ -278,9 +303,11 @@ const int TRIANGLES = RenderingContext.TRIANGLES;
|
|||
const int TRIANGLE_FAN = RenderingContext.TRIANGLE_FAN;
|
||||
const int TRIANGLE_STRIP = RenderingContext.TRIANGLE_STRIP;
|
||||
const int UNPACK_ALIGNMENT = RenderingContext.UNPACK_ALIGNMENT;
|
||||
const int UNPACK_COLORSPACE_CONVERSION_WEBGL = RenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL;
|
||||
const int UNPACK_COLORSPACE_CONVERSION_WEBGL =
|
||||
RenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL;
|
||||
const int UNPACK_FLIP_Y_WEBGL = RenderingContext.UNPACK_FLIP_Y_WEBGL;
|
||||
const int UNPACK_PREMULTIPLY_ALPHA_WEBGL = RenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL;
|
||||
const int UNPACK_PREMULTIPLY_ALPHA_WEBGL =
|
||||
RenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL;
|
||||
const int UNSIGNED_BYTE = RenderingContext.UNSIGNED_BYTE;
|
||||
const int UNSIGNED_INT = RenderingContext.UNSIGNED_INT;
|
||||
const int UNSIGNED_SHORT = RenderingContext.UNSIGNED_SHORT;
|
||||
|
@ -290,12 +317,17 @@ const int UNSIGNED_SHORT_5_6_5 = RenderingContext.UNSIGNED_SHORT_5_6_5;
|
|||
const int VALIDATE_STATUS = RenderingContext.VALIDATE_STATUS;
|
||||
const int VENDOR = RenderingContext.VENDOR;
|
||||
const int VERSION = RenderingContext.VERSION;
|
||||
const int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = RenderingContext.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
|
||||
const int VERTEX_ATTRIB_ARRAY_ENABLED = RenderingContext.VERTEX_ATTRIB_ARRAY_ENABLED;
|
||||
const int VERTEX_ATTRIB_ARRAY_NORMALIZED = RenderingContext.VERTEX_ATTRIB_ARRAY_NORMALIZED;
|
||||
const int VERTEX_ATTRIB_ARRAY_POINTER = RenderingContext.VERTEX_ATTRIB_ARRAY_POINTER;
|
||||
const int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING =
|
||||
RenderingContext.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
|
||||
const int VERTEX_ATTRIB_ARRAY_ENABLED =
|
||||
RenderingContext.VERTEX_ATTRIB_ARRAY_ENABLED;
|
||||
const int VERTEX_ATTRIB_ARRAY_NORMALIZED =
|
||||
RenderingContext.VERTEX_ATTRIB_ARRAY_NORMALIZED;
|
||||
const int VERTEX_ATTRIB_ARRAY_POINTER =
|
||||
RenderingContext.VERTEX_ATTRIB_ARRAY_POINTER;
|
||||
const int VERTEX_ATTRIB_ARRAY_SIZE = RenderingContext.VERTEX_ATTRIB_ARRAY_SIZE;
|
||||
const int VERTEX_ATTRIB_ARRAY_STRIDE = RenderingContext.VERTEX_ATTRIB_ARRAY_STRIDE;
|
||||
const int VERTEX_ATTRIB_ARRAY_STRIDE =
|
||||
RenderingContext.VERTEX_ATTRIB_ARRAY_STRIDE;
|
||||
const int VERTEX_ATTRIB_ARRAY_TYPE = RenderingContext.VERTEX_ATTRIB_ARRAY_TYPE;
|
||||
const int VERTEX_SHADER = RenderingContext.VERTEX_SHADER;
|
||||
const int VIEWPORT = RenderingContext.VIEWPORT;
|
||||
|
|
|
@ -22,25 +22,37 @@ class _WrappedList<E extends Node> extends ListBase<E>
|
|||
|
||||
// Collection APIs
|
||||
|
||||
void add(E element) { _list.add(element); }
|
||||
void add(E element) {
|
||||
_list.add(element);
|
||||
}
|
||||
|
||||
bool remove(Object element) => _list.remove(element);
|
||||
|
||||
void clear() { _list.clear(); }
|
||||
void clear() {
|
||||
_list.clear();
|
||||
}
|
||||
|
||||
// List APIs
|
||||
|
||||
E operator [](int index) => _downcast/*<Node, E>*/(_list[index]);
|
||||
|
||||
void operator []=(int index, E value) { _list[index] = value; }
|
||||
void operator []=(int index, E value) {
|
||||
_list[index] = value;
|
||||
}
|
||||
|
||||
set length(int newLength) { _list.length = newLength; }
|
||||
set length(int newLength) {
|
||||
_list.length = newLength;
|
||||
}
|
||||
|
||||
void sort([int compare(E a, E b)]) { _list.sort((Node a, Node b) => compare(_downcast/*<Node, E>*/(a), _downcast/*<Node, E>*/(b))); }
|
||||
void sort([int compare(E a, E b)]) {
|
||||
_list.sort((Node a, Node b) =>
|
||||
compare(_downcast/*<Node, E>*/(a), _downcast/*<Node, E>*/(b)));
|
||||
}
|
||||
|
||||
int indexOf(Object element, [int start = 0]) => _list.indexOf(element, start);
|
||||
|
||||
int lastIndexOf(Object element, [int start]) => _list.lastIndexOf(element, start);
|
||||
int lastIndexOf(Object element, [int start]) =>
|
||||
_list.lastIndexOf(element, start);
|
||||
|
||||
void insert(int index, E element) => _list.insert(index, element);
|
||||
|
||||
|
@ -50,7 +62,9 @@ class _WrappedList<E extends Node> extends ListBase<E>
|
|||
_list.setRange(start, end, iterable, skipCount);
|
||||
}
|
||||
|
||||
void removeRange(int start, int end) { _list.removeRange(start, end); }
|
||||
void removeRange(int start, int end) {
|
||||
_list.removeRange(start, end);
|
||||
}
|
||||
|
||||
void replaceRange(int start, int end, Iterable<E> iterable) {
|
||||
_list.replaceRange(start, end, iterable);
|
||||
|
@ -79,4 +93,4 @@ class _WrappedIterator<E extends Node> implements Iterator<E> {
|
|||
}
|
||||
|
||||
// ignore: STRONG_MODE_DOWN_CAST_COMPOSITE
|
||||
/*=To*/ _downcast/*<From, To extends From>*/(dynamic /*=From*/ x) => x;
|
||||
/*=To*/ _downcast/*<From, To extends From>*/(dynamic/*=From*/ x) => x;
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
part of html;
|
||||
|
||||
class _HttpRequestUtils {
|
||||
|
||||
// Helper for factory HttpRequest.get
|
||||
static HttpRequest get(String url,
|
||||
onComplete(HttpRequest request),
|
||||
bool withCredentials) {
|
||||
static HttpRequest get(
|
||||
String url, onComplete(HttpRequest request), bool withCredentials) {
|
||||
final request = new HttpRequest();
|
||||
request.open('GET', url, async: true);
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ part of html;
|
|||
// Iterator for arrays with fixed size.
|
||||
class FixedSizeListIterator<T> implements Iterator<T> {
|
||||
final List<T> _array;
|
||||
final int _length; // Cache array length for faster access.
|
||||
final int _length; // Cache array length for faster access.
|
||||
int _position;
|
||||
T _current;
|
||||
|
||||
|
||||
FixedSizeListIterator(List<T> array)
|
||||
: _array = array,
|
||||
_position = -1,
|
||||
|
|
|
@ -15,10 +15,8 @@ class AppRuntimeLaunchItem extends ChromeObject {
|
|||
* Public constructor
|
||||
*/
|
||||
AppRuntimeLaunchItem({FileEntry entry, String type}) {
|
||||
if (entry != null)
|
||||
this.entry = entry;
|
||||
if (type != null)
|
||||
this.type = type;
|
||||
if (entry != null) this.entry = entry;
|
||||
if (type != null) this.type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -42,7 +40,6 @@ class AppRuntimeLaunchItem extends ChromeObject {
|
|||
set type(String type) {
|
||||
JS('void', '#.type = #', this._jsObject, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AppRuntimeLaunchData extends ChromeObject {
|
||||
|
@ -50,10 +47,8 @@ class AppRuntimeLaunchData extends ChromeObject {
|
|||
* Public constructor
|
||||
*/
|
||||
AppRuntimeLaunchData({String id, List<AppRuntimeLaunchItem> items}) {
|
||||
if (id != null)
|
||||
this.id = id;
|
||||
if (items != null)
|
||||
this.items = items;
|
||||
if (id != null) this.id = id;
|
||||
if (items != null) this.items = items;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -84,7 +79,6 @@ class AppRuntimeLaunchData extends ChromeObject {
|
|||
set items(List<AppRuntimeLaunchItem> items) {
|
||||
JS('void', '#.items = #', this._jsObject, convertArgument(items));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,6 +93,7 @@ class Event_app_runtime_onLaunched extends Event {
|
|||
callback(new AppRuntimeLaunchData._proxy(launchData));
|
||||
}
|
||||
}
|
||||
|
||||
super.addListener(__proxy_callback);
|
||||
}
|
||||
|
||||
|
@ -108,6 +103,7 @@ class Event_app_runtime_onLaunched extends Event {
|
|||
callback(new AppRuntimeLaunchData._proxy(launchData));
|
||||
}
|
||||
}
|
||||
|
||||
super.removeListener(__proxy_callback);
|
||||
}
|
||||
|
||||
|
@ -117,6 +113,7 @@ class Event_app_runtime_onLaunched extends Event {
|
|||
callback(new AppRuntimeLaunchData._proxy(launchData));
|
||||
}
|
||||
}
|
||||
|
||||
super.hasListener(__proxy_callback);
|
||||
}
|
||||
|
||||
|
@ -151,7 +148,9 @@ class API_app_runtime {
|
|||
Event_app_runtime_onLaunched onLaunched;
|
||||
Event_app_runtime_onRestarted onRestarted;
|
||||
API_app_runtime(this._jsObject) {
|
||||
onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._jsObject));
|
||||
onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this._jsObject));
|
||||
onLaunched = new Event_app_runtime_onLaunched(
|
||||
JS('', '#.onLaunched', this._jsObject));
|
||||
onRestarted = new Event_app_runtime_onRestarted(
|
||||
JS('', '#.onRestarted', this._jsObject));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,10 @@ class AppWindowBounds extends ChromeObject {
|
|||
* Public constructor
|
||||
*/
|
||||
AppWindowBounds({int left, int top, int width, int height}) {
|
||||
if (left != null)
|
||||
this.left = left;
|
||||
if (top != null)
|
||||
this.top = top;
|
||||
if (width != null)
|
||||
this.width = width;
|
||||
if (height != null)
|
||||
this.height = height;
|
||||
if (left != null) this.left = left;
|
||||
if (top != null) this.top = top;
|
||||
if (width != null) this.width = width;
|
||||
if (height != null) this.height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,56 +52,56 @@ class AppWindowBounds extends ChromeObject {
|
|||
set height(int height) {
|
||||
JS('void', '#.height = #', this._jsObject, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AppWindowCreateWindowOptions extends ChromeObject {
|
||||
/*
|
||||
* Public constructor
|
||||
*/
|
||||
AppWindowCreateWindowOptions({String id, int defaultWidth, int defaultHeight, int defaultLeft, int defaultTop, int width, int height, int left, int top, int minWidth, int minHeight, int maxWidth, int maxHeight, String type, String frame, AppWindowBounds bounds, bool transparentBackground, String state, bool hidden, bool resizable, bool singleton}) {
|
||||
if (id != null)
|
||||
this.id = id;
|
||||
if (defaultWidth != null)
|
||||
this.defaultWidth = defaultWidth;
|
||||
if (defaultHeight != null)
|
||||
this.defaultHeight = defaultHeight;
|
||||
if (defaultLeft != null)
|
||||
this.defaultLeft = defaultLeft;
|
||||
if (defaultTop != null)
|
||||
this.defaultTop = defaultTop;
|
||||
if (width != null)
|
||||
this.width = width;
|
||||
if (height != null)
|
||||
this.height = height;
|
||||
if (left != null)
|
||||
this.left = left;
|
||||
if (top != null)
|
||||
this.top = top;
|
||||
if (minWidth != null)
|
||||
this.minWidth = minWidth;
|
||||
if (minHeight != null)
|
||||
this.minHeight = minHeight;
|
||||
if (maxWidth != null)
|
||||
this.maxWidth = maxWidth;
|
||||
if (maxHeight != null)
|
||||
this.maxHeight = maxHeight;
|
||||
if (type != null)
|
||||
this.type = type;
|
||||
if (frame != null)
|
||||
this.frame = frame;
|
||||
if (bounds != null)
|
||||
this.bounds = bounds;
|
||||
AppWindowCreateWindowOptions(
|
||||
{String id,
|
||||
int defaultWidth,
|
||||
int defaultHeight,
|
||||
int defaultLeft,
|
||||
int defaultTop,
|
||||
int width,
|
||||
int height,
|
||||
int left,
|
||||
int top,
|
||||
int minWidth,
|
||||
int minHeight,
|
||||
int maxWidth,
|
||||
int maxHeight,
|
||||
String type,
|
||||
String frame,
|
||||
AppWindowBounds bounds,
|
||||
bool transparentBackground,
|
||||
String state,
|
||||
bool hidden,
|
||||
bool resizable,
|
||||
bool singleton}) {
|
||||
if (id != null) this.id = id;
|
||||
if (defaultWidth != null) this.defaultWidth = defaultWidth;
|
||||
if (defaultHeight != null) this.defaultHeight = defaultHeight;
|
||||
if (defaultLeft != null) this.defaultLeft = defaultLeft;
|
||||
if (defaultTop != null) this.defaultTop = defaultTop;
|
||||
if (width != null) this.width = width;
|
||||
if (height != null) this.height = height;
|
||||
if (left != null) this.left = left;
|
||||
if (top != null) this.top = top;
|
||||
if (minWidth != null) this.minWidth = minWidth;
|
||||
if (minHeight != null) this.minHeight = minHeight;
|
||||
if (maxWidth != null) this.maxWidth = maxWidth;
|
||||
if (maxHeight != null) this.maxHeight = maxHeight;
|
||||
if (type != null) this.type = type;
|
||||
if (frame != null) this.frame = frame;
|
||||
if (bounds != null) this.bounds = bounds;
|
||||
if (transparentBackground != null)
|
||||
this.transparentBackground = transparentBackground;
|
||||
if (state != null)
|
||||
this.state = state;
|
||||
if (hidden != null)
|
||||
this.hidden = hidden;
|
||||
if (resizable != null)
|
||||
this.resizable = resizable;
|
||||
if (singleton != null)
|
||||
this.singleton = singleton;
|
||||
if (state != null) this.state = state;
|
||||
if (hidden != null) this.hidden = hidden;
|
||||
if (resizable != null) this.resizable = resizable;
|
||||
if (singleton != null) this.singleton = singleton;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -230,7 +226,8 @@ class AppWindowCreateWindowOptions extends ChromeObject {
|
|||
/// Size and position of the content in the window (excluding the titlebar). If
|
||||
/// an id is also specified and a window with a matching id has been shown
|
||||
/// before, the remembered bounds of the window will be used instead.
|
||||
AppWindowBounds get bounds => new AppWindowBounds._proxy(JS('', '#.bounds', this._jsObject));
|
||||
AppWindowBounds get bounds =>
|
||||
new AppWindowBounds._proxy(JS('', '#.bounds', this._jsObject));
|
||||
|
||||
set bounds(AppWindowBounds bounds) {
|
||||
JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds));
|
||||
|
@ -238,10 +235,12 @@ class AppWindowCreateWindowOptions extends ChromeObject {
|
|||
|
||||
/// Enable window background transparency. Only supported in ash. Requires
|
||||
/// experimental API permission.
|
||||
bool get transparentBackground => JS('bool', '#.transparentBackground', this._jsObject);
|
||||
bool get transparentBackground =>
|
||||
JS('bool', '#.transparentBackground', this._jsObject);
|
||||
|
||||
set transparentBackground(bool transparentBackground) {
|
||||
JS('void', '#.transparentBackground = #', this._jsObject, transparentBackground);
|
||||
JS('void', '#.transparentBackground = #', this._jsObject,
|
||||
transparentBackground);
|
||||
}
|
||||
|
||||
/// The initial state of the window, allowing it to be created already
|
||||
|
@ -277,7 +276,6 @@ class AppWindowCreateWindowOptions extends ChromeObject {
|
|||
set singleton(bool singleton) {
|
||||
JS('void', '#.singleton = #', this._jsObject, singleton);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AppWindowAppWindow extends ChromeObject {
|
||||
|
@ -297,7 +295,7 @@ class AppWindowAppWindow extends ChromeObject {
|
|||
// TODO(sashab, sra): Detect whether this is the current window, or an
|
||||
// external one, and return an appropriately-typed object
|
||||
WindowBase get contentWindow =>
|
||||
JS("Window", "#.contentWindow", this._jsObject);
|
||||
JS("Window", "#.contentWindow", this._jsObject);
|
||||
|
||||
/*
|
||||
* Methods
|
||||
|
@ -327,10 +325,12 @@ class AppWindowAppWindow extends ChromeObject {
|
|||
void restore() => JS('void', '#.restore()', this._jsObject);
|
||||
|
||||
/// Move the window to the position (|left|, |top|).
|
||||
void moveTo(int left, int top) => JS('void', '#.moveTo(#, #)', this._jsObject, left, top);
|
||||
void moveTo(int left, int top) =>
|
||||
JS('void', '#.moveTo(#, #)', this._jsObject, left, top);
|
||||
|
||||
/// Resize the window to |width|x|height| pixels in size.
|
||||
void resizeTo(int width, int height) => JS('void', '#.resizeTo(#, #)', this._jsObject, width, height);
|
||||
void resizeTo(int width, int height) =>
|
||||
JS('void', '#.resizeTo(#, #)', this._jsObject, width, height);
|
||||
|
||||
/// Draw attention to the window.
|
||||
void drawAttention() => JS('void', '#.drawAttention()', this._jsObject);
|
||||
|
@ -358,13 +358,14 @@ class AppWindowAppWindow extends ChromeObject {
|
|||
new AppWindowBounds._proxy(JS('void', '#.getBounds()', this._jsObject));
|
||||
|
||||
/// Set the window's bounds.
|
||||
void setBounds(AppWindowBounds bounds) => JS('void', '#.setBounds(#)', this._jsObject, convertArgument(bounds));
|
||||
void setBounds(AppWindowBounds bounds) =>
|
||||
JS('void', '#.setBounds(#)', this._jsObject, convertArgument(bounds));
|
||||
|
||||
/// Set the app icon for the window (experimental). Currently this is only
|
||||
/// being implemented on Ash. TODO(stevenjb): Investigate implementing this on
|
||||
/// Windows and OSX.
|
||||
void setIcon(String icon_url) => JS('void', '#.setIcon(#)', this._jsObject, icon_url);
|
||||
|
||||
void setIcon(String icon_url) =>
|
||||
JS('void', '#.setIcon(#)', this._jsObject, icon_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,14 +481,15 @@ class API_app_window {
|
|||
|
||||
// TODO(sashab): This override is no longer needed once prefixes are removed.
|
||||
void create(String url,
|
||||
[AppWindowCreateWindowOptions options,
|
||||
void callback(AppWindowAppWindow created_window)]) {
|
||||
[AppWindowCreateWindowOptions options,
|
||||
void callback(AppWindowAppWindow created_window)]) {
|
||||
void __proxy_callback(created_window) {
|
||||
if (callback != null)
|
||||
callback(new AppWindowAppWindow._proxy(created_window));
|
||||
}
|
||||
JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
|
||||
JS('void', '#.create(#, #, #)', this._jsObject, url,
|
||||
convertArgument(options), convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Returns an $ref:AppWindow object for the current script context (ie
|
||||
|
@ -503,14 +505,21 @@ class API_app_window {
|
|||
AppWindowAppWindow current() =>
|
||||
new AppWindowAppWindow._proxy(JS('void', '#.current()', this._jsObject));
|
||||
|
||||
void initializeAppWindow(Object state) => JS('void', '#.initializeAppWindow(#)', this._jsObject, convertArgument(state));
|
||||
void initializeAppWindow(Object state) => JS('void',
|
||||
'#.initializeAppWindow(#)', this._jsObject, convertArgument(state));
|
||||
|
||||
API_app_window(this._jsObject) {
|
||||
onBoundsChanged = new Event_app_window_onBoundsChanged(JS('', '#.onBoundsChanged', this._jsObject));
|
||||
onClosed = new Event_app_window_onClosed(JS('', '#.onClosed', this._jsObject));
|
||||
onFullscreened = new Event_app_window_onFullscreened(JS('', '#.onFullscreened', this._jsObject));
|
||||
onMaximized = new Event_app_window_onMaximized(JS('', '#.onMaximized', this._jsObject));
|
||||
onMinimized = new Event_app_window_onMinimized(JS('', '#.onMinimized', this._jsObject));
|
||||
onRestored = new Event_app_window_onRestored(JS('', '#.onRestored', this._jsObject));
|
||||
onBoundsChanged = new Event_app_window_onBoundsChanged(
|
||||
JS('', '#.onBoundsChanged', this._jsObject));
|
||||
onClosed =
|
||||
new Event_app_window_onClosed(JS('', '#.onClosed', this._jsObject));
|
||||
onFullscreened = new Event_app_window_onFullscreened(
|
||||
JS('', '#.onFullscreened', this._jsObject));
|
||||
onMaximized = new Event_app_window_onMaximized(
|
||||
JS('', '#.onMaximized', this._jsObject));
|
||||
onMinimized = new Event_app_window_onMinimized(
|
||||
JS('', '#.onMinimized', this._jsObject));
|
||||
onRestored =
|
||||
new Event_app_window_onRestored(JS('', '#.onRestored', this._jsObject));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,4 @@
|
|||
|
||||
// TODO(sashab, sra): Detect whether this is the current window, or an
|
||||
// external one, and return an appropriately-typed object
|
||||
WindowBase get contentWindow =>
|
||||
JS("Window", "#.contentWindow", this._jsObject);
|
||||
WindowBase get contentWindow => JS("Window", "#.contentWindow", this._jsObject);
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
// TODO(sashab): This override is no longer needed once prefixes are removed.
|
||||
void create(String url,
|
||||
[AppWindowCreateWindowOptions options,
|
||||
void callback(AppWindowAppWindow created_window)]) {
|
||||
[AppWindowCreateWindowOptions options,
|
||||
void callback(AppWindowAppWindow created_window)]) {
|
||||
void __proxy_callback(created_window) {
|
||||
if (callback != null)
|
||||
callback(new AppWindowAppWindow._proxy(created_window));
|
||||
}
|
||||
JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
|
|
@ -6,4 +6,3 @@
|
|||
// correctly. Currently, it just reads void for all functions.
|
||||
AppWindowAppWindow current() =>
|
||||
new AppWindowAppWindow._proxy(JS('void', '#.current()', this._jsObject));
|
||||
|
||||
|
|
|
@ -14,13 +14,11 @@ class FilesystemAcceptOption extends ChromeObject {
|
|||
/*
|
||||
* Public constructor
|
||||
*/
|
||||
FilesystemAcceptOption({String description, List<String> mimeTypes, List<String> extensions}) {
|
||||
if (description != null)
|
||||
this.description = description;
|
||||
if (mimeTypes != null)
|
||||
this.mimeTypes = mimeTypes;
|
||||
if (extensions != null)
|
||||
this.extensions = extensions;
|
||||
FilesystemAcceptOption(
|
||||
{String description, List<String> mimeTypes, List<String> extensions}) {
|
||||
if (description != null) this.description = description;
|
||||
if (mimeTypes != null) this.mimeTypes = mimeTypes;
|
||||
if (extensions != null) this.extensions = extensions;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -43,34 +41,35 @@ class FilesystemAcceptOption extends ChromeObject {
|
|||
|
||||
/// Mime-types to accept, e.g. "image/jpeg" or "audio/*". One of mimeTypes or
|
||||
/// extensions must contain at least one valid element.
|
||||
List<String> get mimeTypes => JS('List<String>', '#.mimeTypes', this._jsObject);
|
||||
List<String> get mimeTypes =>
|
||||
JS('List<String>', '#.mimeTypes', this._jsObject);
|
||||
|
||||
set mimeTypes(List<String> mimeTypes) {
|
||||
JS('void', '#.mimeTypes = #', this._jsObject, mimeTypes);
|
||||
}
|
||||
|
||||
/// Extensions to accept, e.g. "jpg", "gif", "crx".
|
||||
List<String> get extensions => JS('List<String>', '#.extensions', this._jsObject);
|
||||
List<String> get extensions =>
|
||||
JS('List<String>', '#.extensions', this._jsObject);
|
||||
|
||||
set extensions(List<String> extensions) {
|
||||
JS('void', '#.extensions = #', this._jsObject, extensions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FilesystemChooseEntryOptions extends ChromeObject {
|
||||
/*
|
||||
* Public constructor
|
||||
*/
|
||||
FilesystemChooseEntryOptions({String type, String suggestedName, List<FilesystemAcceptOption> accepts, bool acceptsAllTypes}) {
|
||||
if (type != null)
|
||||
this.type = type;
|
||||
if (suggestedName != null)
|
||||
this.suggestedName = suggestedName;
|
||||
if (accepts != null)
|
||||
this.accepts = accepts;
|
||||
if (acceptsAllTypes != null)
|
||||
this.acceptsAllTypes = acceptsAllTypes;
|
||||
FilesystemChooseEntryOptions(
|
||||
{String type,
|
||||
String suggestedName,
|
||||
List<FilesystemAcceptOption> accepts,
|
||||
bool acceptsAllTypes}) {
|
||||
if (type != null) this.type = type;
|
||||
if (suggestedName != null) this.suggestedName = suggestedName;
|
||||
if (accepts != null) this.accepts = accepts;
|
||||
if (acceptsAllTypes != null) this.acceptsAllTypes = acceptsAllTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -99,7 +98,8 @@ class FilesystemChooseEntryOptions extends ChromeObject {
|
|||
/// The optional list of accept options for this file opener. Each option will
|
||||
/// be presented as a unique group to the end-user.
|
||||
List<FilesystemAcceptOption> get accepts {
|
||||
List<FilesystemAcceptOption> __proxy_accepts = new List<FilesystemAcceptOption>();
|
||||
List<FilesystemAcceptOption> __proxy_accepts =
|
||||
new List<FilesystemAcceptOption>();
|
||||
int count = JS('int', '#.accepts.length', this._jsObject);
|
||||
for (int i = 0; i < count; i++) {
|
||||
var item = JS('', '#.accepts[#]', this._jsObject, i);
|
||||
|
@ -120,7 +120,6 @@ class FilesystemChooseEntryOptions extends ChromeObject {
|
|||
set acceptsAllTypes(bool acceptsAllTypes) {
|
||||
JS('void', '#.acceptsAllTypes = #', this._jsObject, acceptsAllTypes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,30 +138,44 @@ class API_file_system {
|
|||
/// Get the display path of a FileEntry object. The display path is based on
|
||||
/// the full path of the file on the local file system, but may be made more
|
||||
/// readable for display purposes.
|
||||
void getDisplayPath(FileEntry fileEntry, void callback(String displayPath)) => JS('void', '#.getDisplayPath(#, #)', this._jsObject, convertArgument(fileEntry), convertDartClosureToJS(callback, 1));
|
||||
void getDisplayPath(FileEntry fileEntry, void callback(String displayPath)) =>
|
||||
JS('void', '#.getDisplayPath(#, #)', this._jsObject,
|
||||
convertArgument(fileEntry), convertDartClosureToJS(callback, 1));
|
||||
|
||||
/// Get a writable FileEntry from another FileEntry. This call will fail if the
|
||||
/// application does not have the 'write' permission under 'fileSystem'.
|
||||
void getWritableEntry(FileEntry fileEntry, void callback(FileEntry fileEntry)) {
|
||||
void getWritableEntry(
|
||||
FileEntry fileEntry, void callback(FileEntry fileEntry)) {
|
||||
void __proxy_callback(fileEntry) {
|
||||
if (callback != null) {
|
||||
callback(fileEntry);
|
||||
}
|
||||
}
|
||||
JS('void', '#.getWritableEntry(#, #)', this._jsObject, convertArgument(fileEntry), convertDartClosureToJS(__proxy_callback, 1));
|
||||
|
||||
JS(
|
||||
'void',
|
||||
'#.getWritableEntry(#, #)',
|
||||
this._jsObject,
|
||||
convertArgument(fileEntry),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Gets whether this FileEntry is writable or not.
|
||||
void isWritableEntry(FileEntry fileEntry, void callback(bool isWritable)) => JS('void', '#.isWritableEntry(#, #)', this._jsObject, convertArgument(fileEntry), convertDartClosureToJS(callback, 1));
|
||||
void isWritableEntry(FileEntry fileEntry, void callback(bool isWritable)) =>
|
||||
JS('void', '#.isWritableEntry(#, #)', this._jsObject,
|
||||
convertArgument(fileEntry), convertDartClosureToJS(callback, 1));
|
||||
|
||||
/// Ask the user to choose a file.
|
||||
void chooseEntry(void callback(FileEntry fileEntry), [FilesystemChooseEntryOptions options]) {
|
||||
void chooseEntry(void callback(FileEntry fileEntry),
|
||||
[FilesystemChooseEntryOptions options]) {
|
||||
void __proxy_callback(fileEntry) {
|
||||
if (callback != null) {
|
||||
callback(fileEntry);
|
||||
}
|
||||
}
|
||||
JS('void', '#.chooseEntry(#, #)', this._jsObject, convertArgument(options), convertDartClosureToJS(__proxy_callback, 1));
|
||||
|
||||
JS('void', '#.chooseEntry(#, #)', this._jsObject, convertArgument(options),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Returns the file entry with the given id if it can be restored. This call
|
||||
|
@ -173,12 +186,19 @@ class API_file_system {
|
|||
callback(fileEntry);
|
||||
}
|
||||
}
|
||||
JS('void', '#.restoreEntry(#, #)', this._jsObject, id, convertDartClosureToJS(__proxy_callback, 1));
|
||||
|
||||
JS('void', '#.restoreEntry(#, #)', this._jsObject, id,
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Returns whether a file entry for the given id can be restored, i.e. whether
|
||||
/// restoreEntry would succeed with this id now.
|
||||
void isRestorable(String id, void callback(bool isRestorable)) => JS('void', '#.isRestorable(#, #)', this._jsObject, id, convertDartClosureToJS(callback, 1));
|
||||
void isRestorable(String id, void callback(bool isRestorable)) => JS(
|
||||
'void',
|
||||
'#.isRestorable(#, #)',
|
||||
this._jsObject,
|
||||
id,
|
||||
convertDartClosureToJS(callback, 1));
|
||||
|
||||
/// Returns an id that can be passed to restoreEntry to regain access to a
|
||||
/// given file entry. Only the 500 most recently used entries are retained,
|
||||
|
@ -186,8 +206,8 @@ class API_file_system {
|
|||
/// the 'retainEntries' permission under 'fileSystem', entries are retained
|
||||
/// indefinitely. Otherwise, entries are retained only while the app is running
|
||||
/// and across restarts.
|
||||
String retainEntry(FileEntry fileEntry) => JS('String', '#.retainEntry(#)', this._jsObject, convertArgument(fileEntry));
|
||||
String retainEntry(FileEntry fileEntry) => JS(
|
||||
'String', '#.retainEntry(#)', this._jsObject, convertArgument(fileEntry));
|
||||
|
||||
API_file_system(this._jsObject) {
|
||||
}
|
||||
API_file_system(this._jsObject) {}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ abstract class ChromeObject {
|
|||
*/
|
||||
Object _convertMapArgument(Map argument) {
|
||||
Map m = new Map();
|
||||
for (Object key in argument.keys)
|
||||
m[key] = convertArgument(argument[key]);
|
||||
for (Object key in argument.keys) m[key] = convertArgument(argument[key]);
|
||||
return convertDartToNative_Dictionary(m);
|
||||
}
|
||||
|
||||
|
@ -57,8 +56,7 @@ Object _convertMapArgument(Map argument) {
|
|||
*/
|
||||
List _convertListArgument(List argument) {
|
||||
List l = new List();
|
||||
for (var i = 0; i < argument.length; i ++)
|
||||
l.add(convertArgument(argument[i]));
|
||||
for (var i = 0; i < argument.length; i++) l.add(convertArgument(argument[i]));
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -73,20 +71,16 @@ List _convertListArgument(List argument) {
|
|||
* Cannot be used for functions.
|
||||
*/
|
||||
Object convertArgument(var argument) {
|
||||
if (argument == null)
|
||||
return argument;
|
||||
if (argument == null) return argument;
|
||||
|
||||
if (argument is num || argument is String || argument is bool)
|
||||
return argument;
|
||||
|
||||
if (argument is ChromeObject)
|
||||
return argument._jsObject;
|
||||
if (argument is ChromeObject) return argument._jsObject;
|
||||
|
||||
if (argument is List)
|
||||
return _convertListArgument(argument);
|
||||
if (argument is List) return _convertListArgument(argument);
|
||||
|
||||
if (argument is Map)
|
||||
return _convertMapArgument(argument);
|
||||
if (argument is Map) return _convertMapArgument(argument);
|
||||
|
||||
if (argument is Function)
|
||||
throw new Exception("Cannot serialize Function argument ${argument}.");
|
||||
|
@ -140,7 +134,6 @@ class Rule extends ChromeObject {
|
|||
set priority(int priority) {
|
||||
JS('void', '#.priority = #', this._jsObject, priority);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,35 +180,19 @@ class Event {
|
|||
*/
|
||||
|
||||
/// Registers an event listener <em>callback</em> to an event.
|
||||
void addListener(Function callback) =>
|
||||
JS('void',
|
||||
'#.addListener(#)',
|
||||
this._jsObject,
|
||||
convertDartClosureToJS(callback, this._callbackArity)
|
||||
);
|
||||
void addListener(Function callback) => JS('void', '#.addListener(#)',
|
||||
this._jsObject, convertDartClosureToJS(callback, this._callbackArity));
|
||||
|
||||
/// Deregisters an event listener <em>callback</em> from an event.
|
||||
void removeListener(Function callback) =>
|
||||
JS('void',
|
||||
'#.removeListener(#)',
|
||||
this._jsObject,
|
||||
convertDartClosureToJS(callback, this._callbackArity)
|
||||
);
|
||||
void removeListener(Function callback) => JS('void', '#.removeListener(#)',
|
||||
this._jsObject, convertDartClosureToJS(callback, this._callbackArity));
|
||||
|
||||
/// Returns True if <em>callback</em> is registered to the event.
|
||||
bool hasListener(Function callback) =>
|
||||
JS('bool',
|
||||
'#.hasListener(#)',
|
||||
this._jsObject,
|
||||
convertDartClosureToJS(callback, this._callbackArity)
|
||||
);
|
||||
bool hasListener(Function callback) => JS('bool', '#.hasListener(#)',
|
||||
this._jsObject, convertDartClosureToJS(callback, this._callbackArity));
|
||||
|
||||
/// Returns true if any event listeners are registered to the event.
|
||||
bool hasListeners() =>
|
||||
JS('bool',
|
||||
'#.hasListeners()',
|
||||
this._jsObject
|
||||
);
|
||||
bool hasListeners() => JS('bool', '#.hasListeners()', this._jsObject);
|
||||
|
||||
/// Registers rules to handle events.
|
||||
///
|
||||
|
@ -224,26 +201,25 @@ class Event {
|
|||
/// rules. [callback] is called with registered rules.
|
||||
///
|
||||
void addRules(String eventName, List<Rule> rules,
|
||||
[void callback(List<Rule> rules)]) {
|
||||
[void callback(List<Rule> rules)]) {
|
||||
// proxy the callback
|
||||
void __proxy_callback(List rules) {
|
||||
if (callback != null) {
|
||||
List<Rule> __proxy_rules = new List<Rule>();
|
||||
|
||||
for (Object o in rules)
|
||||
__proxy_rules.add(new Rule._proxy(o));
|
||||
for (Object o in rules) __proxy_rules.add(new Rule._proxy(o));
|
||||
|
||||
callback(__proxy_rules);
|
||||
}
|
||||
}
|
||||
|
||||
JS('void',
|
||||
'#.addRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(rules),
|
||||
convertDartClosureToJS(__proxy_callback, 1)
|
||||
);
|
||||
JS(
|
||||
'void',
|
||||
'#.addRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(rules),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Returns currently registered rules.
|
||||
|
@ -252,27 +228,26 @@ class Event {
|
|||
/// is passed as [ruleIdentifiers], only rules with identifiers contained in
|
||||
/// this array are returned. [callback] is called with registered rules.
|
||||
///
|
||||
void getRules(String eventName, [List<String> ruleIdentifiers,
|
||||
void callback(List<Rule> rules)]) {
|
||||
void getRules(String eventName,
|
||||
[List<String> ruleIdentifiers, void callback(List<Rule> rules)]) {
|
||||
// proxy the callback
|
||||
void __proxy_callback(List rules) {
|
||||
if (callback != null) {
|
||||
List<Rule> __proxy_rules = new List<Rule>();
|
||||
|
||||
for (Object o in rules)
|
||||
__proxy_rules.add(new Rule._proxy(o));
|
||||
for (Object o in rules) __proxy_rules.add(new Rule._proxy(o));
|
||||
|
||||
callback(__proxy_rules);
|
||||
}
|
||||
}
|
||||
|
||||
JS('void',
|
||||
'#.getRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(ruleIdentifiers),
|
||||
convertDartClosureToJS(__proxy_callback, 1)
|
||||
);
|
||||
JS(
|
||||
'void',
|
||||
'#.getRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(ruleIdentifiers),
|
||||
convertDartClosureToJS(__proxy_callback, 1));
|
||||
}
|
||||
|
||||
/// Unregisters currently registered rules.
|
||||
|
@ -282,14 +257,13 @@ class Event {
|
|||
/// this array are unregistered. [callback] is called when the rules are
|
||||
/// unregistered.
|
||||
///
|
||||
void removeRules(String eventName, [List<String> ruleIdentifiers,
|
||||
void callback()]) =>
|
||||
JS('void',
|
||||
'#.removeRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(ruleIdentifiers),
|
||||
convertDartClosureToJS(callback, 0)
|
||||
);
|
||||
void removeRules(String eventName,
|
||||
[List<String> ruleIdentifiers, void callback()]) =>
|
||||
JS(
|
||||
'void',
|
||||
'#.removeRules(#, #, #)',
|
||||
this._jsObject,
|
||||
convertArgument(eventName),
|
||||
convertArgument(ruleIdentifiers),
|
||||
convertDartClosureToJS(callback, 0));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// 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.
|
||||
|
||||
|
||||
// Conversions for Window. These check if the window is the local
|
||||
// window, and if it's not, wraps or unwraps it with a secure wrapper.
|
||||
// We need to test for EventTarget here as well as it's a base type.
|
||||
|
@ -30,8 +29,7 @@ EventTarget _convertNativeToDart_EventTarget(e) {
|
|||
return window;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
final List<CssClassSetImpl> _sets;
|
||||
|
||||
factory _MultiElementCssClassSet(Iterable<Element> elements) {
|
||||
return new _MultiElementCssClassSet._(elements,
|
||||
elements.map((Element e) => e.classes).toList());
|
||||
return new _MultiElementCssClassSet._(
|
||||
elements, elements.map((Element e) => e.classes).toList());
|
||||
}
|
||||
|
||||
_MultiElementCssClassSet._(this._elementIterable, this._sets);
|
||||
|
@ -43,7 +43,7 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
* After f returns, the modified set is written to the
|
||||
* className property of this element.
|
||||
*/
|
||||
modify( f(Set<String> s)) {
|
||||
modify(f(Set<String> s)) {
|
||||
_sets.forEach((CssClassSetImpl e) => e.modify(f));
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,10 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
* TODO(sra): It seems wrong to collect a 'changed' flag like this when the
|
||||
* underlying toggle returns an 'is set' flag.
|
||||
*/
|
||||
bool toggle(String value, [bool shouldAdd]) =>
|
||||
_sets.fold(false,
|
||||
(bool changed, CssClassSetImpl e) =>
|
||||
e.toggle(value, shouldAdd) || changed);
|
||||
bool toggle(String value, [bool shouldAdd]) => _sets.fold(
|
||||
false,
|
||||
(bool changed, CssClassSetImpl e) =>
|
||||
e.toggle(value, shouldAdd) || changed);
|
||||
|
||||
/**
|
||||
* Remove the class [value] from element, and return true on successful
|
||||
|
@ -66,8 +66,8 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
* This is the Dart equivalent of jQuery's
|
||||
* [removeClass](http://api.jquery.com/removeClass/).
|
||||
*/
|
||||
bool remove(Object value) => _sets.fold(false,
|
||||
(bool changed, CssClassSetImpl e) => e.remove(value) || changed);
|
||||
bool remove(Object value) => _sets.fold(
|
||||
false, (bool changed, CssClassSetImpl e) => e.remove(value) || changed);
|
||||
}
|
||||
|
||||
class _ElementCssClassSet extends CssClassSetImpl {
|
||||
|
@ -218,19 +218,19 @@ class _ElementCssClassSet extends CssClassSetImpl {
|
|||
// work-around for the lack of annotations to express the full behaviour of
|
||||
// the DomTokenList methods.
|
||||
|
||||
static DomTokenList _classListOf(Element e) =>
|
||||
JS('returns:DomTokenList;creates:DomTokenList;effects:none;depends:all;',
|
||||
'#.classList', e);
|
||||
static DomTokenList _classListOf(Element e) => JS(
|
||||
'returns:DomTokenList;creates:DomTokenList;effects:none;depends:all;',
|
||||
'#.classList',
|
||||
e);
|
||||
|
||||
static int _classListLength(DomTokenList list) =>
|
||||
JS('returns:JSUInt31;effects:none;depends:all;', '#.length', list);
|
||||
|
||||
static bool _classListContains(DomTokenList list, String value) =>
|
||||
JS('returns:bool;effects:none;depends:all',
|
||||
'#.contains(#)', list, value);
|
||||
JS('returns:bool;effects:none;depends:all', '#.contains(#)', list, value);
|
||||
|
||||
static bool _classListContainsBeforeAddOrRemove(
|
||||
DomTokenList list, String value) =>
|
||||
DomTokenList list, String value) =>
|
||||
// 'throws:never' is a lie, since 'contains' will throw on an illegal
|
||||
// token. However, we always call this function immediately prior to
|
||||
// add/remove/toggle with the same token. Often the result of 'contains'
|
||||
|
|
|
@ -23,12 +23,14 @@ _callAttached(receiver) {
|
|||
_callDetached(receiver) {
|
||||
return receiver.detached();
|
||||
}
|
||||
_callAttributeChanged(receiver, name, oldValue, newValue) {
|
||||
|
||||
_callAttributeChanged(receiver, name, oldValue, newValue) {
|
||||
return receiver.attributeChanged(name, oldValue, newValue);
|
||||
}
|
||||
|
||||
_makeCallbackMethod(callback) {
|
||||
return JS('',
|
||||
return JS(
|
||||
'',
|
||||
'''((function(invokeCallback) {
|
||||
return function() {
|
||||
return invokeCallback(this);
|
||||
|
@ -38,7 +40,8 @@ _makeCallbackMethod(callback) {
|
|||
}
|
||||
|
||||
_makeCallbackMethod3(callback) {
|
||||
return JS('',
|
||||
return JS(
|
||||
'',
|
||||
'''((function(invokeCallback) {
|
||||
return function(arg1, arg2, arg3) {
|
||||
return invokeCallback(this, arg1, arg2, arg3);
|
||||
|
@ -57,13 +60,14 @@ void _checkExtendsNativeClassOrTemplate(
|
|||
Element element, String extendsTag, String baseClassName) {
|
||||
if (!JS('bool', '(# instanceof window[#])', element, baseClassName) &&
|
||||
!((extendsTag == 'template' &&
|
||||
JS('bool', '(# instanceof window["HTMLUnknownElement"])', element)))) {
|
||||
JS('bool', '(# instanceof window["HTMLUnknownElement"])',
|
||||
element)))) {
|
||||
throw new UnsupportedError('extendsTag does not match base native class');
|
||||
}
|
||||
}
|
||||
|
||||
void _registerCustomElement(context, document, String tag, Type type,
|
||||
String extendsTagName) {
|
||||
void _registerCustomElement(
|
||||
context, document, String tag, Type type, String extendsTagName) {
|
||||
// Function follows the same pattern as the following JavaScript code for
|
||||
// registering a custom element.
|
||||
//
|
||||
|
@ -113,7 +117,10 @@ void _registerCustomElement(context, document, String tag, Type type,
|
|||
|
||||
var properties = JS('=Object', '{}');
|
||||
|
||||
JS('void', '#.createdCallback = #', properties,
|
||||
JS(
|
||||
'void',
|
||||
'#.createdCallback = #',
|
||||
properties,
|
||||
JS('=Object', '{value: #}',
|
||||
_makeCallbackMethod(_callConstructor(constructor, interceptor))));
|
||||
JS('void', '#.attachedCallback = #', properties,
|
||||
|
|
|
@ -13,9 +13,9 @@ class _DOMWindowCrossFrame implements WindowBase {
|
|||
|
||||
// Fields.
|
||||
HistoryBase get history =>
|
||||
_HistoryCrossFrame._createSafe(JS('HistoryBase', '#.history', _window));
|
||||
LocationBase get location =>
|
||||
_LocationCrossFrame._createSafe(JS('LocationBase', '#.location', _window));
|
||||
_HistoryCrossFrame._createSafe(JS('HistoryBase', '#.history', _window));
|
||||
LocationBase get location => _LocationCrossFrame
|
||||
._createSafe(JS('LocationBase', '#.location', _window));
|
||||
|
||||
// TODO(vsm): Add frames to navigate subframes. See 2312.
|
||||
|
||||
|
@ -30,13 +30,18 @@ class _DOMWindowCrossFrame implements WindowBase {
|
|||
// Methods.
|
||||
void close() => JS('void', '#.close()', _window);
|
||||
|
||||
void postMessage(var message, String targetOrigin, [List messagePorts = null]) {
|
||||
void postMessage(var message, String targetOrigin,
|
||||
[List messagePorts = null]) {
|
||||
if (messagePorts == null) {
|
||||
JS('void', '#.postMessage(#,#)', _window,
|
||||
convertDartToNative_SerializedScriptValue(message), targetOrigin);
|
||||
} else {
|
||||
JS('void', '#.postMessage(#,#,#)', _window,
|
||||
convertDartToNative_SerializedScriptValue(message), targetOrigin,
|
||||
JS(
|
||||
'void',
|
||||
'#.postMessage(#,#,#)',
|
||||
_window,
|
||||
convertDartToNative_SerializedScriptValue(message),
|
||||
targetOrigin,
|
||||
messagePorts);
|
||||
}
|
||||
}
|
||||
|
@ -55,25 +60,29 @@ class _DOMWindowCrossFrame implements WindowBase {
|
|||
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
Events get on => throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
'You can only attach EventListeners to your own window.');
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
void _addEventListener(String type, EventListener listener, [bool useCapture])
|
||||
=> throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
void _addEventListener(String type, EventListener listener,
|
||||
[bool useCapture]) =>
|
||||
throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
void addEventListener(String type, EventListener listener, [bool useCapture])
|
||||
=> throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
void addEventListener(String type, EventListener listener,
|
||||
[bool useCapture]) =>
|
||||
throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
bool dispatchEvent(Event event) => throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
'You can only attach EventListeners to your own window.');
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
void _removeEventListener(String type, EventListener listener,
|
||||
[bool useCapture]) => throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
[bool useCapture]) =>
|
||||
throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
// TODO(efortuna): Remove this method. dartbug.com/16814
|
||||
void removeEventListener(String type, EventListener listener,
|
||||
[bool useCapture]) => throw new UnsupportedError(
|
||||
[bool useCapture]) =>
|
||||
throw new UnsupportedError(
|
||||
'You can only attach EventListeners to your own window.');
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
}
|
||||
|
||||
/** Construct a KeyEvent with [parent] as the event we're emulating. */
|
||||
KeyEvent.wrap(KeyboardEvent parent): super(parent) {
|
||||
KeyEvent.wrap(KeyboardEvent parent) : super(parent) {
|
||||
_parent = parent;
|
||||
_shadowAltKey = _realAltKey;
|
||||
_shadowCharCode = _realCharCode;
|
||||
|
@ -86,9 +86,16 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
|
||||
/** Programmatically create a new KeyEvent (and KeyboardEvent). */
|
||||
factory KeyEvent(String type,
|
||||
{Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0,
|
||||
int charCode: 0, int keyLocation: 1, bool ctrlKey: false,
|
||||
bool altKey: false, bool shiftKey: false, bool metaKey: false,
|
||||
{Window view,
|
||||
bool canBubble: true,
|
||||
bool cancelable: true,
|
||||
int keyCode: 0,
|
||||
int charCode: 0,
|
||||
int keyLocation: 1,
|
||||
bool ctrlKey: false,
|
||||
bool altKey: false,
|
||||
bool shiftKey: false,
|
||||
bool metaKey: false,
|
||||
EventTarget currentTarget}) {
|
||||
if (view == null) {
|
||||
view = window;
|
||||
|
@ -128,12 +135,21 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
canBubble: canBubble, cancelable: cancelable);
|
||||
|
||||
// Chromium Hack
|
||||
JS('void', "Object.defineProperty(#, 'keyCode', {"
|
||||
" get : function() { return this.keyCodeVal; } })", eventObj);
|
||||
JS('void', "Object.defineProperty(#, 'which', {"
|
||||
" get : function() { return this.keyCodeVal; } })", eventObj);
|
||||
JS('void', "Object.defineProperty(#, 'charCode', {"
|
||||
" get : function() { return this.charCodeVal; } })", eventObj);
|
||||
JS(
|
||||
'void',
|
||||
"Object.defineProperty(#, 'keyCode', {"
|
||||
" get : function() { return this.keyCodeVal; } })",
|
||||
eventObj);
|
||||
JS(
|
||||
'void',
|
||||
"Object.defineProperty(#, 'which', {"
|
||||
" get : function() { return this.keyCodeVal; } })",
|
||||
eventObj);
|
||||
JS(
|
||||
'void',
|
||||
"Object.defineProperty(#, 'charCode', {"
|
||||
" get : function() { return this.charCodeVal; } })",
|
||||
eventObj);
|
||||
|
||||
var keyIdentifier = _convertToHexString(charCode, keyCode);
|
||||
eventObj._initKeyboardEvent(type, canBubble, cancelable, view,
|
||||
|
@ -152,10 +168,10 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
}
|
||||
|
||||
// Currently known to work on all browsers but IE.
|
||||
static bool get canUseDispatchEvent =>
|
||||
JS('bool',
|
||||
'(typeof document.body.dispatchEvent == "function")'
|
||||
'&& document.body.dispatchEvent.length > 0');
|
||||
static bool get canUseDispatchEvent => JS(
|
||||
'bool',
|
||||
'(typeof document.body.dispatchEvent == "function")'
|
||||
'&& document.body.dispatchEvent.length > 0');
|
||||
|
||||
/** The currently registered target for this event. */
|
||||
EventTarget get currentTarget => _currentTarget;
|
||||
|
@ -202,10 +218,11 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
bool get shiftKey => _parent.shiftKey;
|
||||
InputDevice get sourceDevice => _parent.sourceDevice;
|
||||
Window get view => _parent.view;
|
||||
void _initUIEvent(String type, bool canBubble, bool cancelable,
|
||||
Window view, int detail) {
|
||||
void _initUIEvent(
|
||||
String type, bool canBubble, bool cancelable, Window view, int detail) {
|
||||
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
|
||||
}
|
||||
|
||||
String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
|
||||
|
||||
int get _charCode => charCode;
|
||||
|
@ -215,12 +232,22 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
String get _keyIdentifier {
|
||||
throw new UnsupportedError("keyIdentifier is unsupported.");
|
||||
}
|
||||
void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
|
||||
Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
|
||||
bool altKey, bool shiftKey, bool metaKey) {
|
||||
|
||||
void _initKeyboardEvent(
|
||||
String type,
|
||||
bool canBubble,
|
||||
bool cancelable,
|
||||
Window view,
|
||||
String keyIdentifier,
|
||||
int keyLocation,
|
||||
bool ctrlKey,
|
||||
bool altKey,
|
||||
bool shiftKey,
|
||||
bool metaKey) {
|
||||
throw new UnsupportedError(
|
||||
"Cannot initialize a KeyboardEvent from a KeyEvent.");
|
||||
}
|
||||
|
||||
@Experimental() // untriaged
|
||||
bool getModifierState(String keyArgument) => throw new UnimplementedError();
|
||||
@Experimental() // untriaged
|
||||
|
|
|
@ -7,7 +7,7 @@ part of html;
|
|||
class _TypedArrayFactoryProvider {
|
||||
static ByteData createByteData(int length) => _B8(length);
|
||||
static ByteData createByteData_fromBuffer(ByteBuffer buffer,
|
||||
[int byteOffset = 0, int length]) {
|
||||
[int byteOffset = 0, int length]) {
|
||||
if (length == null) return _B8_2(buffer, byteOffset);
|
||||
return _B8_3(buffer, byteOffset, length);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class _TypedArrayFactoryProvider {
|
|||
static Float32List createFloat32List_fromList(List<num> list) =>
|
||||
_F32(ensureNative(list));
|
||||
static Float32List createFloat32List_fromBuffer(ByteBuffer buffer,
|
||||
[int byteOffset = 0, int length]) {
|
||||
[int byteOffset = 0, int length]) {
|
||||
if (length == null) return _F32_2(buffer, byteOffset);
|
||||
return _F32_3(buffer, byteOffset, length);
|
||||
}
|
||||
|
@ -87,30 +87,22 @@ class _TypedArrayFactoryProvider {
|
|||
static Uint8ClampedList createUint8ClampedList(int length) => _U8C(length);
|
||||
static Uint8ClampedList createUint8ClampedList_fromList(List<num> list) =>
|
||||
_U8C(ensureNative(list));
|
||||
static Uint8ClampedList createUint8ClampedList_fromBuffer(
|
||||
ByteBuffer buffer, [int byteOffset = 0, int length]) {
|
||||
static Uint8ClampedList createUint8ClampedList_fromBuffer(ByteBuffer buffer,
|
||||
[int byteOffset = 0, int length]) {
|
||||
if (length == null) return _U8C_2(buffer, byteOffset);
|
||||
return _U8C_3(buffer, byteOffset, length);
|
||||
}
|
||||
|
||||
static ByteData _B8(arg) =>
|
||||
JS('ByteData', 'new DataView(new ArrayBuffer(#))', arg);
|
||||
static Float32List _F32(arg) =>
|
||||
JS('Float32List', 'new Float32Array(#)', arg);
|
||||
static Float64List _F64(arg) =>
|
||||
JS('Float64List', 'new Float64Array(#)', arg);
|
||||
static Int8List _I8(arg) =>
|
||||
JS('Int8List', 'new Int8Array(#)', arg);
|
||||
static Int16List _I16(arg) =>
|
||||
JS('Int16List', 'new Int16Array(#)', arg);
|
||||
static Int32List _I32(arg) =>
|
||||
JS('Int32List', 'new Int32Array(#)', arg);
|
||||
static Uint8List _U8(arg) =>
|
||||
JS('Uint8List', 'new Uint8Array(#)', arg);
|
||||
static Uint16List _U16(arg) =>
|
||||
JS('Uint16List', 'new Uint16Array(#)', arg);
|
||||
static Uint32List _U32(arg) =>
|
||||
JS('Uint32List', 'new Uint32Array(#)', arg);
|
||||
static Float32List _F32(arg) => JS('Float32List', 'new Float32Array(#)', arg);
|
||||
static Float64List _F64(arg) => JS('Float64List', 'new Float64Array(#)', arg);
|
||||
static Int8List _I8(arg) => JS('Int8List', 'new Int8Array(#)', arg);
|
||||
static Int16List _I16(arg) => JS('Int16List', 'new Int16Array(#)', arg);
|
||||
static Int32List _I32(arg) => JS('Int32List', 'new Int32Array(#)', arg);
|
||||
static Uint8List _U8(arg) => JS('Uint8List', 'new Uint8Array(#)', arg);
|
||||
static Uint16List _U16(arg) => JS('Uint16List', 'new Uint16Array(#)', arg);
|
||||
static Uint32List _U32(arg) => JS('Uint32List', 'new Uint32Array(#)', arg);
|
||||
static Uint8ClampedList _U8C(arg) =>
|
||||
JS('Uint8ClampedList', 'new Uint8ClampedArray(#)', arg);
|
||||
|
||||
|
@ -153,11 +145,10 @@ class _TypedArrayFactoryProvider {
|
|||
JS('Uint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3);
|
||||
static Uint32List _U32_3(arg1, arg2, arg3) =>
|
||||
JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3);
|
||||
static Uint8ClampedList _U8C_3(arg1, arg2, arg3) =>
|
||||
JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)', arg1, arg2, arg3);
|
||||
|
||||
static Uint8ClampedList _U8C_3(arg1, arg2, arg3) => JS(
|
||||
'Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)', arg1, arg2, arg3);
|
||||
|
||||
// Ensures that [list] is a JavaScript Array or a typed array. If necessary,
|
||||
// copies the list.
|
||||
static ensureNative(List list) => list; // TODO: make sure.
|
||||
static ensureNative(List list) => list; // TODO: make sure.
|
||||
}
|
||||
|
|
|
@ -31,10 +31,8 @@ class _WrappedEvent implements Event {
|
|||
|
||||
String get type => wrapped.type;
|
||||
|
||||
void _initEvent(String eventTypeArg, bool canBubbleArg,
|
||||
bool cancelableArg) {
|
||||
throw new UnsupportedError(
|
||||
'Cannot initialize this Event.');
|
||||
void _initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) {
|
||||
throw new UnsupportedError('Cannot initialize this Event.');
|
||||
}
|
||||
|
||||
void preventDefault() {
|
||||
|
|
|
@ -13,14 +13,14 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
Iterable<_ElementCssClassSet> _elementCssClassSetIterable;
|
||||
|
||||
_MultiElementCssClassSet(this._elementIterable) {
|
||||
_elementCssClassSetIterable = new List.from(_elementIterable).map(
|
||||
(e) => new _ElementCssClassSet(e));
|
||||
_elementCssClassSetIterable =
|
||||
new List.from(_elementIterable).map((e) => new _ElementCssClassSet(e));
|
||||
}
|
||||
|
||||
Set<String> readClasses() {
|
||||
var s = new LinkedHashSet<String>();
|
||||
_elementCssClassSetIterable.forEach(
|
||||
(_ElementCssClassSet e) => s.addAll(e.readClasses()));
|
||||
_elementCssClassSetIterable
|
||||
.forEach((_ElementCssClassSet e) => s.addAll(e.readClasses()));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
* After f returns, the modified set is written to the
|
||||
* className property of this element.
|
||||
*/
|
||||
modify( f(Set<String> s)) {
|
||||
modify(f(Set<String> s)) {
|
||||
_elementCssClassSetIterable.forEach((_ElementCssClassSet e) => e.modify(f));
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,8 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
* is.
|
||||
*/
|
||||
bool toggle(String value, [bool shouldAdd]) =>
|
||||
_elementCssClassSetIterable.fold(false,
|
||||
_elementCssClassSetIterable.fold(
|
||||
false,
|
||||
(bool changed, _ElementCssClassSet e) =>
|
||||
e.toggle(value, shouldAdd) || changed);
|
||||
|
||||
|
@ -65,7 +66,6 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
|
|||
}
|
||||
|
||||
class _ElementCssClassSet extends CssClassSetImpl {
|
||||
|
||||
final Element _element;
|
||||
|
||||
_ElementCssClassSet(this._element);
|
||||
|
|
|
@ -10,15 +10,14 @@ class _VMElementUpgrader implements ElementUpgrader {
|
|||
final Type _nativeType;
|
||||
final String _extendsTag;
|
||||
|
||||
_VMElementUpgrader(Document document, Type type, String extendsTag) :
|
||||
_type = type,
|
||||
_extendsTag = extendsTag,
|
||||
_nativeType = _validateCustomType(type).reflectedType {
|
||||
|
||||
_VMElementUpgrader(Document document, Type type, String extendsTag)
|
||||
: _type = type,
|
||||
_extendsTag = extendsTag,
|
||||
_nativeType = _validateCustomType(type).reflectedType {
|
||||
if (extendsTag == null) {
|
||||
if (_nativeType != HtmlElement) {
|
||||
throw new UnsupportedError('Class must provide extendsTag if base '
|
||||
'native class is not HtmlElement');
|
||||
'native class is not HtmlElement');
|
||||
}
|
||||
} else {
|
||||
if (document.createElement(extendsTag).runtimeType != _nativeType) {
|
||||
|
@ -78,7 +77,7 @@ ClassMirror _validateCustomType(Type type) {
|
|||
cls != null && cls.qualifiedName == elementName;
|
||||
ClassMirror superClass = cls.superclass;
|
||||
ClassMirror nativeClass = _isBuiltinType(superClass) ? superClass : null;
|
||||
while(!isRoot(superClass) && !isElement(superClass)) {
|
||||
while (!isRoot(superClass) && !isElement(superClass)) {
|
||||
superClass = superClass.superclass;
|
||||
if (nativeClass == null && _isBuiltinType(superClass)) {
|
||||
nativeClass = superClass;
|
||||
|
@ -87,7 +86,6 @@ ClassMirror _validateCustomType(Type type) {
|
|||
return nativeClass;
|
||||
}
|
||||
|
||||
|
||||
bool _isBuiltinType(ClassMirror cls) {
|
||||
// TODO(vsm): Find a less hackish way to do this.
|
||||
LibraryMirror lib = cls.owner;
|
||||
|
|
|
@ -68,41 +68,54 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
EventTarget _currentTarget;
|
||||
|
||||
/** Construct a KeyEvent with [parent] as the event we're emulating. */
|
||||
KeyEvent.wrap(KeyboardEvent parent): super(parent) {
|
||||
KeyEvent.wrap(KeyboardEvent parent) : super(parent) {
|
||||
_parent = parent;
|
||||
_shadowAltKey = _realAltKey;
|
||||
_shadowCharCode = _realCharCode;
|
||||
_shadowKeyCode = _realKeyCode;
|
||||
_currentTarget = _parent.currentTarget == null? window :
|
||||
_parent.currentTarget;
|
||||
_currentTarget =
|
||||
_parent.currentTarget == null ? window : _parent.currentTarget;
|
||||
}
|
||||
|
||||
/** Programmatically create a new KeyEvent (and KeyboardEvent). */
|
||||
factory KeyEvent(String type,
|
||||
{Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0,
|
||||
int charCode: 0, int keyLocation: 1, bool ctrlKey: false,
|
||||
bool altKey: false, bool shiftKey: false, bool metaKey: false,
|
||||
EventTarget currentTarget}) {
|
||||
var parent = new KeyboardEvent(type, view: view, canBubble: canBubble,
|
||||
cancelable: cancelable, keyLocation: keyLocation, ctrlKey: ctrlKey,
|
||||
altKey: altKey, shiftKey: shiftKey, metaKey: metaKey);
|
||||
var keyEvent = new KeyEvent.wrap(parent);
|
||||
keyEvent._shadowAltKey = altKey;
|
||||
keyEvent._shadowCharCode = charCode;
|
||||
keyEvent._shadowKeyCode = keyCode;
|
||||
keyEvent._currentTarget = currentTarget == null ? window : currentTarget;
|
||||
return keyEvent;
|
||||
}
|
||||
factory KeyEvent(String type,
|
||||
{Window view,
|
||||
bool canBubble: true,
|
||||
bool cancelable: true,
|
||||
int keyCode: 0,
|
||||
int charCode: 0,
|
||||
int keyLocation: 1,
|
||||
bool ctrlKey: false,
|
||||
bool altKey: false,
|
||||
bool shiftKey: false,
|
||||
bool metaKey: false,
|
||||
EventTarget currentTarget}) {
|
||||
var parent = new KeyboardEvent(type,
|
||||
view: view,
|
||||
canBubble: canBubble,
|
||||
cancelable: cancelable,
|
||||
keyLocation: keyLocation,
|
||||
ctrlKey: ctrlKey,
|
||||
altKey: altKey,
|
||||
shiftKey: shiftKey,
|
||||
metaKey: metaKey);
|
||||
var keyEvent = new KeyEvent.wrap(parent);
|
||||
keyEvent._shadowAltKey = altKey;
|
||||
keyEvent._shadowCharCode = charCode;
|
||||
keyEvent._shadowKeyCode = keyCode;
|
||||
keyEvent._currentTarget = currentTarget == null ? window : currentTarget;
|
||||
return keyEvent;
|
||||
}
|
||||
|
||||
/** Accessor to provide a stream of KeyEvents on the desired target. */
|
||||
static EventStreamProvider<KeyEvent> keyDownEvent =
|
||||
new _KeyboardEventHandler('keydown');
|
||||
new _KeyboardEventHandler('keydown');
|
||||
/** Accessor to provide a stream of KeyEvents on the desired target. */
|
||||
static EventStreamProvider<KeyEvent> keyUpEvent =
|
||||
new _KeyboardEventHandler('keyup');
|
||||
new _KeyboardEventHandler('keyup');
|
||||
/** Accessor to provide a stream of KeyEvents on the desired target. */
|
||||
static EventStreamProvider<KeyEvent> keyPressEvent =
|
||||
new _KeyboardEventHandler('keypress');
|
||||
new _KeyboardEventHandler('keypress');
|
||||
|
||||
/** The currently registered target for this event. */
|
||||
EventTarget get currentTarget => _currentTarget;
|
||||
|
@ -121,10 +134,11 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
/** True if the shift key was pressed during this event. */
|
||||
bool get shiftKey => _parent.shiftKey;
|
||||
Window get view => _parent.view;
|
||||
void _initUIEvent(String type, bool canBubble, bool cancelable,
|
||||
Window view, int detail) {
|
||||
void _initUIEvent(
|
||||
String type, bool canBubble, bool cancelable, Window view, int detail) {
|
||||
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
|
||||
}
|
||||
|
||||
String get _shadowKeyIdentifier => _parent._keyIdentifier;
|
||||
|
||||
int get _charCode => charCode;
|
||||
|
@ -133,12 +147,22 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
|
|||
String get _keyIdentifier {
|
||||
throw new UnsupportedError("keyIdentifier is unsupported.");
|
||||
}
|
||||
void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
|
||||
Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
|
||||
bool altKey, bool shiftKey, bool metaKey) {
|
||||
|
||||
void _initKeyboardEvent(
|
||||
String type,
|
||||
bool canBubble,
|
||||
bool cancelable,
|
||||
Window view,
|
||||
String keyIdentifier,
|
||||
int keyLocation,
|
||||
bool ctrlKey,
|
||||
bool altKey,
|
||||
bool shiftKey,
|
||||
bool metaKey) {
|
||||
throw new UnsupportedError(
|
||||
"Cannot initialize a KeyboardEvent from a KeyEvent.");
|
||||
}
|
||||
|
||||
@Experimental() // untriaged
|
||||
bool getModifierState(String keyArgument) => throw new UnimplementedError();
|
||||
@Experimental() // untriaged
|
||||
|
|
|
@ -37,10 +37,8 @@ class _WrappedEvent implements Event {
|
|||
|
||||
String get type => wrapped.type;
|
||||
|
||||
void _initEvent(String eventTypeArg, bool canBubbleArg,
|
||||
bool cancelableArg) {
|
||||
throw new UnsupportedError(
|
||||
'Cannot initialize this Event.');
|
||||
void _initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) {
|
||||
throw new UnsupportedError('Cannot initialize this Event.');
|
||||
}
|
||||
|
||||
void preventDefault() {
|
||||
|
|
|
@ -585,8 +585,8 @@ class _Utils {
|
|||
map.forEach((symbol, mirror) {
|
||||
if (mirror.isStatic == isStatic && !mirror.isPrivate) {
|
||||
var name = MirrorSystem.getName(symbol);
|
||||
if (mirror is MethodMirror && mirror.isSetter) name =
|
||||
name.substring(0, name.length - 1);
|
||||
if (mirror is MethodMirror && mirror.isSetter)
|
||||
name = name.substring(0, name.length - 1);
|
||||
completions.add(name);
|
||||
}
|
||||
});
|
||||
|
@ -1074,28 +1074,45 @@ class _DOMWindowCrossFrame extends DartHtmlDomObject implements WindowBase {
|
|||
// use _DOMWindowCrossFrame.
|
||||
return window;
|
||||
}
|
||||
return win is _DOMWindowCrossFrame ? win : _blink.Blink_Utils.setInstanceInterceptor(win, _DOMWindowCrossFrame);
|
||||
return win is _DOMWindowCrossFrame
|
||||
? win
|
||||
: _blink.Blink_Utils.setInstanceInterceptor(win, _DOMWindowCrossFrame);
|
||||
}
|
||||
|
||||
// Fields.
|
||||
HistoryBase get history {
|
||||
var history = _blink.BlinkWindow.instance.history_Getter_(this);
|
||||
return history is _HistoryCrossFrame ? history : _blink.Blink_Utils.setInstanceInterceptor(history, _HistoryCrossFrame);
|
||||
var history = _blink.BlinkWindow.instance.history_Getter_(this);
|
||||
return history is _HistoryCrossFrame
|
||||
? history
|
||||
: _blink.Blink_Utils
|
||||
.setInstanceInterceptor(history, _HistoryCrossFrame);
|
||||
}
|
||||
|
||||
LocationBase get location {
|
||||
var location = _blink.BlinkWindow.instance.location_Getter_(this);
|
||||
return location is _LocationCrossFrame ? location : _blink.Blink_Utils.setInstanceInterceptor(location, _LocationCrossFrame);
|
||||
return location is _LocationCrossFrame
|
||||
? location
|
||||
: _blink.Blink_Utils
|
||||
.setInstanceInterceptor(location, _LocationCrossFrame);
|
||||
}
|
||||
|
||||
bool get closed => _blink.BlinkWindow.instance.closed_Getter_(this);
|
||||
WindowBase get opener => _convertNativeToDart_Window(_blink.BlinkWindow.instance.opener_Getter_(this));
|
||||
WindowBase get parent => _convertNativeToDart_Window(_blink.BlinkWindow.instance.parent_Getter_(this));
|
||||
WindowBase get top => _convertNativeToDart_Window(_blink.BlinkWindow.instance.top_Getter_(this));
|
||||
WindowBase get opener => _convertNativeToDart_Window(
|
||||
_blink.BlinkWindow.instance.opener_Getter_(this));
|
||||
WindowBase get parent => _convertNativeToDart_Window(
|
||||
_blink.BlinkWindow.instance.parent_Getter_(this));
|
||||
WindowBase get top => _convertNativeToDart_Window(
|
||||
_blink.BlinkWindow.instance.top_Getter_(this));
|
||||
|
||||
// Methods.
|
||||
void close() => _blink.BlinkWindow.instance.close_Callback_0_(this);
|
||||
void postMessage(Object message, String targetOrigin, [List<MessagePort> transfer]) => _blink.BlinkWindow.instance.postMessage_Callback_3_(this, convertDartToNative_SerializedScriptValue(message), targetOrigin, transfer);
|
||||
void postMessage(Object message, String targetOrigin,
|
||||
[List<MessagePort> transfer]) =>
|
||||
_blink.BlinkWindow.instance.postMessage_Callback_3_(
|
||||
this,
|
||||
convertDartToNative_SerializedScriptValue(message),
|
||||
targetOrigin,
|
||||
transfer);
|
||||
|
||||
// Implementation support.
|
||||
String get typeName => "Window";
|
||||
|
@ -1151,7 +1168,8 @@ class _LocationCrossFrame extends DartHtmlDomObject implements LocationBase {
|
|||
_LocationCrossFrame.internal();
|
||||
|
||||
// Fields.
|
||||
set href(String value) => _blink.BlinkLocation.instance.href_Setter_(this, value);
|
||||
set href(String value) =>
|
||||
_blink.BlinkLocation.instance.href_Setter_(this, value);
|
||||
|
||||
// Implementation support.
|
||||
String get typeName => "Location";
|
||||
|
@ -1221,6 +1239,7 @@ _helperIsolateMain(originalSendPort) {
|
|||
ping() {
|
||||
replyTo.send(_TIMER_PING);
|
||||
}
|
||||
|
||||
;
|
||||
_TIMER_REGISTRY[replyTo] = periodic
|
||||
? new Timer.periodic(duration, (_) {
|
||||
|
|
|
@ -7,7 +7,7 @@ part of dart.dom.svg;
|
|||
class _SvgElementFactoryProvider {
|
||||
static SvgElement createSvgElement_tag(String tag) {
|
||||
final Element temp =
|
||||
document.createElementNS("http://www.w3.org/2000/svg", tag);
|
||||
document.createElementNS("http://www.w3.org/2000/svg", tag);
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,20 @@ part of dart.dom.html;
|
|||
typedef R _wrapZoneCallback<A, R>(A a);
|
||||
typedef R _wrapZoneBinaryCallback<A, B, R>(A a, B b);
|
||||
|
||||
_wrapZoneCallback/*<A, R>*/ _wrapZone/*<A, R>*/(_wrapZoneCallback/*<A, R>*/ callback) {
|
||||
_wrapZoneCallback/*<A, R>*/ _wrapZone/*<A, R>*/(
|
||||
_wrapZoneCallback/*<A, R>*/ callback) {
|
||||
// For performance reasons avoid wrapping if we are in the root zone.
|
||||
if (Zone.current == Zone.ROOT) return callback;
|
||||
if (callback == null) return null;
|
||||
return Zone.current.bindUnaryCallback/*<R, A>*/(callback, runGuarded: true);
|
||||
}
|
||||
|
||||
_wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinaryCallback/*<A, B, R>*/ callback) {
|
||||
_wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(
|
||||
_wrapZoneBinaryCallback/*<A, B, R>*/ callback) {
|
||||
if (Zone.current == Zone.ROOT) return callback;
|
||||
if (callback == null) return null;
|
||||
return Zone.current.bindBinaryCallback/*<R, A, B>*/(callback, runGuarded: true);
|
||||
return Zone.current
|
||||
.bindBinaryCallback/*<R, A, B>*/(callback, runGuarded: true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +37,8 @@ Element query(String relativeSelectors) => document.query(relativeSelectors);
|
|||
*/
|
||||
@deprecated
|
||||
@Experimental()
|
||||
ElementList<Element> queryAll(String relativeSelectors) => document.queryAll(relativeSelectors);
|
||||
ElementList<Element> queryAll(String relativeSelectors) =>
|
||||
document.queryAll(relativeSelectors);
|
||||
|
||||
/**
|
||||
* Finds the first descendant element of this document that matches the
|
||||
|
@ -71,7 +75,8 @@ Element querySelector(String selectors) => document.querySelector(selectors);
|
|||
* For details about CSS selector syntax, see the
|
||||
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
|
||||
*/
|
||||
ElementList<Element> querySelectorAll(String selectors) => document.querySelectorAll(selectors);
|
||||
ElementList<Element> querySelectorAll(String selectors) =>
|
||||
document.querySelectorAll(selectors);
|
||||
|
||||
/// A utility for changing the Dart wrapper type for elements.
|
||||
abstract class ElementUpgrader {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
part of gardening.shard2group;
|
||||
|
||||
const Map<String, List<String>> shardGroups = const {
|
||||
|
||||
'vm': const <String>[
|
||||
'vm-mac-debug-simdbc64-be',
|
||||
'vm-mac-release-simdbc64-be',
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
/// Converts block-style Doc comments in Dart code to line style.
|
||||
library line_doc_comments;
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import '../pkg/path/lib/path.dart' as path;
|
||||
|
@ -21,14 +22,13 @@ main(List<String> args) {
|
|||
}
|
||||
|
||||
var dir = new Directory(args[0]);
|
||||
dir.list(recursive: true, followLinks: false).listen(
|
||||
(entity) {
|
||||
if (entity is File) {
|
||||
var file = entity.path;
|
||||
if (path.extension(file) != '.dart') return;
|
||||
fixFile(file);
|
||||
}
|
||||
});
|
||||
dir.list(recursive: true, followLinks: false).listen((entity) {
|
||||
if (entity is File) {
|
||||
var file = entity.path;
|
||||
if (path.extension(file) != '.dart') return;
|
||||
fixFile(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void fixFile(String path) {
|
||||
|
|
|
@ -10,40 +10,55 @@ import "dart:io";
|
|||
import "testing/dart/multitest.dart";
|
||||
import "testing/dart/status_file_parser.dart";
|
||||
import "testing/dart/test_suite.dart"
|
||||
show multiHtmlTestGroupRegExp, multiTestRegExp, multiHtmlTestRegExp,
|
||||
TestUtils;
|
||||
show
|
||||
multiHtmlTestGroupRegExp,
|
||||
multiTestRegExp,
|
||||
multiHtmlTestRegExp,
|
||||
TestUtils;
|
||||
import "testing/dart/utils.dart" show Path;
|
||||
|
||||
// [STATUS_TUPLES] is a list of (suite-name, directory, status-file)-tuples.
|
||||
final STATUS_TUPLES = [
|
||||
["corelib", "tests/corelib", "tests/corelib/corelib.status"],
|
||||
["html", "tests/html", "tests/html/html.status"],
|
||||
["isolate", "tests/isolate", "tests/isolate/isolate.status"],
|
||||
["language", "tests/language", "tests/language/language.status"],
|
||||
["language", "tests/language", "tests/language/language_analyzer2.status"],
|
||||
["language","tests/language", "tests/language/language_analyzer.status"],
|
||||
["language","tests/language", "tests/language/language_dart2js.status"],
|
||||
["lib", "tests/lib", "tests/lib/lib.status"],
|
||||
["standalone", "tests/standalone", "tests/standalone/standalone.status"],
|
||||
["pkg", "pkg", "pkg/pkg.status"],
|
||||
["pkgbuild", ".", "pkg/pkgbuild.status"],
|
||||
["utils", "tests/utils", "tests/utils/utils.status"],
|
||||
["samples", "samples", "samples/samples.status"],
|
||||
["analyze_library", "sdk", "tests/lib/analyzer/analyze_library.status"],
|
||||
["dart2js_extra", "tests/compiler/dart2js_extra",
|
||||
"tests/compiler/dart2js_extra/dart2js_extra.status"],
|
||||
["dart2js_native", "tests/compiler/dart2js_native",
|
||||
"tests/compiler/dart2js_native/dart2js_native.status"],
|
||||
["dart2js", "tests/compiler/dart2js",
|
||||
"tests/compiler/dart2js/dart2js.status"],
|
||||
["benchmark_smoke", "tests/benchmark_smoke",
|
||||
"tests/benchmark_smoke/benchmark_smoke.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-analyzer2.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-analyzer.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-dart2js.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-co19.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-dartium.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-runtime.status"],
|
||||
["corelib", "tests/corelib", "tests/corelib/corelib.status"],
|
||||
["html", "tests/html", "tests/html/html.status"],
|
||||
["isolate", "tests/isolate", "tests/isolate/isolate.status"],
|
||||
["language", "tests/language", "tests/language/language.status"],
|
||||
["language", "tests/language", "tests/language/language_analyzer2.status"],
|
||||
["language", "tests/language", "tests/language/language_analyzer.status"],
|
||||
["language", "tests/language", "tests/language/language_dart2js.status"],
|
||||
["lib", "tests/lib", "tests/lib/lib.status"],
|
||||
["standalone", "tests/standalone", "tests/standalone/standalone.status"],
|
||||
["pkg", "pkg", "pkg/pkg.status"],
|
||||
["pkgbuild", ".", "pkg/pkgbuild.status"],
|
||||
["utils", "tests/utils", "tests/utils/utils.status"],
|
||||
["samples", "samples", "samples/samples.status"],
|
||||
["analyze_library", "sdk", "tests/lib/analyzer/analyze_library.status"],
|
||||
[
|
||||
"dart2js_extra",
|
||||
"tests/compiler/dart2js_extra",
|
||||
"tests/compiler/dart2js_extra/dart2js_extra.status"
|
||||
],
|
||||
[
|
||||
"dart2js_native",
|
||||
"tests/compiler/dart2js_native",
|
||||
"tests/compiler/dart2js_native/dart2js_native.status"
|
||||
],
|
||||
[
|
||||
"dart2js",
|
||||
"tests/compiler/dart2js",
|
||||
"tests/compiler/dart2js/dart2js.status"
|
||||
],
|
||||
[
|
||||
"benchmark_smoke",
|
||||
"tests/benchmark_smoke",
|
||||
"tests/benchmark_smoke/benchmark_smoke.status"
|
||||
],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-analyzer2.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-analyzer.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-dart2js.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-co19.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-dartium.status"],
|
||||
["co19", "tests/co19/src", "tests/co19/co19-runtime.status"],
|
||||
];
|
||||
|
||||
void main(List<String> args) {
|
||||
|
@ -107,16 +122,16 @@ class StatusFileNonExistentTestRemover extends StatusFileProcessor {
|
|||
});
|
||||
}
|
||||
|
||||
bool _testExists(String filePath,
|
||||
List<String> testFiles,
|
||||
String directory,
|
||||
TestRule rule) {
|
||||
bool _testExists(String filePath, List<String> testFiles, String directory,
|
||||
TestRule rule) {
|
||||
// TODO: Unify this regular expression matching with status_file_parser.dart
|
||||
List<RegExp> getRuleRegex(String name) {
|
||||
return name.split("/")
|
||||
return name
|
||||
.split("/")
|
||||
.map((name) => new RegExp(name.replaceAll('*', '.*')))
|
||||
.toList();
|
||||
}
|
||||
|
||||
bool matchRegexp(List<RegExp> patterns, String str) {
|
||||
var parts = str.split("/");
|
||||
if (patterns.length > parts.length) {
|
||||
|
@ -135,8 +150,8 @@ class StatusFileNonExistentTestRemover extends StatusFileProcessor {
|
|||
return testFiles.any((String file) {
|
||||
// TODO: Use test_suite.dart's [buildTestCaseDisplayName] instead.
|
||||
var filePath = new Path(file).relativeTo(new Path(directory));
|
||||
String baseTestName = _concat("${filePath.directoryPath}",
|
||||
"${filePath.filenameWithoutExtension}");
|
||||
String baseTestName = _concat(
|
||||
"${filePath.directoryPath}", "${filePath.filenameWithoutExtension}");
|
||||
|
||||
List<String> testNames = [];
|
||||
for (var name in multiTestDetector.getMultitestNames(file)) {
|
||||
|
@ -148,21 +163,20 @@ class StatusFileNonExistentTestRemover extends StatusFileProcessor {
|
|||
testNames.add(baseTestName);
|
||||
}
|
||||
|
||||
return testNames.any(
|
||||
(String testName) => matchRegexp(rulePattern, testName));
|
||||
return testNames
|
||||
.any((String testName) => matchRegexp(rulePattern, testName));
|
||||
});
|
||||
}
|
||||
|
||||
Set<int> _analyzeStatusFile(String directory,
|
||||
String filePath,
|
||||
List<Section> sections) {
|
||||
Set<int> _analyzeStatusFile(
|
||||
String directory, String filePath, List<Section> sections) {
|
||||
var invalidLines = new Set<int>();
|
||||
var dartFiles = testFileLister.listTestFiles(directory);
|
||||
for (var section in sections) {
|
||||
for (var rule in section.testRules) {
|
||||
if (!_testExists(filePath, dartFiles, directory, rule)) {
|
||||
print("Invalid rule: ${rule.name} in file "
|
||||
"$filePath:${rule.lineNumber}");
|
||||
"$filePath:${rule.lineNumber}");
|
||||
invalidLines.add(rule.lineNumber);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +195,7 @@ class StatusFileNonExistentTestRemover extends StatusFileProcessor {
|
|||
}
|
||||
var outputFile = new File("$statusFilePath.fixed");
|
||||
outputFile.writeAsStringSync(outputLines.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
String _concat(String base, String part) {
|
||||
if (base == "") return part;
|
||||
|
@ -197,15 +211,14 @@ class StatusFileDeflaker extends StatusFileProcessor {
|
|||
return _readSections(filePath).then((List<Section> sections) {
|
||||
return _generatedDeflakedLines(suiteName, sections)
|
||||
.then((Map<int, String> fixedLines) {
|
||||
if (fixedLines.length > 0) {
|
||||
return _writeFixedStatusFile(filePath, fixedLines);
|
||||
}
|
||||
if (fixedLines.length > 0) {
|
||||
return _writeFixedStatusFile(filePath, fixedLines);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future _generatedDeflakedLines(String suiteName,
|
||||
List<Section> sections) {
|
||||
Future _generatedDeflakedLines(String suiteName, List<Section> sections) {
|
||||
var fixedLines = new Map<int, String>();
|
||||
return Future.forEach(sections, (Section section) {
|
||||
return Future.forEach(section.testRules, (rule) {
|
||||
|
@ -214,10 +227,8 @@ class StatusFileDeflaker extends StatusFileProcessor {
|
|||
}).then((_) => fixedLines);
|
||||
}
|
||||
|
||||
Future _maybeFixStatusfileLine(String suiteName,
|
||||
Section section,
|
||||
TestRule rule,
|
||||
Map<int, String> fixedLines) {
|
||||
Future _maybeFixStatusfileLine(String suiteName, Section section,
|
||||
TestRule rule, Map<int, String> fixedLines) {
|
||||
print("Processing ${section.statusFile.location}: ${rule.lineNumber}");
|
||||
// None of our status file lines have expressions, so we pass {} here.
|
||||
var notedOutcomes = rule.expression
|
||||
|
@ -231,9 +242,9 @@ class StatusFileDeflaker extends StatusFileProcessor {
|
|||
// TODO: [rule.name] is actually a pattern not just a testname. We should
|
||||
// find all possible testnames this rule matches against and unify the
|
||||
// outcomes of these tests.
|
||||
return _testOutcomeFetcher.outcomesOf(suiteName, section, rule.name)
|
||||
.then((Set<Expectation> actualOutcomes) {
|
||||
|
||||
return _testOutcomeFetcher
|
||||
.outcomesOf(suiteName, section, rule.name)
|
||||
.then((Set<Expectation> actualOutcomes) {
|
||||
var outcomesThatNeverHappened = new Set<Expectation>();
|
||||
for (Expectation notedOutcome in notedOutcomes) {
|
||||
bool found = false;
|
||||
|
@ -251,11 +262,11 @@ class StatusFileDeflaker extends StatusFileProcessor {
|
|||
if (outcomesThatNeverHappened.length > 0 && actualOutcomes.length > 0) {
|
||||
// Print the change to stdout.
|
||||
print("${rule.name} "
|
||||
"(${section.statusFile.location}:${rule.lineNumber}):");
|
||||
"(${section.statusFile.location}:${rule.lineNumber}):");
|
||||
print(" Actual outcomes: ${actualOutcomes.toList()}");
|
||||
print(" Outcomes in status file: ${notedOutcomes.toList()}");
|
||||
print(" Outcomes in status file that never happened : "
|
||||
"${outcomesThatNeverHappened.toList()}\n");
|
||||
"${outcomesThatNeverHappened.toList()}\n");
|
||||
|
||||
// Build the fixed status file line.
|
||||
fixedLines[rule.lineNumber] =
|
||||
|
@ -279,13 +290,12 @@ class StatusFileDeflaker extends StatusFileProcessor {
|
|||
var output = outputLines.join("\n");
|
||||
var outputFile = new File("$filePath.deflaked");
|
||||
outputFile.writeAsStringSync(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MultiTestDetector {
|
||||
final multiTestsCache = new Map<String,List<String>>();
|
||||
final multiHtmlTestsCache = new Map<String,List<String>>();
|
||||
|
||||
final multiTestsCache = new Map<String, List<String>>();
|
||||
final multiHtmlTestsCache = new Map<String, List<String>>();
|
||||
|
||||
List<String> getMultitestNames(String file) {
|
||||
List<String> names = [];
|
||||
|
@ -317,8 +327,9 @@ class MultiTestDetector {
|
|||
var content = new File(file).readAsStringSync();
|
||||
|
||||
if (multiHtmlTestRegExp.hasMatch(content)) {
|
||||
var matchesIter = multiHtmlTestGroupRegExp.allMatches(content).iterator;
|
||||
while(matchesIter.moveNext()) {
|
||||
var matchesIter =
|
||||
multiHtmlTestGroupRegExp.allMatches(content).iterator;
|
||||
while (matchesIter.moveNext()) {
|
||||
String fullMatch = matchesIter.current.group(0);
|
||||
subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1));
|
||||
}
|
||||
|
@ -339,10 +350,11 @@ class TestFileLister {
|
|||
return _filesCache.putIfAbsent(directory, () {
|
||||
var dir = new Directory(directory);
|
||||
// Cannot test for _test.dart because co19 tests don't have that ending.
|
||||
var dartFiles = dir.listSync(recursive: true)
|
||||
var dartFiles = dir
|
||||
.listSync(recursive: true)
|
||||
.where((fe) => fe is File)
|
||||
.where((file) => file.path.endsWith(".dart") ||
|
||||
file.path.endsWith("_test.html"))
|
||||
.where((file) =>
|
||||
file.path.endsWith(".dart") || file.path.endsWith("_test.html"))
|
||||
.map((file) => file.path)
|
||||
.toList();
|
||||
return dartFiles;
|
||||
|
@ -350,7 +362,6 @@ class TestFileLister {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* [TestOutcomeFetcher] will fetch test results from a server using a REST-like
|
||||
* interface.
|
||||
|
@ -363,53 +374,60 @@ class TestOutcomeFetcher {
|
|||
|
||||
Future<Set<Expectation>> outcomesOf(
|
||||
String suiteName, Section section, String testName) {
|
||||
var pathComponents = ['json', 'test-outcomes', 'outcomes',
|
||||
Uri.encodeComponent("$suiteName/$testName")];
|
||||
var pathComponents = [
|
||||
'json',
|
||||
'test-outcomes',
|
||||
'outcomes',
|
||||
Uri.encodeComponent("$suiteName/$testName")
|
||||
];
|
||||
var path = pathComponents.join('/') + '/';
|
||||
var url = new Uri(scheme: 'http', host: SERVER, port: PORT, path: path);
|
||||
|
||||
return _client.getUrl(url)
|
||||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
return response.transform(UTF8.decoder).transform(JSON.decoder).first
|
||||
.then((List testResults) {
|
||||
var setOfActualOutcomes = new Set<Expectation>();
|
||||
return _client
|
||||
.getUrl(url)
|
||||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
return response
|
||||
.transform(UTF8.decoder)
|
||||
.transform(JSON.decoder)
|
||||
.first
|
||||
.then((List testResults) {
|
||||
var setOfActualOutcomes = new Set<Expectation>();
|
||||
|
||||
try {
|
||||
for (var result in testResults) {
|
||||
var config = result['configuration'];
|
||||
var testResult = result['test_result'];
|
||||
var outcome = testResult['outcome'];
|
||||
try {
|
||||
for (var result in testResults) {
|
||||
var config = result['configuration'];
|
||||
var testResult = result['test_result'];
|
||||
var outcome = testResult['outcome'];
|
||||
|
||||
// These variables are derived variables and will be set in
|
||||
// tools/testing/dart/test_options.dart.
|
||||
// [Mostly due to the fact that we don't have an unary !
|
||||
// operator in status file expressions.]
|
||||
config['unchecked'] = !config['checked'];
|
||||
config['unminified'] = !config['minified'];
|
||||
config['nocsp'] = !config['csp'];
|
||||
config['browser'] =
|
||||
TestUtils.isBrowserRuntime(config['runtime']);
|
||||
config['analyzer'] =
|
||||
TestUtils.isCommandLineAnalyzer(config['compiler']);
|
||||
config['jscl'] =
|
||||
TestUtils.isJsCommandLineRuntime(config['runtime']);
|
||||
// These variables are derived variables and will be set in
|
||||
// tools/testing/dart/test_options.dart.
|
||||
// [Mostly due to the fact that we don't have an unary !
|
||||
// operator in status file expressions.]
|
||||
config['unchecked'] = !config['checked'];
|
||||
config['unminified'] = !config['minified'];
|
||||
config['nocsp'] = !config['csp'];
|
||||
config['browser'] = TestUtils.isBrowserRuntime(config['runtime']);
|
||||
config['analyzer'] =
|
||||
TestUtils.isCommandLineAnalyzer(config['compiler']);
|
||||
config['jscl'] =
|
||||
TestUtils.isJsCommandLineRuntime(config['runtime']);
|
||||
|
||||
if (section.condition == null ||
|
||||
section.condition.evaluate(config)) {
|
||||
setOfActualOutcomes.add(Expectation.byName(outcome));
|
||||
}
|
||||
}
|
||||
return setOfActualOutcomes;
|
||||
} catch (error) {
|
||||
print("Warning: Error occured while processing testoutcomes"
|
||||
": $error");
|
||||
return [];
|
||||
}
|
||||
}).catchError((error) {
|
||||
print("Warning: Error occured while fetching testoutcomes: $error");
|
||||
return [];
|
||||
});
|
||||
if (section.condition == null ||
|
||||
section.condition.evaluate(config)) {
|
||||
setOfActualOutcomes.add(Expectation.byName(outcome));
|
||||
}
|
||||
}
|
||||
return setOfActualOutcomes;
|
||||
} catch (error) {
|
||||
print("Warning: Error occured while processing testoutcomes"
|
||||
": $error");
|
||||
return [];
|
||||
}
|
||||
}).catchError((error) {
|
||||
print("Warning: Error occured while fetching testoutcomes: $error");
|
||||
return [];
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ Future _deleteTemporaryDartDirectories() {
|
|||
if (environment['DART_TESTING_DELETE_TEMPORARY_DIRECTORIES'] == '1') {
|
||||
LeftOverTempDirPrinter.getLeftOverTemporaryDirectories().listen(
|
||||
(FileSystemEntity tempEntity) {
|
||||
Directory tempDirectory = tempEntity as Directory;
|
||||
try {
|
||||
tempDirectory.deleteSync(recursive: true);
|
||||
} catch (error) {
|
||||
DebugLogger.error(error);
|
||||
}
|
||||
}, onDone: completer.complete);
|
||||
Directory tempDirectory = tempEntity as Directory;
|
||||
try {
|
||||
tempDirectory.deleteSync(recursive: true);
|
||||
} catch (error) {
|
||||
DebugLogger.error(error);
|
||||
}
|
||||
}, onDone: completer.complete);
|
||||
} else {
|
||||
completer.complete();
|
||||
}
|
||||
|
|
|
@ -20,16 +20,16 @@ class AdbCommandResult {
|
|||
final int exitCode;
|
||||
final bool timedOut;
|
||||
|
||||
AdbCommandResult(this.command, this.stdout, this.stderr, this.exitCode,
|
||||
this.timedOut);
|
||||
AdbCommandResult(
|
||||
this.command, this.stdout, this.stderr, this.exitCode, this.timedOut);
|
||||
|
||||
void throwIfFailed() {
|
||||
if (exitCode != 0) {
|
||||
var error = "Running: $command failed:"
|
||||
"stdout:\n ${stdout.trim()}\n"
|
||||
"stderr:\n ${stderr.trim()}\n"
|
||||
"exitCode: $exitCode\n"
|
||||
"timedOut: $timedOut";
|
||||
"stdout:\n ${stdout.trim()}\n"
|
||||
"stderr:\n ${stderr.trim()}\n"
|
||||
"exitCode: $exitCode\n"
|
||||
"timedOut: $timedOut";
|
||||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ class AdbCommandResult {
|
|||
* If the exit code of the process was nonzero it will complete with an error.
|
||||
* If starting the process failed, it will complete with an error as well.
|
||||
*/
|
||||
Future<AdbCommandResult> _executeCommand(
|
||||
String executable, List<String> args,
|
||||
Future<AdbCommandResult> _executeCommand(String executable, List<String> args,
|
||||
{String stdin, Duration timeout}) {
|
||||
Future<String> getOutput(Stream<List<int>> stream) {
|
||||
return stream
|
||||
|
@ -70,9 +69,9 @@ Future<AdbCommandResult> _executeCommand(
|
|||
}
|
||||
|
||||
var results = await Future.wait([
|
||||
getOutput(process.stdout),
|
||||
getOutput(process.stderr),
|
||||
process.exitCode
|
||||
getOutput(process.stdout),
|
||||
getOutput(process.stderr),
|
||||
process.exitCode
|
||||
]);
|
||||
if (timer != null) timer.cancel();
|
||||
|
||||
|
@ -216,7 +215,7 @@ class AdbDevice {
|
|||
AdbCommandResult result =
|
||||
await _adbCommand(['shell', 'getprop', 'sys.boot_completed']);
|
||||
if (result.stdout.trim() == '1') return;
|
||||
} catch (_) { }
|
||||
} catch (_) {}
|
||||
await new Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
}
|
||||
|
@ -254,8 +253,8 @@ class AdbDevice {
|
|||
*/
|
||||
Future pushCachedData(String local, String remote) {
|
||||
if (_cachedData[remote] == local) {
|
||||
return new Future.value(new AdbCommandResult(
|
||||
"Skipped cached push", "", "", 0, false));
|
||||
return new Future.value(
|
||||
new AdbCommandResult("Skipped cached push", "", "", 0, false));
|
||||
}
|
||||
_cachedData[remote] = local;
|
||||
return _adbCommand(['push', local, remote]);
|
||||
|
@ -321,33 +320,33 @@ class AdbDevice {
|
|||
}
|
||||
|
||||
Future<AdbCommandResult> runAdbCommand(List<String> adbArgs,
|
||||
{Duration timeout}) {
|
||||
return _executeCommand(
|
||||
"adb", _deviceSpecificArgs(adbArgs), timeout: timeout);
|
||||
{Duration timeout}) {
|
||||
return _executeCommand("adb", _deviceSpecificArgs(adbArgs),
|
||||
timeout: timeout);
|
||||
}
|
||||
|
||||
Future<AdbCommandResult> runAdbShellCommand(List<String> shellArgs,
|
||||
{Duration timeout}) async {
|
||||
{Duration timeout}) async {
|
||||
const MARKER = 'AdbShellExitCode: ';
|
||||
|
||||
// The exitcode of 'adb shell ...' can be 0 even though the command failed
|
||||
// with a non-zero exit code. We therefore explicitly print it to stdout and
|
||||
// search for it.
|
||||
|
||||
var args = ['shell',
|
||||
"${shellArgs.join(' ')} ; echo $MARKER \$?"];
|
||||
var args = ['shell', "${shellArgs.join(' ')} ; echo $MARKER \$?"];
|
||||
AdbCommandResult result = await _executeCommand(
|
||||
"adb", _deviceSpecificArgs(args), timeout: timeout);
|
||||
"adb", _deviceSpecificArgs(args),
|
||||
timeout: timeout);
|
||||
int exitCode = result.exitCode;
|
||||
var lines = result
|
||||
.stdout.split('\n')
|
||||
var lines = result.stdout
|
||||
.split('\n')
|
||||
.where((line) => line.trim().length > 0)
|
||||
.toList();
|
||||
if (lines.length > 0) {
|
||||
int index = lines.last.indexOf(MARKER);
|
||||
if (index >= 0) {
|
||||
exitCode = int.parse(
|
||||
lines.last.substring(index + MARKER.length).trim());
|
||||
exitCode =
|
||||
int.parse(lines.last.substring(index + MARKER.length).trim());
|
||||
if (exitCode > 128 && exitCode <= 128 + 31) {
|
||||
// Return negative exit codes for signals 1..31 (128+N for signal N)
|
||||
exitCode = 128 - exitCode;
|
||||
|
@ -357,9 +356,8 @@ class AdbDevice {
|
|||
assert(result.exitCode != 0);
|
||||
}
|
||||
}
|
||||
return new AdbCommandResult(
|
||||
result.command, result.stdout, result.stderr, exitCode,
|
||||
result.timedOut);
|
||||
return new AdbCommandResult(result.command, result.stdout, result.stderr,
|
||||
exitCode, result.timedOut);
|
||||
}
|
||||
|
||||
Future<AdbCommandResult> _adbCommand(List<String> adbArgs) async {
|
||||
|
@ -426,8 +424,7 @@ class AdbDevicePool {
|
|||
var names = await AdbHelper.listDevices();
|
||||
var devices = names.map((id) => new AdbDevice(id)).toList();
|
||||
if (devices.length == 0) {
|
||||
throw new Exception(
|
||||
'No android devices found. '
|
||||
throw new Exception('No android devices found. '
|
||||
'Please make sure "adb devices" shows your device!');
|
||||
}
|
||||
print("Found ${devices.length} Android devices.");
|
||||
|
|
|
@ -47,7 +47,13 @@ const List<List<String>> COMMAND_LINES = const <List<String>>[
|
|||
'--use-sdk',
|
||||
'--checked'
|
||||
],
|
||||
const <String>['-mrelease', '-rdartium', '-cnone', '--use-sdk', '--fast-startup'],
|
||||
const <String>[
|
||||
'-mrelease',
|
||||
'-rdartium',
|
||||
'-cnone',
|
||||
'--use-sdk',
|
||||
'--fast-startup'
|
||||
],
|
||||
const <String>['-mrelease', '-rdartium', '-cnone', '--use-sdk'],
|
||||
];
|
||||
|
||||
|
|
|
@ -103,13 +103,13 @@ abstract class CompilerConfiguration {
|
|||
isAndroid: configuration['system'] == 'android');
|
||||
case 'dartk':
|
||||
return new NoneCompilerConfiguration(
|
||||
isDebug: isDebug,
|
||||
isChecked: isChecked,
|
||||
isHostChecked: isHostChecked,
|
||||
useSdk: useSdk,
|
||||
hotReload: hotReload,
|
||||
hotReloadRollback: hotReloadRollback,
|
||||
useDFE: true);
|
||||
isDebug: isDebug,
|
||||
isChecked: isChecked,
|
||||
isHostChecked: isHostChecked,
|
||||
useSdk: useSdk,
|
||||
hotReload: hotReload,
|
||||
hotReloadRollback: hotReloadRollback,
|
||||
useDFE: true);
|
||||
case 'dartkp':
|
||||
return new PrecompilerCompilerConfiguration(
|
||||
isDebug: isDebug,
|
||||
|
@ -191,10 +191,13 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
|
|||
final bool useDFE;
|
||||
|
||||
NoneCompilerConfiguration(
|
||||
{bool isDebug, bool isChecked, bool isHostChecked, bool useSdk,
|
||||
bool this.hotReload,
|
||||
bool this.hotReloadRollback,
|
||||
this.useDFE: false})
|
||||
{bool isDebug,
|
||||
bool isChecked,
|
||||
bool isHostChecked,
|
||||
bool useSdk,
|
||||
bool this.hotReload,
|
||||
bool this.hotReloadRollback,
|
||||
this.useDFE: false})
|
||||
: super._subclass(
|
||||
isDebug: isDebug,
|
||||
isChecked: isChecked,
|
||||
|
@ -235,10 +238,15 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
|
|||
class DartKCompilerConfiguration extends CompilerConfiguration {
|
||||
final bool verify, strong, treeShake;
|
||||
|
||||
DartKCompilerConfiguration({bool isChecked, bool isHostChecked, bool useSdk,
|
||||
this.verify, this.strong, this.treeShake})
|
||||
: super._subclass(isChecked: isChecked, isHostChecked: isHostChecked,
|
||||
useSdk: useSdk);
|
||||
DartKCompilerConfiguration(
|
||||
{bool isChecked,
|
||||
bool isHostChecked,
|
||||
bool useSdk,
|
||||
this.verify,
|
||||
this.strong,
|
||||
this.treeShake})
|
||||
: super._subclass(
|
||||
isChecked: isChecked, isHostChecked: isHostChecked, useSdk: useSdk);
|
||||
|
||||
@override
|
||||
String computeCompilerPath(String buildDir) {
|
||||
|
@ -298,8 +306,8 @@ class DartKCompilerConfiguration extends CompilerConfiguration {
|
|||
args.add('--enable_type_checks');
|
||||
}
|
||||
|
||||
var newOriginalArguments = replaceDartFileWith(
|
||||
originalArguments, artifact.filename);
|
||||
var newOriginalArguments =
|
||||
replaceDartFileWith(originalArguments, artifact.filename);
|
||||
|
||||
return args
|
||||
..addAll(vmOptions)
|
||||
|
@ -309,8 +317,7 @@ class DartKCompilerConfiguration extends CompilerConfiguration {
|
|||
}
|
||||
|
||||
typedef List<String> CompilerArgumentsFunction(
|
||||
List<String> globalArguments,
|
||||
String previousCompilerOutput);
|
||||
List<String> globalArguments, String previousCompilerOutput);
|
||||
|
||||
class PipelineCommand {
|
||||
final CompilerConfiguration compilerConfiguration;
|
||||
|
@ -319,20 +326,20 @@ class PipelineCommand {
|
|||
PipelineCommand._(this.compilerConfiguration, this._argumentsFunction);
|
||||
|
||||
factory PipelineCommand.runWithGlobalArguments(CompilerConfiguration conf) {
|
||||
return new PipelineCommand._(conf, (List<String> globalArguments,
|
||||
String previousOutput) {
|
||||
return new PipelineCommand._(conf,
|
||||
(List<String> globalArguments, String previousOutput) {
|
||||
assert(previousOutput == null);
|
||||
return globalArguments;
|
||||
});
|
||||
}
|
||||
|
||||
factory PipelineCommand.runWithDartOrKernelFile(CompilerConfiguration conf) {
|
||||
return new PipelineCommand._(conf, (List<String> globalArguments,
|
||||
String previousOutput) {
|
||||
return new PipelineCommand._(conf,
|
||||
(List<String> globalArguments, String previousOutput) {
|
||||
var filtered = globalArguments
|
||||
.where((String name) => name.endsWith('.dart') ||
|
||||
name.endsWith('.dill'))
|
||||
.toList();
|
||||
.where(
|
||||
(String name) => name.endsWith('.dart') || name.endsWith('.dill'))
|
||||
.toList();
|
||||
assert(filtered.length == 1);
|
||||
return filtered;
|
||||
});
|
||||
|
@ -340,15 +347,15 @@ class PipelineCommand {
|
|||
|
||||
factory PipelineCommand.runWithPreviousKernelOutput(
|
||||
CompilerConfiguration conf) {
|
||||
return new PipelineCommand._(conf, (List<String> globalArguments,
|
||||
String previousOutput) {
|
||||
return new PipelineCommand._(conf,
|
||||
(List<String> globalArguments, String previousOutput) {
|
||||
assert(previousOutput.endsWith('.dill'));
|
||||
return replaceDartFileWith(globalArguments, previousOutput);
|
||||
});
|
||||
}
|
||||
|
||||
List<String> extractArguments(List<String> globalArguments,
|
||||
String previousOutput) {
|
||||
List<String> extractArguments(
|
||||
List<String> globalArguments, String previousOutput) {
|
||||
return _argumentsFunction(globalArguments, previousOutput);
|
||||
}
|
||||
}
|
||||
|
@ -364,14 +371,14 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
|
|||
CommandBuilder commandBuilder,
|
||||
List globalArguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
|
||||
List<Command> allCommands = [];
|
||||
|
||||
// The first compilation command is as usual.
|
||||
var arguments = pipelineCommands[0].extractArguments(globalArguments, null);
|
||||
CommandArtifact artifact =
|
||||
pipelineCommands[0].compilerConfiguration.computeCompilationArtifact(
|
||||
buildDir, tempDir, commandBuilder, arguments, environmentOverrides);
|
||||
CommandArtifact artifact = pipelineCommands[0]
|
||||
.compilerConfiguration
|
||||
.computeCompilationArtifact(
|
||||
buildDir, tempDir, commandBuilder, arguments, environmentOverrides);
|
||||
allCommands.addAll(artifact.commands);
|
||||
|
||||
// The following compilation commands are based on the output of the
|
||||
|
@ -407,40 +414,66 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
|
|||
CompilerConfiguration lastCompilerConfiguration =
|
||||
pipelineCommands.last.compilerConfiguration;
|
||||
return lastCompilerConfiguration.computeRuntimeArguments(
|
||||
runtimeConfiguration, buildDir, info, vmOptions, sharedOptions,
|
||||
originalArguments, artifact);
|
||||
runtimeConfiguration,
|
||||
buildDir,
|
||||
info,
|
||||
vmOptions,
|
||||
sharedOptions,
|
||||
originalArguments,
|
||||
artifact);
|
||||
}
|
||||
|
||||
static ComposedCompilerConfiguration createDartKPConfiguration(
|
||||
{bool isChecked, bool isHostChecked, String arch, bool useBlobs,
|
||||
bool isAndroid, bool useSdk, bool verify, bool strong, bool treeShake}) {
|
||||
{bool isChecked,
|
||||
bool isHostChecked,
|
||||
String arch,
|
||||
bool useBlobs,
|
||||
bool isAndroid,
|
||||
bool useSdk,
|
||||
bool verify,
|
||||
bool strong,
|
||||
bool treeShake}) {
|
||||
var nested = [];
|
||||
|
||||
// Compile with dartk.
|
||||
nested.add(new PipelineCommand.runWithGlobalArguments(
|
||||
new DartKCompilerConfiguration(isChecked: isChecked,
|
||||
isHostChecked: isHostChecked, useSdk: useSdk, verify: verify,
|
||||
strong: strong, treeShake: treeShake)));
|
||||
new DartKCompilerConfiguration(
|
||||
isChecked: isChecked,
|
||||
isHostChecked: isHostChecked,
|
||||
useSdk: useSdk,
|
||||
verify: verify,
|
||||
strong: strong,
|
||||
treeShake: treeShake)));
|
||||
|
||||
// Run the normal precompiler.
|
||||
nested.add(new PipelineCommand.runWithPreviousKernelOutput(
|
||||
new PrecompilerCompilerConfiguration(
|
||||
isChecked: isChecked, arch: arch, useBlobs: useBlobs,
|
||||
isAndroid: isAndroid)));
|
||||
isChecked: isChecked,
|
||||
arch: arch,
|
||||
useBlobs: useBlobs,
|
||||
isAndroid: isAndroid)));
|
||||
|
||||
return new ComposedCompilerConfiguration(nested);
|
||||
}
|
||||
|
||||
static ComposedCompilerConfiguration createDartKConfiguration(
|
||||
{bool isChecked, bool isHostChecked, bool useSdk, bool verify,
|
||||
bool strong, bool treeShake}) {
|
||||
{bool isChecked,
|
||||
bool isHostChecked,
|
||||
bool useSdk,
|
||||
bool verify,
|
||||
bool strong,
|
||||
bool treeShake}) {
|
||||
var nested = [];
|
||||
|
||||
// Compile with dartk.
|
||||
nested.add(new PipelineCommand.runWithGlobalArguments(
|
||||
new DartKCompilerConfiguration(isChecked: isChecked,
|
||||
isHostChecked: isHostChecked, useSdk: useSdk,
|
||||
verify: verify, strong: strong, treeShake: treeShake)));
|
||||
new DartKCompilerConfiguration(
|
||||
isChecked: isChecked,
|
||||
isHostChecked: isHostChecked,
|
||||
useSdk: useSdk,
|
||||
verify: verify,
|
||||
strong: strong,
|
||||
treeShake: treeShake)));
|
||||
|
||||
return new ComposedCompilerConfiguration(nested);
|
||||
}
|
||||
|
@ -580,8 +613,13 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
final bool isAndroid;
|
||||
final bool useDFE;
|
||||
|
||||
PrecompilerCompilerConfiguration({bool isDebug, bool isChecked,
|
||||
this.arch, this.useBlobs, this.isAndroid, this.useDFE: false})
|
||||
PrecompilerCompilerConfiguration(
|
||||
{bool isDebug,
|
||||
bool isChecked,
|
||||
this.arch,
|
||||
this.useBlobs,
|
||||
this.isAndroid,
|
||||
this.useDFE: false})
|
||||
: super._subclass(isDebug: isDebug, isChecked: isChecked);
|
||||
|
||||
int computeTimeoutMultiplier() {
|
||||
|
@ -598,15 +636,16 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
List arguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
var commands = new List<Command>();
|
||||
commands.add(this.computeCompilationCommand(tempDir, buildDir, CommandBuilder.instance,
|
||||
arguments, environmentOverrides));
|
||||
commands.add(this.computeCompilationCommand(tempDir, buildDir,
|
||||
CommandBuilder.instance, arguments, environmentOverrides));
|
||||
if (!useBlobs) {
|
||||
commands.add(this.computeAssembleCommand(tempDir, buildDir, CommandBuilder.instance,
|
||||
arguments, environmentOverrides));
|
||||
commands.add(this.computeAssembleCommand(tempDir, buildDir,
|
||||
CommandBuilder.instance, arguments, environmentOverrides));
|
||||
commands.add(this.computeRemoveAssemblyCommand(tempDir, buildDir,
|
||||
CommandBuilder.instance, arguments, environmentOverrides));
|
||||
}
|
||||
return new CommandArtifact(commands, '$tempDir', 'application/dart-precompiled');
|
||||
return new CommandArtifact(
|
||||
commands, '$tempDir', 'application/dart-precompiled');
|
||||
}
|
||||
|
||||
CompilationCommand computeCompilationCommand(
|
||||
|
@ -651,7 +690,6 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
CommandBuilder commandBuilder,
|
||||
List arguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
|
||||
var cc, shared, ld_flags;
|
||||
if (isAndroid) {
|
||||
var ndk = "third_party/android_tools/ndk";
|
||||
|
@ -779,8 +817,8 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
// directory on the device, use that one instead.
|
||||
dir = DartPrecompiledAdbRuntimeConfiguration.DeviceTestDir;
|
||||
}
|
||||
originalArguments = replaceDartFileWith(
|
||||
originalArguments, "$dir/out.aotsnapshot");
|
||||
originalArguments =
|
||||
replaceDartFileWith(originalArguments, "$dir/out.aotsnapshot");
|
||||
|
||||
return args
|
||||
..addAll(vmOptions)
|
||||
|
@ -808,8 +846,8 @@ class AppJitCompilerConfiguration extends CompilerConfiguration {
|
|||
Map<String, String> environmentOverrides) {
|
||||
var snapshot = "$tempDir/out.jitsnapshot";
|
||||
return new CommandArtifact(<Command>[
|
||||
this.computeCompilationCommand(tempDir, buildDir,
|
||||
CommandBuilder.instance, arguments, environmentOverrides)
|
||||
this.computeCompilationCommand(tempDir, buildDir, CommandBuilder.instance,
|
||||
arguments, environmentOverrides)
|
||||
], snapshot, 'application/dart-snapshot');
|
||||
}
|
||||
|
||||
|
@ -826,14 +864,8 @@ class AppJitCompilerConfiguration extends CompilerConfiguration {
|
|||
args.add("--snapshot-kind=app-jit");
|
||||
args.addAll(arguments);
|
||||
|
||||
return commandBuilder.getCompilationCommand(
|
||||
'app_jit',
|
||||
tempDir,
|
||||
!useSdk,
|
||||
bootstrapDependencies(buildDir),
|
||||
exec,
|
||||
args,
|
||||
environmentOverrides);
|
||||
return commandBuilder.getCompilationCommand('app_jit', tempDir, !useSdk,
|
||||
bootstrapDependencies(buildDir), exec, args, environmentOverrides);
|
||||
}
|
||||
|
||||
List<String> computeCompilerArguments(
|
||||
|
@ -862,10 +894,7 @@ class AppJitCompilerConfiguration extends CompilerConfiguration {
|
|||
args.add('--enable_asserts');
|
||||
args.add('--enable_type_checks');
|
||||
}
|
||||
args
|
||||
..addAll(vmOptions)
|
||||
..addAll(sharedOptions)
|
||||
..addAll(originalArguments);
|
||||
args..addAll(vmOptions)..addAll(sharedOptions)..addAll(originalArguments);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
if (args[i].endsWith(".dart")) {
|
||||
args[i] = artifact.filename;
|
||||
|
@ -877,8 +906,11 @@ class AppJitCompilerConfiguration extends CompilerConfiguration {
|
|||
|
||||
class AnalyzerCompilerConfiguration extends CompilerConfiguration {
|
||||
AnalyzerCompilerConfiguration(
|
||||
{bool isDebug, bool isChecked, bool isStrong, bool isHostChecked, bool
|
||||
useSdk})
|
||||
{bool isDebug,
|
||||
bool isChecked,
|
||||
bool isStrong,
|
||||
bool isHostChecked,
|
||||
bool useSdk})
|
||||
: super._subclass(
|
||||
isDebug: isDebug,
|
||||
isChecked: isChecked,
|
||||
|
@ -918,7 +950,7 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration {
|
|||
if (isChecked || isStrong) {
|
||||
arguments.add('--enable_type_checks');
|
||||
}
|
||||
if (isStrong){
|
||||
if (isStrong) {
|
||||
arguments.add('--strong');
|
||||
}
|
||||
return new CommandArtifact(<Command>[
|
||||
|
|
|
@ -91,9 +91,8 @@ main(List<String> arguments) {
|
|||
if (args['help']) {
|
||||
print(parser.getUsage());
|
||||
} else {
|
||||
var servers = new TestingServers(args['build-directory'],
|
||||
args['csp'], args['runtime'], null, args['package-root'],
|
||||
args['packages']);
|
||||
var servers = new TestingServers(args['build-directory'], args['csp'],
|
||||
args['runtime'], null, args['package-root'], args['packages']);
|
||||
var port = int.parse(args['port']);
|
||||
var crossOriginPort = int.parse(args['crossOriginPort']);
|
||||
servers
|
||||
|
@ -143,8 +142,8 @@ class TestingServers {
|
|||
} else {
|
||||
_dartDirectory = Uri.base.resolveUri(new Uri.directory(dartDirectory));
|
||||
}
|
||||
if (packageRoot == null ) {
|
||||
if (packages == null ) {
|
||||
if (packageRoot == null) {
|
||||
if (packages == null) {
|
||||
_packages = _dartDirectory.resolve('.packages');
|
||||
} else {
|
||||
_packages = new Uri.file(packages);
|
||||
|
@ -167,27 +166,31 @@ class TestingServers {
|
|||
* "Access-Control-Allow-Credentials: true"
|
||||
*/
|
||||
Future startServers(String host,
|
||||
{int port: 0,
|
||||
int crossOriginPort: 0}) async {
|
||||
{int port: 0, int crossOriginPort: 0}) async {
|
||||
if (_packages != null) {
|
||||
_resolver = await SyncPackageResolver.loadConfig(_packages);
|
||||
} else {
|
||||
_resolver = new SyncPackageResolver.root(_packageRoot);
|
||||
}
|
||||
_server = await _startHttpServer(host, port: port);
|
||||
await _startHttpServer(host, port: crossOriginPort,
|
||||
allowedPort: _serverList[0].port);
|
||||
await _startHttpServer(host,
|
||||
port: crossOriginPort, allowedPort: _serverList[0].port);
|
||||
}
|
||||
|
||||
String httpServerCommandline() {
|
||||
var dart = Platform.resolvedExecutable;
|
||||
var script = _dartDirectory.resolve('tools/testing/dart/http_server.dart');
|
||||
var buildDirectory = _buildDirectory.toFilePath();
|
||||
var command = [dart, script.toFilePath(),
|
||||
'-p', port,
|
||||
'-c', crossOriginPort,
|
||||
var command = [
|
||||
dart,
|
||||
script.toFilePath(),
|
||||
'-p',
|
||||
port,
|
||||
'-c',
|
||||
crossOriginPort,
|
||||
'--build-directory=$buildDirectory',
|
||||
'--runtime=$runtime'];
|
||||
'--runtime=$runtime'
|
||||
];
|
||||
if (useContentSecurityPolicy) {
|
||||
command.add('--csp');
|
||||
}
|
||||
|
@ -217,6 +220,7 @@ class TestingServers {
|
|||
fileHandler(request) {
|
||||
_handleFileOrDirectoryRequest(request, allowedPort);
|
||||
}
|
||||
|
||||
server.addHandler('/$PREFIX_BUILDDIR', fileHandler);
|
||||
server.addHandler('/$PREFIX_DARTDIR', fileHandler);
|
||||
server.addHandler('/packages', fileHandler);
|
||||
|
@ -225,8 +229,7 @@ class TestingServers {
|
|||
});
|
||||
}
|
||||
|
||||
_handleFileOrDirectoryRequest(HttpRequest request,
|
||||
int allowedPort) async {
|
||||
_handleFileOrDirectoryRequest(HttpRequest request, int allowedPort) async {
|
||||
// Enable browsers to cache file/directory responses.
|
||||
var response = request.response;
|
||||
response.headers
|
||||
|
@ -235,8 +238,8 @@ class TestingServers {
|
|||
if (path != null) {
|
||||
var file = new File.fromUri(path);
|
||||
var directory = new Directory.fromUri(path);
|
||||
if (await file.exists()){
|
||||
_sendFileContent(request, response, allowedPort, file);
|
||||
if (await file.exists()) {
|
||||
_sendFileContent(request, response, allowedPort, file);
|
||||
} else if (await directory.exists()) {
|
||||
_sendDirectoryListing(
|
||||
await _listDirectory(directory), request, response);
|
||||
|
@ -294,7 +297,8 @@ class TestingServers {
|
|||
if (pathSegments.length == 0) return null;
|
||||
int packagesIndex = pathSegments.indexOf('packages');
|
||||
if (packagesIndex != -1) {
|
||||
var packageUri = new Uri(scheme: 'package',
|
||||
var packageUri = new Uri(
|
||||
scheme: 'package',
|
||||
pathSegments: pathSegments.skip(packagesIndex + 1));
|
||||
return _resolver.resolveUri(packageUri);
|
||||
}
|
||||
|
@ -348,8 +352,7 @@ class TestingServers {
|
|||
entries.sort();
|
||||
response.write(header);
|
||||
for (var entry in entries) {
|
||||
response.write(
|
||||
'<li><a href="${request.uri}/${entry.name}">'
|
||||
response.write('<li><a href="${request.uri}/${entry.name}">'
|
||||
'${entry.displayName}</a></li>');
|
||||
}
|
||||
response.write(footer);
|
||||
|
@ -360,8 +363,8 @@ class TestingServers {
|
|||
});
|
||||
}
|
||||
|
||||
void _sendFileContent(HttpRequest request, HttpResponse response,
|
||||
int allowedPort, File file) {
|
||||
void _sendFileContent(
|
||||
HttpRequest request, HttpResponse response, int allowedPort, File file) {
|
||||
if (allowedPort != -1) {
|
||||
var headerOrigin = request.headers.value('Origin');
|
||||
var allowedOrigin;
|
||||
|
@ -421,6 +424,7 @@ class TestingServers {
|
|||
return path.contains(pattern);
|
||||
});
|
||||
}
|
||||
|
||||
if (!isHarmlessPath(request.uri.path)) {
|
||||
DebugLogger.warning('HttpServer: could not find file for request path: '
|
||||
'"${request.uri.path}"');
|
||||
|
|
|
@ -4,17 +4,13 @@
|
|||
|
||||
library package_testing_support;
|
||||
|
||||
import 'dart:convert' show
|
||||
JSON;
|
||||
import 'dart:convert' show JSON;
|
||||
|
||||
import 'test_configurations.dart' show
|
||||
testConfigurations;
|
||||
import 'test_configurations.dart' show testConfigurations;
|
||||
|
||||
import 'test_options.dart' show
|
||||
TestOptionsParser;
|
||||
import 'test_options.dart' show TestOptionsParser;
|
||||
|
||||
import 'test_suite.dart' show
|
||||
TestUtils;
|
||||
import 'test_suite.dart' show TestUtils;
|
||||
|
||||
main(List<String> arguments) {
|
||||
TestUtils.setDartDirUri(Uri.base);
|
||||
|
|
|
@ -2,23 +2,15 @@
|
|||
// 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.
|
||||
|
||||
|
||||
/// Helper program for killing and resetting all Safari settings to a known
|
||||
/// state that works well for testing dart2js output in Safari.
|
||||
///
|
||||
/// Warning: this will delete all your Safari settings and bookmarks.
|
||||
library testing.reset_safari;
|
||||
|
||||
import 'dart:async' show
|
||||
Future,
|
||||
Timer;
|
||||
import 'dart:async' show Future, Timer;
|
||||
|
||||
import 'dart:io' show
|
||||
Directory,
|
||||
File,
|
||||
Platform,
|
||||
Process,
|
||||
ProcessResult;
|
||||
import 'dart:io' show Directory, File, Platform, Process, ProcessResult;
|
||||
|
||||
const String defaultSafariBundleLocation = "/Applications/Safari.app/";
|
||||
|
||||
|
@ -35,11 +27,11 @@ const String safari = "com.apple.Safari";
|
|||
const String defaultsLocation = "/usr/bin/defaults";
|
||||
|
||||
final List<String> safariSettings = <String>[
|
||||
"Library/Caches/$safari",
|
||||
"Library/Safari",
|
||||
"Library/Saved Application State/$safari.savedState",
|
||||
"Library/Caches/Metadata/Safari",
|
||||
"Library/Preferences/$safari.plist",
|
||||
"Library/Caches/$safari",
|
||||
"Library/Safari",
|
||||
"Library/Saved Application State/$safari.savedState",
|
||||
"Library/Caches/Metadata/Safari",
|
||||
"Library/Preferences/$safari.plist",
|
||||
];
|
||||
|
||||
const Duration defaultPollDelay = const Duration(milliseconds: 1);
|
||||
|
@ -107,10 +99,8 @@ final String knownSafariPreference = '''
|
|||
|
||||
Future<Null> get pollDelay => new Future.delayed(defaultPollDelay);
|
||||
|
||||
String signalArgument(
|
||||
String defaultSignal,
|
||||
{bool force: false,
|
||||
bool testOnly: false}) {
|
||||
String signalArgument(String defaultSignal,
|
||||
{bool force: false, bool testOnly: false}) {
|
||||
if (force && testOnly) {
|
||||
throw new ArgumentError("[force] and [testOnly] can't both be true.");
|
||||
}
|
||||
|
@ -119,24 +109,21 @@ String signalArgument(
|
|||
return defaultSignal;
|
||||
}
|
||||
|
||||
Future<int> kill(
|
||||
List<String> pids,
|
||||
{bool force: false,
|
||||
bool testOnly: false}) async {
|
||||
List<String> arguments =
|
||||
<String>[signalArgument("-TERM", force: force, testOnly: testOnly)]
|
||||
..addAll(pids);
|
||||
Future<int> kill(List<String> pids,
|
||||
{bool force: false, bool testOnly: false}) async {
|
||||
List<String> arguments = <String>[
|
||||
signalArgument("-TERM", force: force, testOnly: testOnly)
|
||||
]..addAll(pids);
|
||||
ProcessResult result = await Process.run(killLocation, arguments);
|
||||
return result.exitCode;
|
||||
}
|
||||
|
||||
Future<int> pkill(
|
||||
String pattern,
|
||||
{bool force: false,
|
||||
bool testOnly: false}) async {
|
||||
Future<int> pkill(String pattern,
|
||||
{bool force: false, bool testOnly: false}) async {
|
||||
List<String> arguments = <String>[
|
||||
signalArgument("-HUP", force: force, testOnly: testOnly),
|
||||
pattern];
|
||||
signalArgument("-HUP", force: force, testOnly: testOnly),
|
||||
pattern
|
||||
];
|
||||
ProcessResult result = await Process.run(pkillLocation, arguments);
|
||||
return result.exitCode;
|
||||
}
|
||||
|
@ -144,8 +131,7 @@ Future<int> pkill(
|
|||
Uri validatedBundleName(Uri bundle) {
|
||||
if (bundle == null) return Uri.base.resolve(defaultSafariBundleLocation);
|
||||
if (!bundle.path.endsWith("/")) {
|
||||
throw new ArgumentError(
|
||||
"Bundle ('$bundle') must end with a slash ('/').");
|
||||
throw new ArgumentError("Bundle ('$bundle') must end with a slash ('/').");
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
|
@ -153,8 +139,8 @@ Uri validatedBundleName(Uri bundle) {
|
|||
Future<Null> killSafari({Uri bundle}) async {
|
||||
bundle = validatedBundleName(bundle);
|
||||
Uri safariBinary = bundle.resolve(relativeSafariLocation);
|
||||
ProcessResult result = await Process.run(
|
||||
lsofLocation, ["-t", safariBinary.toFilePath()]);
|
||||
ProcessResult result =
|
||||
await Process.run(lsofLocation, ["-t", safariBinary.toFilePath()]);
|
||||
if (result.exitCode == 0) {
|
||||
String stdout = result.stdout;
|
||||
List<String> pids = new List<String>.from(
|
||||
|
@ -209,8 +195,8 @@ Future<Null> resetSafariSettings() async {
|
|||
for (String setting in safariSettings) {
|
||||
await deleteIfExists(homeDirectory.resolve(setting));
|
||||
}
|
||||
ProcessResult result = await Process.run(
|
||||
defaultsLocation, <String>["write", safari, knownSafariPreference]);
|
||||
ProcessResult result = await Process
|
||||
.run(defaultsLocation, <String>["write", safari, knownSafariPreference]);
|
||||
if (result.exitCode != 0) {
|
||||
throw "Unable to reset Safari settings: ${result.stdout}${result.stderr}";
|
||||
}
|
||||
|
|
|
@ -281,16 +281,15 @@ class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration {
|
|||
}
|
||||
|
||||
return <Command>[
|
||||
commandBuilder.getVmCommand(suite.dartPrecompiledBinaryFileName,
|
||||
arguments, environmentOverrides)
|
||||
commandBuilder.getVmCommand(
|
||||
suite.dartPrecompiledBinaryFileName, arguments, environmentOverrides)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class DartPrecompiledAdbRuntimeConfiguration
|
||||
extends DartVmRuntimeConfiguration {
|
||||
static const String DeviceDir =
|
||||
'/data/local/tmp/precompilation-testing';
|
||||
extends DartVmRuntimeConfiguration {
|
||||
static const String DeviceDir = '/data/local/tmp/precompilation-testing';
|
||||
static const String DeviceTestDir =
|
||||
'/data/local/tmp/precompilation-testing/test';
|
||||
|
||||
|
@ -312,11 +311,8 @@ class DartPrecompiledAdbRuntimeConfiguration
|
|||
String precompiledRunner = suite.dartPrecompiledBinaryFileName;
|
||||
String processTest = suite.processTestBinaryFileName;
|
||||
return <Command>[
|
||||
commandBuilder.getAdbPrecompiledCommand(precompiledRunner,
|
||||
processTest,
|
||||
script,
|
||||
arguments,
|
||||
useBlobs)
|
||||
commandBuilder.getAdbPrecompiledCommand(
|
||||
precompiledRunner, processTest, script, arguments, useBlobs)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +326,7 @@ class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration {
|
|||
|
||||
void searchForSelfCheckers() {
|
||||
Uri pkg = TestUtils.dartDirUri.resolve('pkg');
|
||||
for (var entry in new Directory.fromUri(pkg).listSync(recursive: true)) {
|
||||
for (var entry in new Directory.fromUri(pkg).listSync(recursive: true)) {
|
||||
if (entry is File && entry.path.endsWith('_self_check.dart')) {
|
||||
selfCheckers.add(entry.path);
|
||||
}
|
||||
|
|
|
@ -286,8 +286,7 @@ Future testConfigurations(List<Map> configurations) async {
|
|||
// make a pool of all available adb devices.
|
||||
AdbDevicePool adbDevicePool;
|
||||
bool needsAdbDevicePool = configurations.any((Map conf) {
|
||||
return conf['runtime'] == 'dart_precompiled' &&
|
||||
conf['system'] == 'android';
|
||||
return conf['runtime'] == 'dart_precompiled' && conf['system'] == 'android';
|
||||
});
|
||||
if (needsAdbDevicePool) {
|
||||
adbDevicePool = await AdbDevicePool.create();
|
||||
|
@ -305,10 +304,10 @@ Future testConfigurations(List<Map> configurations) async {
|
|||
var text =
|
||||
await new File(VS_TOOLCHAIN_FILE.toNativePath()).readAsString();
|
||||
firstConf['win_sdk_path'] = JSON.decode(text)['win_sdk'];
|
||||
} on dynamic {
|
||||
// Ignore errors here. If win_sdk is not found, stack trace dumping
|
||||
// for timeouts won't work.
|
||||
}
|
||||
} on dynamic {
|
||||
// Ignore errors here. If win_sdk is not found, stack trace dumping
|
||||
// for timeouts won't work.
|
||||
}
|
||||
}
|
||||
|
||||
// [firstConf] is needed here, since the ProcessQueue needs to know the
|
||||
|
|
|
@ -301,8 +301,8 @@ class TestOptionsParser {
|
|||
new _TestOptionSpecification(
|
||||
'verify-ir', 'Verify kernel IR', ['--verify-ir'], [], false,
|
||||
type: 'bool'),
|
||||
new _TestOptionSpecification(
|
||||
'no-tree-shake', 'Disable kernel IR tree shaking', ['--no-tree-shake'], [], false,
|
||||
new _TestOptionSpecification('no-tree-shake',
|
||||
'Disable kernel IR tree shaking', ['--no-tree-shake'], [], false,
|
||||
type: 'bool'),
|
||||
new _TestOptionSpecification(
|
||||
'list', 'List tests only, do not run them', ['--list'], [], false,
|
||||
|
|
|
@ -284,8 +284,10 @@ class TestOutcomeLogWriter extends EventListener {
|
|||
if (output != null) {
|
||||
double duration = output.time.inMicroseconds / 1000.0;
|
||||
totalDuration += duration;
|
||||
commandResults
|
||||
.add({'name': command.displayName, 'duration': duration,});
|
||||
commandResults.add({
|
||||
'name': command.displayName,
|
||||
'duration': duration,
|
||||
});
|
||||
}
|
||||
}
|
||||
_writeTestOutcomeRecord({
|
||||
|
@ -334,8 +336,7 @@ class UnexpectedCrashLogger extends EventListener {
|
|||
final binName = lastCommand.executable;
|
||||
final binFile = new File(binName);
|
||||
final binBaseName = new Path(binName).filename;
|
||||
if (!archivedBinaries.containsKey(binName) &&
|
||||
binFile.existsSync()) {
|
||||
if (!archivedBinaries.containsKey(binName) && binFile.existsSync()) {
|
||||
final mode = test.configuration['mode'];
|
||||
final arch = test.configuration['arch'];
|
||||
final archived = "binary.${mode}_${arch}_${binBaseName}";
|
||||
|
|
|
@ -236,8 +236,7 @@ class KernelCompilationCommand extends CompilationCommand {
|
|||
List<String> arguments,
|
||||
Map<String, String> environmentOverrides)
|
||||
: super._(displayName, outputFile, neverSkipCompilation,
|
||||
bootstrapDependencies, executable, arguments,
|
||||
environmentOverrides);
|
||||
bootstrapDependencies, executable, arguments, environmentOverrides);
|
||||
|
||||
int get maxNumRetries => 1;
|
||||
}
|
||||
|
@ -374,14 +373,14 @@ class VmBatchCommand extends ProcessCommand implements VmCommand {
|
|||
final bool checked;
|
||||
|
||||
VmBatchCommand._(String executable, String dartFile, List<String> arguments,
|
||||
Map<String, String> environmentOverrides, {this.checked: true})
|
||||
Map<String, String> environmentOverrides,
|
||||
{this.checked: true})
|
||||
: this.dartFile = dartFile,
|
||||
super._('vm-batch', executable, arguments, environmentOverrides);
|
||||
|
||||
@override
|
||||
List<String> get batchArguments => checked
|
||||
? ['--checked', dartFile]
|
||||
: [dartFile];
|
||||
List<String> get batchArguments =>
|
||||
checked ? ['--checked', dartFile] : [dartFile];
|
||||
|
||||
@override
|
||||
bool _equal(VmBatchCommand other) {
|
||||
|
@ -405,11 +404,12 @@ class AdbPrecompilationCommand extends Command {
|
|||
final List<String> arguments;
|
||||
final bool useBlobs;
|
||||
|
||||
AdbPrecompilationCommand._(this.precompiledRunnerFilename,
|
||||
this.processTestFilename,
|
||||
this.precompiledTestDirectory,
|
||||
this.arguments,
|
||||
this.useBlobs)
|
||||
AdbPrecompilationCommand._(
|
||||
this.precompiledRunnerFilename,
|
||||
this.processTestFilename,
|
||||
this.precompiledTestDirectory,
|
||||
this.arguments,
|
||||
this.useBlobs)
|
||||
: super._("adb_precompilation");
|
||||
|
||||
void _buildHashCode(HashCodeBuilder builder) {
|
||||
|
@ -648,17 +648,18 @@ class CommandBuilder {
|
|||
VmBatchCommand getVmBatchCommand(String executable, String tester,
|
||||
List<String> arguments, Map<String, String> environmentOverrides,
|
||||
{bool checked: true}) {
|
||||
var command =
|
||||
new VmBatchCommand._(executable, tester, arguments, environmentOverrides,
|
||||
checked: checked);
|
||||
var command = new VmBatchCommand._(
|
||||
executable, tester, arguments, environmentOverrides,
|
||||
checked: checked);
|
||||
return _getUniqueCommand(command);
|
||||
}
|
||||
|
||||
AdbPrecompilationCommand getAdbPrecompiledCommand(String precompiledRunner,
|
||||
String processTest,
|
||||
String testDirectory,
|
||||
List<String> arguments,
|
||||
bool useBlobs) {
|
||||
AdbPrecompilationCommand getAdbPrecompiledCommand(
|
||||
String precompiledRunner,
|
||||
String processTest,
|
||||
String testDirectory,
|
||||
List<String> arguments,
|
||||
bool useBlobs) {
|
||||
var command = new AdbPrecompilationCommand._(
|
||||
precompiledRunner, processTest, testDirectory, arguments, useBlobs);
|
||||
return _getUniqueCommand(command);
|
||||
|
@ -687,9 +688,8 @@ class CommandBuilder {
|
|||
Command getPubCommand(String pubCommand, String pubExecutable,
|
||||
String pubspecYamlDirectory, String pubCacheDirectory,
|
||||
{List<String> arguments: const <String>[]}) {
|
||||
var command = new PubCommand._(
|
||||
pubCommand, pubExecutable, pubspecYamlDirectory, pubCacheDirectory,
|
||||
arguments);
|
||||
var command = new PubCommand._(pubCommand, pubExecutable,
|
||||
pubspecYamlDirectory, pubCacheDirectory, arguments);
|
||||
return _getUniqueCommand(command);
|
||||
}
|
||||
|
||||
|
@ -1610,11 +1610,15 @@ class CompilationCommandOutputImpl extends CommandOutputImpl {
|
|||
|
||||
class KernelCompilationCommandOutputImpl extends CompilationCommandOutputImpl {
|
||||
KernelCompilationCommandOutputImpl(
|
||||
Command command, int exitCode, bool timedOut,
|
||||
List<int> stdout, List<int> stderr,
|
||||
Duration time, bool compilationSkipped)
|
||||
Command command,
|
||||
int exitCode,
|
||||
bool timedOut,
|
||||
List<int> stdout,
|
||||
List<int> stderr,
|
||||
Duration time,
|
||||
bool compilationSkipped)
|
||||
: super(command, exitCode, timedOut, stdout, stderr, time,
|
||||
compilationSkipped);
|
||||
compilationSkipped);
|
||||
|
||||
bool get canRunDependendCommands {
|
||||
// See [BatchRunnerProcess]: 0 means success, 1 means compile-time error.
|
||||
|
@ -1784,16 +1788,16 @@ class OutputLog {
|
|||
? tail.sublist(tail.length - TAIL_LENGTH)
|
||||
: tail;
|
||||
|
||||
|
||||
void _checkUtf8(List<int> data) {
|
||||
try {
|
||||
UTF8.decode(data, allowMalformed: false);
|
||||
} on FormatException catch (e) {
|
||||
hasNonUtf8 = true;
|
||||
String malformed = UTF8.decode(data, allowMalformed: true);
|
||||
data..clear()
|
||||
..addAll(UTF8.encode(malformed))
|
||||
..addAll("""
|
||||
data
|
||||
..clear()
|
||||
..addAll(UTF8.encode(malformed))
|
||||
..addAll("""
|
||||
|
||||
*****************************************************************************
|
||||
|
||||
|
@ -1802,11 +1806,10 @@ class OutputLog {
|
|||
*****************************************************************************
|
||||
|
||||
"""
|
||||
.codeUnits);
|
||||
.codeUnits);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<int> toList() {
|
||||
if (complete == null) {
|
||||
complete = head;
|
||||
|
@ -1840,14 +1843,19 @@ Future<List<int>> _getPidList(pid, diagnostics) async {
|
|||
var lines;
|
||||
var start_line = 0;
|
||||
if (io.Platform.isLinux || io.Platform.isMacOS) {
|
||||
var result = await io.Process.run("pgrep",
|
||||
["-P", "${pid_list[0]}"],
|
||||
runInShell: true);
|
||||
var result = await io.Process
|
||||
.run("pgrep", ["-P", "${pid_list[0]}"], runInShell: true);
|
||||
lines = result.stdout.split('\n');
|
||||
} else if (io.Platform.isWindows) {
|
||||
var result = await io.Process.run("wmic",
|
||||
["process", "where" , "(ParentProcessId=${pid_list[0]})",
|
||||
"get", "ProcessId"],
|
||||
var result = await io.Process.run(
|
||||
"wmic",
|
||||
[
|
||||
"process",
|
||||
"where",
|
||||
"(ParentProcessId=${pid_list[0]})",
|
||||
"get",
|
||||
"ProcessId"
|
||||
],
|
||||
runInShell: true);
|
||||
lines = result.stdout.split('\n');
|
||||
// Skip first line containing header "ProcessId".
|
||||
|
@ -1891,9 +1899,7 @@ class RunningProcess {
|
|||
Completer<CommandOutput> completer;
|
||||
Map configuration;
|
||||
|
||||
RunningProcess(this.command,
|
||||
this.timeout,
|
||||
{this.configuration});
|
||||
RunningProcess(this.command, this.timeout, {this.configuration});
|
||||
|
||||
Future<CommandOutput> run() {
|
||||
completer = new Completer<CommandOutput>();
|
||||
|
@ -1910,8 +1916,7 @@ class RunningProcess {
|
|||
} else {
|
||||
var processEnvironment = _createProcessEnvironment();
|
||||
var args = command.arguments;
|
||||
Future processFuture = io.Process.start(
|
||||
command.executable, args,
|
||||
Future processFuture = io.Process.start(command.executable, args,
|
||||
environment: processEnvironment,
|
||||
workingDirectory: command.workingDirectory);
|
||||
processFuture.then((io.Process process) {
|
||||
|
@ -1941,6 +1946,7 @@ class RunningProcess {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeStderr([_]) {
|
||||
if (!stderrDone) {
|
||||
stderrCompleter.complete();
|
||||
|
@ -1968,18 +1974,20 @@ class RunningProcess {
|
|||
executable = '/usr/bin/sample';
|
||||
} else if (io.Platform.isWindows) {
|
||||
bool is_x64 = command.executable.contains("X64") ||
|
||||
command.executable.contains("SIMARM64");
|
||||
command.executable.contains("SIMARM64");
|
||||
var win_sdk_path = configuration['win_sdk_path'];
|
||||
if (win_sdk_path != null) {
|
||||
executable = win_sdk_path +
|
||||
"\\Debuggers\\" + (is_x64 ? "x64" : "x86") + "\\cdb.exe";
|
||||
"\\Debuggers\\" +
|
||||
(is_x64 ? "x64" : "x86") +
|
||||
"\\cdb.exe";
|
||||
diagnostics.add("Using $executable to print stack traces");
|
||||
} else {
|
||||
diagnostics.add("win_sdk path not found");
|
||||
}
|
||||
} else {
|
||||
diagnostics.add("Capturing stack traces on"
|
||||
"${io.Platform.operatingSystem} not supported");
|
||||
"${io.Platform.operatingSystem} not supported");
|
||||
}
|
||||
if (executable != null) {
|
||||
var pid_list = await _getPidList(process.pid, diagnostics);
|
||||
|
@ -2100,7 +2108,7 @@ class RunningProcess {
|
|||
}
|
||||
}
|
||||
|
||||
class BatchRunnerProcess {
|
||||
class BatchRunnerProcess {
|
||||
Completer<CommandOutput> _completer;
|
||||
ProcessCommand _command;
|
||||
List<String> _arguments;
|
||||
|
@ -2225,6 +2233,7 @@ class BatchRunnerProcess {
|
|||
_process = null;
|
||||
}
|
||||
}
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
@ -2236,7 +2245,9 @@ class BatchRunnerProcess {
|
|||
_startProcess(callback) {
|
||||
assert(_command is ProcessCommand);
|
||||
var executable = _command.executable;
|
||||
var arguments = []..addAll(_command.batchArguments)..add('--batch');
|
||||
var arguments = []
|
||||
..addAll(_command.batchArguments)
|
||||
..add('--batch');
|
||||
var environment = new Map.from(io.Platform.environment);
|
||||
if (_processEnvironmentOverrides != null) {
|
||||
for (var key in _processEnvironmentOverrides.keys) {
|
||||
|
@ -2379,6 +2390,7 @@ class TestCaseEnqueuer {
|
|||
iterator.current.forEachTest(newTest, testCache, enqueueNextSuite);
|
||||
}
|
||||
}
|
||||
|
||||
enqueueNextSuite();
|
||||
}
|
||||
}
|
||||
|
@ -2669,6 +2681,7 @@ class CommandExecutorImpl implements CommandExecutor {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
return runCommand(command.maxNumRetries);
|
||||
}
|
||||
|
||||
|
@ -2705,8 +2718,9 @@ class CommandExecutorImpl implements CommandExecutor {
|
|||
return _getBatchRunner(command.displayName + command.dartFile)
|
||||
.runCommand(name, command, timeout, command.arguments);
|
||||
} else {
|
||||
return new RunningProcess(
|
||||
command, timeout, configuration: globalConfiguration).run();
|
||||
return new RunningProcess(command, timeout,
|
||||
configuration: globalConfiguration)
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2734,12 +2748,15 @@ class CommandExecutorImpl implements CommandExecutor {
|
|||
|
||||
steps.add(() => device.runAdbShellCommand(['rm', '-Rf', deviceTestDir]));
|
||||
steps.add(() => device.runAdbShellCommand(['mkdir', '-p', deviceTestDir]));
|
||||
steps.add(() => device.pushCachedData(runner,
|
||||
'$devicedir/dart_precompiled_runtime'));
|
||||
steps.add(() => device.pushCachedData(processTest,
|
||||
'$devicedir/process_test'));
|
||||
steps.add(() => device.runAdbShellCommand(
|
||||
['chmod', '777', '$devicedir/dart_precompiled_runtime $devicedir/process_test']));
|
||||
steps.add(() =>
|
||||
device.pushCachedData(runner, '$devicedir/dart_precompiled_runtime'));
|
||||
steps.add(
|
||||
() => device.pushCachedData(processTest, '$devicedir/process_test'));
|
||||
steps.add(() => device.runAdbShellCommand([
|
||||
'chmod',
|
||||
'777',
|
||||
'$devicedir/dart_precompiled_runtime $devicedir/process_test'
|
||||
]));
|
||||
|
||||
for (var file in files) {
|
||||
steps.add(() => device
|
||||
|
@ -2928,11 +2945,11 @@ bool shouldRetryCommand(CommandOutput output) {
|
|||
return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) ||
|
||||
line.contains(MESSAGE_FAILED_TO_RUN_COMMAND);
|
||||
}
|
||||
|
||||
if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ String prettifyJson(Object json, {int startIndentation: 0, int shiftWidth: 6}) {
|
|||
addString("$obj", indentation: indentation, newLine: newLine);
|
||||
}
|
||||
}
|
||||
|
||||
prettifyJsonInternal(json);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
|
|
@ -255,8 +255,12 @@ class ArgParser {
|
|||
* * There is already an option named [name].
|
||||
* * There is already an option using abbreviation [abbr].
|
||||
*/
|
||||
void addFlag(String name, {String abbr, String help, bool defaultsTo: false,
|
||||
bool negatable: true, void callback(bool value)}) {
|
||||
void addFlag(String name,
|
||||
{String abbr,
|
||||
String help,
|
||||
bool defaultsTo: false,
|
||||
bool negatable: true,
|
||||
void callback(bool value)}) {
|
||||
_addOption(name, abbr, help, null, null, defaultsTo, callback,
|
||||
isFlag: true, negatable: negatable);
|
||||
}
|
||||
|
@ -267,17 +271,21 @@ class ArgParser {
|
|||
* * There is already an option with name [name].
|
||||
* * There is already an option using abbreviation [abbr].
|
||||
*/
|
||||
void addOption(String name, {String abbr, String help, List<String> allowed,
|
||||
Map<String, String> allowedHelp, String defaultsTo,
|
||||
void callback(value), bool allowMultiple: false}) {
|
||||
_addOption(name, abbr, help, allowed, allowedHelp, defaultsTo,
|
||||
callback, isFlag: false, allowMultiple: allowMultiple);
|
||||
void addOption(String name,
|
||||
{String abbr,
|
||||
String help,
|
||||
List<String> allowed,
|
||||
Map<String, String> allowedHelp,
|
||||
String defaultsTo,
|
||||
void callback(value),
|
||||
bool allowMultiple: false}) {
|
||||
_addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, callback,
|
||||
isFlag: false, allowMultiple: allowMultiple);
|
||||
}
|
||||
|
||||
void _addOption(String name, String abbr, String help, List<String> allowed,
|
||||
Map<String, String> allowedHelp, defaultsTo,
|
||||
void callback(value), {bool isFlag, bool negatable: false,
|
||||
bool allowMultiple: false}) {
|
||||
Map<String, String> allowedHelp, defaultsTo, void callback(value),
|
||||
{bool isFlag, bool negatable: false, bool allowMultiple: false}) {
|
||||
// Make sure the name isn't in use.
|
||||
if (options.containsKey(name)) {
|
||||
throw new ArgumentError('Duplicate option "$name".');
|
||||
|
@ -297,9 +305,9 @@ class ArgParser {
|
|||
}
|
||||
}
|
||||
|
||||
options[name] = new Option(name, abbr, help, allowed, allowedHelp,
|
||||
defaultsTo, callback, isFlag: isFlag, negatable: negatable,
|
||||
allowMultiple: allowMultiple);
|
||||
options[name] = new Option(
|
||||
name, abbr, help, allowed, allowedHelp, defaultsTo, callback,
|
||||
isFlag: isFlag, negatable: negatable, allowMultiple: allowMultiple);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,8 +360,8 @@ class Option {
|
|||
final bool allowMultiple;
|
||||
|
||||
Option(this.name, this.abbreviation, this.help, this.allowed,
|
||||
this.allowedHelp, this.defaultValue, this.callback, {this.isFlag,
|
||||
this.negatable, this.allowMultiple: false});
|
||||
this.allowedHelp, this.defaultValue, this.callback,
|
||||
{this.isFlag, this.negatable, this.allowMultiple: false});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,8 +397,7 @@ class ArgResults {
|
|||
/** Gets the parsed command-line option named [name]. */
|
||||
operator [](String name) {
|
||||
if (!_options.containsKey(name)) {
|
||||
throw new ArgumentError(
|
||||
'Could not find an option named "$name".');
|
||||
throw new ArgumentError('Could not find an option named "$name".');
|
||||
}
|
||||
|
||||
return _options[name];
|
||||
|
@ -399,4 +406,3 @@ class ArgResults {
|
|||
/** Get the names of the options as a [Collection]. */
|
||||
List<String> get options => _options.keys.toList();
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ class Parser {
|
|||
*/
|
||||
void readNextArgAsValue(Option option) {
|
||||
// Take the option argument from the next command line arg.
|
||||
validate(args.length > 0,
|
||||
'Missing argument for "${option.name}".');
|
||||
validate(args.length > 0, 'Missing argument for "${option.name}".');
|
||||
|
||||
// Make sure it isn't an option itself.
|
||||
validate(!_ABBR_OPT.hasMatch(current) && !_LONG_OPT.hasMatch(current),
|
||||
|
@ -130,8 +129,8 @@ class Parser {
|
|||
var option = grammar.findByAbbreviation(soloOpt[1]);
|
||||
if (option == null) {
|
||||
// Walk up to the parent command if possible.
|
||||
validate(parent != null,
|
||||
'Could not find an option or flag "-${soloOpt[1]}".');
|
||||
validate(
|
||||
parent != null, 'Could not find an option or flag "-${soloOpt[1]}".');
|
||||
return parent.parseSoloOption();
|
||||
}
|
||||
|
||||
|
@ -161,8 +160,8 @@ class Parser {
|
|||
var first = grammar.findByAbbreviation(c);
|
||||
if (first == null) {
|
||||
// Walk up to the parent command if possible.
|
||||
validate(parent != null,
|
||||
'Could not find an option with short name "-$c".');
|
||||
validate(
|
||||
parent != null, 'Could not find an option with short name "-$c".');
|
||||
return parent.parseAbbreviation(innermostCommand);
|
||||
} else if (!first.isFlag) {
|
||||
// The first character is a non-flag option, so the rest must be the
|
||||
|
@ -172,9 +171,10 @@ class Parser {
|
|||
} else {
|
||||
// If we got some non-flag characters, then it must be a value, but
|
||||
// if we got here, it's a flag, which is wrong.
|
||||
validate(abbrOpt[2] == '',
|
||||
'Option "-$c" is a flag and cannot handle value '
|
||||
'"${abbrOpt[1].substring(1)}${abbrOpt[2]}".');
|
||||
validate(
|
||||
abbrOpt[2] == '',
|
||||
'Option "-$c" is a flag and cannot handle value '
|
||||
'"${abbrOpt[1].substring(1)}${abbrOpt[2]}".');
|
||||
|
||||
// Not an option, so all characters should be flags.
|
||||
// We use "innermostCommand" here so that if a parent command parses the
|
||||
|
@ -194,16 +194,16 @@ class Parser {
|
|||
var option = grammar.findByAbbreviation(c);
|
||||
if (option == null) {
|
||||
// Walk up to the parent command if possible.
|
||||
validate(parent != null,
|
||||
'Could not find an option with short name "-$c".');
|
||||
validate(
|
||||
parent != null, 'Could not find an option with short name "-$c".');
|
||||
parent.parseShortFlag(c);
|
||||
return;
|
||||
}
|
||||
|
||||
// In a list of short options, only the first can be a non-flag. If
|
||||
// we get here we've checked that already.
|
||||
validate(option.isFlag,
|
||||
'Option "-$c" must be a flag to be in a collapsed "-".');
|
||||
validate(
|
||||
option.isFlag, 'Option "-$c" must be a flag to be in a collapsed "-".');
|
||||
|
||||
setOption(results, option, true);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ main(List<String> arguments) async {
|
|||
Uri input = Uri.base.resolve(arguments[0]);
|
||||
Uri output = Uri.base.resolve(arguments[1]);
|
||||
var yaml = loadYaml(await new File.fromUri(input).readAsString());
|
||||
await new File.fromUri(output).writeAsString(
|
||||
const JsonEncoder.withIndent(" ").convert(yaml));
|
||||
await new File.fromUri(output)
|
||||
.writeAsString(const JsonEncoder.withIndent(" ").convert(yaml));
|
||||
port.close();
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import 'dart:io';
|
|||
Future<String> getVersion(var rootPath) {
|
||||
var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
var printVersionScript = rootPath.resolve("tools/print_version.py");
|
||||
return Process.run("python$suffix",
|
||||
[printVersionScript.toFilePath()]).then((result) {
|
||||
return Process
|
||||
.run("python$suffix", [printVersionScript.toFilePath()]).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw "Could not generate version";
|
||||
}
|
||||
|
@ -19,8 +19,7 @@ Future<String> getVersion(var rootPath) {
|
|||
Future<String> getSnapshotGenerationFile(var args, var rootPath) {
|
||||
var dart2js = rootPath.resolve(args["dart2js_main"]);
|
||||
return getVersion(rootPath).then((version) {
|
||||
var snapshotGenerationText =
|
||||
"""
|
||||
var snapshotGenerationText = """
|
||||
import '${dart2js.toFilePath(windows: false)}' as dart2jsMain;
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -41,8 +40,7 @@ void main(List<String> arguments) {
|
|||
Future<String> getDart2jsSnapshotGenerationFile(var args, var rootPath) {
|
||||
var dart2js = rootPath.resolve(args["dart2js_main"]);
|
||||
return getVersion(rootPath).then((version) {
|
||||
var snapshotGenerationText =
|
||||
"""
|
||||
var snapshotGenerationText = """
|
||||
import '${dart2js.toFilePath(windows: false)}' as dart2jsMain;
|
||||
|
||||
void main(List<String> arguments) {
|
||||
|
@ -55,25 +53,25 @@ void main(List<String> arguments) {
|
|||
}
|
||||
|
||||
void writeSnapshotFile(var path, var content) {
|
||||
File file = new File(path);
|
||||
var writer = file.openSync(mode: FileMode.WRITE);
|
||||
writer.writeStringSync(content);
|
||||
writer.close();
|
||||
File file = new File(path);
|
||||
var writer = file.openSync(mode: FileMode.WRITE);
|
||||
writer.writeStringSync(content);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
Future createSnapshot(var dart_file) {
|
||||
return Process.run(Platform.executable,
|
||||
["--packages=../../.packages",
|
||||
"--snapshot=$dart_file.snapshot",
|
||||
dart_file])
|
||||
.then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
print("Could not generate snapshot: result code ${result.exitCode}");
|
||||
print(result.stdout);
|
||||
print(result.stderr);
|
||||
throw "Could not generate snapshot";
|
||||
}
|
||||
});
|
||||
return Process.run(Platform.executable, [
|
||||
"--packages=../../.packages",
|
||||
"--snapshot=$dart_file.snapshot",
|
||||
dart_file
|
||||
]).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
print("Could not generate snapshot: result code ${result.exitCode}");
|
||||
print(result.stdout);
|
||||
print(result.stderr);
|
||||
throw "Could not generate snapshot";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,5 +107,4 @@ void main(List<String> arguments) {
|
|||
writeSnapshotFile(wrapper, result);
|
||||
createSnapshot(wrapper);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import 'dart:io';
|
|||
Future<String> getVersion(var rootPath) {
|
||||
var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
var printVersionScript = rootPath.resolve("tools/print_version.py");
|
||||
return Process.run("python$suffix",
|
||||
[printVersionScript.toFilePath()]).then((result) {
|
||||
return Process
|
||||
.run("python$suffix", [printVersionScript.toFilePath()]).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw "Could not generate version";
|
||||
}
|
||||
|
@ -19,8 +19,7 @@ Future<String> getVersion(var rootPath) {
|
|||
Future<String> getSnapshotGenerationFile(var args, var rootPath) {
|
||||
var dart2js = rootPath.resolve(args["dart2js_main"]);
|
||||
return getVersion(rootPath).then((version) {
|
||||
var snapshotGenerationText =
|
||||
"""
|
||||
var snapshotGenerationText = """
|
||||
import '${dart2js.toFilePath(windows: false)}' as dart2jsMain;
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -41,8 +40,7 @@ void main(List<String> arguments) {
|
|||
Future<String> getDart2jsSnapshotGenerationFile(var args, var rootPath) {
|
||||
var dart2js = rootPath.resolve(args["dart2js_main"]);
|
||||
return getVersion(rootPath).then((version) {
|
||||
var snapshotGenerationText =
|
||||
"""
|
||||
var snapshotGenerationText = """
|
||||
import '${dart2js.toFilePath(windows: false)}' as dart2jsMain;
|
||||
|
||||
void main(List<String> arguments) {
|
||||
|
@ -55,10 +53,10 @@ void main(List<String> arguments) {
|
|||
}
|
||||
|
||||
void writeSnapshotFile(var path, var content) {
|
||||
File file = new File(path);
|
||||
var writer = file.openSync(mode: FileMode.WRITE);
|
||||
writer.writeStringSync(content);
|
||||
writer.close();
|
||||
File file = new File(path);
|
||||
var writer = file.openSync(mode: FileMode.WRITE);
|
||||
writer.writeStringSync(content);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,10 +55,8 @@ _Rule CHARCODE(spec, [name]) {
|
|||
* CHAR does not generate a value.
|
||||
*/
|
||||
_Rule CHAR([characters]) {
|
||||
if (characters == null)
|
||||
return const _AnyCharRule();
|
||||
if (characters is int)
|
||||
return CHARCODE(characters);
|
||||
if (characters == null) return const _AnyCharRule();
|
||||
if (characters is int) return CHARCODE(characters);
|
||||
|
||||
// Find the range of character codes and construct an array of flags for codes
|
||||
// within the range.
|
||||
|
@ -66,14 +64,11 @@ _Rule CHAR([characters]) {
|
|||
codes.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||
int lo = codes[0];
|
||||
int hi = codes[codes.length - 1];
|
||||
if (lo == hi)
|
||||
return CHARCODE(lo);
|
||||
if (lo == hi) return CHARCODE(lo);
|
||||
int len = hi - lo + 1;
|
||||
var flags = new List<bool>(len);
|
||||
for (int i = 0; i < len; ++i)
|
||||
flags[i] = false;
|
||||
for (int code in codes)
|
||||
flags[code - lo] = true;
|
||||
for (int i = 0; i < len; ++i) flags[i] = false;
|
||||
for (int code in codes) flags[code - lo] = true;
|
||||
|
||||
return CHARCODE((code) => code >= lo && code <= hi && flags[code - lo]);
|
||||
}
|
||||
|
@ -137,11 +132,11 @@ _Rule LEX(arg1, [arg2]) {
|
|||
*
|
||||
* TEXT always generates a value.
|
||||
*/
|
||||
_Rule TEXT(rule, [extractor]) =>
|
||||
new _TextValueRule(_compile(rule),
|
||||
extractor == null
|
||||
? (string, start, end) => string.substring(start, end)
|
||||
: extractor);
|
||||
_Rule TEXT(rule, [extractor]) => new _TextValueRule(
|
||||
_compile(rule),
|
||||
extractor == null
|
||||
? (string, start, end) => string.substring(start, end)
|
||||
: extractor);
|
||||
|
||||
/**
|
||||
* Matches an optional rule.
|
||||
|
@ -185,27 +180,80 @@ _Rule MANY0(rule, [separator = null]) {
|
|||
*
|
||||
* OR is value-generating.
|
||||
*/
|
||||
_Rule OR([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]) =>
|
||||
_Rule OR(
|
||||
[a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
f,
|
||||
g,
|
||||
h,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
l,
|
||||
m,
|
||||
n,
|
||||
o,
|
||||
p,
|
||||
q,
|
||||
r,
|
||||
s,
|
||||
t,
|
||||
u,
|
||||
v,
|
||||
w,
|
||||
x,
|
||||
y,
|
||||
z]) =>
|
||||
_compileMultiRule(
|
||||
(a is List && b == null) // Backward compat. OR([a, b]) => OR(a, b).
|
||||
? a
|
||||
: _unspread(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z),
|
||||
(a is List && b == null) // Backward compat. OR([a, b]) => OR(a, b).
|
||||
? a
|
||||
: _unspread(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s,
|
||||
t, u, v, w, x, y, z),
|
||||
false,
|
||||
(compiledRules, valueCount, reducer) =>
|
||||
new _ChoiceRule(compiledRules));
|
||||
(compiledRules, valueCount, reducer) => new _ChoiceRule(compiledRules));
|
||||
|
||||
|
||||
|
||||
_Rule SEQ([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]) =>
|
||||
_compile(_unspread(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z));
|
||||
_Rule SEQ(
|
||||
[a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
f,
|
||||
g,
|
||||
h,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
l,
|
||||
m,
|
||||
n,
|
||||
o,
|
||||
p,
|
||||
q,
|
||||
r,
|
||||
s,
|
||||
t,
|
||||
u,
|
||||
v,
|
||||
w,
|
||||
x,
|
||||
y,
|
||||
z]) =>
|
||||
_compile(_unspread(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s,
|
||||
t, u, v, w, x, y, z));
|
||||
|
||||
/**
|
||||
* Matches [rule]
|
||||
*/
|
||||
_Rule MEMO(rule) => new _MemoRule(_compile(rule));
|
||||
|
||||
_Rule TAG(tag, rule) => _compile([rule, (ast) => [tag, ast]]);
|
||||
|
||||
_Rule TAG(tag, rule) => _compile([
|
||||
rule,
|
||||
(ast) => [tag, ast]
|
||||
]);
|
||||
|
||||
class ParseError implements Exception {
|
||||
const ParseError(String this._message);
|
||||
|
@ -224,7 +272,9 @@ class Grammar {
|
|||
_Rule _whitespace;
|
||||
|
||||
_Rule get whitespace => _whitespace;
|
||||
void set whitespace(rule) { _whitespace = _compile(rule); }
|
||||
void set whitespace(rule) {
|
||||
_whitespace = _compile(rule);
|
||||
}
|
||||
|
||||
Grammar() {
|
||||
_symbols = new Map<String, Symbol>();
|
||||
|
@ -236,8 +286,7 @@ class Grammar {
|
|||
* to define recursive rules.
|
||||
*/
|
||||
Symbol operator [](String name) {
|
||||
if (_symbols.containsKey(name))
|
||||
return _symbols[name];
|
||||
if (_symbols.containsKey(name)) return _symbols[name];
|
||||
Symbol s = new Symbol(name, this);
|
||||
_symbols[name] = s;
|
||||
return s;
|
||||
|
@ -249,17 +298,14 @@ class Grammar {
|
|||
*/
|
||||
parse(root, String text) {
|
||||
for (var symbol in _symbols.values)
|
||||
if (symbol._rule == null)
|
||||
print('${symbol.name} is undefined');
|
||||
if (symbol._rule == null) print('${symbol.name} is undefined');
|
||||
|
||||
var state = new _ParserState(text, whitespace: whitespace);
|
||||
var match = _compile(root).match(state, 0);
|
||||
if (match == null)
|
||||
return diagnose(state);
|
||||
if (match == null) return diagnose(state);
|
||||
var pos = match[0];
|
||||
pos = _skip_whitespace(state, pos);
|
||||
if (pos == state._end)
|
||||
return match[1];
|
||||
if (pos == state._end) return match[1];
|
||||
// TODO: Make this complain about expecting end of file.
|
||||
return diagnose(state);
|
||||
}
|
||||
|
@ -268,15 +314,14 @@ class Grammar {
|
|||
var message = 'unexpected error';
|
||||
if (!state.max_rule.isEmpty) {
|
||||
var s = new Set();
|
||||
for (var rule in state.max_rule)
|
||||
s.add(rule.description());
|
||||
for (var rule in state.max_rule) s.add(rule.description());
|
||||
var tokens = new List<String>.from(s);
|
||||
tokens.sort((a, b) =>
|
||||
a.startsWith("'") == b.startsWith("'")
|
||||
? a.compareTo(b)
|
||||
: a.startsWith("'") ? 1 : -1);
|
||||
tokens.sort((a, b) => a.startsWith("'") == b.startsWith("'")
|
||||
? a.compareTo(b)
|
||||
: a.startsWith("'") ? 1 : -1);
|
||||
var expected = tokens.join(' or ');
|
||||
var found = state.max_pos == state._end ? 'end of file'
|
||||
var found = state.max_pos == state._end
|
||||
? 'end of file'
|
||||
: "'${state._text[state.max_pos]}'";
|
||||
message = 'Expected $expected but found $found';
|
||||
}
|
||||
|
@ -305,14 +350,13 @@ class Symbol {
|
|||
Symbol(this.name, this.grammar);
|
||||
|
||||
void set def(rule) {
|
||||
assert(_rule == null); // Assign once.
|
||||
assert(_rule == null); // Assign once.
|
||||
_rule = _compile(rule);
|
||||
}
|
||||
|
||||
toString() => _rule == null ? '<$name>' : '<$name = $_rule>';
|
||||
}
|
||||
|
||||
|
||||
class _ParserState {
|
||||
_ParserState(this._text, {_Rule whitespace}) {
|
||||
_end = this._text.length;
|
||||
|
@ -345,7 +389,7 @@ class _Rule {
|
|||
const _Rule();
|
||||
// Returns null for a match failure or [pos, ast] for success.
|
||||
match(_ParserState state, int pos) {
|
||||
if (! state.inWhitespaceMode) {
|
||||
if (!state.inWhitespaceMode) {
|
||||
pos = _skip_whitespace(state, pos);
|
||||
}
|
||||
return matchAfterWS(state, pos);
|
||||
|
@ -387,14 +431,12 @@ class _Rule {
|
|||
int _skip_whitespace(state, pos) {
|
||||
// Returns the next non-whitespace position.
|
||||
// This is done by matching the optional whitespaceRule with the current text.
|
||||
if (state.whitespaceRule == null)
|
||||
return pos;
|
||||
if (state.whitespaceRule == null) return pos;
|
||||
state.inWhitespaceMode = true;
|
||||
state.inhibitExpectedTrackingDepth++;
|
||||
while (true) {
|
||||
var match = state.whitespaceRule.match(state, pos);
|
||||
if (match == null)
|
||||
break;
|
||||
if (match == null) break;
|
||||
pos = match[0];
|
||||
}
|
||||
state.inWhitespaceMode = false;
|
||||
|
@ -402,23 +444,19 @@ int _skip_whitespace(state, pos) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
_Rule _compileOptional(rule) {
|
||||
return rule == null ? null : _compile(rule);
|
||||
}
|
||||
|
||||
_Rule _compile(rule) {
|
||||
if (rule is _Rule)
|
||||
return rule;
|
||||
if (rule is String)
|
||||
return new _StringRule(rule);
|
||||
if (rule is Symbol)
|
||||
return new _SymbolRule(rule);
|
||||
if (rule is RegExp)
|
||||
return new _RegExpRule(rule);
|
||||
if (rule is _Rule) return rule;
|
||||
if (rule is String) return new _StringRule(rule);
|
||||
if (rule is Symbol) return new _SymbolRule(rule);
|
||||
if (rule is RegExp) return new _RegExpRule(rule);
|
||||
if (rule is List) {
|
||||
return _compileMultiRule(
|
||||
rule, true,
|
||||
rule,
|
||||
true,
|
||||
(compiledRules, valueCount, reducer) =>
|
||||
new _SequenceRule(compiledRules, valueCount, reducer));
|
||||
}
|
||||
|
@ -427,8 +465,7 @@ _Rule _compile(rule) {
|
|||
|
||||
class _EndOfInputRule extends _Rule {
|
||||
_match(_ParserState state, int pos) {
|
||||
if (pos == state._end)
|
||||
return [pos, null];
|
||||
if (pos == state._end) return [pos, null];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -450,11 +487,9 @@ class _CharCodeRule extends _Rule {
|
|||
var _name;
|
||||
_CharCodeRule(this._predicate, this._name);
|
||||
_match(_ParserState state, int pos) {
|
||||
if (pos == state._end)
|
||||
return null;
|
||||
if (pos == state._end) return null;
|
||||
int code = state._text.codeUnitAt(pos);
|
||||
if (_predicate(code))
|
||||
return [pos + 1, null];
|
||||
if (_predicate(code)) return [pos + 1, null];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -464,8 +499,7 @@ class _CharCodeRule extends _Rule {
|
|||
class _AnyCharRule extends _Rule {
|
||||
const _AnyCharRule();
|
||||
_match(_ParserState state, int pos) {
|
||||
if (pos == state._end)
|
||||
return null;
|
||||
if (pos == state._end) return null;
|
||||
return [pos + 1, null];
|
||||
}
|
||||
|
||||
|
@ -492,8 +526,7 @@ class _SkipRule extends _Rule {
|
|||
_SkipRule(_Rule this._rule);
|
||||
_match(_ParserState state, int pos) {
|
||||
var match = _rule.matchAfterWS(state, pos);
|
||||
if (match == null)
|
||||
return null;
|
||||
if (match == null) return null;
|
||||
return [match[0], null];
|
||||
}
|
||||
|
||||
|
@ -508,11 +541,9 @@ class _StringRule extends _Rule implements _Expectable {
|
|||
}
|
||||
|
||||
_match(_ParserState state, int pos) {
|
||||
if (pos + _len > state._end)
|
||||
return null;
|
||||
if (pos + _len > state._end) return null;
|
||||
for (int i = 0; i < _len; i++) {
|
||||
if (state._text.codeUnitAt(pos + i) != _string.codeUnitAt(i))
|
||||
return null;
|
||||
if (state._text.codeUnitAt(pos + i) != _string.codeUnitAt(i)) return null;
|
||||
}
|
||||
return [pos + _len, null];
|
||||
}
|
||||
|
@ -556,7 +587,7 @@ class _LexicalRule extends _Rule implements _Expectable {
|
|||
|
||||
class _TextValueRule extends _Rule {
|
||||
final _Rule _rule;
|
||||
final _extract; // Function
|
||||
final _extract; // Function
|
||||
|
||||
_TextValueRule(_Rule this._rule, Function this._extract);
|
||||
|
||||
|
@ -574,9 +605,8 @@ class _TextValueRule extends _Rule {
|
|||
toString() => 'TEXT($_rule)';
|
||||
}
|
||||
|
||||
_Rule _compileMultiRule(List rules,
|
||||
bool allowReducer,
|
||||
finish(compiledRules, valueCount, reducer)) {
|
||||
_Rule _compileMultiRule(
|
||||
List rules, bool allowReducer, finish(compiledRules, valueCount, reducer)) {
|
||||
int valueCount = 0;
|
||||
List compiledRules = new List<_Rule>();
|
||||
Function reducer;
|
||||
|
@ -590,8 +620,7 @@ _Rule _compileMultiRule(List rules,
|
|||
throw new Exception('Bad rule: "$rule"');
|
||||
} else {
|
||||
_Rule compiledRule = _compile(rule);
|
||||
if (compiledRule.generatesValue)
|
||||
++valueCount;
|
||||
if (compiledRule.generatesValue) ++valueCount;
|
||||
compiledRules.add(compiledRule);
|
||||
}
|
||||
}
|
||||
|
@ -617,9 +646,8 @@ class _SequenceRule extends _Rule {
|
|||
final int _generatingSubRules;
|
||||
final Function _reducer;
|
||||
bool _generatesValue;
|
||||
_SequenceRule(List<_Rule> this._rules,
|
||||
int this._generatingSubRules,
|
||||
Function this._reducer) {
|
||||
_SequenceRule(List<_Rule> this._rules, int this._generatingSubRules,
|
||||
Function this._reducer) {
|
||||
_generatesValue = _generatingSubRules > 0 || _reducer != null;
|
||||
}
|
||||
|
||||
|
@ -627,8 +655,7 @@ class _SequenceRule extends _Rule {
|
|||
var sequence = [];
|
||||
for (var rule in _rules) {
|
||||
var match = rule.match(state, pos);
|
||||
if (match == null)
|
||||
return null;
|
||||
if (match == null) return null;
|
||||
if (rule.generatesValue) {
|
||||
var ast = match[1];
|
||||
sequence.add(ast);
|
||||
|
@ -636,10 +663,8 @@ class _SequenceRule extends _Rule {
|
|||
pos = match[0];
|
||||
}
|
||||
if (_reducer == null) {
|
||||
if (_generatingSubRules == 0)
|
||||
return [pos, null];
|
||||
if (_generatingSubRules == 1)
|
||||
return [pos, sequence[0]];
|
||||
if (_generatingSubRules == 0) return [pos, null];
|
||||
if (_generatingSubRules == 1) return [pos, sequence[0]];
|
||||
return [pos, sequence];
|
||||
} else {
|
||||
return [pos, _apply(_reducer, sequence)];
|
||||
|
@ -683,13 +708,8 @@ class _OptionalRule extends _Rule {
|
|||
_OptionalRule(_Rule this._rule);
|
||||
_match(_ParserState state, int pos) {
|
||||
var match = _rule.match(state, pos);
|
||||
if (_rule.generatesValue)
|
||||
return match == null
|
||||
? [pos, null]
|
||||
: match;
|
||||
return match == null
|
||||
? [pos, false]
|
||||
: [match[0], true];
|
||||
if (_rule.generatesValue) return match == null ? [pos, null] : match;
|
||||
return match == null ? [pos, false] : [match[0], true];
|
||||
}
|
||||
|
||||
bool get generatesValue => true;
|
||||
|
@ -703,8 +723,7 @@ class _ContextRule extends _Rule {
|
|||
_match(_ParserState state, int pos) {
|
||||
// TODO: protect error state.
|
||||
var match = _rule._match(state, pos);
|
||||
if (match == null)
|
||||
return null;
|
||||
if (match == null) return null;
|
||||
return [pos, null];
|
||||
}
|
||||
|
||||
|
@ -717,8 +736,7 @@ class _NegativeContextRule extends _Rule {
|
|||
_match(_ParserState state, int pos) {
|
||||
// TODO: protect error state.
|
||||
var match = _rule._match(state, pos);
|
||||
if (match == null)
|
||||
return [pos, null];
|
||||
if (match == null) return [pos, null];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -736,26 +754,23 @@ class _RepeatRule extends _Rule {
|
|||
_match(state, pos) {
|
||||
// First match.
|
||||
var match = _rule.match(state, pos);
|
||||
if (match == null)
|
||||
if (_min == 0)
|
||||
return [pos, []];
|
||||
else
|
||||
return null;
|
||||
if (match == null) if (_min == 0)
|
||||
return [pos, []];
|
||||
else
|
||||
return null;
|
||||
pos = match[0];
|
||||
var result = [match[1]];
|
||||
|
||||
// Subsequent matches:
|
||||
while (true) {
|
||||
while (true) {
|
||||
var newPos = pos;
|
||||
if (_separator != null) {
|
||||
match = _separator.match(state, pos);
|
||||
if (match == null)
|
||||
return [pos, result];
|
||||
if (match == null) return [pos, result];
|
||||
newPos = match[0];
|
||||
}
|
||||
match = _rule.match(state, newPos);
|
||||
if (match == null)
|
||||
return [pos, result];
|
||||
if (match == null) return [pos, result];
|
||||
pos = match[0];
|
||||
result.add(match[1]);
|
||||
}
|
||||
|
@ -763,7 +778,8 @@ class _RepeatRule extends _Rule {
|
|||
|
||||
bool get generatesValue => true;
|
||||
|
||||
toString() => 'MANY(min:$_min, $_rule${_separator==null?'':", sep: $_separator"})';
|
||||
toString() =>
|
||||
'MANY(min:$_min, $_rule${_separator==null?'':", sep: $_separator"})';
|
||||
}
|
||||
|
||||
class _MemoRule extends _Rule {
|
||||
|
@ -774,7 +790,7 @@ class _MemoRule extends _Rule {
|
|||
// A map from position to result. Can this be replaced with something
|
||||
// smaller?
|
||||
// TODO: figure out how to discard the map and parseInstance after parsing.
|
||||
Map<int,Object> map;
|
||||
Map<int, Object> map;
|
||||
|
||||
_MemoRule(this._rule);
|
||||
|
||||
|
@ -782,7 +798,7 @@ class _MemoRule extends _Rule {
|
|||
// See if we are still parsing the same input. Relies on the fact that the
|
||||
// input is a string and strings are immutable.
|
||||
if (!identical(parseInstance, state._text)) {
|
||||
map = new Map<int,Object>();
|
||||
map = new Map<int, Object>();
|
||||
parseInstance = state._text;
|
||||
}
|
||||
// TODO: does this have to check or preserve parse state (like
|
||||
|
@ -803,31 +819,44 @@ class _MemoRule extends _Rule {
|
|||
|
||||
_apply(fn, List args) {
|
||||
switch (args.length) {
|
||||
case 0: return fn();
|
||||
case 1: return fn(args[0]);
|
||||
case 2: return fn(args[0], args[1]);
|
||||
case 3: return fn(args[0], args[1], args[2]);
|
||||
case 4: return fn(args[0], args[1], args[2], args[3]);
|
||||
case 5: return fn(args[0], args[1], args[2], args[3], args[4]);
|
||||
case 6: return fn(args[0], args[1], args[2], args[3], args[4],
|
||||
args[5]);
|
||||
case 7: return fn(args[0], args[1], args[2], args[3], args[4],
|
||||
args[5], args[6]);
|
||||
case 8: return fn(args[0], args[1], args[2], args[3], args[4],
|
||||
args[5], args[6], args[7]);
|
||||
case 9: return fn(args[0], args[1], args[2], args[3], args[4],
|
||||
args[5], args[6], args[7], args[8]);
|
||||
case 10: return fn(args[0], args[1], args[2], args[3], args[4],
|
||||
args[5], args[6], args[7], args[8], args[9]);
|
||||
case 0:
|
||||
return fn();
|
||||
case 1:
|
||||
return fn(args[0]);
|
||||
case 2:
|
||||
return fn(args[0], args[1]);
|
||||
case 3:
|
||||
return fn(args[0], args[1], args[2]);
|
||||
case 4:
|
||||
return fn(args[0], args[1], args[2], args[3]);
|
||||
case 5:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4]);
|
||||
case 6:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4], args[5]);
|
||||
case 7:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
||||
case 8:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6],
|
||||
args[7]);
|
||||
case 9:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6],
|
||||
args[7], args[8]);
|
||||
case 10:
|
||||
return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6],
|
||||
args[7], args[8], args[9]);
|
||||
|
||||
default:
|
||||
throw new Exception('Too many arguments in _apply: $args');
|
||||
}
|
||||
}
|
||||
|
||||
List _unspread(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) {
|
||||
List _unspread(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v,
|
||||
w, x, y, z) {
|
||||
List list = new List();
|
||||
add(element) { if (element != null) list.add(element); }
|
||||
add(element) {
|
||||
if (element != null) list.add(element);
|
||||
}
|
||||
|
||||
add(a);
|
||||
add(b);
|
||||
add(c);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library peg_tests;
|
||||
|
||||
import 'dart:core' hide Symbol;
|
||||
import '../../peg/pegparser.dart';
|
||||
|
||||
|
@ -10,7 +11,7 @@ testParens() {
|
|||
Grammar g = new Grammar();
|
||||
Symbol a = g['A'];
|
||||
|
||||
a.def = ['(', MANY(a, min:0), ')', (a) => a];
|
||||
a.def = ['(', MANY(a, min: 0), ')', (a) => a];
|
||||
|
||||
check(g, a, "", null);
|
||||
check(g, a, "()", '[]');
|
||||
|
@ -19,20 +20,22 @@ testParens() {
|
|||
}
|
||||
|
||||
testBlockComment() {
|
||||
|
||||
// Block comment in whitespace.
|
||||
|
||||
Grammar g = new Grammar();
|
||||
Symbol blockComment = g['blockComment'];
|
||||
|
||||
blockComment.def =
|
||||
['/*',
|
||||
MANY(OR([blockComment,
|
||||
[NOT('*/'), CHAR()],
|
||||
[END, ERROR('EOF in block comment')]
|
||||
]),
|
||||
min: 0),
|
||||
'*/'];
|
||||
blockComment.def = [
|
||||
'/*',
|
||||
MANY(
|
||||
OR([
|
||||
blockComment,
|
||||
[NOT('*/'), CHAR()],
|
||||
[END, ERROR('EOF in block comment')]
|
||||
]),
|
||||
min: 0),
|
||||
'*/'
|
||||
];
|
||||
print(blockComment);
|
||||
|
||||
var a = MANY(TEXT('x'));
|
||||
|
@ -44,36 +47,36 @@ testBlockComment() {
|
|||
check(g, a, "x /*/***/ x", 'EOF in block comment');
|
||||
check(g, a, "x /*/*/x**/**/ x", '[x,x]');
|
||||
|
||||
check(g, a, r"""
|
||||
check(
|
||||
g,
|
||||
a,
|
||||
r"""
|
||||
/* Comment */
|
||||
/* Following comment with /* nested comment*/ */
|
||||
x
|
||||
/* x in comment */
|
||||
x /* outside comment */
|
||||
""",
|
||||
'[x,x]');
|
||||
'[x,x]');
|
||||
}
|
||||
|
||||
testTEXT() {
|
||||
Grammar g = new Grammar();
|
||||
|
||||
// TEXT grabs the parsed text,
|
||||
check(g, TEXT(LEX(MANY(OR(['1','a'])))), ' 1a1 ', '1a1');
|
||||
check(g, TEXT(LEX(MANY(OR(['1', 'a'])))), ' 1a1 ', '1a1');
|
||||
|
||||
// Without the lexical context, TEXT will grab intervening whitespace.
|
||||
check(g, TEXT(MANY(OR(['1','a']))), ' 1a1 ', '1a1');
|
||||
check(g, TEXT(MANY(OR(['1','a']))), ' 1 a 1 ', '1 a 1');
|
||||
check(g, TEXT(MANY(OR(['1', 'a']))), ' 1a1 ', '1a1');
|
||||
check(g, TEXT(MANY(OR(['1', 'a']))), ' 1 a 1 ', '1 a 1');
|
||||
|
||||
// Custom processing of the TEXT substring.
|
||||
var binaryNumber =
|
||||
TEXT(LEX(MANY(OR(['0','1']))),
|
||||
(str, start, end) {
|
||||
var r = 0;
|
||||
var zero = '0'.codeUnitAt(0);
|
||||
for (int i = start; i < end; i++)
|
||||
r = r * 2 + (str.codeUnitAt(i) - zero);
|
||||
return r;
|
||||
});
|
||||
var binaryNumber = TEXT(LEX(MANY(OR(['0', '1']))), (str, start, end) {
|
||||
var r = 0;
|
||||
var zero = '0'.codeUnitAt(0);
|
||||
for (int i = start; i < end; i++) r = r * 2 + (str.codeUnitAt(i) - zero);
|
||||
return r;
|
||||
});
|
||||
|
||||
check(g, binaryNumber, ' 10101 ', 21);
|
||||
check(g, binaryNumber, '1010111', 87);
|
||||
|
@ -83,10 +86,15 @@ testTEXT() {
|
|||
testOR() {
|
||||
// OR matches the first match.
|
||||
Grammar g = new Grammar();
|
||||
check(g, OR([['a', NOT(END), () => 1],
|
||||
['a', () => 2],
|
||||
['a', () => 3]]),
|
||||
'a', 2);
|
||||
check(
|
||||
g,
|
||||
OR([
|
||||
['a', NOT(END), () => 1],
|
||||
['a', () => 2],
|
||||
['a', () => 3]
|
||||
]),
|
||||
'a',
|
||||
2);
|
||||
}
|
||||
|
||||
testCODE() {
|
||||
|
@ -96,8 +104,8 @@ testCODE() {
|
|||
check(g, a, 'bbb', 'bbb');
|
||||
check(g, a, 'ccc', 'ccc');
|
||||
check(g, a, 'ddd', 'ddd');
|
||||
check(g, a, 'bad', null); // a is outside range.
|
||||
check(g, a, 'bed', null); // e is outside range.
|
||||
check(g, a, 'bad', null); // a is outside range.
|
||||
check(g, a, 'bed', null); // e is outside range.
|
||||
}
|
||||
|
||||
testC() {
|
||||
|
@ -106,8 +114,7 @@ testC() {
|
|||
unary(operation) => () => (first) => [operation, first];
|
||||
reform(a, fns) {
|
||||
var r = a;
|
||||
for (var fn in fns)
|
||||
r = fn(r);
|
||||
for (var fn in fns) r = fn(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -126,128 +133,177 @@ testC() {
|
|||
Symbol assignment_e = g['assignment_e'];
|
||||
|
||||
// Lexical elements.
|
||||
var idStartChar = CHAR(
|
||||
r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
var idNextChar = CHAR(
|
||||
r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$_");
|
||||
var idStartChar =
|
||||
CHAR(r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
var idNextChar =
|
||||
CHAR(r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$_");
|
||||
|
||||
var id = TEXT(LEX('identifier', [idStartChar, MANY(idNextChar, min: 0)]));
|
||||
|
||||
var lit = TEXT(LEX('literal', MANY(CHAR('0123456789'))));
|
||||
|
||||
|
||||
var type_name = id;
|
||||
|
||||
|
||||
// Expression grammar.
|
||||
var primary_e = OR([id,
|
||||
lit,
|
||||
['(', expression, ')', (e) => e]
|
||||
]);
|
||||
var primary_e = OR([
|
||||
id,
|
||||
lit,
|
||||
['(', expression, ')', (e) => e]
|
||||
]);
|
||||
|
||||
var postfixes = OR([['(', MANY(assignment_e, separator: ',', min: 0), ')', binary('apply')],
|
||||
['++', unary('postinc')],
|
||||
['--', unary('postdec')],
|
||||
['.', id, binary('field')],
|
||||
['->', id, binary('ptr')],
|
||||
]);
|
||||
var postfixes = OR([
|
||||
['(', MANY(assignment_e, separator: ',', min: 0), ')', binary('apply')],
|
||||
['++', unary('postinc')],
|
||||
['--', unary('postdec')],
|
||||
['.', id, binary('field')],
|
||||
['->', id, binary('ptr')],
|
||||
]);
|
||||
|
||||
postfix_e.def = [primary_e, MANY(postfixes, min:0), reform];
|
||||
postfix_e.def = [primary_e, MANY(postfixes, min: 0), reform];
|
||||
|
||||
|
||||
var unary_op = OR([['&', () => 'address'],
|
||||
['*', () => 'indir'],
|
||||
['!', () => 'not'],
|
||||
['~', () => 'not'],
|
||||
['-', () => 'negate'],
|
||||
['+', () => 'uplus'],
|
||||
]);
|
||||
var unary_op = OR([
|
||||
['&', () => 'address'],
|
||||
['*', () => 'indir'],
|
||||
['!', () => 'not'],
|
||||
['~', () => 'not'],
|
||||
['-', () => 'negate'],
|
||||
['+', () => 'uplus'],
|
||||
]);
|
||||
var sizeof = LEX('sizeof', ['sizeof', NOT(idNextChar)]);
|
||||
|
||||
Symbol unary_e_plain = g['unary_e_plain'];
|
||||
unary_e_plain.def =
|
||||
OR([ ['++', unary_e, (e) => ['preinc', e]],
|
||||
['--', unary_e, (e) => ['predec', e]],
|
||||
[unary_op, cast_e, (o, e) => [o, e]],
|
||||
[sizeof, unary_e, (e) => ['sizeof-expr', e]],
|
||||
[sizeof, '(', type_name , ')', (t) => ['sizeof-type', t]],
|
||||
postfix_e
|
||||
]);
|
||||
unary_e_plain.def = OR([
|
||||
[
|
||||
'++', unary_e, (e) => ['preinc', e] //
|
||||
],
|
||||
[
|
||||
'--', unary_e, (e) => ['predec', e] //
|
||||
],
|
||||
[
|
||||
unary_op, cast_e, (o, e) => [o, e] //
|
||||
],
|
||||
[
|
||||
sizeof, unary_e, (e) => ['sizeof-expr', e] //
|
||||
],
|
||||
[
|
||||
sizeof, '(', type_name, ')', (t) => ['sizeof-type', t] //
|
||||
],
|
||||
postfix_e
|
||||
]);
|
||||
|
||||
unary_e.def = MEMO(unary_e_plain);
|
||||
//unary_e.def = unary_e_plain;
|
||||
|
||||
cast_e.def = OR([ ['(', type_name, ')', cast_e, (t, e) => ['cast', t, e]],
|
||||
unary_e,
|
||||
]);
|
||||
cast_e.def = OR([
|
||||
[
|
||||
'(', type_name, ')', cast_e, (t, e) => ['cast', t, e] //
|
||||
],
|
||||
unary_e,
|
||||
]);
|
||||
|
||||
var mult_ops = OR([['*', cast_e, binary('mult')],
|
||||
['/', cast_e, binary('div')],
|
||||
['%', cast_e, binary('rem')],
|
||||
]);
|
||||
mult_e.def = [cast_e, MANY(mult_ops, min:0), reform];
|
||||
var mult_ops = OR([
|
||||
['*', cast_e, binary('mult')],
|
||||
['/', cast_e, binary('div')],
|
||||
['%', cast_e, binary('rem')],
|
||||
]);
|
||||
mult_e.def = [cast_e, MANY(mult_ops, min: 0), reform];
|
||||
|
||||
var add_ops = OR([['+', mult_e, binary('add')],
|
||||
['-', mult_e, binary('sub')],
|
||||
]);
|
||||
add_e.def = [mult_e, MANY(add_ops, min:0), reform];
|
||||
var add_ops = OR([
|
||||
['+', mult_e, binary('add')],
|
||||
['-', mult_e, binary('sub')],
|
||||
]);
|
||||
add_e.def = [mult_e, MANY(add_ops, min: 0), reform];
|
||||
|
||||
var shift_ops = OR([['>>', add_e, binary('shl')],
|
||||
['<<', add_e, binary('shr')],
|
||||
]);
|
||||
shift_e.def = [add_e, MANY(shift_ops, min:0), reform];
|
||||
var shift_ops = OR([
|
||||
['>>', add_e, binary('shl')],
|
||||
['<<', add_e, binary('shr')],
|
||||
]);
|
||||
shift_e.def = [add_e, MANY(shift_ops, min: 0), reform];
|
||||
|
||||
var relational_ops = OR([['<=', shift_e, binary('le')],
|
||||
['>=', shift_e, binary('ge')],
|
||||
['<', shift_e, binary('lt')],
|
||||
['>', shift_e, binary('gt')],
|
||||
]);
|
||||
relational_e.def = [shift_e, MANY(relational_ops, min:0), reform];
|
||||
var relational_ops = OR([
|
||||
['<=', shift_e, binary('le')],
|
||||
['>=', shift_e, binary('ge')],
|
||||
['<', shift_e, binary('lt')],
|
||||
['>', shift_e, binary('gt')],
|
||||
]);
|
||||
relational_e.def = [shift_e, MANY(relational_ops, min: 0), reform];
|
||||
|
||||
var equality_ops = OR([
|
||||
['==', shift_e, binary('eq')],
|
||||
['!=', shift_e, binary('ne')],
|
||||
]);
|
||||
equality_e.def = [relational_e, MANY(equality_ops, min: 0), reform];
|
||||
|
||||
var equality_ops = OR([['==', shift_e, binary('eq')],
|
||||
['!=', shift_e, binary('ne')],
|
||||
]);
|
||||
equality_e.def = [relational_e, MANY(equality_ops, min:0), reform];
|
||||
|
||||
|
||||
var bit_and_op = LEX('&', ['&', NOT('&')]); // Don't see '&&' and '&', '&'
|
||||
var bit_and_op = LEX('&', ['&', NOT('&')]); // Don't see '&&' and '&', '&'
|
||||
var bit_or_op = LEX('|', ['|', NOT('|')]);
|
||||
|
||||
var and_e = [equality_e, MANY([bit_and_op, equality_e, binary('bitand')], min:0), reform];
|
||||
var xor_e = [and_e, MANY(['^', and_e, binary('bitxor')], min:0), reform];
|
||||
var or_e = [xor_e, MANY([bit_or_op, xor_e, binary('bitor')], min:0), reform];
|
||||
var and_e = [
|
||||
equality_e,
|
||||
MANY([bit_and_op, equality_e, binary('bitand')], min: 0),
|
||||
reform
|
||||
];
|
||||
var xor_e = [
|
||||
and_e,
|
||||
MANY(['^', and_e, binary('bitxor')], min: 0),
|
||||
reform
|
||||
];
|
||||
var or_e = [
|
||||
xor_e,
|
||||
MANY([bit_or_op, xor_e, binary('bitor')], min: 0),
|
||||
reform
|
||||
];
|
||||
|
||||
var log_and_e = [or_e, MANY(['&&', or_e, binary('and')], min:0), reform];
|
||||
var log_and_e = [
|
||||
or_e,
|
||||
MANY(['&&', or_e, binary('and')], min: 0),
|
||||
reform
|
||||
];
|
||||
|
||||
var log_or_e = [log_and_e, MANY(['||', log_and_e, binary('or')], min:0), reform];
|
||||
var log_or_e = [
|
||||
log_and_e,
|
||||
MANY(['||', log_and_e, binary('or')], min: 0),
|
||||
reform
|
||||
];
|
||||
|
||||
//cond_e.def = OR([ [log_or_e, '?', expression, ':', cond_e,
|
||||
// (p,a,b) => ['cond', p, a, b]],
|
||||
// log_or_e]);
|
||||
// Alternate version avoids reparsing log_or_e.
|
||||
cond_e.def = [log_or_e, MAYBE(['?', expression, ':', cond_e]),
|
||||
(p, r) => r == null || r == false ? p : ['cond', p, r[0], r[1]]];
|
||||
cond_e.def = [
|
||||
log_or_e,
|
||||
MAYBE(['?', expression, ':', cond_e]),
|
||||
(p, r) => r == null || r == false ? p : ['cond', p, r[0], r[1]]
|
||||
];
|
||||
|
||||
var assign_op = OR([['*=', () => 'mulassign'],
|
||||
['=', () => 'assign']]);
|
||||
var assign_op = OR([
|
||||
['*=', () => 'mulassign'],
|
||||
['=', () => 'assign']
|
||||
]);
|
||||
|
||||
// TODO: Figure out how not to re-parse a unary_e.
|
||||
// Order matters - cond_e can't go first since cond_e will succeed on, e.g. 'a'.
|
||||
assignment_e.def = OR([[unary_e, assign_op, assignment_e,
|
||||
(u, op, a) => [op, u, a]],
|
||||
cond_e]);
|
||||
assignment_e.def = OR([
|
||||
[
|
||||
unary_e,
|
||||
assign_op,
|
||||
assignment_e,
|
||||
(u, op, a) => [op, u, a]
|
||||
],
|
||||
cond_e
|
||||
]);
|
||||
|
||||
expression.def = [assignment_e,
|
||||
MANY([',', assignment_e, binary('comma')], min:0),
|
||||
reform];
|
||||
expression.def = [
|
||||
assignment_e,
|
||||
MANY([',', assignment_e, binary('comma')], min: 0),
|
||||
reform
|
||||
];
|
||||
|
||||
show(g, expression, 'a');
|
||||
check(g, expression, 'a', 'a');
|
||||
check(g, expression, '(a)', 'a');
|
||||
check(g, expression, ' ( ( a ) ) ', 'a');
|
||||
|
||||
check(g, expression, 'a(~1,2)', '[apply,a,[[not,1],2]]');
|
||||
check(g, expression, 'a(~1,2)', '[apply,a,[[not,1],2]]');
|
||||
check(g, expression, 'a(1)(x,2)', '[apply,[apply,a,[1]],[x,2]]');
|
||||
check(g, expression, 'a(1,2())', '[apply,a,[1,[apply,2,[]]]]');
|
||||
|
||||
|
@ -271,22 +327,20 @@ testC() {
|
|||
check(g, expression, 'a<1&&b', '[and,[lt,a,1],b]');
|
||||
|
||||
check(g, expression, 'a<1 & &b', '[bitand,[lt,a,1],[address,b]]');
|
||||
check(g, expression,
|
||||
'a ? b ? c : d : e ? f : g',
|
||||
'[cond,a,[cond,b,c,d],[cond,e,f,g]]');
|
||||
check(g, expression, 'a ? b ? c : d : e ? f : g',
|
||||
'[cond,a,[cond,b,c,d],[cond,e,f,g]]');
|
||||
|
||||
check(g, expression, 'a,b,c', '[comma,[comma,a,b],c]');
|
||||
check(g, expression, 'a=1,b,c', '[comma,[comma,[assign,a,1],b],c]');
|
||||
|
||||
check(g, expression,
|
||||
'((((((((((((a))))))))))))=1,b,c', '[comma,[comma,[assign,a,1],b],c]');
|
||||
check(g, expression, '((((((((((((a))))))))))))=1,b,c',
|
||||
'[comma,[comma,[assign,a,1],b],c]');
|
||||
|
||||
check(g, expression, 'sizeof a', '[sizeof-expr,a]');
|
||||
check(g, expression, 'sizeofa', 'sizeofa');
|
||||
check(g, expression, 'sizeof (a)', '[sizeof-expr,a]');
|
||||
}
|
||||
|
||||
|
||||
show(grammar, rule, input) {
|
||||
print('show: "$input"');
|
||||
var ast;
|
||||
|
@ -313,13 +367,11 @@ void check(grammar, rule, input, expected) {
|
|||
}
|
||||
|
||||
var formatted = ast;
|
||||
if (expected is String)
|
||||
formatted = printList(ast);
|
||||
if (expected is String) formatted = printList(ast);
|
||||
|
||||
//Expect.equals(expected, formatted, "parse: $input");
|
||||
if (expected != formatted) {
|
||||
throw new ArgumentError(
|
||||
"parse: $input"
|
||||
throw new ArgumentError("parse: $input"
|
||||
"\n expected: $expected"
|
||||
"\n found: $formatted");
|
||||
}
|
||||
|
@ -339,8 +391,7 @@ printList(item) {
|
|||
sb.write(']');
|
||||
return sb.toString();
|
||||
}
|
||||
if (item == null)
|
||||
return 'null';
|
||||
if (item == null) return 'null';
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,4 +21,3 @@ main() {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,18 +12,17 @@ main() {
|
|||
var get = (String what, int code, String text) {
|
||||
var c = new Completer();
|
||||
HttpClient client = new HttpClient();
|
||||
client.getUrl(Uri.parse("http://127.0.0.1:3456/$what"))
|
||||
.then((HttpClientRequest request) {
|
||||
client
|
||||
.getUrl(Uri.parse("http://127.0.0.1:3456/$what"))
|
||||
.then((HttpClientRequest request) {
|
||||
// Prepare the request then call close on it to send it.
|
||||
return request.close();
|
||||
})
|
||||
.then((HttpClientResponse response) {
|
||||
}).then((HttpClientResponse response) {
|
||||
// Process the response.
|
||||
expect(response.statusCode, code);
|
||||
var sb = new StringBuffer();
|
||||
response.transform(UTF8.decoder)
|
||||
.listen((data) {
|
||||
sb.write(data);
|
||||
response.transform(UTF8.decoder).listen((data) {
|
||||
sb.write(data);
|
||||
}, onDone: () {
|
||||
expect(sb.toString(), text);
|
||||
c.complete();
|
||||
|
@ -38,4 +37,3 @@ main() {
|
|||
return get('fail.txt', 404, "");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -14,4 +14,3 @@ main() {
|
|||
document.body.nodes.add(lbl);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -21,4 +21,3 @@ main() {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,3 @@ main() {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import 'package:unittest/unittest.dart';
|
|||
var dart;
|
||||
var debug = false;
|
||||
|
||||
Future runTestrunner(command, List<String> args,
|
||||
List<String> stdout, List<String> stderr) {
|
||||
Future runTestrunner(
|
||||
command, List<String> args, List<String> stdout, List<String> stderr) {
|
||||
if (debug) {
|
||||
print("Running $command ${args.join(' ')}");
|
||||
}
|
||||
|
@ -20,8 +20,7 @@ Future runTestrunner(command, List<String> args,
|
|||
var lineEndings = new RegExp("\r\n|\n");
|
||||
stdout.addAll(result.stdout.trim().split(lineEndings));
|
||||
stderr.addAll(result.stderr.trim().split(lineEndings));
|
||||
})
|
||||
.catchError((e) {
|
||||
}).catchError((e) {
|
||||
stderr.add("Error starting process:");
|
||||
stderr.add(" Command: $command");
|
||||
stderr.add(" Error: ${e}");
|
||||
|
@ -33,22 +32,21 @@ Future runTestrunner(command, List<String> args,
|
|||
void dump(label, list) {
|
||||
if (!debug) return;
|
||||
print('\n@=[ $label ]=============================\n');
|
||||
for (var i = 0; i < list.length; i++)
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
print('@ ${list[i]}\n');
|
||||
}
|
||||
print('------------------------------------------\n');
|
||||
}
|
||||
|
||||
int stringCompare(String s1, String s2) => s1.compareTo(s2);
|
||||
|
||||
Future runTest(
|
||||
List<String> args,
|
||||
List<String> expected_stdout,
|
||||
Future runTest(List<String> args, List<String> expected_stdout,
|
||||
{List<String> expected_stderr, sort: false}) {
|
||||
var stdout = new List<String>();
|
||||
var stderr = new List<String>();
|
||||
for (var i = 0; i < expected_stdout.length; i++) {
|
||||
expected_stdout[i] = expected_stdout[i].
|
||||
replaceAll('/', Platform.pathSeparator);
|
||||
expected_stdout[i] =
|
||||
expected_stdout[i].replaceAll('/', Platform.pathSeparator);
|
||||
}
|
||||
if (debug) {
|
||||
args.insert(1, "--log=stderr");
|
||||
|
@ -79,12 +77,12 @@ Future runTest(
|
|||
if (expected_stdout[l].startsWith('*')) {
|
||||
expect(actual, endsWith(expected_stdout[l].substring(1)));
|
||||
} else if (expected_stdout[l].startsWith('?')) {
|
||||
var pat = expected_stdout[l].substring(1);
|
||||
if (Platform.operatingSystem == 'windows') {
|
||||
// The joys of Windows...
|
||||
pat = pat.replaceAll('\\','\\\\');
|
||||
var pat = expected_stdout[l].substring(1);
|
||||
if (Platform.operatingSystem == 'windows') {
|
||||
// The joys of Windows...
|
||||
pat = pat.replaceAll('\\', '\\\\');
|
||||
}
|
||||
expect(actual, matches(pat));
|
||||
expect(actual, matches(pat));
|
||||
} else {
|
||||
expect(actual, expected_stdout[l]);
|
||||
}
|
||||
|
@ -100,7 +98,7 @@ Future runTest(
|
|||
|
||||
// A useful function to quickly disable a group of tests; just
|
||||
// replace group() with skip_group().
|
||||
skip_group(_1,_2) {}
|
||||
skip_group(_1, _2) {}
|
||||
|
||||
main() {
|
||||
dart = Platform.executable;
|
||||
|
@ -111,212 +109,236 @@ main() {
|
|||
}
|
||||
var _ = Platform.pathSeparator;
|
||||
var testrunner = '../../testrunner/testrunner.dart'
|
||||
.replaceAll('/', Platform.pathSeparator);
|
||||
.replaceAll('/', Platform.pathSeparator);
|
||||
|
||||
group("list tests", () {
|
||||
test('list file', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--list-files',
|
||||
'non_browser_tests' ],
|
||||
[ '?.*/non_browser_tests/non_browser_test.dart' ]);
|
||||
return runTest([testrunner, '--list-files', 'non_browser_tests'],
|
||||
['?.*/non_browser_tests/non_browser_test.dart']);
|
||||
});
|
||||
test('list files', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--list-files',
|
||||
'--test-file-pattern=.dart\$' ],
|
||||
[ '*browser_tests/web/browser_test.dart',
|
||||
'*http_client_tests/http_client_test.dart',
|
||||
'*layout_tests/web/layout_test.dart',
|
||||
'*non_browser_tests/non_browser_test.dart',
|
||||
'*non_browser_tests/non_browser_toast.dart',
|
||||
'*/testrunner_test.dart' ]
|
||||
);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--list-files',
|
||||
'--test-file-pattern=.dart\$'
|
||||
], [
|
||||
'*browser_tests/web/browser_test.dart',
|
||||
'*http_client_tests/http_client_test.dart',
|
||||
'*layout_tests/web/layout_test.dart',
|
||||
'*non_browser_tests/non_browser_test.dart',
|
||||
'*non_browser_tests/non_browser_toast.dart',
|
||||
'*/testrunner_test.dart'
|
||||
]);
|
||||
});
|
||||
test('list files', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--list-files',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'non_browser_tests' ],
|
||||
[ '*non_browser_tests/non_browser_test.dart',
|
||||
'*non_browser_tests/non_browser_toast.dart' ],
|
||||
sort:true
|
||||
);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--list-files',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'*non_browser_tests/non_browser_test.dart',
|
||||
'*non_browser_tests/non_browser_toast.dart'
|
||||
], sort: true);
|
||||
});
|
||||
test('list groups', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--list-groups',
|
||||
'non_browser_tests' ],
|
||||
[ '*non_browser_tests/non_browser_test.dart group1',
|
||||
'*non_browser_tests/non_browser_test.dart group2']);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--list-groups',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'*non_browser_tests/non_browser_test.dart group1',
|
||||
'*non_browser_tests/non_browser_test.dart group2'
|
||||
]);
|
||||
});
|
||||
test('list tests', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--list-tests',
|
||||
'non_browser_tests' ],
|
||||
[ '*non_browser_tests/non_browser_test.dart group1 test1',
|
||||
'*non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--list-tests',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'*non_browser_tests/non_browser_test.dart group1 test1',
|
||||
'*non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
group("vm", () {
|
||||
test("vm without timing info", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
test("vm with timing info", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--time',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL [0-9.]+s .*/non_browser_tests/non_browser_test.dart group1'
|
||||
' test1 Expected: false',
|
||||
'?PASS [0-9.]+s .*/non_browser_tests/non_browser_test.dart group2'
|
||||
' test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--time',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL [0-9.]+s .*/non_browser_tests/non_browser_test.dart group1'
|
||||
' test1 Expected: false',
|
||||
'?PASS [0-9.]+s .*/non_browser_tests/non_browser_test.dart group2'
|
||||
' test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
group("selection", () {
|
||||
test("--include", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--include=group1',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--include=group1',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
test("--exclude", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--exclude=group1',
|
||||
'non_browser_tests' ],
|
||||
[ '?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
[testrunner, '--recurse', '--exclude=group1', 'non_browser_tests'],
|
||||
['?PASS .*/non_browser_tests/non_browser_test.dart group2 test2']);
|
||||
});
|
||||
|
||||
|
||||
test("test file pattern", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--test-file-pattern=toast',
|
||||
'non_browser_tests' ],
|
||||
[ '?PASS .*/non_browser_tests/non_browser_toast.dart foo bar' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--test-file-pattern=toast',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?PASS .*/non_browser_tests/non_browser_toast.dart foo bar'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
group("stop on failure tests", () {
|
||||
test("without stop", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--tasks=1',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2',
|
||||
'?PASS .*/non_browser_tests/non_browser_toast.dart foo bar' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--tasks=1',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2',
|
||||
'?PASS .*/non_browser_tests/non_browser_toast.dart foo bar'
|
||||
]);
|
||||
});
|
||||
test("with stop", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--tasks=1',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'--stop-on-failure',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--sort',
|
||||
'--tasks=1',
|
||||
'--test-file-pattern=.dart\$',
|
||||
'--stop-on-failure',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
group("output control", () {
|
||||
test("summary test", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--summary',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2',
|
||||
'',
|
||||
'?.*/non_browser_tests/non_browser_test.dart: '
|
||||
'1 PASSED, 1 FAILED, 0 ERRORS' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--summary',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2',
|
||||
'',
|
||||
'?.*/non_browser_tests/non_browser_test.dart: '
|
||||
'1 PASSED, 1 FAILED, 0 ERRORS'
|
||||
]);
|
||||
});
|
||||
|
||||
test('list tests with custom format', () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--list-tests',
|
||||
'--list-format="<FILENAME><TESTNAME>"',
|
||||
'non_browser_tests' ],
|
||||
[ '?.*/non_browser_tests/non_browser_test.dart test1',
|
||||
'?.*/non_browser_tests/non_browser_test.dart test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--list-tests',
|
||||
'--list-format="<FILENAME><TESTNAME>"',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?.*/non_browser_tests/non_browser_test.dart test1',
|
||||
'?.*/non_browser_tests/non_browser_test.dart test2'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
test("custom message formatting", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--pass-format=YIPPEE! <GROUPNAME><TESTNAME>',
|
||||
'--fail-format=EPIC FAIL! <GROUPNAME><TESTNAME>',
|
||||
'non_browser_tests' ],
|
||||
[ 'EPIC FAIL! group1 test1', 'YIPPEE! group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--pass-format=YIPPEE! <GROUPNAME><TESTNAME>',
|
||||
'--fail-format=EPIC FAIL! <GROUPNAME><TESTNAME>',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'EPIC FAIL! group1 test1',
|
||||
'YIPPEE! group2 test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test("checked mode test", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--checked',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
"?FAIL .*/non_browser_tests/non_browser_test.dart group2 test2 "
|
||||
"Caught type 'int' is not a subtype of type 'bool' of 'x'." ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--checked',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
"?FAIL .*/non_browser_tests/non_browser_test.dart group2 test2 "
|
||||
"Caught type 'int' is not a subtype of type 'bool' of 'x'."
|
||||
]);
|
||||
});
|
||||
|
||||
group("browser", () {
|
||||
test("native test", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--runtime=drt-dart',
|
||||
'browser_tests' ],
|
||||
[ '?FAIL .*/browser_tests/web/browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/browser_tests/web/browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--runtime=drt-dart',
|
||||
'browser_tests'
|
||||
], [
|
||||
'?FAIL .*/browser_tests/web/browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/browser_tests/web/browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
test("compiled test", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--runtime=drt-js',
|
||||
'browser_tests' ],
|
||||
[ '?FAIL .*/browser_tests/web/browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/browser_tests/web/browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--runtime=drt-js',
|
||||
'browser_tests'
|
||||
], [
|
||||
'?FAIL .*/browser_tests/web/browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/browser_tests/web/browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -327,33 +349,39 @@ main() {
|
|||
if (f.existsSync()) {
|
||||
f.deleteSync();
|
||||
}
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests' ],
|
||||
[ '?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file'
|
||||
]);
|
||||
});
|
||||
test("create baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'--regenerate',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'--regenerate',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
test("test baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
});
|
||||
group("drt-js", () {
|
||||
|
@ -362,33 +390,39 @@ main() {
|
|||
if (f.existsSync()) {
|
||||
f.deleteSync();
|
||||
}
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests' ],
|
||||
[ '?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file'
|
||||
]);
|
||||
});
|
||||
test("create baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'--regenerate',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'--regenerate',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
test("test baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-text',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -400,33 +434,39 @@ main() {
|
|||
if (f.existsSync()) {
|
||||
f.deleteSync();
|
||||
}
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests' ],
|
||||
[ '?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file'
|
||||
]);
|
||||
});
|
||||
test("create baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'--regenerate',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'--regenerate',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
test("test baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
// TODO(gram): Should add a test that changes a byte of the
|
||||
// expectation .png.
|
||||
|
@ -437,85 +477,98 @@ main() {
|
|||
if (f.existsSync()) {
|
||||
f.deleteSync();
|
||||
}
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests' ],
|
||||
[ '?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?FAIL .*/layout_tests/web/layout_test.dart layout '
|
||||
'No expectation file'
|
||||
]);
|
||||
});
|
||||
test("create baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'--regenerate',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'--regenerate',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
test("test baseline", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests' ],
|
||||
[ '?PASS .*/layout_tests/web/layout_test.dart layout' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--layout-pixel',
|
||||
'layout_tests'
|
||||
], [
|
||||
'?PASS .*/layout_tests/web/layout_test.dart layout'
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group("run in isolate", () {
|
||||
test("vm", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=vm',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=vm',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
test("drt-dart", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-dart',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1'
|
||||
' Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
test("drt-js", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests' ],
|
||||
[ '?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--runtime=drt-js',
|
||||
'--recurse',
|
||||
'--isolate',
|
||||
'non_browser_tests'
|
||||
], [
|
||||
'?FAIL .*/non_browser_tests/non_browser_test.dart group1 test1 '
|
||||
'Expected: false',
|
||||
'?PASS .*/non_browser_tests/non_browser_test.dart group2 test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
group("embedded server", () {
|
||||
test("get test", () {
|
||||
return runTest(
|
||||
[ testrunner,
|
||||
'--recurse',
|
||||
'--server',
|
||||
'--port=3456',
|
||||
'--root=${Directory.current.path}',
|
||||
'http_client_tests' ],
|
||||
[ '?PASS .*/http_client_tests/http_client_test.dart test1',
|
||||
'?PASS .*/http_client_tests/http_client_test.dart test2' ]);
|
||||
return runTest([
|
||||
testrunner,
|
||||
'--recurse',
|
||||
'--server',
|
||||
'--port=3456',
|
||||
'--root=${Directory.current.path}',
|
||||
'http_client_tests'
|
||||
], [
|
||||
'?PASS .*/http_client_tests/http_client_test.dart test1',
|
||||
'?PASS .*/http_client_tests/http_client_test.dart test2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue