pass map to shared library
- Posted by raseu Jul 12, 2012
- 1472 views
Euphoria Interpreter v4.1.0 development
32-bit Windows, Using System Memory
Revision Date: unknown, Id: 0:unknown
is it possible to pass a euphoria map to a shared library .so/.dll?
if so, it would be a great bonus when developing eui shared libraries
i have the following code compiled as a dll
--// maplib.e --// euc -dll maplib.e include std/map.e export function mapfunc(map params) if map(params) then printf(1, "map\n") end if if object(params) then printf(1, "object\n") end if if sequence(params) then printf(1, "sequence\n") end if if integer(params) then printf(1, "integer\n") end if if atom(params) then printf(1, "atom\n") end if ? map:get(params, "integer") ? map:get(params, "atom") puts(1, map:get(params, "sequence") & "\n") map:put(params,"retval", "return value") return params end function
and the following code to load and test the library
--// testmap.e --// eui testmap.e include std/dll.e include std/map.e include lib/maplib.e map testmap = map:new() map:put(testmap, "integer", 1) map:put(testmap, "atom", 2.0) map:put(testmap, "sequence", "string") --// call directly mapfunc(testmap) --// call via dll constant libhandle = open_dll("maplib.dll") constant __mapfunc = define_c_proc(libhandle, "mapfunc", { E_OBJECT }) if (libhandle > 0) then ? { libhandle, __mapfunc } c_proc(__mapfunc, { testmap }) end if
provides the following output
map
object
integer
atom
1
2
string
{50921472,39}
object
integer
atom
the program fails when attempting to read from the map
via the dll function call
any help appreciated
ras