This commit is contained in:
Michael Bebenita 2012-07-11 19:31:13 -07:00
Родитель 1685db125e
Коммит f5b0e6d541
4 изменённых файлов: 42 добавлений и 15 удалений

Просмотреть файл

@ -223,6 +223,13 @@
function createAVM2(loadPlayerGlobal, next) {
new BinaryFileReader(avm2Root + "generated/builtin.abc").readAll(null, function (buffer) {
var vm = new AVM2(new Uint8Array(buffer), ALWAYS_INTERPRET);
vm.onConstruct = function (instance, args) {
var ci = instance.public$constructor.classInfo;
print("Creating: " + ci.instanceInfo.name.getQualifiedName() +
", with args: [" + args + "]");
};
if (loadPlayerGlobal) {
new BinaryFileReader(avm2Root + "generated/playerGlobal.swf").readAll(null, function (buffer) {
vm.loadPlayerGlobal(new Uint8Array(buffer));

Просмотреть файл

@ -867,6 +867,10 @@ var Runtime = (function () {
return error;
};
runtime.prototype.notifyConstruct = function notifyConstruct(instance, args) {
return this.domain.vm.notifyConstruct(instance, args);
};
return runtime;
})();

Просмотреть файл

@ -11,6 +11,9 @@ var AVM2 = (function () {
// TODO: this will change when we implement security domains.
this.systemDomain = sysDomain;
this.applicationDomain = new Domain(this, sysDomain, appMode, false);
// Triggered whenever an AS3 class instance is constructed.
this.onConstruct = undefined;
}
AVM2.prototype = {
@ -30,6 +33,9 @@ var AVM2 = (function () {
}
});
Timer.stop();
},
notifyConstruct: function notifyConstruct (instance, args) {
return this.onConstruct ? this.onConstruct(instance, args) : undefined;
}
};

Просмотреть файл

@ -1,5 +1,10 @@
natives.EventDispatcherClass = function EventDispatcherClass(runtime, scope, instance, baseClass) {
var c = new runtime.domain.system.Class("EventDispatcher", instance, Domain.passthroughCallable(instance));
function constructorHook() {
this.d = runtime.notifyConstruct(this, Array.prototype.slice.call(arguments, 0));
return instance.apply(this, arguments);
}
var c = new runtime.domain.system.Class("EventDispatcher", constructorHook, Domain.passthroughCallable(constructorHook));
c.extend(baseClass);
c.nativeStatics = {};
@ -40,66 +45,71 @@ natives.EventDispatcherClass = function EventDispatcherClass(runtime, scope, ins
};
natives.EventClass = function EventClass(runtime, scope, instance, baseClass) {
var c = new runtime.domain.system.Class("Event", instance, Domain.passthroughCallable(instance));
function constructorHook() {
this.d = runtime.notifyConstruct(this, Array.prototype.slice.call(arguments, 0));
return instance.apply(this, arguments);
}
var c = new runtime.domain.system.Class("Event", constructorHook, Domain.passthroughCallable(constructorHook));
c.extend(baseClass);
c.nativeStatics = {
};
c.nativeStatics = {};
c.nativeMethods = {
// ctor :: type:String, bubbles:Boolean, cancelable:Boolean -> void
ctor: function ctor(type, bubbles, cancelable) {
notImplemented("Event.ctor");
notImplemented("Event.ctor");
},
// type :: void -> String
"get type": function type() {
notImplemented("Event.type");
notImplemented("Event.type");
},
// bubbles :: void -> Boolean
"get bubbles": function bubbles() {
notImplemented("Event.bubbles");
notImplemented("Event.bubbles");
},
// cancelable :: void -> Boolean
"get cancelable": function cancelable() {
notImplemented("Event.cancelable");
notImplemented("Event.cancelable");
},
// target :: void -> Object
"get target": function target() {
notImplemented("Event.target");
notImplemented("Event.target");
},
// currentTarget :: void -> Object
"get currentTarget": function currentTarget() {
notImplemented("Event.currentTarget");
notImplemented("Event.currentTarget");
},
// eventPhase :: void -> uint
"get eventPhase": function eventPhase() {
notImplemented("Event.eventPhase");
notImplemented("Event.eventPhase");
},
// stopPropagation :: void -> void
stopPropagation: function stopPropagation() {
notImplemented("Event.stopPropagation");
notImplemented("Event.stopPropagation");
},
// stopImmediatePropagation :: void -> void
stopImmediatePropagation: function stopImmediatePropagation() {
notImplemented("Event.stopImmediatePropagation");
notImplemented("Event.stopImmediatePropagation");
},
// preventDefault :: void -> void
preventDefault: function preventDefault() {
notImplemented("Event.preventDefault");
notImplemented("Event.preventDefault");
},
// isDefaultPrevented :: void -> Boolean
isDefaultPrevented: function isDefaultPrevented() {
notImplemented("Event.isDefaultPrevented");
// notImplemented("Event.isDefaultPrevented");
return Boolean(false);
}
};