Re: Window API Coding
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 13, 2002
- 409 views
Thanks for your thoughts Matt. This is a really really low priority item on my list, but I'll keep a copy of your note just in case somebody ever gets around to the DLL idea on day. ---------------- cheers, Derek Parnell ----- Original Message ----- From: "Matthew Lewis" <matthewwalkerlewis at YAHOO.COM> To: "EUforum" <EUforum at topica.com> Subject: RE: Window API Coding > > > > From: Derek Parnell [mailto:ddparnell at bigpond.com] > > > I'd love to make win32lib a DLL one day, but first we have to > > get over the routine_id passing issue > > that presents. > > I've never really bought into the win32lib as dll idea, for a couple of > reasons--these are mainly doubts that could quite likely be proven wrong. > We would still need some wrapper, unless you want to subject people to > c_func, et. al. all over the place. Given that, I'm not sure how much of a > speedup you'd be likely to see, at least in general. There are perhaps a > few routines that would see significant enough increases in speed to > overcome the additional layer of overhead. Besides, part of the appeal of > win32lib (to me, at least) is that its native code, no dll required (yeah, > yeah, but everyone needs to use the windows dlls to function, so they don't > count). > > Assuming that it is worth it to move to a compiled win32lib, it should be > fairly straightforward to pass routine_id's. I'll assume that in the > wrapper for the win32lib dll, you've used the same names, so that we can > 'seamlessly' go from an interpreted to compiled win32lib. In other words, I > can use setHandler() in the same manner. Now, in your wrapper, you need to > set up a couple of call back functions (or one, with an added parameter to > specify func/proc distinctions) to call_func/proc the routine_id's of your > app. The tricky part is passing sequences back and forth, since a call_back > has to pass a 32-bit integer: > > > -- win32libdll.ew > > constant > win32libdll = open_dll("win32lib.dll"), > xGetSequence = define_c_func( win32libdll, "getSequence", {}, E_SEQUENCE ), > xPassSequence = define_c_proc( win32libdll, "passSequence", {E_SEQUENCE} ) > > procedure passSequence( sequence seq) > c_proc( xPassSequence, { seq } ) > end procedure > > function getSequence() > return c_func( xGetSequence, {} ) > end function > > global procedure setHandler(...) > c_proc( xSetHandler, {...}) > end function > > -- call back used by the dll > function w32CallFunc( integer rid ) > object result > result = call_func( rid, getSequence() ) > if sequence(result) then > passSequence( result ) > result = 0 > end if > return result > end function > > -- call back used by the dll > function w32CallProc( integer rid ) > call_proc( rid, getSequence() ) > return 0 > end function > > -- end > > > >