Skip to content

Commit

Permalink
Fix quoted method names not getting exported (ie setters)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjv360 committed Dec 24, 2022
1 parent 1854633 commit 72423fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ExternalClassTest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ class ExternalClass:

method testStatic {.static.} = discard

var testCustomSetterValue = 6
method testCustomSetter(): int = this.testCustomSetterValue
method `testCustomSetter=`(v: int) = this.testCustomSetterValue = v

singleton ExternalSingleton:
var v1 = 3
2 changes: 1 addition & 1 deletion classes.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.2.12"
version = "0.2.13"
author = "jjv360"
description = "Adds class support to Nim."
license = "MIT"
Expand Down
8 changes: 4 additions & 4 deletions src/classes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ proc createClassStructure(head: NimNode, bodyNode: NimNode, result: NimNode, isS
# methodNode.pragma.add(newNimNode(nnkPragma).add(ident"base"))

# Make sure it's exported
if methodNode[0].kind == nnkIdent:
if methodNode[0].kind == nnkIdent or methodNode[0].kind == nnkAccQuoted:
methodNode[0] = newTree(nnkPostfix, ident"*", methodNode[0])

# Add it
Expand Down Expand Up @@ -688,7 +688,7 @@ proc createClassStructure(head: NimNode, bodyNode: NimNode, result: NimNode, isS


# Make sure it's exported
if methodNode[0].kind == nnkIdent:
if methodNode[0].kind == nnkIdent or methodNode[0].kind == nnkAccQuoted:
methodNode[0] = newTree(nnkPostfix, ident"*", methodNode[0])

# Add it
Expand Down Expand Up @@ -770,8 +770,8 @@ proc createClassStructure(head: NimNode, bodyNode: NimNode, result: NimNode, isS
return `sharedVarName`
)

# if $className == "AsyncCls":
# echo result.repr
# if $className == "ExternalClass":
# echo result.repr

# Export new keyword which was imported from our lib
# let newIdent = ident"new"
Expand Down
4 changes: 4 additions & 0 deletions test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ let customGetterSetter = CustomGetterSetter.init()
customGetterSetter.v2 = 7
assert(customGetterSetter.v2 == 7)

let externalGetterSetter = ExternalClass.init()
externalGetterSetter.testCustomSetter = 8
assert(externalGetterSetter.testCustomSetter == 8)




Expand Down

0 comments on commit 72423fa

Please sign in to comment.