|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- (find-fline "flua-lua.lua")
lua
strings.Cextras1 = strings.Cextras1 .. [[
#include "dllua.h"
/* define L (from now on, and in this file only) as a shorthand
* for a long variable name:
*/
#define L flua_lua_state
lua_State *L = NULL;
#define Cfprim00(fun) ((funptr)fun)()
#define Cfprim10(fun) ((funptr)fun)(DS[0]); DS--
#define Cfprim20(fun) ((funptr)fun)(DS[-1],DS[0]); DS-=2
#define Cfprim30(fun) ((funptr)fun)(DS[-2],DS[-1],DS[0]); DS-=3
#define Cfprim01(fun) DS[1]=((funptr)fun)(); DS++
#define Cfprim11(fun) DS[0]=((funptr)fun)(DS[0])
#define Cfprim21(fun) DS[-1]=((funptr)fun)(DS[-1],DS[0]); DS--
#define Cfprim31(fun) DS[-2]=((funptr)fun)(DS[-2],DS[-1],DS[0]); DS-=2
#define CLuafprim00(fun) ((funptr)fun)(L)
#define CLuafprim10(fun) ((funptr)fun)(L,DS[0]); DS--
#define CLuafprim20(fun) ((funptr)fun)(L,DS[-1],DS[0]); DS-=2
#define CLuafprim30(fun) ((funptr)fun)(L,DS[-2],DS[-1],DS[0]); DS-=3
#define CLuafprim01(fun) DS[1]=((funptr)fun)(L); DS++
#define CLuafprim11(fun) DS[0]=((funptr)fun)(L,DS[0])
#define CLuafprim21(fun) DS[-1]=((funptr)fun)(L,DS[-1],DS[0]); DS--
#define CLuafprim31(fun) DS[-2]=((funptr)fun)(L,DS[-2],DS[-1],DS[0]); DS-=2
]]
add_Fprims(
"lua_state "," DS[1]=(void *)L; DS++; goto forth;",
"lua_state!"," L=(void *)(DS[0]); DS--; goto forth;",
"lua_pop "," lua_settop(L, -(DS[0])-1); DS--; goto forth;",
"lua_pushnumber"," lua_pushnumber(L, DS[0]); DS--; goto forth;"
)
function makecfprimword(immedword, macro)
action[immedword] = function()
local cfunction = getword()
add_Fprims(cfunction, format("%s(%s); goto forth;", %macro, cfunction))
end
end
makecfprimword("C0::", "Cfprim01")
makecfprimword("C1::", "Cfprim11")
makecfprimword("C2::", "Cfprim21")
makecfprimword("C3::", "Cfprim31")
makecfprimword("CLUA0::", "CLuafprim01")
makecfprimword("CLUA1::", "CLuafprim11")
makecfprimword("CLUA2::", "CLuafprim21")
makecfprimword("CLUA3::", "CLuafprim31")
makecfprimword("CLUA00::", "CLuafprim00")
makecfprimword("CLUA10::", "CLuafprim10")
makecfprimword("CLUA20::", "CLuafprim20")
makecfprimword("CLUA30::", "CLuafprim30")
-- (find-angg "flua/flua-comp.lua" "cnword")
end;
C1:: lua_open -- ( nels -- lua_State* )
CLUA00:: lua_close -- ( -- )
C1:: dllua_open -- ( nels -- lua_Stt* )
-- (find-node "(lua)The Stack and Indices")
CLUA0:: lua_gettop -- ( -- nelements )
CLUA0:: lua_stackspace -- ( -- nelements )
-- (find-node "(lua)Stack Manipulation")
CLUA10:: lua_settop -- ( index -- )
CLUA10:: lua_pushvalue -- ( index -- )
CLUA10:: lua_remove -- ( index -- )
CLUA10:: lua_insert -- ( index -- )
-- (find-node "(lua)Pushing Values Onto The Stack")
CLUA20:: lua_pushlstring -- ( adr len -- )
CLUA10:: lua_pushstring -- ( adr -- )
CLUA20:: lua_pushusertag -- ( adr tag -- )
CLUA00:: lua_pushnil -- ( -- )
-- CLUA10:: lua_pushcfunction -- ( luacfun -- )
-- (find-node "(lua)Executing Lua Code")
CLUA10:: lua_dofile -- ( fnameadr -- )
CLUA10:: lua_dostring -- ( stradr -- )
CLUA30:: lua_dobuffer -- ( adr len nameadr -- )
-- (find-node "(lua)Manipulating Global Variables in Lua")
CLUA10:: lua_getglobal -- ( varname -- )
CLUA10:: lua_setglobal -- ( varname -- )
CLUA00:: lua_getglobals -- ( -- )
CLUA00:: lua_setglobals -- ( -- )
-- (find-node "(lua)Manipulating Tables in Lua")
CLUA10:: lua_gettable -- ( index -- )
CLUA10:: lua_rawget -- ( index -- )
CLUA10:: lua_settable -- ( index -- )
CLUA10:: lua_rawset -- ( index -- )
CLUA00:: lua_newtable -- ( -- )
-- (find-node "(lua)Using Tables as Arrays")
CLUA00:: lua_rawgeti -- ( index n -- )
CLUA00:: lua_rawseti -- ( index n -- )
CLUA00:: lua_getn -- ( index -- n)
-- (find-node "(lua)Calling Lua Functions")
CLUA2:: lua_call -- ( nargs nresults -- errcode )
CLUA20:: lua_rawcall -- ( nargs nresults -- )
CLUA1:: lua_error -- ( msgstr -- )
CLUA20:: lua_settagmethod -- ( tag evname -- )
CLUA20:: lua_gettagmethod -- ( tag evname -- )
CLUA20:: lua_copytagmethods -- ( tto tfrom-- )
CLUA1:: lua_next -- ( index -- status )
CLUA10:: lua_concat -- ( n -- )