catvm/CatVm2/browser/MimeType.js
Big1moster d843fcb236 dsf
2023-02-06 11:36:48 +08:00

50 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 存储一些值,避免污染全局变量空间
catvm.memory.mimetype = {};
var MimeType = function MimeType() { // 构造函数
throw new TypeError("Illegal constructor");
};
catvm.safefunction(MimeType);
Object.defineProperties(MimeType.prototype, {
[Symbol.toStringTag]: {
value: "MimeType",
configurable: true
},
});
////////// 浏览器代码自动生成部分
MimeType.prototype.description = "";
MimeType.prototype.enabledPlugin = null;
MimeType.prototype.suffixes = "";
MimeType.prototype.type = "";
for (var _prototype in MimeType.prototype) {
if (typeof (MimeType.prototype[_prototype]) != "function") {
// 相当于Object.defineProperty的get方法Proxy的get方法hook原型上的所有方法属性
MimeType.prototype.__defineGetter__(_prototype, function () {
throw new TypeError("Illegal constructor");
});
}
}
////////
catvm.memory.mimetype.new = function (data,initPlugin) {
var mimetype = {};
if (data != undefined) {
mimetype.description = data.description;
mimetype.enabledPlugin = initPlugin; // plugin实例
mimetype.suffixes = data.suffixes;
mimetype.type = data.type;
}
// 先赋完值,在指向原型
mimetype.__proto__ = MimeType.prototype;
return mimetype;
};
// 代理一般挂在实例上
navigator.plugins = catvm.proxy(navigator.plugins);