You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Piotr Zarzycki <pi...@gmail.com> on 2018/03/20 17:09:16 UTC

Re: [royale-compiler] branch develop updated: allow override of the State class

Hi Alex,

Just out of curious what is the scenario which is the results of that
changes ? I'm trying to understand from the code, but cannot imagine.

Thanks, Piotr

2018-03-20 18:03 GMT+01:00 <ah...@apache.org>:

> This is an automated email from the ASF dual-hosted git repository.
>
> aharui pushed a commit to branch develop
> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>
>
> The following commit(s) were added to refs/heads/develop by this push:
>      new 808fe2a  allow override of the State class
> 808fe2a is described below
>
> commit 808fe2ab3c28fa414c42ea55c7d388bab1cad6b9
> Author: Alex Harui <ah...@apache.org>
> AuthorDate: Tue Mar 20 10:03:13 2018 -0700
>
>     allow override of the State class
> ---
>  .../compiler/internal/projects/RoyaleProject.java  |  5 ++++
>  .../internal/tree/mxml/MXMLInstanceNode.java       | 30
> +++++++++++++++++++++-
>  2 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/compiler/src/main/java/org/apache/royale/compiler/
> internal/projects/RoyaleProject.java b/compiler/src/main/java/org/
> apache/royale/compiler/internal/projects/RoyaleProject.java
> index a2dff6f..0d73440 100644
> --- a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/
> RoyaleProject.java
> +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/
> RoyaleProject.java
> @@ -170,6 +170,11 @@ public class RoyaleProject extends ASProject
> implements IRoyaleProject, ICompile
>      private String stateClass;
>
>      /**
> +     * The resolved stateClass
> +     */
> +    public ITypeDefinition stateClassType = null;
> +
> +    /**
>       * The fully-qualified name of the runtime interface
>       * for a component with a <code>currentState</code> property.
>       * Currently this is "mx.core.IStateClient".
> diff --git a/compiler/src/main/java/org/apache/royale/compiler/
> internal/tree/mxml/MXMLInstanceNode.java b/compiler/src/main/java/org/
> apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java
> index 72f87ce..1405b81 100644
> --- a/compiler/src/main/java/org/apache/royale/compiler/
> internal/tree/mxml/MXMLInstanceNode.java
> +++ b/compiler/src/main/java/org/apache/royale/compiler/
> internal/tree/mxml/MXMLInstanceNode.java
> @@ -34,7 +34,10 @@ import org.apache.royale.compiler.
> common.DependencyType;
>  import org.apache.royale.compiler.constants.IASLanguageConstants;
>  import org.apache.royale.compiler.definitions.IClassDefinition;
>  import org.apache.royale.compiler.definitions.IDefinition;
> +import org.apache.royale.compiler.definitions.ITypeDefinition;
>  import org.apache.royale.compiler.definitions.IVariableDefinition;
> +import org.apache.royale.compiler.definitions.references.
> IResolvedQualifiersReference;
> +import org.apache.royale.compiler.definitions.references.
> ReferenceFactory;
>  import org.apache.royale.compiler.internal.mxml.MXMLDialect;
>  import org.apache.royale.compiler.internal.projects.RoyaleProject;
>  import org.apache.royale.compiler.internal.scopes.ASScope;
> @@ -56,6 +59,31 @@ import org.apache.royale.compiler.
> tree.mxml.IMXMLInstanceNode;
>
>  class MXMLInstanceNode extends MXMLClassReferenceNodeBase implements
> IMXMLInstanceNode
>  {
> +       private static boolean isStateClass(String instanceType,
> RoyaleProject project)
> +       {
> +               // we are going to require that all subclasses are also
> named State
> +               // but just in different packages.  That way we don't have
> to keep resolving
> +               // instanceType
> +               if (!instanceType.endsWith(".State"))
> +                       return false;
> +
> +               if (instanceType.equals(project.getStateClass()))
> +                       return true;
> +
> +        IResolvedQualifiersReference instanceRef = ReferenceFactory.
> packageQualifiedReference(
> +                project.getWorkspace(), instanceType);
> +        ITypeDefinition instanceTypeDef = (ITypeDefinition)instanceRef.
> resolve(project);
> +
> +        if (project.stateClassType == null)
> +        {
> +            IResolvedQualifiersReference stateRef = ReferenceFactory.
> packageQualifiedReference(
> +                    project.getWorkspace(), project.getStateClass());
> +            project.stateClassType = (ITypeDefinition)stateRef.
> resolve(project);
> +        }
> +
> +        return (instanceTypeDef.isInstanceOf(project.stateClassType,
> project));
> +       }
> +
>      protected static MXMLInstanceNode createInstanceNode(MXMLTreeBuilder
> builder,
>                                                           String
> instanceType,
>                                                           NodeBase parent)
> @@ -89,7 +117,7 @@ class MXMLInstanceNode extends
> MXMLClassReferenceNodeBase implements IMXMLInstan
>          else if (instanceType.equals(IASLanguageConstants.Vector_qname))
>              return new MXMLVectorNode(parent);
>
> -        else if (instanceType.equals(builder.getProject().getStateClass())
> && mxmlDialect != MXMLDialect.MXML_2006)
> +        else if (isStateClass(instanceType, builder.getProject()) &&
> mxmlDialect != MXMLDialect.MXML_2006)
>              return new MXMLStateNode(parent);
>
>          else if (instanceType.equals(builder.getProject().
> getWebServiceQName()))
>
> --
> To stop receiving notification emails like this one, please contact
> aharui@apache.org.
>



-- 

Piotr Zarzycki

Patreon: *https://www.patreon.com/piotrzarzycki
<https://www.patreon.com/piotrzarzycki>*

Re: [royale-compiler] branch develop updated: allow override of the State class

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Hi Piotr,

The MXML compiler has a lot of special case code.   In this case, the MXML
compiler looks for a State class specified in the configuration and then
remembers the state name as a valid state for includeIn, excludeFrom and
prop.stateName.  In Royale, the State class is
org.apache.royale.states.State.

However, folks migrating from Flex will be using mx.states.State and
before this change, the compiler did not see mx:State as a valid state
declaration.  I thought about having migrating users change their configs
to set the State class to mx.states.State which we are providing in the
emulation components, but decided against it, because if they eventually
try to migrate off the emulation components to Basic or Express they will
probably be in a situation where some MXML files are using mx.states.State
and others are using org.apache.royale.states.State.

Hope that makes sense,
-Alex

On 3/20/18, 10:09 AM, "Piotr Zarzycki" <pi...@gmail.com> wrote:

>Hi Alex,
>
>Just out of curious what is the scenario which is the results of that
>changes ? I'm trying to understand from the code, but cannot imagine.
>
>Thanks, Piotr
>
>2018-03-20 18:03 GMT+01:00 <ah...@apache.org>:
>
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> aharui pushed a commit to branch develop
>> in repository 
>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.a
>>pache.org%2Frepos%2Fasf%2Froyale-compiler.git&data=02%7C01%7Caharui%40ado
>>be.com%7C07ac8bf61c7e48f91d9808d58e8553ac%7Cfa7b1b5a7b34438794aed2c178dec
>>ee1%7C0%7C0%7C636571625641624502&sdata=N96V2T8bhZLQwnkjJ3WN9HR9lIQ0uAjxR8
>>84eOpXG0M%3D&reserved=0
>>
>>
>> The following commit(s) were added to refs/heads/develop by this push:
>>      new 808fe2a  allow override of the State class
>> 808fe2a is described below
>>
>> commit 808fe2ab3c28fa414c42ea55c7d388bab1cad6b9
>> Author: Alex Harui <ah...@apache.org>
>> AuthorDate: Tue Mar 20 10:03:13 2018 -0700
>>
>>     allow override of the State class
>> ---
>>  .../compiler/internal/projects/RoyaleProject.java  |  5 ++++
>>  .../internal/tree/mxml/MXMLInstanceNode.java       | 30
>> +++++++++++++++++++++-
>>  2 files changed, 34 insertions(+), 1 deletion(-)
>>
>> diff --git a/compiler/src/main/java/org/apache/royale/compiler/
>> internal/projects/RoyaleProject.java b/compiler/src/main/java/org/
>> apache/royale/compiler/internal/projects/RoyaleProject.java
>> index a2dff6f..0d73440 100644
>> --- 
>>a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/
>> RoyaleProject.java
>> +++ 
>>b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/
>> RoyaleProject.java
>> @@ -170,6 +170,11 @@ public class RoyaleProject extends ASProject
>> implements IRoyaleProject, ICompile
>>      private String stateClass;
>>
>>      /**
>> +     * The resolved stateClass
>> +     */
>> +    public ITypeDefinition stateClassType = null;
>> +
>> +    /**
>>       * The fully-qualified name of the runtime interface
>>       * for a component with a <code>currentState</code> property.
>>       * Currently this is "mx.core.IStateClient".
>> diff --git a/compiler/src/main/java/org/apache/royale/compiler/
>> internal/tree/mxml/MXMLInstanceNode.java b/compiler/src/main/java/org/
>> apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java
>> index 72f87ce..1405b81 100644
>> --- a/compiler/src/main/java/org/apache/royale/compiler/
>> internal/tree/mxml/MXMLInstanceNode.java
>> +++ b/compiler/src/main/java/org/apache/royale/compiler/
>> internal/tree/mxml/MXMLInstanceNode.java
>> @@ -34,7 +34,10 @@ import org.apache.royale.compiler.
>> common.DependencyType;
>>  import org.apache.royale.compiler.constants.IASLanguageConstants;
>>  import org.apache.royale.compiler.definitions.IClassDefinition;
>>  import org.apache.royale.compiler.definitions.IDefinition;
>> +import org.apache.royale.compiler.definitions.ITypeDefinition;
>>  import org.apache.royale.compiler.definitions.IVariableDefinition;
>> +import org.apache.royale.compiler.definitions.references.
>> IResolvedQualifiersReference;
>> +import org.apache.royale.compiler.definitions.references.
>> ReferenceFactory;
>>  import org.apache.royale.compiler.internal.mxml.MXMLDialect;
>>  import org.apache.royale.compiler.internal.projects.RoyaleProject;
>>  import org.apache.royale.compiler.internal.scopes.ASScope;
>> @@ -56,6 +59,31 @@ import org.apache.royale.compiler.
>> tree.mxml.IMXMLInstanceNode;
>>
>>  class MXMLInstanceNode extends MXMLClassReferenceNodeBase implements
>> IMXMLInstanceNode
>>  {
>> +       private static boolean isStateClass(String instanceType,
>> RoyaleProject project)
>> +       {
>> +               // we are going to require that all subclasses are also
>> named State
>> +               // but just in different packages.  That way we don't
>>have
>> to keep resolving
>> +               // instanceType
>> +               if (!instanceType.endsWith(".State"))
>> +                       return false;
>> +
>> +               if (instanceType.equals(project.getStateClass()))
>> +                       return true;
>> +
>> +        IResolvedQualifiersReference instanceRef = ReferenceFactory.
>> packageQualifiedReference(
>> +                project.getWorkspace(), instanceType);
>> +        ITypeDefinition instanceTypeDef = (ITypeDefinition)instanceRef.
>> resolve(project);
>> +
>> +        if (project.stateClassType == null)
>> +        {
>> +            IResolvedQualifiersReference stateRef = ReferenceFactory.
>> packageQualifiedReference(
>> +                    project.getWorkspace(), project.getStateClass());
>> +            project.stateClassType = (ITypeDefinition)stateRef.
>> resolve(project);
>> +        }
>> +
>> +        return (instanceTypeDef.isInstanceOf(project.stateClassType,
>> project));
>> +       }
>> +
>>      protected static MXMLInstanceNode
>>createInstanceNode(MXMLTreeBuilder
>> builder,
>>                                                           String
>> instanceType,
>>                                                           NodeBase
>>parent)
>> @@ -89,7 +117,7 @@ class MXMLInstanceNode extends
>> MXMLClassReferenceNodeBase implements IMXMLInstan
>>          else if
>>(instanceType.equals(IASLanguageConstants.Vector_qname))
>>              return new MXMLVectorNode(parent);
>>
>> -        else if
>>(instanceType.equals(builder.getProject().getStateClass())
>> && mxmlDialect != MXMLDialect.MXML_2006)
>> +        else if (isStateClass(instanceType, builder.getProject()) &&
>> mxmlDialect != MXMLDialect.MXML_2006)
>>              return new MXMLStateNode(parent);
>>
>>          else if (instanceType.equals(builder.getProject().
>> getWebServiceQName()))
>>
>> --
>> To stop receiving notification emails like this one, please contact
>> aharui@apache.org.
>>
>
>
>
>-- 
>
>Piotr Zarzycki
>
>Patreon: 
>*https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.patr
>eon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7C07ac8bf61c7e48
>f91d9808d58e8553ac%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365716256
>41624502&sdata=KmQaHNhwj%2BHE5iIECHuXWsU%2FSZLJ%2BFVWY1WzASvoP84%3D&reserv
>ed=0
><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.patr
>eon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7C07ac8bf61c7e48
>f91d9808d58e8553ac%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365716256
>41624502&sdata=KmQaHNhwj%2BHE5iIECHuXWsU%2FSZLJ%2BFVWY1WzASvoP84%3D&reserv
>ed=0>*