lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 01.04.2014 12:01 schrieb steve donovan:
> It's the first thing any Lua person would do - if they want some
> initialization to happen once, then let require() do that job.
> 
> And I don't understand - the loading _will_ happen exactly once.

Yes, I was afraid that I didn't quite get my wording right.

The loading does happen once. Problem is the one who loads. Maybe I can paint it....

 
     UnitTestProgram    MyApplication
| |
| |
+----------------´
v
links
|
v
MyDLL ---- contains ----+--- code_invoking_lua()
| |
| +--- code_to_be_invoked_by_lua()
|
v
executes code_invoking_lua()
|
|
v
LuaScript
|
|
"
local ffi = require("ffi")
ffi.cdef[[
__declspec(dllexport) void code_to_be_invoked_by_lua();
]]

-- does not work
ffi.C.code_to_be_invoked_by_lua()

-- works
mydll = ffi.load('MyDLL') <----- but MyDLL is present twice
mydll.code_to_be_invoked_by_lua()
"

So even if the scripts cache all that, the DLL is still duplicate. But maybe I just have to understand Lua better.

Cheers,
Moose