зеркало из https://github.com/mozilla/shumway.git
Hook up the inspector with avm2.
This commit is contained in:
Родитель
1ad26524f5
Коммит
d37f7af9dc
|
@ -150,7 +150,10 @@
|
|||
function readFile(file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function() {
|
||||
SWF.embed(this.result, stage[0]);
|
||||
var result = this.result;
|
||||
createAVM2(true, function (avm2) {
|
||||
SWF.embed(result, stage[0], {avm2: avm2});
|
||||
});
|
||||
}
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
|
@ -201,83 +204,41 @@
|
|||
return constructor;
|
||||
})();
|
||||
|
||||
var avm2Root = "../../src/avm2/"
|
||||
|
||||
function runAVM2(file) {
|
||||
var avm2;
|
||||
var loadPlayerGlobal = true;
|
||||
var queue = [];
|
||||
|
||||
/**
|
||||
* Chain together a bunch of I/O callbacks to intialize AVM2.
|
||||
*/
|
||||
|
||||
queue.push(function () {
|
||||
new BinaryFileReader(avm2Root + "generated/builtin.abc").readAll(null, function (buffer) {
|
||||
avm2 = new AVM2(new Uint8Array(buffer), ALWAYS_INTERPRET);
|
||||
executeNext();
|
||||
});
|
||||
});
|
||||
|
||||
if (loadPlayerGlobal) {
|
||||
queue.push(function () {
|
||||
function createAVM2(loadPlayerGlobal, next) {
|
||||
new BinaryFileReader(avm2Root + "generated/builtin.abc").readAll(null, function (buffer) {
|
||||
var vm = new AVM2(new Uint8Array(buffer), ALWAYS_INTERPRET);
|
||||
if (loadPlayerGlobal) {
|
||||
new BinaryFileReader(avm2Root + "generated/playerGlobal.swf").readAll(null, function (buffer) {
|
||||
avm2.loadPlayerGlobal(new Uint8Array(buffer));
|
||||
executeNext();
|
||||
vm.loadPlayerGlobal(new Uint8Array(buffer));
|
||||
next(vm);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: This needs to be hooked in the Loader somewhere.
|
||||
|
||||
if (file.endsWith(".swf")) {
|
||||
queue.push(function() {
|
||||
new BinaryFileReader(file).readAll(null, function(buffer) {
|
||||
SWF.parse(new Uint8Array(buffer), {
|
||||
oncomplete: function(result) {
|
||||
var tags = result.tags;
|
||||
for (var i = 0, n = tags.length; i < n; i++) {
|
||||
var tag = tags[i];
|
||||
if (tag.type === "abc") {
|
||||
avm2.applicationDomain.loadAbc(new AbcFile(tag.data, "playerGlobal/library" + i + ".abc"));
|
||||
} else if (tag.type === "symbols") {
|
||||
for (var j = tag.references.length - 1; j >= 0; j--) {
|
||||
if (tag.references[j].id === 0) {
|
||||
avm2.applicationDomain.getProperty(
|
||||
Multiname.fromSimpleName(tag.references[j].name),
|
||||
true, true
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
executeNext();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
queue.push(function () {
|
||||
new BinaryFileReader(file).readAll(null, function (buffer) {
|
||||
avm2.applicationDomain.executeAbc(new AbcFile(new Uint8Array(buffer), file, true));
|
||||
executeNext();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function executeNext() {
|
||||
if (queue.length === 0) {
|
||||
return;
|
||||
} else {
|
||||
next(vm);
|
||||
}
|
||||
queue.shift()();
|
||||
}
|
||||
|
||||
executeNext();
|
||||
});
|
||||
}
|
||||
|
||||
var avm2Root = "../../src/avm2/";
|
||||
var file = getQueryVariable("file");
|
||||
|
||||
/**
|
||||
* You can also specify the file as a query string parameters, ?file=... to load it automatically when the
|
||||
* page loads.
|
||||
*/
|
||||
if (file) {
|
||||
runAVM2(file || avm2Root + "tests/watch.swf");
|
||||
if (file.endsWith(".abc")) {
|
||||
createAVM2(true, function(avm2) {
|
||||
new BinaryFileReader(file).readAll(null, function(buffer) {
|
||||
avm2.applicationDomain.executeAbc(new AbcFile(new Uint8Array(buffer), file, true));
|
||||
});
|
||||
});
|
||||
} else if (file.endsWith(".swf")) {
|
||||
createAVM2(true, function(avm2) {
|
||||
new BinaryFileReader(file).readAll(null, function(buffer) {
|
||||
SWF.embed(buffer, $("#stage")[0], {avm2: avm2});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
function Loader() {
|
||||
function Loader(parameters) {
|
||||
this.avm1 = parameters.avm1;
|
||||
this.avm2 = parameters.avm2;
|
||||
this._dictionary = new ObjDictionary;
|
||||
}
|
||||
|
||||
Loader.SCRIPT_PATH = './Loader.js';
|
||||
Loader.WORKERS_ENABLED = true;
|
||||
Loader.WORKERS_ENABLED = false;
|
||||
Loader.WORKER_SCRIPTS = [
|
||||
'../../../lib/DataView.js/DataView.js',
|
||||
|
||||
|
@ -212,8 +214,7 @@ Loader.prototype = Object.create(baseProto, {
|
|||
var i = 0;
|
||||
var block;
|
||||
while (block = blocks[i++]) {
|
||||
var abc = new AbcFile(block);
|
||||
executeAbc(abc, ALWAYS_INTERPRET);
|
||||
this.avm2.applicationDomain.executeAbc(new AbcFile(block, file, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ Stage.prototype = Object.create(new DisplayObjectContainer, {
|
|||
_attachToCanvas: descMethod(function(parameters) {
|
||||
var canvas = parameters.canvas;
|
||||
var ctx = canvas.getContext('2d');
|
||||
var loader = new Loader();
|
||||
var loader = new Loader({ avm1: undefined, avm2: parameters.avm2 });
|
||||
var loaderInfo = loader.contentLoaderInfo;
|
||||
var stage = this;
|
||||
var isPlaying = false;
|
||||
|
|
|
@ -15,6 +15,8 @@ SWF.embed = function(file, container, options) {
|
|||
stage._attachToCanvas({
|
||||
canvas: canvas,
|
||||
file: file,
|
||||
avm1: options.avm1,
|
||||
avm2: options.avm2,
|
||||
|
||||
onstart: function(root, stage) {
|
||||
if (container.clientHeight) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче