Skip to content

Commit

Permalink
Support globals with explicit getters/setters (#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe authored Nov 19, 2024
1 parent b2aca7e commit 9b8d79b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ GlobalVariableDeclaration parseGlobalVariableDeclaration(
ParsedSymbolgraph symbolgraph, {
bool isStatic = false,
}) {
final isConstant = _parseVariableIsConstant(variableSymbolJson);
final hasSetter = _parsePropertyHasSetter(variableSymbolJson);
return GlobalVariableDeclaration(
id: parseSymbolId(variableSymbolJson),
name: parseSymbolName(variableSymbolJson),
type: _parseVariableType(variableSymbolJson, symbolgraph),
isConstant: _parseVariableIsConstant(variableSymbolJson),
isConstant: isConstant || !hasSetter,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public let globalRepresentableConstant = 1
public var globalCustomVariable = MyOtherClass()
public let globalCustomConstant = MyOtherClass()

public var globalGetterVariable: Double { get { 123 } }
public var globalSetterVariable: Double { get { 123 } set {} }

public func globalCustomFunction(label1 param1: Int, param2: MyOtherClass) -> MyOtherClass {
return MyOtherClass()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ import Foundation
}
}

@objc static public var globalGetterVariableWrapper: Double {
get {
globalGetterVariable
}
}

@objc static public var globalSetterVariableWrapper: Double {
get {
globalSetterVariable
}
set {
globalSetterVariable = newValue
}
}

@objc static public var globalRepresentableConstantWrapper: Int {
get {
globalRepresentableConstant
Expand Down

0 comments on commit 9b8d79b

Please sign in to comment.