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; }
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 int do_getstat(lua_State * L, int i) { int t; const char *st; charfunc f; intfunc g; numfunc n; int str; t = stats[i].type; switch (t) { case 'S': f = stats[i].value; st = f(); lua_pushstring(L, st); break; case 's': str = *(int *) (stats[i].value); if (str) { char *ss = makecstring(str); lua_pushstring(L, ss); free(ss); } else { lua_pushnil(L); } break; case 'N': n = stats[i].value; lua_pushnumber(L, n()); break; case 'G': g = stats[i].value; lua_pushnumber(L, g()); break; case 'g': lua_pushnumber(L, *(int *) (stats[i].value)); break; case 'B': g = stats[i].value; lua_pushboolean(L, g()); break; case 'n': if (*(halfword *) (stats[i].value) != 0) lua_nodelib_push_fast(L, *(halfword *) (stats[i].value)); else lua_pushnil(L); break; case 'b': lua_pushboolean(L, *(int *) (stats[i].value)); break; default: lua_pushnil(L); } return 1; }
static int run_scan_glue(lua_State * L) { saved_tex_scanner texstate; int v = 0; int mu = false; int t = lua_gettop(L); if (t>0) mu = lua_toboolean(L,1); /* mu units required ?*/ save_tex_scanner(texstate); scan_glue((mu ? mu_val_level : glue_val_level)); v = cur_val; /* which is a glue_spec node */ unsave_tex_scanner(texstate); lua_nodelib_push_fast(L,(halfword)v); return 1; }