Skip to content

Commit

Permalink
fix a bug with generating static properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad3id committed Oct 5, 2024
1 parent 3e42af5 commit bb95a1f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,15 @@ List<String> _generateClassProperties(ClassDeclaration declaration) {
return declaration.properties.map(
(property) {
final header = StringBuffer();

if (property.hasObjCAnnotation) {
header.write('@objc ');
}

if (property.isStatic) {
header.write('static ');
}

header.write('public var ${property.name}: ${property.type.name} {');

final getterLines = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import Foundation
@objc public class MyClassWrapper: NSObject {
var wrappedInstance: MyClass

@objc public var customGetterVariable: MyOtherClassWrapper {
@objc static public var customGetterVariable: MyOtherClassWrapper {
get {
MyOtherClassWrapper(MyClass.customGetterVariable)
}
}

@objc public var customSetterVariable: MyOtherClassWrapper {
@objc static public var customSetterVariable: MyOtherClassWrapper {
get {
MyOtherClassWrapper(MyClass.customSetterVariable)
}
Expand All @@ -28,13 +28,13 @@ import Foundation
}
}

@objc public var customConstantProperty: MyOtherClassWrapper {
@objc static public var customConstantProperty: MyOtherClassWrapper {
get {
MyOtherClassWrapper(MyClass.customConstantProperty)
}
}

@objc public var customVariableProperty: MyOtherClassWrapper {
@objc static public var customVariableProperty: MyOtherClassWrapper {
get {
MyOtherClassWrapper(MyClass.customVariableProperty)
}
Expand All @@ -43,13 +43,13 @@ import Foundation
}
}

@objc public var representableGetterVariable: Int {
@objc static public var representableGetterVariable: Int {
get {
MyClass.representableGetterVariable
}
}

@objc public var representableSetterVariable: Int {
@objc static public var representableSetterVariable: Int {
get {
MyClass.representableSetterVariable
}
Expand All @@ -58,13 +58,13 @@ import Foundation
}
}

@objc public var representableConstantProperty: Int {
@objc static public var representableConstantProperty: Int {
get {
MyClass.representableConstantProperty
}
}

@objc public var representableVariableProperty: Int {
@objc static public var representableVariableProperty: Int {
get {
MyClass.representableVariableProperty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import Foundation

@objc public class GlobalsWrapper: NSObject {
@objc public var globalCustomConstantWrapper: MyOtherClassWrapper {
@objc static public var globalCustomConstantWrapper: MyOtherClassWrapper {
get {
MyOtherClassWrapper(globalCustomConstant)
}
}

@objc public var globalCustomVariableWrapper: MyOtherClassWrapper {
@objc static public var globalCustomVariableWrapper: MyOtherClassWrapper {
get {
MyOtherClassWrapper(globalCustomVariable)
}
Expand All @@ -18,13 +18,13 @@ import Foundation
}
}

@objc public var globalRepresentableConstantWrapper: Int {
@objc static public var globalRepresentableConstantWrapper: Int {
get {
globalRepresentableConstant
}
}

@objc public var globalRepresentableVariableWrapper: Int {
@objc static public var globalRepresentableVariableWrapper: Int {
get {
globalRepresentableVariable
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import Foundation
@objc public class MyStructWrapper: NSObject {
var wrappedInstance: MyStruct

@objc public var customGetterVariable: MyOtherStructWrapper {
@objc static public var customGetterVariable: MyOtherStructWrapper {
get {
MyOtherStructWrapper(MyStruct.customGetterVariable)
}
}

@objc public var customSetterVariable: MyOtherStructWrapper {
@objc static public var customSetterVariable: MyOtherStructWrapper {
get {
MyOtherStructWrapper(MyStruct.customSetterVariable)
}
Expand All @@ -28,13 +28,13 @@ import Foundation
}
}

@objc public var customConstantProperty: MyOtherStructWrapper {
@objc static public var customConstantProperty: MyOtherStructWrapper {
get {
MyOtherStructWrapper(MyStruct.customConstantProperty)
}
}

@objc public var customVariableProperty: MyOtherStructWrapper {
@objc static public var customVariableProperty: MyOtherStructWrapper {
get {
MyOtherStructWrapper(MyStruct.customVariableProperty)
}
Expand All @@ -43,13 +43,13 @@ import Foundation
}
}

@objc public var representableGetterVariable: Int {
@objc static public var representableGetterVariable: Int {
get {
MyStruct.representableGetterVariable
}
}

@objc public var representableSetterVariable: Int {
@objc static public var representableSetterVariable: Int {
get {
MyStruct.representableSetterVariable
}
Expand All @@ -58,13 +58,13 @@ import Foundation
}
}

@objc public var representableConstantProperty: Int {
@objc static public var representableConstantProperty: Int {
get {
MyStruct.representableConstantProperty
}
}

@objc public var representableVariableProperty: Int {
@objc static public var representableVariableProperty: Int {
get {
MyStruct.representableVariableProperty
}
Expand Down

0 comments on commit bb95a1f

Please sign in to comment.