summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system.nim')
-rwxr-xr-xlib/system.nim14
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: