texlive[43840] Build/source/texk/web2c: MFLua 0.8
commits+lscarso at tug.org
commits+lscarso at tug.org
Sun Apr 16 12:11:23 CEST 2017
Revision: 43840
http://tug.org/svn/texlive?view=revision&revision=43840
Author: lscarso
Date: 2017-04-16 12:11:22 +0200 (Sun, 16 Apr 2017)
Log Message:
-----------
MFLua 0.8
Modified Paths:
--------------
trunk/Build/source/texk/web2c/mfluadir/ChangeLog
trunk/Build/source/texk/web2c/mfluadir/am/mflua.am
trunk/Build/source/texk/web2c/mfluadir/mf-lua.ch
trunk/Build/source/texk/web2c/mfluadir/mflua_version.h
trunk/Build/source/texk/web2c/mfluadir/mfluac.c
trunk/Build/source/texk/web2c/mfluadir/mfluaextra.h
trunk/Build/source/texk/web2c/mfluajitdir/ChangeLog
trunk/Build/source/texk/web2c/mfluajitdir/am/mfluajit.am
trunk/Build/source/texk/web2c/mfluajitdir/mfluajitextra.h
Removed Paths:
-------------
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua
trunk/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_mf.lua
Modified: trunk/Build/source/texk/web2c/mfluadir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/ChangeLog 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/ChangeLog 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,4 +1,11 @@
+2017-04-16 Luigi Scarso <luigi.scarso at gmail.com>
+
+ * MFLua 0.8. New primitive runscript, cleanup of the Lua code.
+ * new backend ttx .
+ * am/mflua.am: deleted useless lua files
+
2016-04-15 Luigi Scarso <luigi.scarso at gmail.com>
+
* mfluac.c priv_lua_writemessage: write to stdout
when a lua file is loaded.
Modified: trunk/Build/source/texk/web2c/mfluadir/am/mflua.am
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/am/mflua.am 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/am/mflua.am 2017-04-16 10:11:22 UTC (rev 43840)
@@ -131,20 +131,8 @@
## Test data
##
EXTRA_DIST += \
- mfluadir/mfluatrap/begin_program.lua \
- mfluadir/mfluatrap/do_add_to.lua \
- mfluadir/mfluatrap/end_program.lua \
- mfluadir/mfluatrap/fill_envelope.lua \
- mfluadir/mfluatrap/fill_spec.lua \
- mfluadir/mfluatrap/final_cleanup.lua \
- mfluadir/mfluatrap/main_control.lua \
- mfluadir/mfluatrap/make_ellipse.lua \
- mfluadir/mfluatrap/mfluaini.lua \
- mfluadir/mfluatrap/offset_prep.lua \
- mfluadir/mfluatrap/print_edges.lua \
- mfluadir/mfluatrap/print_path.lua \
- mfluadir/mfluatrap/scan_direction.lua \
- mfluadir/mfluatrap/skew_line_edges.lua \
- mfluadir/mfluatrap/start_of_mf.lua \
+ mfluadir/mfluatrap/mflua.lua \
+ mfluadir/mfluatrap/mflua_svg_backend.lua \
+ mfluadir/mfluatrap/mflua_ttx_backend.lua \
mfluadir/mfluatrap/texmf.cnf \
mfluadir/mfluatrap/mfluatrap.diffs
Modified: trunk/Build/source/texk/web2c/mfluadir/mf-lua.ch
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mf-lua.ch 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mf-lua.ch 2017-04-16 10:11:22 UTC (rev 43840)
@@ -19,7 +19,7 @@
@y
@d METAFONT_banner=='This is METAFONT, Version 2.7182818' {printed when \MF\ starts}
@#
- at d MFLua_version_string=='-0.5'
+ at d MFLua_version_string=='-0.8'
@#
@d MFLua_banner=='This is MFLua, Version 2.7182818', MFLua_version_string
{printed when MFLua starts}
Modified: trunk/Build/source/texk/web2c/mfluadir/mflua_version.h
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mflua_version.h 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mflua_version.h 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +1 @@
-#define MFLUA_VERSION "0.5"
+#define MFLUA_VERSION "0.8"
Modified: trunk/Build/source/texk/web2c/mfluadir/mfluac.c
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluac.c 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluac.c 2017-04-16 10:11:22 UTC (rev 43840)
@@ -17,8 +17,41 @@
/**************************************************************/
static lua_State *Luas[1];
-static void priv_lua_reporterrors(lua_State *L, int status)
+static
+void stackdump_g(lua_State* L)
{
+ int i;
+ int top = lua_gettop(L);
+
+ printf("total in stack %d\n",top);
+
+ for (i = 1; i <= top; i++)
+ { /* repeat for each level */
+ int t = lua_type(L, i);
+ printf("[%d][%d] ",i,i-top-1);
+ switch (t) {
+ case LUA_TSTRING: /* strings */
+ printf("string: '%s'\n", lua_tostring(L, i));
+ break;
+ case LUA_TBOOLEAN: /* booleans */
+ printf("boolean %s\n",lua_toboolean(L, i) ? "true" : "false");
+ break;
+ case LUA_TNUMBER: /* numbers */
+ printf("number: %g\n", lua_tonumber(L, i));
+ break;
+ default: /* other values */
+ printf("%s\n", lua_typename(L, t));
+ break;
+ }
+ printf(" "); /* put a separator */
+ }
+ printf("\n"); /* end the listing */
+}
+
+
+static
+void priv_lua_reporterrors(lua_State *L, int status)
+{
if ( status!=0 ) {
fprintf(stderr,"\n! %s\n",lua_tostring(L, -1));
lua_pop(L, 1); /* remove error message */
@@ -26,7 +59,8 @@
}
-static void priv_lua_writemessage(lua_State *L, char *startmsg, char *bodymsg, char *endmsg, int status)
+static
+void priv_lua_writemessage(lua_State *L, char *startmsg, char *bodymsg, char *endmsg, int status)
{
(void) L;
if ( status!=0 ) {
@@ -243,8 +277,7 @@
/* @ The |make_spec| routine has an interesting side effect, namely to set */
/* the global variable |turning_number| to the number of times the tangent */
/* vector of the given cyclic path winds around the origin. */
-
-
+/* */
/* @<Glob...@>= */
/* @!turning_number:integer; {another output of |make_spec|} */
static int priv_mfweb_LUAGLOBALGET_turning_number(lua_State *L)
@@ -256,7 +289,6 @@
-
/* @ \MF\ also has a bunch of internal parameters that a user might want to */
/* fuss with. Every such parameter has an identifying code number, defined here. */
/* Warning: these parameters must be the same of the original MF !! */
@@ -421,14 +453,62 @@
-
-
-
/**************************************************************/
/* */
/* mflua layer */
/* */
/**************************************************************/
+static const struct luaL_Reg MFbuiltin_l[] = {
+ {"link", priv_mfweb_link},
+ {"info", priv_mfweb_info},
+ {"x_coord", priv_mfweb_x_coord},
+ {"y_coord", priv_mfweb_y_coord},
+ {"left_type", priv_mfweb_left_type},
+ {"right_type", priv_mfweb_right_type},
+ {"left_x", priv_mfweb_left_x},
+ {"left_y", priv_mfweb_left_y},
+ {"right_x", priv_mfweb_right_x},
+ {"right_y", priv_mfweb_right_y},
+ {"n_sin_cos", priv_mfweb_n_sin_cos},
+ {"cur_edges", priv_mfweb_LUAGLOBALGET_cur_edges},
+ {"cur_exp", priv_mfweb_LUAGLOBALGET_cur_exp},
+ {"mem_top", priv_mfweb_LUAGLOBALGET_mem_top},
+ {"cur_pen", priv_mfweb_LUAGLOBALGET_cur_pen},
+ {"octant", priv_mfweb_LUAGLOBALGET_octant},
+ {"char_code", priv_mfweb_LUAGLOBALGET_char_code},
+ {"char_ext", priv_mfweb_LUAGLOBALGET_char_ext},
+ {"char_wd", priv_mfweb_LUAGLOBALGET_char_wd},
+ {"char_ht", priv_mfweb_LUAGLOBALGET_char_ht},
+ {"char_dp", priv_mfweb_LUAGLOBALGET_char_dp},
+ {"char_ic", priv_mfweb_LUAGLOBALGET_char_ic},
+ {"char_dx", priv_mfweb_LUAGLOBALGET_char_dx},
+ {"char_dy", priv_mfweb_LUAGLOBALGET_char_dy},
+ {"designsize", priv_mfweb_LUAGLOBALGET_designsize},
+ {"hppp", priv_mfweb_LUAGLOBALGET_hppp},
+ {"vppp", priv_mfweb_LUAGLOBALGET_vppp},
+ {"x_offset", priv_mfweb_LUAGLOBALGET_x_offset},
+ {"y_offset", priv_mfweb_LUAGLOBALGET_y_offset},
+ {"granularity", priv_mfweb_LUAGLOBALGET_granularity},
+ {"fillin", priv_mfweb_LUAGLOBALGET_fillin},
+ {"turning_check", priv_mfweb_LUAGLOBALGET_turning_check},
+ {"boundary_char", priv_mfweb_LUAGLOBALGET_boundary_char},
+ {"turning_number", priv_mfweb_LUAGLOBALGET_turning_number},
+ {NULL, NULL} /* sentinel */
+};
+
+
+#define lua_swap(L) lua_insert(L, -2)
+
+#define GETGLOBALTABLEMFLUA(a) lua_getglobal(L, "mflua");\
+ if (!lua_istable(L, -1)) { \
+ lua_pushstring(L,#a); \
+ lua_pushstring(L,":global table mflua not found"); \
+ lua_concat (L, 2); \
+ priv_lua_reporterrors(L, 1); \
+ } \
+
+
+
int mfluabeginprogram(void)
{
lua_State *L ;
@@ -438,95 +518,135 @@
L = luaL_newstate();
luaL_openlibs(L);
Luas[0] = L;
+ /* register lua functions */
+ luaopen_kpse(L);
+ /* to be sure of having a clear stack */
+ lua_settop(L,0);
+
- luafile = kpse_find_file("begin_program.lua", kpse_lua_format, 0);
- /* execute Lua external "begin_program.lua" */
+ lua_getglobal(L, "mflua");
+ if (!lua_istable(L, -1)) {
+ lua_pop(L,1);
+ lua_newtable(L);
+ lua_setglobal(L,"mflua");
+ /* check it */
+ lua_getglobal(L,"mflua");
+ if (!lua_istable(L, -1)) {
+ printf("mflua table NOT registered!\n");
+ } else {
+ lua_pushstring(L,"MFbuiltin");
+#ifdef MFLuaJIT
+ /* 5.1 */
+ lua_newtable(L);
+ luaL_register (L,NULL,MFbuiltin_l);
+#else
+ luaL_newlib(L,MFbuiltin_l);
+#endif
+ lua_settable(L, -3);
+ }
+ lua_pop(L,1);
+ }
+
+
+ luafile = kpse_find_file("mflua.lua", kpse_lua_format, 0);
if (luafile==NULL) {
res = 1;
- lua_pushstring(L,"begin_program.lua not found");
+ lua_pushstring(L,"mflua.lua not found.");
priv_lua_reporterrors(L, res);
- return 0;
+ goto EXIT;
}
- priv_lua_writemessage(L,"(",luafile,")",1);
res = luaL_loadfile(L, luafile);
free(luafile);
- if ( res==0 ) {
- res = lua_pcall(L, 0, 0, 0);
+ if ( res==LUA_OK ) {
+ if(res=lua_pcall(L,0,0,0)){
+ priv_lua_reporterrors(L, res);
+ goto EXIT;
+ }
+ } else {
+ priv_lua_reporterrors(L, res);
+ goto EXIT;
}
- /* stackdump_g(L); */
- priv_lua_reporterrors(L, res);
+ /* Still a chance that mflua is around */
+ GETGLOBALTABLEMFLUA(mfluabeginprogram);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"begin_program");
+ if(res=lua_pcall(L,0,0,0))
+ priv_lua_reporterrors(L, res);
+ }
+ EXIT:
+ lua_settop(L,0);
return 0;
}
+/* /\* TODO*\/ */
+/* int mfluaendprogram(void) */
+/* { */
+/* lua_State *L; */
+/* char* luafile; */
+/* int res; */
+
+/* L = Luas[0]; */
+/* GETGLOBALTABLEMFLUA(mfluaendprogram); */
+/* luafile = kpse_find_file("end_program.lua", kpse_lua_format, 0); */
+/* if (luafile==NULL) { */
+/* res = 1; */
+/* lua_pushstring(L,"end_program.lua not found"); */
+/* priv_lua_reporterrors(L, res); */
+/* lua_settop(L,0); */
+/* return 0; */
+/* } */
+/* priv_lua_writemessage(L,"(",luafile,")",1); */
+/* res = luaL_loadfile(L, luafile); */
+/* free(luafile); */
+/* if ( res==0 ) { */
+/* res = lua_pcall(L, 0, 0, 0); */
+/* } */
+/* /\* stackdump_g(L); *\/ */
+/* priv_lua_reporterrors(L, res); */
+/* lua_settop(L,0); */
+/* return 0; */
+/* } */
+
int mfluaendprogram(void)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- /* execute Lua external "end_program.lua" */
- luafile = kpse_find_file("end_program.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"end_program.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaendprogram);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"end_program");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in end_program:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free(luafile);
- if ( res==0 ) {
- res = lua_pcall(L, 0, 0, 0);
- }
- /* stackdump_g(L); */
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
int mfluaPREstartofMF(void)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("start_of_mf.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"start_of_mf.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREstartofMF);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"PRE_start_of_MF");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in PRE_start_of_MF:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_start_of_MF"); /* function to be called */
- /* do the call (0 arguments, 1 result) */
- res = lua_pcall(L, 0, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_start_of_MF number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /* stackdump_g(L); */
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
@@ -533,204 +653,87 @@
int mfluaPREmaincontrol(void)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("main_control.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"main_control.lua");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmaincontrol);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_main_control");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in PRE_main_control:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_main_control"); /* function to be called */
- /* do the call (0 arguments, 1 result) */
- res = lua_pcall(L, 0, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_main_control called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
-
int mfluaPOSTmaincontrol(void)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("main_control.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"main_control.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmaincontrol);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_main_control");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in POST_main_control:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_main_control"); /* function to be called */
- /* do the call (0 arguments, 1 result) */
- res = lua_pcall(L, 0, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_main_control called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
+
int mfluainitialize(void)
{
lua_State *L;
- char* luafile;
- int res ;
+ int res;
L = Luas[0];
- luafile = kpse_find_file("mfluaini.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"mfluaini.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluainitialize);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "mflua_initialize");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in mflua_initialize:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- /* register lua functions */
- luaopen_kpse(L);
- lua_pushcfunction(L, priv_mfweb_link);lua_setglobal(L, "link");
- lua_pushcfunction(L, priv_mfweb_info);lua_setglobal(L, "info");
- lua_pushcfunction(L, priv_mfweb_x_coord);lua_setglobal(L, "x_coord");
- lua_pushcfunction(L, priv_mfweb_y_coord);lua_setglobal(L, "y_coord");
- lua_pushcfunction(L, priv_mfweb_left_type);lua_setglobal(L, "left_type");
- lua_pushcfunction(L, priv_mfweb_right_type);lua_setglobal(L, "right_type");
- lua_pushcfunction(L, priv_mfweb_left_x);lua_setglobal(L, "left_x");
- lua_pushcfunction(L, priv_mfweb_left_y);lua_setglobal(L, "left_y");
- lua_pushcfunction(L, priv_mfweb_right_x);lua_setglobal(L, "right_x");
- lua_pushcfunction(L, priv_mfweb_right_y);lua_setglobal(L, "right_y");
- lua_pushcfunction(L, priv_mfweb_n_sin_cos);lua_setglobal(L, "n_sin_cos");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_edges);lua_setglobal(L, "LUAGLOBALGET_cur_edges");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_exp);lua_setglobal(L, "LUAGLOBALGET_cur_exp");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_mem_top);lua_setglobal(L, "LUAGLOBALGET_mem_top");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_cur_pen);lua_setglobal(L, "LUAGLOBALGET_cur_pen");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_octant);lua_setglobal(L, "LUAGLOBALGET_octant");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_code);lua_setglobal(L, "LUAGLOBALGET_char_code");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ext);lua_setglobal(L, "LUAGLOBALGET_char_ext");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_wd);lua_setglobal(L, "LUAGLOBALGET_char_wd");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ht);lua_setglobal(L, "LUAGLOBALGET_char_ht");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dp);lua_setglobal(L, "LUAGLOBALGET_char_dp");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_ic);lua_setglobal(L, "LUAGLOBALGET_char_ic");
- /* */
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dx);lua_setglobal(L,"LUAGLOBALGET_char_dx");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_char_dy);lua_setglobal(L,"LUAGLOBALGET_char_dy");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_designsize);lua_setglobal(L,"LUAGLOBALGET_designsize");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_hppp);lua_setglobal(L,"LUAGLOBALGET_hppp");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_vppp);lua_setglobal(L,"LUAGLOBALGET_vppp");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_x_offset);lua_setglobal(L,"LUAGLOBALGET_x_offset");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_y_offset);lua_setglobal(L,"LUAGLOBALGET_y_offset");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_granularity);lua_setglobal(L,"LUAGLOBALGET_granularity");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_fillin);lua_setglobal(L,"LUAGLOBALGET_fillin");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_turning_check);lua_setglobal(L,"LUAGLOBALGET_turning_check");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_boundary_char);lua_setglobal(L,"LUAGLOBALGET_boundary_char");
- lua_pushcfunction(L, priv_mfweb_LUAGLOBALGET_turning_number);lua_setglobal(L,"LUAGLOBALGET_turning_number");
- /* execute Lua external "mfluaini.lua" */
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ) {
- res = lua_pcall(L, 0, 0, 0);
- }
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
-
int mfluaPOSTfinalcleanup(void)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("final_cleanup.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"final_cleanup.lua not found");
- priv_lua_reporterrors(L, res);
+ GETGLOBALTABLEMFLUA(mfluaPOSTfinalcleanup);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_final_cleanup");
+ /* do the call (0 arguments, 0 result) */
+ if(res = lua_pcall(L, 0, 0, 0)){
+ lua_pushstring(L,"error in POST_final_cleanup:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
+ }
+ lua_settop(L,0);
return 0;
- }
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- /*if (res!=0) {fprintf(stderr,"\n! Warning: file final_cleanup not loaded\n",lua_tostring(L, -1)); return res;}*/
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- /*if (res!=0) {fprintf(stderr,"\n! Error: final_cleanup lua_pcall fails\n",lua_tostring(L, -1)); return res;}*/
- if (res==0){
- lua_getglobal(L, "POST_final_cleanup"); /* function to be called */
- /* do the call (0 arguments, 1 result) */
- res = lua_pcall(L, 0, 1, 0) ;
- /*if (res!=0) {fprintf(stderr,"\n! Error:function `POST_final_cleanup called fails\n",lua_tostring(L, -1)); return res;}*/
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_final_cleanup called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
- return 0;
}
-
/* Not a good way: */
/* 1) these definitions are taken from mfcoerc.h which is generated at run-time */
/* 2) too much coupling with webc2c translation of mf.web*/
@@ -766,140 +769,52 @@
int mfluaprintpath(halfword h, strnumber s, boolean nuline)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("print_path.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"print_path.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaprintpath);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "printpath");
+ lua_pushnumber(L, h); /* push 1st argument */
+ lua_pushnumber(L, s); /* push 2nd argument */
+ lua_pushnumber(L, nuline); /* push 3nd argument */
+ /* do the call (3 arguments, 0 result) */
+ if(res = lua_pcall(L, 3, 0, 0)){
+ lua_pushstring(L,"error in printpath:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "print_path"); /* function to be called */
- lua_pushnumber(L, h); /* push 1st argument */
- lua_pushnumber(L, s); /* push 2nd argument */
- lua_pushnumber(L, nuline); /* push 3nd argument */
- /* do the call (3 arguments, 1 result) */
- res = lua_pcall(L, 3, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `print_path' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L); */
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
int mfluaprintedges(strnumber s, boolean nuline, integer xoff, integer yoff)
{
-
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("print_edges.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"print_edges.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaprintedges);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "printedges");
+ lua_pushnumber(L, s); /* push 1st argument */
+ lua_pushnumber(L, nuline); /* push 2nd argument */
+ lua_pushnumber(L, xoff); /* push 3nd argument */
+ lua_pushnumber(L, yoff); /* push 4nd argument */
+ /* do the call (4 arguments, 0 result) */
+ if(res = lua_pcall(L, 4, 0, 0)){
+ lua_pushstring(L,"error in printedges:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "print_edges"); /* function to be called */
- lua_pushnumber(L, s); /* push 1st argument */
- lua_pushnumber(L, nuline); /* push 2nd argument */
- lua_pushnumber(L, xoff); /* push 3nd argument */
- lua_pushnumber(L, yoff); /* push 4nd argument */
- /* do the call (4 arguments, 1 result) */
- res = lua_pcall(L, 4, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `print_edges' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
-/* int mfluaoffsetprep(halfword c, halfword h) */
-/* { */
-
-/* lua_State *L = Luas[0]; */
-/* char* file = kpse_find_file("offset_prep.lua",kpse_lua_format, 0); */
-/* int res = luaL_loadfile(L, file); */
-/* if (file) free (file); */
-/* if ( res==0 ){ */
-/* res = lua_pcall(L, 0, 0, 0); */
-/* if (res==0){ */
-/* lua_getglobal(L, "offset_prep"); /\* function to be called *\/ */
-/* lua_pushnumber(L, c); /\* push 1st argument *\/ */
-/* lua_pushnumber(L, h); /\* push 2nd argument *\/ */
-/* /\* do the call (2 arguments, 1 result) *\/ */
-/* res = lua_pcall(L, 2, 1, 0) ; */
-/* if (res==0) { */
-/* /\* retrieve result *\/ */
-/* int z = 0; */
-/* if (!lua_isnumber(L, -1)){ */
-/* fprintf(stderr,"\n! Error:function `offset_prep' must return a number\n",lua_tostring(L, -1)); */
-/* lua_pop(L, 1); /\* pop returned value *\/ */
-/* return z; */
-/* }else { */
-/* z = lua_tonumber(L, -1); */
-/* lua_pop(L, 1); /\* pop returned value *\/ */
-/* return z; */
-/* } */
-/* } */
-/* } */
-/* } */
-/* // */
-/* //stackdump_g(L); */
-/* // */
-/* priv_lua_reporterrors(L, res); */
-/* return 0; */
-
-/* } */
-
-
/* */
/* Sensor before and after offset_prep */
/* */
@@ -907,137 +822,67 @@
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("offset_prep.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"offset_prep.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREoffsetprep);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_offset_prep");
+ lua_pushnumber(L, c); /* push 1st argument */
+ lua_pushnumber(L, h); /* push 2nd argument */
+ /* do the call (2 arguments, 0 result) */
+ if(res = lua_pcall(L, 2, 0, 0)){
+ lua_pushstring(L,"error in PRE_offset_prep:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_offset_prep"); /* function to be called */
- lua_pushnumber(L, c); /* push 1st argument */
- lua_pushnumber(L, h); /* push 2nd argument */
- /* do the call (2 arguments, 1 result) */
- res = lua_pcall(L, 2, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_offset_prep' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
+
int mfluaPOSToffsetprep(halfword c, halfword h)
{
-
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("offset_prep.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"offset_prep.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSToffsetprep);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_offset_prep");
+ lua_pushnumber(L, c); /* push 1st argument */
+ lua_pushnumber(L, h); /* push 2nd argument */
+ /* do the call (2 arguments, 0 result) */
+ if(res = lua_pcall(L, 2, 0, 0)){
+ lua_pushstring(L,"error in POST_offset_prep:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_offset_prep"); /* function to be called */
- lua_pushnumber(L, c); /* push 1st argument */
- lua_pushnumber(L, h); /* push 2nd argument */
- /* do the call (2 arguments, 1 result) */
- res = lua_pcall(L, 2, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_offset_prep' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
+
int mfluaPREmakespecrhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmakespecrhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_make_spec_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_make_spec_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_make_spec_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_make_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1045,44 +890,21 @@
int mfluaPOSTmakespecrhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmakespecrhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_make_spec_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_make_spec_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_make_spec_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_make_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1090,89 +912,42 @@
int mfluaPREmakespeclhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmakespeclhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_make_spec_lhs");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_make_spec_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_make_spec_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_make_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
int mfluaPOSTmakespeclhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmakespeclhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_make_spec_lhs");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_make_spec_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_make_spec_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_make_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1181,89 +956,44 @@
int mfluaPREfillenveloperhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREfillenveloperhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_fill_envelope_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_fill_envelope_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_fill_envelope_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_fill_envelope_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
int mfluaPOSTfillenveloperhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTfillenveloperhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_fill_envelope_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_fill_envelope_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_fill_envelope_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_fill_envelope_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L); */
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1272,89 +1002,44 @@
int mfluaPREfillenvelopelhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREfillenvelopelhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_fill_envelope_lhs");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_fill_envelope_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_fill_envelope_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_fill_envelope_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
int mfluaPOSTfillenvelopelhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTfillenvelopelhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_fill_envelope_lhs");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_fill_envelope_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_fill_envelope_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_fill_envelope_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1363,134 +1048,64 @@
int mfluaPREfillspecrhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREfillspecrhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_fill_spec_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_fill_spec_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_fill_spec_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_fill_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
int mfluaPOSTfillspecrhs(halfword rhs)
{
lua_State *L;
- char* luafile;
int res;
-
+
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTfillspecrhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_fill_spec_rhs");
+ lua_pushnumber(L, rhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_fill_spec_rhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_fill_spec_rhs"); /* function to be called */
- lua_pushnumber(L, rhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_fill_spec_rhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
int mfluaPREfillspeclhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREfillspeclhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_fill_spec_lhs");
+ L = Luas[0];
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_fill_spec_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_fill_spec_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_fill_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
@@ -1498,279 +1113,139 @@
int mfluaPOSTfillspeclhs(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"do_add_to.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTfillspeclhs);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_fill_spec_lhs");
+ L = Luas[0];
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_fill_spec_lhs:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_fill_spec_lhs"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_fill_spec_lhs' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
+
int mfluaPREmovetoedges(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("fill_spec.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"fill_spec.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmovetoedges);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "PRE_move_to_edges");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_move_to_edges:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_move_to_edges"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_move_to_edges' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
int mfluaPOSTmovetoedges(halfword lhs)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("fill_spec.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"fill_spec.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmovetoedges);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1, "POST_move_to_edges");
+ lua_pushnumber(L, lhs); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_move_to_edges:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_move_to_edges"); /* function to be called */
- lua_pushnumber(L, lhs); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_move_to_edges' must return a number called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
int mfluaPREmakechoices(halfword p)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("scan_direction.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"scan_direction.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmakechoices);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"PRE_make_choices"); /* function to be called */
+ lua_pushnumber(L, p); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in PRE_make_choices:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_make_choices"); /* function to be called */
- lua_pushnumber(L, p); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_make_choices' must return a number and not %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
int mfluaPOSTmakechoices(halfword p)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("scan_direction.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"scan_direction.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmakechoices);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"POST_make_choices"); /* function to be called */
+ lua_pushnumber(L, p); /* push 1st argument */
+ /* do the call (1 arguments, 0 result) */
+ if(res = lua_pcall(L, 1, 0, 0)){
+ lua_pushstring(L,"error in POST_make_choices:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_make_choices"); /* function to be called */
- lua_pushnumber(L, p); /* push 1st argument */
- /* do the call (1 arguments, 1 result) */
- res = lua_pcall(L, 1, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `POST_make_choices' must return a number and not %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
-
-
-
int mfluaprintretrogradeline(integer x0, integer y0, integer cur_x, integer cur_y)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("skew_line_edges.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"skew_line_edges.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaprintretrogradeline);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"print_retrograde_line");
+ lua_pushnumber(L, x0); /* push 1st argument */
+ lua_pushnumber(L, y0); /* push 2nd argument */
+ lua_pushnumber(L, cur_x); /* push 3th argument */
+ lua_pushnumber(L, cur_y); /* push 4th argument */
+ /* do the call (4 arguments, 0 result) */
+ if(res = lua_pcall(L, 4, 0, 0)){
+ lua_pushstring(L,"error in print_retrograde_line:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "print_retrograde_line"); /* function to be called */
- lua_pushnumber(L, x0); /* push 1st argument */
- lua_pushnumber(L, y0); /* push 2nd argument */
- lua_pushnumber(L, cur_x); /* push 3th argument */
- lua_pushnumber(L, cur_y); /* push 4th argument */
- /* do the call (4 arguments, 1 result) */
- res = lua_pcall(L, 4, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `print_retrograde_line called with %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
@@ -1777,195 +1252,105 @@
int mfluaPREmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("make_ellipse.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"make_ellipse.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPREmakeellipse);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"PRE_make_ellipse");
+ lua_pushnumber(L, major_axis); /* push 1st argument */
+ lua_pushnumber(L, minor_axis); /* push 2nd argument */
+ lua_pushnumber(L, theta); /* push 3th argument */
+ lua_pushnumber(L, tx); /* push 4th argument */
+ lua_pushnumber(L, ty); /* push 5th argument */
+ lua_pushnumber(L, q); /* push 6th argument */
+ /* do the call (6 arguments, 0 result) */
+ if(res = lua_pcall(L, 6, 1, 0)){
+ lua_pushstring(L,"error in PRE_make_ellipse:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "PRE_make_ellipse"); /* function to be called */
- lua_pushnumber(L, major_axis); /* push 1st argument */
- lua_pushnumber(L, minor_axis); /* push 2nd argument */
- lua_pushnumber(L, theta); /* push 3th argument */
- lua_pushnumber(L, tx); /* push 4th argument */
- lua_pushnumber(L, ty); /* push 5th argument */
- lua_pushnumber(L, q); /* push 6th argument */
- /* do the call (6 arguments, 1 result) */
- res = lua_pcall(L, 6, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_make_ellipse returns %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
+
int mfluaPOSTmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("make_ellipse.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"make_ellipse.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaPOSTmakeellipse);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"POST_make_ellipse");
+ lua_pushnumber(L, major_axis); /* push 1st argument */
+ lua_pushnumber(L, minor_axis); /* push 2nd argument */
+ lua_pushnumber(L, theta); /* push 3th argument */
+ lua_pushnumber(L, tx); /* push 4th argument */
+ lua_pushnumber(L, ty); /* push 5th argument */
+ lua_pushnumber(L, q); /* push 6th argument */
+ /* do the call (6 arguments, 0 result) */
+ if(res = lua_pcall(L, 6, 1, 0)){
+ lua_pushstring(L,"error in POST_make_ellipse:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "POST_make_ellipse"); /* function to be called */
- lua_pushnumber(L, major_axis); /* push 1st argument */
- lua_pushnumber(L, minor_axis); /* push 2nd argument */
- lua_pushnumber(L, theta); /* push 3th argument */
- lua_pushnumber(L, tx); /* push 4th argument */
- lua_pushnumber(L, ty); /* push 5th argument */
- lua_pushnumber(L, q); /* push 6th argument */
- /* do the call (6 arguments, 1 result) */
- res = lua_pcall(L, 6, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `PRE_make_ellipse returns %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
-
}
+
-
int mfluaprinttransitionlinefrom(integer x, integer y)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("fill_envelope.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"fill_envelope.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaprinttransitionlinefrom);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"print_transition_line_from");
+ lua_pushnumber(L, x); /* push 1st argument */
+ lua_pushnumber(L, y); /* push 2nd argument */
+ /* do the call (2 arguments, 0 result) */
+ if(res = lua_pcall(L, 2, 0, 0)){
+ lua_pushstring(L,"error in print_transition_line_from:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "print_transition_line_from"); /* function to be called */
- lua_pushnumber(L, x); /* push 1st argument */
- lua_pushnumber(L, y); /* push 2nd argument */
- /* do the call (2 arguments, 1 result) */
- res = lua_pcall(L, 2, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `print_transition_from' must return a number and nt %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
int mfluaprinttransitionlineto(integer x, integer y)
{
lua_State *L;
- char* luafile;
int res;
L = Luas[0];
- luafile = kpse_find_file("fill_envelope.lua", kpse_lua_format, 0);
- if (luafile==NULL) {
- res = 1;
- lua_pushstring(L,"fill_envelope.lua not found");
- priv_lua_reporterrors(L, res);
- return 0;
+ GETGLOBALTABLEMFLUA(mfluaprinttransitionlineto);
+ if (lua_istable(L, -1)) {
+ lua_getfield(L,-1,"print_transition_line_to");
+ lua_pushnumber(L, x); /* push 1st argument */
+ lua_pushnumber(L, y); /* push 2nd argument */
+ /* do the call (2 arguments, 0 result) */
+ if(res = lua_pcall(L, 2, 0, 0)){
+ lua_pushstring(L,"error in print_transition_line_to:");
+ lua_swap(L);lua_concat (L, 2);
+ priv_lua_reporterrors(L, res);
+ }
}
- priv_lua_writemessage(L,"(",luafile,")",1);
- res = luaL_loadfile(L, luafile);
- free (luafile);
- if ( res==0 ){
- res = lua_pcall(L, 0, 0, 0);
- if (res==0){
- lua_getglobal(L, "print_transition_line_to"); /* function to be called */
- lua_pushnumber(L, x); /* push 1st argument */
- lua_pushnumber(L, y); /* push 2nd argument */
- /* do the call (2 arguments, 1 result) */
- res = lua_pcall(L, 2, 1, 0) ;
- if (res==0) {
- /* retrieve result */
- int z = 0;
- if (!lua_isnumber(L, -1)){
- fprintf(stderr,"\n! Error:function `print_transition_to' must return a number and not %s\n",lua_tostring(L, -1));
- lua_pop(L, 1); /* pop returned value */
- return z;
- }else {
- z = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
- return z;
- }
- }
- }
- }
- /*stackdump_g(L);*/
- priv_lua_reporterrors(L, res);
+ lua_settop(L,0);
return 0;
}
+
+
#define priv_append_char(c) do { \
strpool[poolptr]=c; \
poolptr++; \
Modified: trunk/Build/source/texk/web2c/mfluadir/mfluaextra.h
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluaextra.h 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluaextra.h 2017-04-16 10:11:22 UTC (rev 43840)
@@ -21,3 +21,4 @@
#define INPUT_FORMAT kpse_mf_format
#define INI_PROGRAM "inimflua"
#define VIR_PROGRAM "virmflua"
+#define MFLua
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/begin_program.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
--- empty
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/do_add_to.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,9 +0,0 @@
-function PRE_fill_envelope_rhs(rhs) return 0 end
-function POST_fill_envelope_rhs(rhs) return 0 end
-function PRE_fill_envelope_lhs(rhs) return 0 end
-function POST_fill_envelope_lhs(rhs) return 0 end
-
-function PRE_fill_spec_rhs(rhs) return 0 end
-function POST_fill_spec_rhs(rhs) return 0 end
-function PRE_fill_spec_lhs(rhs) return 0 end
-function POST_fill_spec_lhs(rhs) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/end_program.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
--- empty
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_envelope.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function print_transition_line_from(x,y) return 0 end
-function print_transition_line_to(x,y) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/fill_spec.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function PRE_move_to_edges(lhs) return 0 end
-function POST_move_to_edges(lhs) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/final_cleanup.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
-function POST_final_cleanup() return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/main_control.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function PRE_main_control() return 0 end
-function POST_main_control() return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/make_ellipse.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function PRE_make_ellipse(major_axis,minor_axis,theta,tx,ty) return 0 end
-function POST_make_ellipse(major_axis,minor_axis,theta,tx,ty) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/mfluaini.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
--- empty
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/offset_prep.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function PRE_offset_prep(c,h) return 0 end
-function POST_offset_prep(c,h) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_edges.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
-function print_edges(s,nuline,xoff,yoff) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/print_path.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
-function print_path(h,s,nuline) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/scan_direction.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,2 +0,0 @@
-function PRE_make_choices(p) return 0 end
-function POST_make_choices(p) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/skew_line_edges.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
-function print_retrograde_line(x0,y0,cur_x,cur_y) return 0 end
\ No newline at end of file
Deleted: trunk/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_mf.lua
===================================================================
--- trunk/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_mf.lua 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluadir/mfluatrap/start_of_mf.lua 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1 +0,0 @@
-function PRE_start_of_MF() return 0 end
\ No newline at end of file
Modified: trunk/Build/source/texk/web2c/mfluajitdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/mfluajitdir/ChangeLog 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluajitdir/ChangeLog 2017-04-16 10:11:22 UTC (rev 43840)
@@ -1,3 +1,8 @@
+2017-04-16 Luigi Scarso <luigi.scarso at gmail.com>
+
+ * am/mfluajit.am: delete useless lua files
+
+
2016-04-05 Karl Berry <karl at tug.org>
* am/mflua.am: no need for inimfluajit.
Modified: trunk/Build/source/texk/web2c/mfluajitdir/am/mfluajit.am
===================================================================
--- trunk/Build/source/texk/web2c/mfluajitdir/am/mfluajit.am 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluajitdir/am/mfluajit.am 2017-04-16 10:11:22 UTC (rev 43840)
@@ -124,23 +124,12 @@
mfluajittrap-clean:
rm -rf mfluajittrapdir
+
## Test data
##
EXTRA_DIST += \
- mfluadir/mfluatrap/begin_program.lua \
- mfluadir/mfluatrap/do_add_to.lua \
- mfluadir/mfluatrap/end_program.lua \
- mfluadir/mfluatrap/fill_envelope.lua \
- mfluadir/mfluatrap/fill_spec.lua \
- mfluadir/mfluatrap/final_cleanup.lua \
- mfluadir/mfluatrap/main_control.lua \
- mfluadir/mfluatrap/make_ellipse.lua \
- mfluadir/mfluatrap/mfluaini.lua \
- mfluadir/mfluatrap/offset_prep.lua \
- mfluadir/mfluatrap/print_edges.lua \
- mfluadir/mfluatrap/print_path.lua \
- mfluadir/mfluatrap/scan_direction.lua \
- mfluadir/mfluatrap/skew_line_edges.lua \
- mfluadir/mfluatrap/start_of_MF.lua \
- mfluadir/mfluatrap/texmf.cnf \
- mfluajitdir/mfluajittrap/mfluajittrap.diffs
+ mfluadir/mfluatrap/mflua.lua \
+ mfluadir/mfluatrap/mflua_svg_backend.lua \
+ mfluadir/mfluatrap/mflua_ttx_backend.lua \
+ mfluadir/mfluatrap/texmf.cnf \
+ mfluadir/mfluatrap/mfluatrap.diffs
Modified: trunk/Build/source/texk/web2c/mfluajitdir/mfluajitextra.h
===================================================================
--- trunk/Build/source/texk/web2c/mfluajitdir/mfluajitextra.h 2017-04-16 09:10:05 UTC (rev 43839)
+++ trunk/Build/source/texk/web2c/mfluajitdir/mfluajitextra.h 2017-04-16 10:11:22 UTC (rev 43840)
@@ -21,3 +21,4 @@
#define INPUT_FORMAT kpse_mf_format
#define INI_PROGRAM "inimfluajit"
#define VIR_PROGRAM "virmfluajit"
+#define MFLuaJIT
\ No newline at end of file
More information about the tex-live-commits
mailing list