as3-vanilla icon indicating copy to clipboard operation
as3-vanilla copied to clipboard

Vector - problem on IOS

Open 5minutes2start opened this issue 10 years ago • 11 comments

Hi there,

I believe there is some bug that do not allow to extract Class with nested Vector. Ths problem seems to happen only on IOS (and only in Release mode. On debug mode it works fine0 Check this sample:

Main Class

 public class VanillaTest
 {

          public function VanillaTest(){

          var myObj:Object = {};
         myObj.elements = [];
         myObj.elements[0] = {name: "john1"};
         myObj.elements[1] = {name: "john2"};
         myObj.elements[2] = {name: "john3"};

      var finalObject:TestClass = new Vanilla().extract(json, TestClass);

                       if (finalObject.elements){

                for (var i:int = 0; i < finalObject.elements.length; i++){

                    trace(finalObject.elements[i].name);

                }
            }

}

}

Test Class

public class TestClass
{
    private var _elements:Vector.<TestObject>;

    public function TestClass()
    {
    }

    public function get elements():Vector.<TestObject>
    {
        return _elements;
    }

    public function set elements(value:Vector.<TestObject>):void
    {
        _elements = value;
    }

}

Test Object

public class TestObject
{
    private var _name:String;

    public function TestObject()
    {
    }

    public function get name():String
    {
        return _name;
    }

    public function set name(value:String):void
    {
        _name = value;
    }

}

5minutes2start avatar Dec 22 '14 09:12 5minutes2start

BTW, it also works fine with array like:

[Marshall (type="TestObject")] private var _elements: Array;

5minutes2start avatar Dec 22 '14 09:12 5minutes2start

My guess would be that it's related to the way AS3 Vanilla determines Vector types at run-time in the isVector method.

return (getQualifiedClassName(obj).indexOf('__AS3__.vec::Vector') == 0);

I don't have an iOS dev environment on this machine; any chance you could run the following code in release mode for me please?

const myVector : Vector.<String> = new Vector.<String>();
trace("qualified class name = " + getQualifiedClassName(myVector));

Thanks.

jonnyreeves avatar Dec 22 '14 09:12 jonnyreeves

        qualified class name = __AS3__.vec::Vector.<String>

5minutes2start avatar Dec 22 '14 10:12 5minutes2start

Hah - good old Adobe ;) I'm pretty busy today, so if you want this fixed upstream quick then please raise a pull request which check for either __AS3__ or AS3 at the start of the vector toString (unless there's a more elegant way of doing this now?)

Thanks! :)

jonnyreeves avatar Dec 22 '14 10:12 jonnyreeves

Oh did you mean to emphasis AS3 to highlight it was missing the leading and trailing underscores, or did you not mean for that markdown to be applied?

jonnyreeves avatar Dec 22 '14 10:12 jonnyreeves

there is NO missing leading and trailling underscores.

5minutes2start avatar Dec 22 '14 10:12 5minutes2start

I've got the exact same problem. Can't seem to run my app on iOS without runtime problems. Any thoughts on how to fix this?

lucianar avatar Jan 27 '15 10:01 lucianar

In my case, I have narrowed the problem down to the Vanilla.extract() method which uses as3common-reflect's Type.forClass() method to instantiate a reflectionMap. When running on debug the lib works perfectly, populating the map's fields with valid parameters, but on release they are all undefined. Those parameters are used later on on the extraction, hence the runtine errors.

if (!injectionMapCache[targetType]) { injectionMapCache[targetType] = new InjectionMap(); var reflectionMap:Type = Type.forClass(targetType, ApplicationDomain.currentDomain); trace(">>||SCOUT TRACE:|| >> Acessor 0 parameter: " + Accessor(reflectionMap.fields[0]).type.parameters[0]); //this guys are all undefined when the error occurs trace(">>||SCOUT TRACE:|| >> Acessor 1 parameter: " + Accessor(reflectionMap.fields[1]).type.parameters[0]); trace(">>||SCOUT TRACE:|| >> Acessor 2 parameter: " + Accessor(reflectionMap.fields[2]).type.parameters[0]); addReflectedRules(injectionMapCache[targetType], targetType, reflectionMap)); }

Can't seem to find how to work around this issue, though. Any thoughts?

lucianar avatar Jan 27 '15 13:01 lucianar

+1

halfjust avatar Jan 27 '15 16:01 halfjust

Sounds like an issue with as3common-reflect - have you tried updating to a new version of the library (.swc) and recompiling AS3 vanilla to see if that resolves the problem?

On 27 January 2015 at 13:15, luciana00br [email protected] wrote:

In my case, I have narrowed the problem down to the Vanilla.extract() method which uses as3common-reflect's Type.forClass() method to instantiate a reflectionMap. When running on debug the lib works perfectly, populating the map's fields with valid parameters, but on release they are all undefined. Those parameters are used later on on the extraction, hence the runtine errors.

if (!injectionMapCache[targetType]) { injectionMapCache[targetType] = new InjectionMap(); var reflectionMap:Type = Type.forClass(targetType, ApplicationDomain.currentDomain); trace(">>||SCOUT TRACE:|| >> Acessor 0 parameter: " + Accessor(reflectionMap.fields[0]).type.parameters[0]); trace(">>||SCOUT TRACE:|| >> Acessor 1 parameter: " + Accessor(reflectionMap.fields[1]).type.parameters[0]); trace(">>||SCOUT TRACE:|| >> Acessor 2 parameter: " + Accessor(reflectionMap.fields[2]).type.parameters[0]); addReflectedRules(injectionMapCache[targetType], targetType, reflectionMap)); }

Can't seem to find how to work around this issue, though. Any thoughts?

— Reply to this email directly or view it on GitHub https://github.com/jonnyreeves/as3-vanilla/issues/12#issuecomment-71645712 .

jonnyreeves avatar Jan 27 '15 16:01 jonnyreeves

I've tried compiling with v 1.6.2 but the issue remains. That lib's source code is showing some dependency problems, so bug tracking it's proving to be a little tricky. I'm still investigating, but any help would be much appreciated.

lucianar avatar Jan 27 '15 17:01 lucianar