google-code-export / lua-alchemy

Automatically exported from code.google.com/p/lua-alchemy
0 stars 1 forks source link

AS3 Sugar pass wrong value to as3 after one invalid usage #163

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. define following class Doer

    public class Doer
    {
        public static var lua:LuaAlchemy = new LuaAlchemy();

        public static function first():void
        {
            lua.doString("as3.class.Doer.property = 'false'");
        }

        public static function second():void
        {
            lua.doString("as3.class.Doer.property = false");
            lua.doString("as3.class.Doer.property = true");
            lua.doString("as3.class.Doer.property = false");
            lua.doString("as3.class.Doer.property = true");
        }

        private static var _property:Boolean;
        public static function set property(value:Boolean):void
        {
            _property = value;
            trace(value + ":" + typeof(value));
        }
    }

2. call Doer.first() 
3. call Doer.second()

What is the expected output? What do you see instead?
In step 2, an error should be thrown in lua, but we see the output:
true:boolean
In step 3, following is printed, which is apparently wrong
true:boolean
true:boolean
true:boolean
true:boolean

What version of the product are you using? On what operating system?
I am using lua-alchemy-v0.3.2.swc, on windows xp sp3

Please provide any additional information below.
The order we call lua.doString is important, expecially the first two call 
after the LuaAlchemy instance is created.
This issue also affect a boolean value returned by lua to as3 (for example, 
"return false" lua statement would return arbitrary value to as3 instead of the 
specified boolean false value).

Immediately after the LuaAlchemy instance is created, the following two call 
can make its behavior acceptable (boolean value set as expected, 'false' 
becomes false, any other string becomes true):
lua.doString("as3.class.Doer.property = false");
lua.doString("as3.class.Doer.property = true");

Original issue reported on code.google.com by DanrenJ...@gmail.com on 8 Jun 2013 at 6:36

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 10 Jun 2013 at 11:14