diff options
author | Araq <rumpf_a@web.de> | 2012-02-08 22:56:31 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-02-08 22:56:31 +0100 |
commit | f3f3fc01aa4d7ff36c8e5865d5e7a234636c42b8 (patch) | |
tree | c97156b5e0f3d120e0bfa509e93a03392021e104 /lib | |
parent | 2c4a1dbc0c2aa59df920cc42af61675f0bd4be71 (diff) | |
download | Nim-f3f3fc01aa4d7ff36c8e5865d5e7a234636c42b8.tar.gz |
further steps for closure support; added 'system.rawProc', 'system.rawEnv'
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/system.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 55abcaea6..bf9250a81 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -1954,6 +1954,20 @@ when not defined(EcmaScript) and not defined(NimrodVM): proc unlikely*(val: bool): bool {.importc: "unlikely", nodecl, nosideeffect.} ## can be used to mark a condition to be unlikely. This is a hint for the ## optimizer. + + proc rawProc*[T: proc](x: T): pointer {.noSideEffect, inline.} = + ## retrieves the raw proc pointer of the closure `x`. This is + ## useful for interfacing closures with C. + {.emit: """ + `result` = `x`.ClPrc; + """.} + + proc rawEnv*[T: proc](x: T): pointer {.noSideEffect, inline.} = + ## retrieves the raw environment pointer of the closure `x`. This is + ## useful for interfacing closures with C. + {.emit: """ + `result` = `x`.ClEnv; + """.} elif defined(ecmaScript) or defined(NimrodVM): # Stubs: |