We have the byRef pragma which we can use to pass Nim value objects as pointers 
to C libs without having to use ugly addr operator.
    
    
    grep -A2 byRef ~/.nimble/pkgs/gintro-#head/gintro/gtk4.nim
      TreeIter* {.pure, byRef.} = object
        stamp*: int32
        userData*: pointer
    --
      TextIter* {.pure, byRef.} = object
        dummy1*: pointer
        dummy2*: pointer
    --
      Requisition* {.pure, byRef.} = object
        width*: int32
        height*: int32
    --
      Border* {.pure, byRef.} = object
        left*: int16
        right*: int16
    --
      PageRange* {.pure, byRef.} = object
        start*: int32
        `end`*: int32
    
    
    Run

So we can allocate these simple structs on the stack and pass it directly to C 
libs. (Well I guess the pure pragma is not needed in this case, as Nim objects 
without inheritance have no hidden fields.)

Reply via email to