-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathDescriptorSet.ts
More file actions
28 lines (24 loc) · 906 Bytes
/
DescriptorSet.ts
File metadata and controls
28 lines (24 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const getmetatable = _G.getmetatable;
const rawget = _G.rawget;
const rawset = _G.rawset;
export function __TS__DescriptorSet(this: any, metatable: any, key: string, value: any): void {
while (metatable) {
const descriptors = rawget(metatable, "_descriptors");
if (descriptors) {
const descriptor: PropertyDescriptor = descriptors[key];
if (descriptor !== undefined) {
if (descriptor.set) {
descriptor.set.call(this, value);
} else {
if (descriptor.writable === false) {
throw `Cannot assign to read only property '${key}' of object '${this}'`;
}
descriptor.value = value;
}
return;
}
}
metatable = getmetatable(metatable);
}
rawset(this, key, value);
}