type
Client = object
proc connect*(client: var Client, server, username, password: cstring) {.exportc.} =
discard
when i call connect from js i have to do this:
var c = newClient()
connect(c, "server", "user", "pw");
what must i do to call it like so:
var c = newClient()
c.connect("server", "user", "pw");
Best I could come up with
import jsffi
type
Client = object
connect {.exportc.}: proc (server, username, password: cstring)
proc connect*(client: var Client, server, username, password: cstring) =
discard
proc newClient*(): Client {.exportc.} =
result = Client{}
result.connect = proc (server, username, password: cstring) =
connect(self, server, username, password)
Are you sure it's worth it? I don't think JS output is supposed to be used in actual JS