32-bit values in a Euphoria DLL
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 04, 2004
- 441 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