Skip to content

Instantly share code, notes, and snippets.

@Skrylar
Created March 24, 2014 13:48
Show Gist options
  • Save Skrylar/9740396 to your computer and use it in GitHub Desktop.
Save Skrylar/9740396 to your computer and use it in GitHub Desktop.
# This works
macro MakeIntoEvent* (etype: typedesc): stmt =
let uid = NextEventTypeUID
Inc(NextEventTypeUID)
debugEcho "DUMP ID #", uid, ": ", repr(etype)
result = quote do:
proc GetEventTypeUid* (
self: typedesc[`etype`]): EventTypeUid {.inline.} =
let x = `uid`
return x
proc GetEventTypeUid* (
self: `etype`): EventTypeUid {.inline.} =
let x = `uid`
return x
# ------
# got (int literal(1)) but expected PNimrodNode
macro MakeIntoEvent* (etype: typedesc): stmt =
let uid = NextEventTypeUID
Inc(NextEventTypeUID)
debugEcho "DUMP ID #", uid, ": ", repr(etype)
result = quote do:
proc GetEventTypeUid* (
self: typedesc[`etype`]): EventTypeUid {.inline.} =
result = `uid`
proc GetEventTypeUid* (
self: `etype`): EventTypeUid {.inline.} =
result = `uid`
# ------
# This ought to work yet doesn't on typedescs
macro MakeIntoEvent* (etype: typedesc): stmt =
let uid = NextEventTypeUID
Inc(NextEventTypeUID)
debugEcho "DUMP ID #", uid, ": ", repr(etype)
result = quote do:
converter ToEventTypeUid* (
self: typedesc[`etype`]): EventTypeUid {.inline.} =
let x = `uid`
return x
converter ToEventTypeUid* (
self: `etype`): EventTypeUid {.inline.} =
let x = `uid`
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment