@awayfl/avm2
Version:
Virtual machine for executing AS3 code
190 lines (189 loc) • 6.75 kB
JavaScript
/*
* Copyright 2014 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { __extends } from "tslib";
import { axCoerceString } from '../run/axCoerceString';
import { release, warning, somewhatImplemented, defineNonEnumerableProperty, ClipboardService } from '@awayfl/swf-loader';
import { ASObject } from '../nat/ASObject';
import { initializeBuiltins } from '../nat/initializeBuiltins';
var IME = /** @class */ (function (_super) {
__extends(IME, _super); /* flash.events.EventDispatcher */
function IME() {
return _super.call(this) || this;
}
Object.defineProperty(IME, "enabled", {
get: function () {
release || release || somewhatImplemented('public flash.system.IME::static get enabled');
return false;
},
set: function (enabled) {
release || release || somewhatImplemented('public flash.system.IME::static set enabled');
enabled = !!enabled;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IME, "conversionMode", {
get: function () {
release || somewhatImplemented('public flash.system.IME::static get conversionMode');
return 'UNKNOWN';
},
set: function (mode) {
mode = axCoerceString(mode);
release || somewhatImplemented('public flash.system.IME::static set conversionMode');
},
enumerable: false,
configurable: true
});
IME.setCompositionString = function (composition) {
composition = axCoerceString(composition);
release || somewhatImplemented('public flash.system.IME::static setCompositionString');
};
IME.doConversion = function () {
release || somewhatImplemented('public flash.system.IME::static doConversion');
};
IME.compositionSelectionChanged = function (start /*int*/, end /*int*/) {
start = start | 0;
end = end | 0;
release || somewhatImplemented('public flash.system.IME::static compositionSelectionChanged');
};
IME.compositionAbandoned = function () {
release || somewhatImplemented('public flash.system.IME::static compositionAbandoned');
};
Object.defineProperty(IME, "isSupported", {
get: function () {
release || somewhatImplemented('public flash.system.IME::static get isSupported');
return false;
},
enumerable: false,
configurable: true
});
return IME;
}(ASObject /* flash.events.EventDispatcher */));
export { IME };
var System = /** @class */ (function (_super) {
__extends(System, _super);
function System() {
return _super !== null && _super.apply(this, arguments) || this;
}
System.classInitializer = function () {
defineNonEnumerableProperty(this, '$Bgargv', this.sec.createArray([]));
};
Object.defineProperty(System, "ime", {
get: function () {
release || somewhatImplemented('public flash.system.System::get ime');
return null;
},
enumerable: false,
configurable: true
});
System.setClipboard = function (string) {
string = axCoerceString(string);
if (ClipboardService === null) {
warning('setClipboard is only available in the Firefox extension');
return;
}
ClipboardService.setClipboard(string);
};
Object.defineProperty(System, "totalMemoryNumber", {
get: function () {
release || somewhatImplemented('public flash.system.System::get totalMemoryNumber');
return 1024 * 1024 * 2;
},
enumerable: false,
configurable: true
});
Object.defineProperty(System, "freeMemory", {
get: function () {
release || somewhatImplemented('public flash.system.System::get freeMemory');
return 1024 * 1024;
},
enumerable: false,
configurable: true
});
Object.defineProperty(System, "privateMemory", {
get: function () {
release || somewhatImplemented('public flash.system.System::get privateMemory');
return 1024 * 1024;
},
enumerable: false,
configurable: true
});
Object.defineProperty(System, "useCodePage", {
get: function () {
return this._useCodePage;
},
set: function (value) {
release || somewhatImplemented('public flash.system.System::set useCodePage');
this._useCodePage = !!value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(System, "vmVersion", {
get: function () {
return '1.0 Shumway - Mozilla Research';
},
enumerable: false,
configurable: true
});
System.pause = function () {
// Debugging-only function we can just ignore.
};
System.resume = function () {
// Debugging-only function we can just ignore.
};
System.exit = function (code /*uint*/) {
// Debugging-only function we can just ignore.
};
System.gc = function () {
// Debugging-only function we can just ignore.
};
System.pauseForGCIfCollectionImminent = function (imminence) {
if (imminence === void 0) { imminence = 0.75; }
// Not gonna happen, probably ever.
};
System.disposeXML = function (node) {
// We have a cycle collector, so we can ignore this. \o/
};
Object.defineProperty(System, "swfVersion", {
get: function () {
return 19;
},
enumerable: false,
configurable: true
});
Object.defineProperty(System, "apiVersion", {
get: function () {
return 26;
},
enumerable: false,
configurable: true
});
System.getArgv = function () {
return [];
};
System.getRunmode = function () {
return 'mixed';
};
System._useCodePage = false;
return System;
}(ASObject));
export { System };
export var OriginalSystem = System;
export function initSystem() {
// Do this here temporarily until we find a nicer place.
initializeBuiltins();
}