1. 32-bit values in a Euphoria DLL
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 04, 2004
- 443 views
I've been working on translating some Euphoria into a dll that requires being able to receive 32-bit values from non-Euphorian sources. I read the previous thread on this topic (April 2003), but didn't particularly like the work arounds that were found at the time. What I did requires a little mucking about with the C source files, but I think is a little cleaner than the only given solution that seemed to work (wrapping all your exports with c-functions). Here's what I did. I created a file named make_atom.e with a dummy global procedure, make_atom(). Then I made sure that this was the first file included in the project (this gets the procedure renamed to _1make_atom). I added a macro at the top of my file: #define _1make_atom(x) if( (unsigned)x > (unsigned)0x7fffffff){ x = NewDouble( (double) x );} Now, each time this is called, I also need to move the Ref() that was before the macro to below the macro (since otherwise the run time library may think it has a pointer to a real atom or sequence, and cause a crash). The only thing to remember is that the value will be signed. Rob, this seems like something that should be easily done automatically by the translator, since it knows which parameters are declared atoms, and which aren't. Matt Lewis
2. Re: 32-bit values in a Euphoria DLL
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 04, 2004
- 424 views
Matt Lewis wrote: > > Rob, this seems like something that should be easily done automatically > by the translator, since it knows which parameters are declared atoms, > and which aren't. > Duh...Of course this would break if an Eu routine calls another global routine with an atom...but maybe if there were an 'official' dummy procedure that gets properly macro'd out (and the Ref issue dealt with) it would be kinda nice. I guess if you want the routine to be compatible with both external and internal calls, you'd have to do a wrapper that converts to atoms, and then calls the 'internal' version, which is what all of your Eu routines would look at... Matt Lewis Matt Lewis