lua-users home
lua-l archive

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

The way I deal with the warnings on data conversions is to make my own
macros to complement Lua's which include a proper cast, such as:

#define lua_pushint(n)			lua_pushnumber((FLOAT)(n))
#define lua_getint(n)			((INT)lua_getnumber(n))
#define lua_getfloat(n)			((FLOAT)lua_getnumber(n))
#define lua_pushuserhandle(h,t)	lua_pushusertag((void *)(h), (t))

#define lua_isactor(n)			(lua_isuserdata(n) && lua_type(n) ==
#define lua_getactor(n)			((INT)lua_getuserdata(n))

#define lua_isset(n)			(lua_isuserdata(n) && lua_type(n) ==
#define lua_getset(n)			((tRoom *)lua_getuserdata(n))

Presumably you have a particular function pointer type that you can cast
to.  Also useful, particularly for debugging, is to overload the "type"
library function and the "concat" fallback to do more specific things
with your user data types... I can't say enough about how this has made
debugging things easier.


"Why, that's the second biggest monkey head I've ever seen!" --Guybrush
"LeChuck's dead. I blew him into a million gooey pieces."    --Guybrush
Bret Mogilefsky   **   **   Programmer, LucasArts

>From: 	John Fletcher[]
>Sent: 	Monday, April 07, 1997 5:54 AM
>To: 	Bret Mogilefsky
>Subject: 	Re: applications that use Lua
>I am exploring using Lua.  As yet I don't have any finished 
>applications, only examples and ideas.
>Firstly.  I am working mainly using DOS.  I have built my examples 
>with Microsoft Visual C/C++ Version 1.5 with the large memory model.  
>It is essential that the same type of addressing is used for data and 
>program, as pointers to functions are passed as data.  I get a lot of 
>warning messages when I build the library, mainly concerned with 
>conversions of integer data types, but the programs work.
>I would like to move over to 32 bit DOS using a DOS extender, and 
>Windows or Windows 95 possibly using a DLL to hold lua.
>I started from the Dr Dobbs article, which mentioned that lua ran 
>under DOS, but have seen no makefiles or other advice for DOS.
>I like the idea of a totally flexible data structure which can grow 
>as needed.  I would like to apply this to family history data, and 
>specifically to conversion of GEDCOM standard data files to HTML for 
>display.  GEDCOM files contain only text data and keywords.  I have 
>some existing software in C and would like to adapt and improve iot 
>using Lua.  I want also for the data base to be persistent.
>I have developed a trial persistent database to store two related 
>sets of data - book titles and authors.  The main problem is in 
>getting Lua to store and restore on numeric keys as well as string 
>keys. (See previous comments on the list.)  At the moment this works 
>but lacks any interface to input new data items and does not deal 
>with deletion or change at all.
>I have also been using LuaL from Waldemar Celes to interface C and 
>C++ code.  Here the interest is in numerical calculations.  I have 
>given Waldemar a simple example of a vector class in C++ interfaced 
>so that vectors are available in Lua.  One possible use of this is to 
>modularize C++ code so that different sections do not need to see the 
>headers of the other sections to be able to use them.  The more 
>recent lua++ code from Waldemar provides the other half.  I have only 
>just got this working under DOS, so I haven't done anything with it 
>I think one of the attractions of Lua when I read the DrDobbs article 
>in a hotel one evening was that I couldn't figure out how to use it!
>I hope this is useful and I am willing to have my examples included 
>in a contribution section.
>John Fletcher
>Dr John P. Fletcher          Tel: (44) 121 359 3611 ext 4625
>Department of Chemical Engineering and Applied Chemistry (CEAC),
>Aston University,            Fax: (44) 121 359 4094
>Aston Triangle,              Email: J.P.Fletcher@ASTON.AC.UK
>CEAC Web site