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/12/09 06:16:59 UTC
[02/10] git commit: [flex-falcon] [refs/heads/develop] - more fixes
to FalconJX binding codegen
more fixes to FalconJX binding codegen
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/18b12c2b
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/18b12c2b
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/18b12c2b
Branch: refs/heads/develop
Commit: 18b12c2be6e669073b354e1ef69623d5464a7673
Parents: a9f15d7
Author: Alex Harui <ah...@apache.org>
Authored: Mon Dec 1 12:53:15 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Dec 8 17:25:01 2014 -0800
----------------------------------------------------------------------
.../internal/codegen/as/ASEmitterTokens.java | 2 +-
.../codegen/js/flexjs/JSFlexJSEmitter.java | 94 +++++++++++++++++++-
.../internal/as/codegen/BindableHelper.java | 1 +
3 files changed, 95 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/18b12c2b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitterTokens.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitterTokens.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitterTokens.java
index d783109..9296a78 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitterTokens.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitterTokens.java
@@ -127,7 +127,7 @@ public enum ASEmitterTokens implements IEmitterTokens
// int TOKEN_OPERATOR_BITWISE_AND = 92;
EQUAL("="),
// int TOKEN_OPERATOR_NOT_EQUAL = 94;
- // int TOKEN_OPERATOR_STRICT_EQUAL = 95;
+ STRICT_EQUAL("==="),
STRICT_NOT_EQUAL("!=="),
// int TOKEN_OPERATOR_GREATER_THAN_EQUALS = 97;
LESS_THAN("<"),
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/18b12c2b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 52f5303..f0145ab 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -34,6 +34,7 @@ import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
import org.apache.flex.compiler.codegen.IDocEmitter;
import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
import org.apache.flex.compiler.common.ASModifier;
+import org.apache.flex.compiler.common.IMetaInfo;
import org.apache.flex.compiler.common.ModifiersSet;
import org.apache.flex.compiler.definitions.IClassDefinition;
import org.apache.flex.compiler.definitions.IDefinition;
@@ -65,6 +66,7 @@ import org.apache.flex.compiler.internal.tree.as.FunctionNode;
import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
import org.apache.flex.compiler.internal.tree.as.ParameterNode;
import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
+import org.apache.flex.compiler.internal.tree.as.SetterNode;
import org.apache.flex.compiler.internal.tree.as.UnaryOperatorAtNode;
import org.apache.flex.compiler.projects.ICompilerProject;
import org.apache.flex.compiler.scopes.IASScope;
@@ -203,6 +205,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
emitAccessors((IAccessorNode) dnode);
write(ASEmitterTokens.SEMICOLON);
}
+ else if (dnode.getNodeID() == ASTNodeID.BindableVariableID)
+ {
+ writeNewline();
+ writeNewline();
+ writeNewline();
+ emitField((IVariableNode) dnode);
+ write(ASEmitterTokens.SEMICOLON);
+ }
}
}
@@ -1254,6 +1264,85 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
if (type == null)
return;
+ boolean isBindableSetter = false;
+ if (node instanceof SetterNode)
+ {
+ IMetaInfo[] metaInfos = null;
+ metaInfos = node.getMetaInfos();
+ for (IMetaInfo metaInfo : metaInfos)
+ {
+ String name = metaInfo.getTagName();
+ if (name.equals("Bindable"))
+ {
+ isBindableSetter = true;
+ break;
+ }
+ }
+ if (isBindableSetter)
+ {
+ getDoc().emitMethodDoc(fn, project);
+ write(type.getQualifiedName());
+ if (!node.hasModifier(ASModifier.STATIC))
+ {
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write(JSEmitterTokens.PROTOTYPE);
+ }
+
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ writeGetSetPrefix(false);
+ writeToken(node.getName());
+ writeToken(ASEmitterTokens.EQUAL);
+ write(ASEmitterTokens.FUNCTION);
+ emitParameters(node.getParameterNodes());
+ write(ASEmitterTokens.SPACE);
+ writeNewline(ASEmitterTokens.BLOCK_OPEN);
+
+ write(ASEmitterTokens.VAR);
+ write(ASEmitterTokens.SPACE);
+ write("oldValue");
+ write(ASEmitterTokens.SPACE);
+ write(ASEmitterTokens.EQUAL);
+ write(ASEmitterTokens.SPACE);
+ write(ASEmitterTokens.THIS);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("get_" + node.getName());
+ write(ASEmitterTokens.PAREN_OPEN);
+ write(ASEmitterTokens.PAREN_CLOSE);
+ writeNewline(ASEmitterTokens.SEMICOLON);
+
+ // add change check
+ write(ASEmitterTokens.IF);
+ write(ASEmitterTokens.SPACE);
+ write(ASEmitterTokens.PAREN_OPEN);
+ write("oldValue");
+ write(ASEmitterTokens.SPACE);
+ write(ASEmitterTokens.STRICT_EQUAL);
+ write(ASEmitterTokens.SPACE);
+ IParameterNode[] params = node.getParameterNodes();
+ write(params[0].getName());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ write(ASEmitterTokens.SPACE);
+ write(ASEmitterTokens.RETURN);
+ writeNewline(ASEmitterTokens.SEMICOLON);
+
+ write(ASEmitterTokens.THIS);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("__bindingWrappedSetter__" + node.getName());
+ write(ASEmitterTokens.PAREN_OPEN);
+ write(params[0].getName());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ writeNewline(ASEmitterTokens.SEMICOLON);
+
+ // add dispatch of change event
+ writeNewline(" this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(");
+ writeNewline(" this, \"" + node.getName() + "\", oldValue, " + params[0].getName() + "));");
+ write(ASEmitterTokens.BLOCK_CLOSE);
+ writeNewline(ASEmitterTokens.SEMICOLON);
+ writeNewline();
+ writeNewline();
+ }
+ }
+
if (project == null)
project = getWalker().getProject();
@@ -1266,7 +1355,10 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
}
write(ASEmitterTokens.MEMBER_ACCESS);
- writeGetSetPrefix(node instanceof IGetterNode);
+ if (isBindableSetter)
+ write("__bindingWrappedSetter__");
+ else
+ writeGetSetPrefix(node instanceof IGetterNode);
writeToken(node.getName());
writeToken(ASEmitterTokens.EQUAL);
write(ASEmitterTokens.FUNCTION);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/18b12c2b/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 d88a105..18e5851 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
@@ -553,6 +553,7 @@ public class BindableHelper
// Following Names are constants to use for various types & properties used in the code generated for Bindable
//
public static Name NAME_PROPERTY_CHANGE_EVENT = new Name(CONSTANT_Qname, new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEvent");
+ public static String PROPERTY_CHANGE_EVENT = "mx.events.PropertyChangeEvent";
public static Name NAME_PROPERTY_CHANGE_EVENT_KIND = new Name(CONSTANT_Qname, new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEventKind");
private static final Name NAME_CREATE_UPDATE_EVENT = new Name("createUpdateEvent");