A lot of Windows APIs accept "pointer to some structure" as parameters, for 
example (in C source): 
    
    
    MSG msg;
    GetMessage(&msg, 0, 0, 0);
    
    
    Run

How to convert this code to nim? 
    
    
    var msg: MSG
    GetMessage(addr msg, 0, 0, 0)
    
    
    Run

Ok, it is easy to understand. The only problem is that I am too lazy to add 
"addr" before each parameter. So with that converter, I can just write: 
    
    
    var msg: MSG
    GetMessage(msg, 0, 0, 0)
    
    
    Run

This is the reason why the converter exists.

Ps. Technically speaking, I add this converter is because that I want make 
winim be compatible with winlean.nim. In winlean, this kind of parameters often 
are "var parameter", but winim follow the SDK definition so they are just "ptr 
object". For example:
    
    
    # winlean
    proc getSystemTimes*(lpIdleTime, lpKernelTime, lpUserTime: var FILETIME): 
WINBOOL
    
    # winim
    proc GetSystemTimes*(lpIdleTime, lpKernelTime, lpUserTime: ptr FILETIME): 
WINBOOL
    
    
    Run

Reply via email to