You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/11/10 19:05:51 UTC
[5/7] git commit: [flex-falcon] [refs/heads/develop] - override a few
more assumed types so FlexJS can use non-flash packages
override a few more assumed types so FlexJS can use non-flash packages
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2d9e4234
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2d9e4234
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2d9e4234
Branch: refs/heads/develop
Commit: 2d9e423432c43e3fa9ef2d954ef7120651cd7924
Parents: f3713dd
Author: Alex Harui <ah...@apache.org>
Authored: Thu Nov 6 22:17:10 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Nov 6 22:17:10 2014 -0800
----------------------------------------------------------------------
.../internal/as/codegen/BindableHelper.java | 2 ++
.../internal/definitions/ClassDefinition.java | 5 +++-
.../projects/FlexProjectConfigurator.java | 6 +++-
.../internal/units/ASCompilationUnit.java | 31 ++++++++++++++------
4 files changed, 33 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2d9e4234/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java b/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
index 203a804..d88a105 100644
--- a/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
+++ b/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
@@ -576,5 +576,7 @@ public class BindableHelper
public static String PROPERTY_CHANGE = "propertyChange";
public static String BINDABLE = "Bindable";
+ public static String STRING_EVENT = "flash.events.Event";
+ public static String STRING_EVENT_DISPATCHER = "flash.events.EventDispatcher";
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2d9e4234/compiler/src/org/apache/flex/compiler/internal/definitions/ClassDefinition.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/definitions/ClassDefinition.java b/compiler/src/org/apache/flex/compiler/internal/definitions/ClassDefinition.java
index 8f5ba4f..4b78e47 100644
--- a/compiler/src/org/apache/flex/compiler/internal/definitions/ClassDefinition.java
+++ b/compiler/src/org/apache/flex/compiler/internal/definitions/ClassDefinition.java
@@ -110,6 +110,9 @@ public class ClassDefinition extends ClassDefinitionBase implements IClassDefini
private static final String NO_REMOTE_CLASS_ALIAS = "";
private static final String HOST_COMPONENT = "hostComponent";
+
+ // this gets replaced in some projects
+ public static String Event = IASLanguageConstants.Event;
private static ClassDefinition makeImplicitClassDefinition(String name)
{
@@ -470,7 +473,7 @@ public class ClassDefinition extends ClassDefinitionBase implements IClassDefini
}
}
if (type == null)
- type = IASLanguageConstants.Event;
+ type = ClassDefinition.Event;
if (name != null)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2d9e4234/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
index 14b98cf..64e5ba5 100644
--- a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
+++ b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
@@ -30,6 +30,7 @@ import org.apache.flex.abc.semantics.Namespace;
import org.apache.flex.abc.semantics.Nsset;
import org.apache.flex.compiler.config.Configuration;
import org.apache.flex.compiler.internal.as.codegen.BindableHelper;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
import org.apache.flex.compiler.mxml.IMXMLTypeConstants;
/**
@@ -180,18 +181,21 @@ public class FlexProjectConfigurator
if (configuration != null)
{
String configValue = configuration.getBindingEventHandlerEvent();
+ ClassDefinition.Event = configValue;
int dotIndex;
dotIndex = configValue.lastIndexOf(".");
String packageName = configValue.substring(0, dotIndex);
String className = configValue.substring(dotIndex + 1);
BindableHelper.NAME_EVENT = new Name(CONSTANT_Qname, new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), className);
+ BindableHelper.STRING_EVENT = configValue;
configValue = configuration.getBindingEventHandlerClass();
dotIndex = configValue.lastIndexOf(".");
packageName = configValue.substring(0, dotIndex);
className = configValue.substring(dotIndex + 1);
BindableHelper.NAME_EVENT_DISPATCHER = new Name(CONSTANT_Qname, new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), className);
-
+ BindableHelper.STRING_EVENT_DISPATCHER = configValue;
+
configValue = configuration.getBindingEventHandlerInterface();
dotIndex = configValue.lastIndexOf(".");
packageName = configValue.substring(0, dotIndex);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2d9e4234/compiler/src/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/units/ASCompilationUnit.java b/compiler/src/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
index 54cd6e0..090e714 100644
--- a/compiler/src/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
+++ b/compiler/src/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
@@ -33,6 +33,7 @@ import org.apache.flex.compiler.common.IMetaInfo;
import org.apache.flex.compiler.definitions.IDefinition;
import org.apache.flex.compiler.filespecs.FileSpecification;
import org.apache.flex.compiler.filespecs.IFileSpecification;
+import org.apache.flex.compiler.internal.as.codegen.BindableHelper;
import org.apache.flex.compiler.internal.as.codegen.CodeGeneratorManager;
import org.apache.flex.compiler.internal.parsing.as.ASParser;
import org.apache.flex.compiler.internal.parsing.as.ASToken;
@@ -44,6 +45,7 @@ import org.apache.flex.compiler.internal.scopes.ASFileScope;
import org.apache.flex.compiler.internal.semantics.PostProcessStep;
import org.apache.flex.compiler.internal.tree.as.BaseDefinitionNode;
import org.apache.flex.compiler.internal.tree.as.ClassNode;
+import org.apache.flex.compiler.internal.tree.as.ExpressionNodeBase;
import org.apache.flex.compiler.internal.tree.as.FileNode;
import org.apache.flex.compiler.internal.tree.as.FullNameNode;
import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
@@ -387,16 +389,27 @@ public class ASCompilationUnit extends CompilationUnitBase
{
// bindable class extends Object, must switch to
// extend EventDispatcher
- IdentifierNode baseClassNode = new IdentifierNode("EventDispatcher");
+ String bindableBaseClassName = BindableHelper.STRING_EVENT_DISPATCHER;
+ String[] pieces = bindableBaseClassName.split("\\.");
+ int n = pieces.length;
+ IdentifierNode baseClassNode = new IdentifierNode(pieces[n - 1]); // "EventDispatcher"
baseClassNode.setParent(classNode);
classNode.setBaseClass(baseClassNode);
- IdentifierNode flash = new IdentifierNode("flash");
- IdentifierNode events = new IdentifierNode("events");
- FullNameNode flashDotEvents = new FullNameNode(flash,
- new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."), events);
- FullNameNode fullNameNode = new FullNameNode(flashDotEvents,
- new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."),
- baseClassNode);
+ ExpressionNodeBase lastNode = null;
+ for (int i = 0; i < n - 1; i++)
+ {
+ IdentifierNode part = new IdentifierNode(pieces[i]);
+ if (i > 0)
+ {
+ FullNameNode packageNode = new FullNameNode(lastNode,
+ new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."), part);
+ lastNode = packageNode;
+ }
+ else
+ lastNode = part;
+ }
+ FullNameNode fullNameNode = new FullNameNode(lastNode,
+ new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."), baseClassNode);
ImportNode importNode = new ImportNode(fullNameNode);
ScopedBlockNode sbn = (ScopedBlockNode)pkg.getChild(1);
sbn.addChild(importNode, 0);
@@ -416,7 +429,7 @@ public class ASCompilationUnit extends CompilationUnitBase
getProject().clearScopeCacheForCompilationUnit(this);
ast.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE));
if (isBindable)
- pkg.getASScope().addImport("flash.events.EventDispatcher");
+ pkg.getASScope().addImport(BindableHelper.STRING_EVENT_DISPATCHER);
}
final ImmutableSet<String> includedFiles = ast.getIncludeHandler().getIncludedFiles();
addScopeToProjectScope(new ASFileScope[] { ast.getFileScope() });