-- ************************************************************************ -- -- A debug module that allows me an interactive view into a Lua state -- Copyright 2020 by Sean Conner. All Rights Reserved. -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- -- Comments, questions and criticisms can be sent to: sean@conman.org -- -- ************************************************************************ -- luacheck: globals handler -- luacheck: ignore 611 local luaview = require "org.flummux.luaview" local nfl = require "org.conman.nfl" local coroutine = require "coroutine" _ENV = {} function handler(conf,_,_,_,ios) if not conf.co then conf.co = coroutine.running() luaview.init() nfl.SOCKETS:insert(luaview,'r',function() if not luaview.step() then nfl.schedule(conf.co) end end) coroutine.yield() nfl.SOCKETS:remove(luaview) luaview.close() conf.co = nil ios:write("20 text/plain\r\nFINISHED\r\n") return 20 else ios:write("20 text/plain\r\nRUNNING\r\n") return 20 end end return _ENV