diff options
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index b7d0f40f4..e48df38f5 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -1582,3 +1582,15 @@ proc getProjectPath*(): string = discard ## Returns the path to the currently compiling project, not to ## be confused with ``system.currentSourcePath`` which returns ## the path of the current module. + +when defined(nimMacrosSizealignof): + proc getSize*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} = + ## Returns the same result as ``system.sizeof``, but it works on + ## ``NimNode`` for use in macro context. + proc getAlign*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} = + ## Returns the same result as ``system.alignof``, but it works on + ## ``NimNode`` for use in macro context. + proc getOffset*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} = + ## Returns the same result as ``system.offsetof``, but it expects + ## a resolved symbol node from a field of a type. Therefore it + ## only requires one argument instead of two. |