MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / ViewMixin

Function ViewMixin

g2all/900/module/view.js:38–94  ·  view source on GitHub ↗
(superclass)

Source from the content-addressed store, hash-verified

36// get_view_vector() still works on them.
37
38function ViewMixin(superclass) {
39 const res = class extends superclass {
40 constructor(...args) {
41 super(...args);
42 this.buffer;
43 }
44
45 get addr() {
46 let res = this._addr_cache;
47 if (res !== undefined) {
48 return res;
49 }
50 res = mt.get_view_vector(this);
51 this._addr_cache = res;
52 return res;
53 }
54
55 get size() {
56 return this.byteLength;
57 }
58
59 addr_at(index) {
60 const size = this.BYTES_PER_ELEMENT;
61 return this.addr.add(index * size);
62 }
63
64 sget(index) {
65 return this[index] | 0;
66 }
67 };
68
69 // workaround for known affected versions: ps4 [6.00, 10.00)
70 //
71 // see from() and of() from
72 // WebKit/Source/JavaScriptCore/builtins/TypedArrayConstructor.js at PS4
73 // 8.0x
74 //
75 // @getByIdDirectPrivate(this, "allocateTypedArray") will fail when "this"
76 // isn't one of the built-in TypedArrays. this is a violation of the
77 // ECMAScript spec at that time
78 //
79 // TODO assumes ps4, support ps5 as well
80 // FIXME define the from/of workaround functions once
81 if (0x600 <= config.target && config.target < 0x1000) {
82 res.from = function from(...args) {
83 const base = this.__proto__;
84 return new this(base.from(...args).buffer);
85 };
86
87 res.of = function of(...args) {
88 const base = this.__proto__;
89 return new this(base.of(...args).buffer);
90 };
91 }
92
93 return res;
94}
95

Callers 3

View1Class · 0.70
View2Class · 0.70
View4Class · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected