Skip to content

Commit 8328d41

Browse files
authored
Remove redundant static subscripts on attributes (#44)
Some properties in generated code have a layer of indirection due to their use of `ReadonlyAttribute` and `ReadWriteAttribute`. There's little value in keeping these static subscripts around and introducing the indirection. Additionally, it makes makes some issues on property code hard to debug when attempting to change union types generation logic in my investigation of #43.
1 parent 78ca09c commit 8328d41

File tree

4 files changed

+242
-232
lines changed

4 files changed

+242
-232
lines changed

Sources/ECMAScript/Attributes.swift

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ import JavaScriptKit
1010
}
1111

1212
@inlinable public var wrappedValue: Wrapped {
13-
get { ReadWriteAttribute[name, in: jsObject] }
14-
nonmutating set { ReadWriteAttribute[name, in: jsObject] = newValue }
15-
}
16-
17-
@inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped {
1813
get { jsObject[name].fromJSValue()! }
19-
set { jsObject[name] = newValue.jsValue }
14+
nonmutating set { jsObject[name] = newValue.jsValue }
2015
}
2116
}
2217

@@ -30,10 +25,6 @@ import JavaScriptKit
3025
}
3126

3227
@inlinable public var wrappedValue: Wrapped {
33-
ReadonlyAttribute[name, in: jsObject]
34-
}
35-
36-
@inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped {
3728
jsObject[name].fromJSValue()!
3829
}
3930
}

0 commit comments

Comments
 (0)