Hi,

There are some very nice loadable extensions for Lua 5,
like lposix. Unfortunately, out of the box SciTE doesn't
enable loadlib.

 Here is a patch:
1) comment out the #if PLATWIN and #endif lines
at src/ LuaExtension.cxx,1371 so that luaopen_loadlib
will be called
2) add the line #define USE_DLOPEN at the top of
lua/src/lib/loadlib.c to force dlopen to be used.

Shouldn't the #define be wrapped in #if PLATGTK? IIRC, loadlib doesn't use DLOPEN in windows.

3) add the link flag -Wl,-export-dynamic
to the link command in the makefile.
(I added this directly to the line 106)

The last isn't strictly necessary to get loadlib going,
but you need it to expose the Lua API so that
Lua extensions can load; otherwise you can only
load plain libraries which can only supply a single
entry point to be called.  The SciTE binary
will be larger however (about 30%)

What I ended up doing since I'm in linux and have lua installed on my machine (libs are in /usr/lib/ liblua50.{a,so}, liblualib50.{a,so}) is link the lua .so files to SciTE which resulted in a 100K size drop. Not sure about the performance, but it appears just fine.

In the makefile beginning on line 75:

#LUA_OBJS = LuaExtension.o IFaceTable.o $(LUA_CORE_OBJS) $(LUA_LIB_OBJS)
LUA_OBJS = LuaExtension.o IFaceTable.o

INCLUDEDIRS=-I ../../scintilla/include -I ../src -I../lua/include
#$(LUA_CORE_OBJS): ../lua/src/*.c
# gcc $(INCLUDEDIRS) $(CXXTFLAGS) -c ../lua/src/*.c
#$(LUA_LIB_OBJS): ../lua/src/lib/*.c
# gcc $(INCLUDEDIRS) $(CXXTFLAGS) -c ../lua/src/lib/*.c
CXXFLAGS=$(CXXTFLAGS)

and then on line 108:

  $(CC) `$(CONFIGTHREADS)` -DGTK $^ -o $@ `$(CONFIGLIB)` -llua50 -llualib50

-Mitchell;


Here (for example) is how to get lposix loaded.
Go to http://www.tecgraf.puc-rio.br/~lhf/ftp/lua
and grab the lposix source; untar it and modify
Makefile so that the variable LUA points to
<scite-source>/lua. The build will  not
entirely succeed, but you will be left with a working lposix.so.

In a SciTE script, you can now say

init = loadlib('<full-path>/lposix.so','luaopen_posix')
if init then
  init()
end

and useful functions like posix.getcwd(), etc will be
available! Unfortunately, the source is the only
documentation :(

steve d.

(It would be really cool if this could go into 1.72, but
it needs to be tested more!)





_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to