Support for Lua added - patch from Mark Gossage
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7365 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e2c90c74a9
commit
127e49e03b
27 changed files with 2266 additions and 0 deletions
25
SWIG/Examples/test-suite/lua/import.lua
Normal file
25
SWIG/Examples/test-suite/lua/import.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- import
|
||||
function import(module,intoglobal)
|
||||
-- imports the file into the program
|
||||
-- for a module example
|
||||
-- this must load 'example.dll'
|
||||
-- and look for the fn 'Example_Init()' (note the capitalisation)
|
||||
|
||||
local libname=module..".dll" -- windows
|
||||
--libname=module..".so" -- unix
|
||||
|
||||
-- capitialising the first letter
|
||||
local c=string.upper(string.sub(module,1,1))
|
||||
local fnname=c..string.sub(module,2).."_Init"
|
||||
|
||||
assert(loadlib(libname,fnname),"error loading module:"..module)()
|
||||
|
||||
-- moving to global namespace
|
||||
if intoglobal then
|
||||
--m=raw_get(_G,module) -- gets the module object
|
||||
local m=_G[module] -- gets the module object
|
||||
assert(m~=nil,"no module table found")
|
||||
local k,v
|
||||
for k,v in m do _G[k]=v end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue