lua-users home
lua-l archive

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


>1. it's very clear from the documentation how to call lua from c and
>register callbacks for lua to call.  but i don't see how to have lua
>load and call functions in an external shared library that isn't part of
>the host.  for example, how do i call a win32 function in the msvcrt.dll
>or expat.dll?  is this possible?  or do i have to proxy every call
>through a callback in the host?

In Lua 5.0 use loadlib.

>2. one of my goals/requirments is that my host is a single shared
>library with no other external files or dependencies.  so, if for
>example, i want to include some lua code that isn't part of lualib.lib
>how do i include it as part of my lua environment.  is it best to use
>luac and embed the resulting binary code as binary data in the host then
>have lua execute it?

Yes. etc/bin2c.c can help you with this.

>3. is there a way from c to tell the difference between a lua variable
>that contains binary data from a string?

No. You may want to look at the first few bytes of the string and see if there's
anything not printable.

>4. is there a way from c to tell the difference between a lua variable
>that contains an integer from a double?

Try function isint(x) return x==floor(x) end
--lhf