lua-users home
lua-l archive

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


On Fri, Jun 01, 2001 at 08:27:32AM +0200, luagnome@free.fr wrote:
> Some time ago, someone if it was possible to call arbitrary C function from the
> Lua interpreter without writing wrappers. A kind soul mentionned a library,
> called libffi that make this kind of feature possible.
> 
> I have wrapped libffi (with luaswig, also use for luagnome/luagtk) and I have
> delivered a working snapshot of this developement. 
> If you are interested, see <http://luagnome.free.fr/luaffi.php3>.
> A short documentation (HOW_TO_USE.html) is included in the downloadable sources.

Wow, that looks way cool!  Not to mention extremely dangerous... but
still way cool!  For fairly controlled environments this could be quite
useful.  I'm thinking in particular that PLua on the Palm could have this
built in so you could use libs easily like, say, the SSL that iang used to
distribute or minigl with little preparation.

This could also be cool for game expansions... Say you are prevented from
changing the main executable for your game after it ships because, oh, say,
it's encrypted on the hard drive and only that encrypted version will
play.  But now you want to give mod authors new functions to play with
that you hadn't even considered when you originally shipped it.  So the
update includes some code and a lua "header" file...  Now the mod author
can pull those functions just the way the second example you gave does.  In
fact, people can write binary expansions for your game without knowing
anything about your engine internals.  

A more specific example: In Black and White, people in your towns get named
after entries in your Outlook addressbook, and you can click on them to
read mail from friends without leaving the game.  Any game shipping with
ffi-enabled Lua could have the same feature added by someone after it
ships, even if you included never had time to hack in and expose functions
for interacting with mail before your game shipped.

Did I mention this could be extremely dangerous?  If you do put this
functionality in your app, I suggest it should spew out some kind of
user-visible audit of ffi loading up new libraries and finding symbols and
making calls...

Bret
-- 
Bret Mogilefsky * Mgr. SCEA Developer Support * mogul@gelatinous.com