static void write_image_or_node(lua_State * L, wrtype_e writetype) { image *a, **aa; image_dict *ad; halfword n; if (lua_gettop(L) != 1) luaL_error(L, "%s needs exactly 1 argument", wrtype_s[writetype]); if (lua_istable(L, 1)) (void) l_new_image(L); /* image --- if everything worked well */ aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* image */ a = *aa; ad = img_dict(a); setup_image(static_pdf, a, writetype); switch (writetype) { case WR_WRITE: n = img_to_node(a); tail_append(n); break; /* image */ case WR_IMMEDIATEWRITE: write_img(static_pdf, ad); break; /* image */ case WR_NODE: /* image */ lua_pop(L, 1); /* - */ n = img_to_node(a); lua_nodelib_push_fast(L, n); break; /* node */ default: assert(0); } if (img_state(ad) < DICT_REFERED) img_state(ad) = DICT_REFERED; }
static void write_image_or_node(lua_State * L, wrtype_e writetype) { image *a, **aa; image_dict *ad; halfword n; if (lua_gettop(L) != 1) luaL_error(L, "%s expects an argument", wrtype_s[writetype]); if (lua_istable(L, 1)) (void) l_new_image(L); aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); a = *aa; ad = img_dict(a); setup_image(static_pdf, a, writetype); switch (writetype) { case WR_WRITE: n = img_to_node(L, a); tail_append(n); break; case WR_IMMEDIATEWRITE: write_img(static_pdf, ad); break; case WR_NODE: lua_pop(L, 1); /* - */ n = img_to_node(L, a); lua_nodelib_push_fast(L, n); break; default: luaL_error(L, "%s expects an valid image", wrtype_s[writetype]); } if (img_state(ad) < DICT_REFERED) img_state(ad) = DICT_REFERED; }