like you might have read in my last post im trying to write a
Plua extension in C for a kind of extended socket support.
I have currently installed:
>Plua 2.0b7 (with the delivered libkit)
>Palm SDK 5.0r3
additionally I have downloaded dbhack and dlk.
"make" works on all sources (dbhack creates the warning: global data
So I've installed the prc files on my palm, opened the Plua2 shell
But dbhack is nil....
I've tried the same with the delivered TestLib.c
The same result... also with loadlib("testlib","test")
-> 'cause I've no idea how this extension stuff really works in Plua
At the moment I'm completely frustrated because nothing I've tried
worked. I also wrote my own extension and was able to load it once,
but I have no idea how. The loaded lib didn't really work, but I've
seen a function name I've defined.
Do you have any Idea what I did wrong?
That is the correct syntax. The second parameter is supposed to be a
function name. In standard Lua, if dynamic library loading is
supported the OS will open the library, search for a function named
"extname" and returns a pointer to it. Then loadlib makes a closure
out of this function and returns it to the caller. In PalmOS however,
there is no OS funcion that works like this. So the library developer
will have to return a function pointer based on the function name
received as parameter to the PluaLibInit function (part of the libkit
x = loadlib("LIBNAME AS DEFINED BY SYSLIB", "NAME AS DEFINED BY
luaL_openlib 2nd arg")
-- x is a function (but only at the first call of loadlib)
-- now the variable "NAME AS DEFINED BY luaL_openlib 2nd arg" is set
to the module table, which contains the defined functions.
I'm now trying to find NetLib in C (with SysLibFind) but the palm
performs a hard reset everytime I call it.
Maybe I'll get it working, I'll post the library then.
> x = loadlib("LIBNAME AS DEFINED BY SYSLIB", "NAME AS DEFINED BY
> luaL_openlib 2nd arg")
> -- x is a function (but only at the first call of loadlib)
> -- now the variable "NAME AS DEFINED BY luaL_openlib 2nd arg" is set
> to the module table, which contains the defined functions.
A small correction: the second argument to loadlib is a function name.
The library function PluaLibInit must return a C function that mathes
this name. Actually, you can ignore this parameter and return any
function you like, but it is present because Lua defines it.