Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-29 Thread Olaf Krueger
Thanks for your input Greg!


>If there is not already some JSON support for public vars and avoiding 
private vars etc, then it could definitely be supported with a replacer 
function that uses royale reflection. 


Just to ensure that we're on the same path:
The current issue is that JSON.stringify() returns the fully qualified name
of all getters, 
e.g. 
{
   "com.mydomain.myapp.myGetter" = "foo";
}

instead of 
{
   "myGetter" = "foo";
}

Is your proposal that this could be fixed by using a replacer function in
JSON.stringify() at framework side which makes usage of Royale reflection?

Thanks,
Olaf



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Greg Dove
Using javascript native Reflect is one option. But maybe you can use
Object.keys and Object.getOwnPropertyDescriptor to keep compatible with
IE11 ?

Royale reflection is 'heavier' but gives you more specific support from
within the framework.

Probably the easiest way to see how to use that is via examples:

https://github.com/apache/royale-asjs/blob/develop/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as


for a public var on an instance

var definition:TypeDefinition = describeType(inst);

var variables:Array = definition.variables;
the VariableDefinition instances in this Array let you get and set the
value on an instance

var varDef:VariableDefinition = variables[0];
trace(varDef.name)
trace(varDef.getValue(inst))

specific example:
https://github.com/apache/royale-asjs/blob/1b905918ca30b3280e8b90ad7ee73ff6193b781d/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as#L237

So the above does provide you with a way to filter public vars (and also
public accessors as well) on an instance, and you can get and set the
values. This avoids all the private vars and any other namespaces that may
appear in native enumeration (reflection).

If there is not already some JSON support for public vars and avoiding
private vars etc, then it could definitely be supported with a replacer
function that uses royale reflection. Using reflection classes from the
framework could be a starting point, but probably using the reflection data
directly would be the better solution. AMFBinaryData uses this extensively
for AMF serialization, doing that with JSON would be a similar thing.












On Fri, Mar 29, 2019 at 8:16 AM Olaf Krueger  wrote:

> Hi,
>
> > But reflection classes now support it...
>
> Just to mention it:
> Thanks to Piotr we're using Reflection [1] to extract the getters in order
> create dynamic objects which can be stringified by using JSON.stringify()
> then.
>
> However, would be even better if Yishay's idea or something other on the
> framework side would provide solutions. I could imagine that others will
> also run into that issue.
>
> Olaf
>
> [1]
> public static function getGetters(obj:Object):Array
> {
> return Reflect.ownKeys(obj).filter(
> function(name:*):* {
>   var dummy:* = typeof Reflect.getOwnPropertyDescriptor(obj,
> name)["get"] === "function";
>   return dummy;
> });
> }
>
>
>
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/
>


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Olaf Krueger
Hi,

> But reflection classes now support it...

Just to mention it:
Thanks to Piotr we're using Reflection [1] to extract the getters in order
create dynamic objects which can be stringified by using JSON.stringify()
then.

However, would be even better if Yishay's idea or something other on the
framework side would provide solutions. I could imagine that others will
also run into that issue.

Olaf

[1]
public static function getGetters(obj:Object):Array 
{
return Reflect.ownKeys(obj).filter(
function(name:*):* {
  var dummy:* = typeof Reflect.getOwnPropertyDescriptor(obj,
name)["get"] === "function";
  return dummy;
});
}



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Greg Dove
Hi Yishay,

No I don't think so. I think you can use some filtering options in a
replacer function in conjunction with stringify. AMF has something similar
for filtering or altering dynamic properties.

The longer term solution for this is to have a better implementation for
namespaces, and to make private members non-enumerable for example, imo.
But I think using a replacer function with some checks against reflection
data would probably be best for now. Maybe there is already something for
that - I know Alex has done some work on JSON serialization already.




On Fri, Mar 29, 2019 at 7:51 AM Yishay Weiss  wrote:

> Hi Greg,
>
>
>
> I’m referring to Olaf’s issue [1] with JSON.stringify() using the
> qualified property names. Could a class alias change the qualification
> prefix?
>
>
>
> [1]
> http://apache-royale-development.20373.n8.nabble.com/Plain-public-variables-complain-they-don-t-have-getters-setters-Was-CreationComplete-event-question-tp9337p9353.html
>
>
>
> 
> From: Greg Dove 
> Sent: Thursday, March 28, 2019 8:28:18 PM
> To: dev@royale.apache.org
> Subject: Re: Plain public variables complain they don't have getters /
> setters (Was "CreationComplete event question")
>
> 'I’m wondering if registerClassAlias or the RemoteClass meta-tag would
> solve this. Anyone know?'
>
> The issue with public car renaming?
>
> I can't see how it could.
> But reflection classes now support it (you can get and set public var
> values in release mode via reflection) and AMF works with public vars too.
>
> On Fri, 29 Mar 2019, 07:20 Yishay Weiss,  wrote:
>
> > I’m wondering if registerClassAlias or the RemoteClass meta-tag would
> > solve this. Anyone know?
> >
> >
> >
> > ____________
> > From: Harbs 
> > Sent: Thursday, March 28, 2019 3:03:46 PM
> > To: dev@royale.apache.org
> > Subject: Re: Plain public variables complain they don't have getters /
> > setters (Was "CreationComplete event question")
> >
> > FWIW, I use a method to convert classes to JSON which allows me to define
> > exactly which properties get written and using what names.
> >
> > i.e. myFoo.toData()
> >
> > > On Mar 28, 2019, at 1:26 PM, Olaf Krueger 
> wrote:
> > >
> > > I would just like to mention that resolving this "public vars" issue by
> > > replacing the public by private vars with getters/setters has a side
> > effect:
> > > JSON.stringify() stringifies all getters with the entire package name
> > which
> > > makes the JSON representation unusable [1].
> > >
> > > [1]
> > > package com.mydomain.myapp.model.vo
> > > {
> > >public class MyVO
> > >{
> > >private var _foo:String = "bar";
> > >
> > >public function get foo():String
> > >{
> > > return this._foo;
> > >}
> > >}
> > > }
> > >
> > > Becomes:
> > > {
> > >"com.mydomain.myapp.model.vo.foo":"bar";
> > > }
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Sent from: http://apache-royale-development.20373.n8.nabble.com/
> >
> >
>


RE: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Yishay Weiss
Hi Greg,



I’m referring to Olaf’s issue [1] with JSON.stringify() using the qualified 
property names. Could a class alias change the qualification prefix?



[1] 
http://apache-royale-development.20373.n8.nabble.com/Plain-public-variables-complain-they-don-t-have-getters-setters-Was-CreationComplete-event-question-tp9337p9353.html




From: Greg Dove 
Sent: Thursday, March 28, 2019 8:28:18 PM
To: dev@royale.apache.org
Subject: Re: Plain public variables complain they don't have getters / setters 
(Was "CreationComplete event question")

'I’m wondering if registerClassAlias or the RemoteClass meta-tag would
solve this. Anyone know?'

The issue with public car renaming?

I can't see how it could.
But reflection classes now support it (you can get and set public var
values in release mode via reflection) and AMF works with public vars too.

On Fri, 29 Mar 2019, 07:20 Yishay Weiss,  wrote:

> I’m wondering if registerClassAlias or the RemoteClass meta-tag would
> solve this. Anyone know?
>
>
>
> 
> From: Harbs 
> Sent: Thursday, March 28, 2019 3:03:46 PM
> To: dev@royale.apache.org
> Subject: Re: Plain public variables complain they don't have getters /
> setters (Was "CreationComplete event question")
>
> FWIW, I use a method to convert classes to JSON which allows me to define
> exactly which properties get written and using what names.
>
> i.e. myFoo.toData()
>
> > On Mar 28, 2019, at 1:26 PM, Olaf Krueger  wrote:
> >
> > I would just like to mention that resolving this "public vars" issue by
> > replacing the public by private vars with getters/setters has a side
> effect:
> > JSON.stringify() stringifies all getters with the entire package name
> which
> > makes the JSON representation unusable [1].
> >
> > [1]
> > package com.mydomain.myapp.model.vo
> > {
> >public class MyVO
> >{
> >private var _foo:String = "bar";
> >
> >public function get foo():String
> >{
> > return this._foo;
> >}
> >}
> > }
> >
> > Becomes:
> > {
> >"com.mydomain.myapp.model.vo.foo":"bar";
> > }
> >
> >
> >
> >
> >
> > --
> > Sent from: http://apache-royale-development.20373.n8.nabble.com/
>
>


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Greg Dove
'I’m wondering if registerClassAlias or the RemoteClass meta-tag would
solve this. Anyone know?'

The issue with public car renaming?

I can't see how it could.
But reflection classes now support it (you can get and set public var
values in release mode via reflection) and AMF works with public vars too.

On Fri, 29 Mar 2019, 07:20 Yishay Weiss,  wrote:

> I’m wondering if registerClassAlias or the RemoteClass meta-tag would
> solve this. Anyone know?
>
>
>
> 
> From: Harbs 
> Sent: Thursday, March 28, 2019 3:03:46 PM
> To: dev@royale.apache.org
> Subject: Re: Plain public variables complain they don't have getters /
> setters (Was "CreationComplete event question")
>
> FWIW, I use a method to convert classes to JSON which allows me to define
> exactly which properties get written and using what names.
>
> i.e. myFoo.toData()
>
> > On Mar 28, 2019, at 1:26 PM, Olaf Krueger  wrote:
> >
> > I would just like to mention that resolving this "public vars" issue by
> > replacing the public by private vars with getters/setters has a side
> effect:
> > JSON.stringify() stringifies all getters with the entire package name
> which
> > makes the JSON representation unusable [1].
> >
> > [1]
> > package com.mydomain.myapp.model.vo
> > {
> >public class MyVO
> >{
> >private var _foo:String = "bar";
> >
> >public function get foo():String
> >{
> > return this._foo;
> >}
> >}
> > }
> >
> > Becomes:
> > {
> >"com.mydomain.myapp.model.vo.foo":"bar";
> > }
> >
> >
> >
> >
> >
> > --
> > Sent from: http://apache-royale-development.20373.n8.nabble.com/
>
>


RE: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Yishay Weiss
I’m wondering if registerClassAlias or the RemoteClass meta-tag would solve 
this. Anyone know?




From: Harbs 
Sent: Thursday, March 28, 2019 3:03:46 PM
To: dev@royale.apache.org
Subject: Re: Plain public variables complain they don't have getters / setters 
(Was "CreationComplete event question")

FWIW, I use a method to convert classes to JSON which allows me to define 
exactly which properties get written and using what names.

i.e. myFoo.toData()

> On Mar 28, 2019, at 1:26 PM, Olaf Krueger  wrote:
>
> I would just like to mention that resolving this "public vars" issue by
> replacing the public by private vars with getters/setters has a side effect:
> JSON.stringify() stringifies all getters with the entire package name which
> makes the JSON representation unusable [1].
>
> [1]
> package com.mydomain.myapp.model.vo
> {
>public class MyVO
>{
>private var _foo:String = "bar";
>
>public function get foo():String
>{
> return this._foo;
>}
>}
> }
>
> Becomes:
> {
>"com.mydomain.myapp.model.vo.foo":"bar";
> }
>
>
>
>
>
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/



Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Harbs
FWIW, I use a method to convert classes to JSON which allows me to define 
exactly which properties get written and using what names.

i.e. myFoo.toData()

> On Mar 28, 2019, at 1:26 PM, Olaf Krueger  wrote:
> 
> I would just like to mention that resolving this "public vars" issue by
> replacing the public by private vars with getters/setters has a side effect:
> JSON.stringify() stringifies all getters with the entire package name which
> makes the JSON representation unusable [1].
> 
> [1]
> package com.mydomain.myapp.model.vo
> {
>public class MyVO
>{
>private var _foo:String = "bar";
> 
>public function get foo():String
>{
> return this._foo;
>}
>}
> }
> 
> Becomes:
> {
>"com.mydomain.myapp.model.vo.foo":"bar"; 
> }
> 
> 
> 
> 
> 
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/



Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Olaf Krueger
I would just like to mention that resolving this "public vars" issue by
replacing the public by private vars with getters/setters has a side effect:
JSON.stringify() stringifies all getters with the entire package name which
makes the JSON representation unusable [1].

[1]
package com.mydomain.myapp.model.vo
{
public class MyVO
{
private var _foo:String = "bar";

public function get foo():String
{
 return this._foo;
}
}
}

Becomes:
{
"com.mydomain.myapp.model.vo.foo":"bar"; 
}





--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


RE: [Non-DoD Source] Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Kessler CTR Mark J


smime.p7m
Description: S/MIME encrypted message


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Olaf Krueger
>More specifically, you shouldn’t use public variables as references *within*
the MXML. The reason for that is that the references in the MXML are saved
as text which might not match the renamed variables when the code is
minified. 

I probably misunderstand something but isn't anything in AS3 a reference?
So that we can say that we never should use public members of VOs within
MXML?

Thanks,
Olaf





--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread Harbs
More specifically, you shouldn’t use public variables as references *within* 
the MXML. The reason for that is that the references in the MXML are saved as 
text which might not match the renamed variables when the code is minified.

> On Mar 28, 2019, at 11:45 AM, yishayw  wrote:
> 
>> Does this have any disadvantages or leads to unpredictable behavior when
>> using public vars?
> 
> 
> In light of this [1] comment it looks like you might run into trouble when
> using classes with public vars from within MXML.
> 
> [1]
> http://apache-royale-development.20373.n8.nabble.com/Public-Vars-tp2698p2702.html
> 
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/
> 
> 
> 
> 
> 
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/



Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-28 Thread yishayw
>Does this have any disadvantages or leads to unpredictable behavior when
>using public vars?


In light of this [1] comment it looks like you might run into trouble when
using classes with public vars from within MXML.

[1]
http://apache-royale-development.20373.n8.nabble.com/Public-Vars-tp2698p2702.html

--
Sent from: http://apache-royale-development.20373.n8.nabble.com/





--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-27 Thread Olaf Krueger
Thanks, Piotr!
And thanks Alex for this helpful wiki article [1]

[1] https://github.com/apache/royale-asjs/wiki/Public-Variables



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-27 Thread Olaf Krueger
>You can set warn-public-vars to false. 

Thanks, Harbs!
Does this have any disadvantages or leads to unpredictable behavior when
using public vars?

Olaf



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-27 Thread Harbs
You can set warn-public-vars to false.

> On Mar 27, 2019, at 12:39 PM, Olaf Krueger  wrote:
> 
> Hi, 
> I want to extract one side note from Marks post [1] to this new thread:
> 
>> VO's with plain public variables now complain they don't have getters /
>> setters
> 
> We always go with private variables here and set getters / setters for those
> vars.
> (VSCode provides code generation for setters/getters)
> 
> Even this works it's a bit cumbersome. Are there any other solutions?
> 
> Thanks,
> Olaf
> 
> [1]
> http://apache-royale-development.20373.n8.nabble.com/CreationComplete-event-question-tp9320p9333.html
> 
> 
> 
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/



Plain public variables complain they don't have getters / setters (Was "CreationComplete event question")

2019-03-27 Thread Olaf Krueger
Hi, 
I want to extract one side note from Marks post [1] to this new thread:

> VO's with plain public variables now complain they don't have getters /
> setters

We always go with private variables here and set getters / setters for those
vars.
(VSCode provides code generation for setters/getters)

Even this works it's a bit cumbersome. Are there any other solutions?

Thanks,
Olaf

[1]
http://apache-royale-development.20373.n8.nabble.com/CreationComplete-event-question-tp9320p9333.html



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/