Beispiel #1
0
int l_new_image(lua_State * L)
{
    image *a, **aa;
    image_dict **add;
    if (lua_gettop(L) > 1)
        luaL_error(L, "img.new() needs maximum 1 argument");
    if (lua_gettop(L) == 1 && !lua_istable(L, -1))
        luaL_error(L, "img.new() needs table as optional argument");    /* (t) */
    aa = (image **) lua_newuserdata(L, sizeof(image *));        /* i (t) */
    luaL_getmetatable(L, TYPE_IMG);     /* m i (t) */
    lua_setmetatable(L, -2);    /* i (t) */
    a = *aa = new_image();
    add = (image_dict **) lua_newuserdata(L, sizeof(image_dict *));     /* ad i (t) */
    luaL_getmetatable(L, TYPE_IMG_DICT);        /* m ad i (t) */
    lua_setmetatable(L, -2);    /* ad i (t) */
    img_dict(a) = *add = new_image_dict();
    img_dictref(a) = luaL_ref(L, LUA_GLOBALSINDEX);     /* i (t) */
    if (lua_gettop(L) == 2) {   /* i t, else just i */
        lua_insert(L, -2);      /* t i */
        lua_pushnil(L);         /* n t i (1st key for iterator) */
        while (lua_next(L, -2) != 0) {  /* v k t i */
            lua_to_image(L, a); /* v k t i */
            lua_pop(L, 1);      /* k t i */
        }                       /* t i */
        lua_pop(L, 1);          /* i */
    }                           /* i */
    return 1;                   /* i */
}
Beispiel #2
0
static int m_img_set(lua_State * L)
{
    image **a = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* v k u */
    image_dict *d = img_dict(*a);
    if (d == NULL) {
        luaL_error(L, "invalid image dictionary");
    } else {
        lua_to_image(L, *a, d);
    }
    return 0;
}
Beispiel #3
0
static int m_img_set(lua_State * L)
{
    image **aa = (image **) luaL_checkudata(L, 1, TYPE_IMG);    /* value key user */
    lua_to_image(L, *aa);       /* v k u */
    return 0;
}