Lua fixes to work on Unix as well as windows.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2005-09-12 22:14:37 +00:00
commit b93b3593bf
5 changed files with 27 additions and 15 deletions

View file

@ -3,10 +3,13 @@
-- This file illustrates class C++ interface generated
-- by SWIG.
-- importing (lua doesnt have a nice way to do this)
if example==nil then
assert(loadlib("example.dll","Example_Init"))()
-- importing (lua does not have a nice way to do this)
loadlibrary = loadlib("example.so","Example_Init")
if loadlibrary == nil then
loadlibrary = loadlib("example.dll","Example_Init")
end
assert(loadlibrary, "could not find dynamic libray")
loadlibrary()
----- Object creation -----

View file

@ -1,9 +1,12 @@
-- file: runme.lua
-- importing (lua doesnt have a nice way to do this)
if example==nil then
assert(loadlib("example.dll","Example_Init"))()
-- importing (lua does not have a nice way to do this)
loadlibrary = loadlib("example.so","Example_Init")
if loadlibrary == nil then
loadlibrary = loadlib("example.dll","Example_Init")
end
assert(loadlibrary, "could not find dynamic libray")
loadlibrary()
-- Call our gcd() function
print("hello world")

View file

@ -1,9 +1,12 @@
-- file: example.lua
-- importing (lua doesnt have a nice way to do this)
if example==nil then
assert(loadlib("example.dll","Example_Init"))()
-- importing (lua does not have a nice way to do this)
loadlibrary = loadlib("example.so","Example_Init")
if loadlibrary == nil then
loadlibrary = loadlib("example.dll","Example_Init")
end
assert(loadlibrary, "could not find dynamic libray")
loadlibrary()
-- Try to set the values of some global variables

View file

@ -45,7 +45,7 @@ LIBS = -L.
# a file is found which has _runme.lua appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
# Clean: (does nothing, we dont generate extra lua code)

View file

@ -2,17 +2,20 @@
function import(module,intoglobal)
-- imports the file into the program
-- for a module example
-- this must load 'example.dll'
-- this must load 'example.dll' or 'example.so'
-- 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)()
-- attempt to load the module using Unix and Windows dll/shared object
local loadlibrary = loadlib(module..".so",fnname)
if loadlibrary == nil then
loadlibrary = loadlib(module..".dll",fnname)
end
assert(loadlibrary~=nil,"could not load module")
loadlibrary()
-- moving to global namespace
if intoglobal then