/* This function assumes there's a class methods table at index 1, and its metatable at 2, when it's initially called, and leaves them that way when done.  */
int wslua_set__index(lua_State *L)
/* This function assumes there's a class methods table at index 1, and its metatable at 2, when it's initially called, and leaves them that way when done.  */
int wslua_set__index(lua_State *L)
{
        fprintf(stderr, "No metatable or class table in the Lua stack when registering __index!\n");
        exit(1);
    }
    lua_pushvalue (L, 1);
    lua_rawsetfield(L, 2, "__methods");
    lua_pushcfunction(L, wslua__index);
    lua_rawsetfield(L, 2, "__index");
    return 0;
}