Skip to content

Commit

Permalink
Remove redundant static subscripts on attributes (#44)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaxDesiatov authored May 26, 2022
1 parent 78ca09c commit 8328d41
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 232 deletions.
11 changes: 1 addition & 10 deletions Sources/ECMAScript/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import JavaScriptKit
}

@inlinable public var wrappedValue: Wrapped {
get { ReadWriteAttribute[name, in: jsObject] }
nonmutating set { ReadWriteAttribute[name, in: jsObject] = newValue }
}

@inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped {
get { jsObject[name].fromJSValue()! }
set { jsObject[name] = newValue.jsValue }
nonmutating set { jsObject[name] = newValue.jsValue }
}
}

Expand All @@ -30,10 +25,6 @@ import JavaScriptKit
}

@inlinable public var wrappedValue: Wrapped {
ReadonlyAttribute[name, in: jsObject]
}

@inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped {
jsObject[name].fromJSValue()!
}
}
Loading

0 comments on commit 8328d41

Please sign in to comment.