lua-users home
lua-l archive

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


I'm porting a large project over to Lua 5. (from 4.0) There have been some
major changes to the Lua C API, and for a few of the changes I'm uncertain
as to the proper way to proceed.
(the program in question is written in C++)
I've overloaded 2 functions for compatability as follows:
------ Code Start ------
lua_State *lua_open (int stacksize)
{
  return lua_open();
}
void  lua_error (lua_State *L, const char *s)
{
  lua_pushstring(L,s);
  lua_error(L);
}
------ Code End ------

Then a have a few pieces of code left that cause errors. Because it would be
a major hassle to change the internal structure of the project I'm hoping to
be able to find drop in replacements for the functions.

I would appreciate any help you can give. Thanks. (Please cc me. I'm not
subscribed to the list).

(Note that the use of lua tags in the program was simply to mark lua objects
that represent object in the game engine. All code relating to tags is
included below.)

Here is the relevent code with unnecessary context removed:
---------- CODE START ----------
/* ... */
    int object_tag;             // Lua tag for `Object's
/* ... */
static bool
is_object(lua_State *L, int idx)
{
    return lua_isuserdata(L,idx) && lua_tag(L,idx)==object_tag; //ERROR
lua_tag not defined
}
/* ... */
static void
pushobject (lua_State *L, Object *obj)
{
    /* Lua does not allow NULL pointers in userdata variables, so
       convert them manually to `nil' values. */
    if (obj == 0)
        lua_pushnil(L);
    else
        lua_pushusertag(L, obj, object_tag); //ERROR lua_pushusertag not
defined
}
/* ... */
lua_State *lua::InitLevel()
{
    char buffer[255];
    lua_State *L = level_state = lua_open(0);
/* ... */
    // Create a new tag for world::Object objects
    object_tag = lua_newtag(L); //ERROR lua_newtag
    return L;
}
---------- CODE END ----------