Referring Issue 149: lua_wrapper.gg(162): dirty state stack

7 views
Skip to first unread message

sillybear

unread,
Jan 26, 2012, 5:49:07 PM1/26/12
to lua-alchemy-dev
Regarding the issue 149: Lua_wrapper.gg(162): dirty state stack:

Tried to call lua.doString("as3.enable_sugar_autoconversion()\r\n" +
scriptChild.getScript()); inside the function call of
lua.doString("as3.enable_sugar_autoconversion()\r\n" +
scriptParent.getScript()); but no success.

====================================================================
First created a new LuaAlchemy instance.

then use luaAlchemy.dostring to load script.

It works fine for one entry, however, it did not work when dostring
will call dostring again.

and I can not find "loadstring" function with LuaAlchemy. How can I
call luaAlchemy.dostring inside luaAlchemy.dostring? Thanks.

My code snapshot is as following:

================================================================


public function LuaWorkSpace() {
lua = new LuaAlchemy();
try {
var env:Env= new Env();
lua.setGlobal("map", env);
} catch (e:Error) {
Logger.error("lua init " + e.message);
}
}


public function runScript(script:String):Boolean {

var eventStack:EventStack= new EventStack();
eventStack.push(new MapEventWrapper());
try {
if (script.getCompiled() == null)
lua.doString("as3.enable_sugar_autoconversion()\r\n" +
script);
eventStack.pop();
return true;
} catch (ex:Error) {
Logger.error("runScript " + ex.message);
return false;
}
return false;
}

Alexander Gladysh

unread,
Feb 25, 2012, 8:30:36 AM2/25/12
to lua-alc...@googlegroups.com
On Fri, Jan 27, 2012 at 02:49, sillybear <jxy...@yahoo.ca> wrote:
> Regarding the issue 149: Lua_wrapper.gg(162): dirty state stack:
>
> Tried to call lua.doString("as3.enable_sugar_autoconversion()\r\n" +
> scriptChild.getScript()); inside the function call of
> lua.doString("as3.enable_sugar_autoconversion()\r\n" +
> scriptParent.getScript()); but no success.
>
> ====================================================================
> First created a new LuaAlchemy instance.
>
> then use luaAlchemy.dostring to load script.
>
> It works fine for one entry, however, it did not work when dostring
> will call dostring again.
>
> and I can not find "loadstring" function with LuaAlchemy. How can I
> call luaAlchemy.dostring inside luaAlchemy.dostring? Thanks.

Working on a fix for doString reentrance.

Meanwhile I re-read what you say about loadstring(), and I'm confused.
Unless you have explicitly done something with global environment
table _G in your state (like sandboxed it), loadstring() should be
there. Please try this in the demo:

http://lua-alchemy.googlecode.com/svn/trunk/demo/index.html

as3.enable_sugar_autoconversion()

-- Use your own AS3 object instead
local label = as3.class.mx.controls.Label.new()
label.text = "return 42" -- assuming this is done somewhere in AS3 code

local fn = assert(loadstring(label.text, "@myCode"))
assert(fn() == 42)

as3.makeprinter(output)("OK")

If that works, try running it in your code (omit last line with OK —
it is only there so you'll better see in demo that everything works).

HTH,
Alexander.

Reply all
Reply to author
Forward
0 new messages