TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
454 stars 142 forks source link

How can I cast a pointer to Int32? #23

Closed kimmking closed 9 years ago

kimmking commented 9 years ago

I use ref and ffi to process a win32

var WndProc = ffi.Callback('uint32', ['pointer', 'uint32', 'pointer', 'pointer'], function(hwnd, uMsg, wParam, lParam) { ...

The third param 'wParam' actually in win32 api : typedef UINT_PTR WPARAM; Here If I set it to pointer type can work in some event-process like as follow, others DefWindowProc process can't work:

gdi32.SetTextColor(wParam,0x0080ff);

If I set it to int32 type, then SetTextColor can't work, but DefWindowProc will be ok.

How can I cast a pointer to Int32 or Int32 to pointer?

TooTallNate commented 9 years ago

Do uint * as the type, and then call wParam.deref() to get the dereferenced int value in JavaScript. Hope that helps!