Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector - problem on IOS #12

Open
5minutes2start opened this issue Dec 22, 2014 · 11 comments
Open

Vector - problem on IOS #12

5minutes2start opened this issue Dec 22, 2014 · 11 comments

Comments

@5minutes2start
Copy link

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
Copy link
Author

BTW, it also works fine with array like:

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

@jonnyreeves
Copy link
Owner

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.

@5minutes2start
Copy link
Author

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

@jonnyreeves
Copy link
Owner

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
Copy link
Owner

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?

@5minutes2start
Copy link
Author

there is NO missing leading and trailling underscores.

@lucianar
Copy link

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
Copy link

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?

@halfjust
Copy link

+1

@jonnyreeves
Copy link
Owner

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
#12 (comment)
.

@lucianar
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants