use AS3 namespace to allow toString overrides for Number, int, uint
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/19cde1d9 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/19cde1d9 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/19cde1d9 Branch: refs/heads/develop Commit: 19cde1d9079651ada3f9435a722fc9dc296795c8 Parents: c14ca97 Author: Alex Harui <[email protected]> Authored: Thu Oct 15 15:30:42 2015 -0700 Committer: Alex Harui <[email protected]> Committed: Thu Oct 15 15:30:42 2015 -0700 ---------------------------------------------------------------------- build.xml | 1 + .../externals/reference/MethodReference.java | 19 +++++++++-- externs/js/src/AS3.as | 33 ++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/19cde1d9/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index df5350b..15a49c6 100644 --- a/build.xml +++ b/build.xml @@ -626,6 +626,7 @@ <arg value="-debug" /> <arg value="-load-config=externs/js/js-compile-config.xml" /> </java> + <copy file="${basedir}/externs/js/src/AS3.as" tofile="${basedir}/externs/js/out/as/classes/AS3.as" /> <java jar="${basedir}/compiler/generated/dist/sdk/lib/falcon-compc.jar" fork="true" failonerror="true"> <arg value="+flexlib=externs" /> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/19cde1d9/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java index b37677b..4770d41 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java @@ -127,8 +127,10 @@ public class MethodReference extends MemberReference @Override public void emit(StringBuilder sb) { + String className = getClassReference().getBaseName(); + // XXX HACK TEMP! - if (getComment().isConstructor() && !getBaseName().equals(getClassReference().getBaseName())) + if (getComment().isConstructor() && !getBaseName().equals(className)) return; if (isConstructor()) @@ -137,8 +139,13 @@ public class MethodReference extends MemberReference return; } - if (getClassReference().hasSuperMethod(getQualifiedName())) + String qName = getQualifiedName(); + // allow overrides of toString for Number, int and uint + if (!qName.equals("toString") && getClassReference().hasSuperMethod(qName)) return; + else if (qName.equals("toString") && + !(className.equals("Number") || className.equals("int") || className.equals("uint"))) + return; emitComment(sb); @@ -170,6 +177,8 @@ public class MethodReference extends MemberReference } } + String qName = getQualifiedName(); + String publicModifier = ""; String braces = ""; String returns = ""; @@ -184,6 +193,12 @@ public class MethodReference extends MemberReference publicModifier = "public "; braces = " { " + returns + " }"; } + + // allow overrides of toString for Number + if (qName.equals("toString") && getClassReference().hasSuperMethod(qName)) + { + publicModifier = "AS3 "; + } sb.append(indent); sb.append(publicModifier); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/19cde1d9/externs/js/src/AS3.as ---------------------------------------------------------------------- diff --git a/externs/js/src/AS3.as b/externs/js/src/AS3.as new file mode 100644 index 0000000..6a2191b --- /dev/null +++ b/externs/js/src/AS3.as @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package +{ + +/** + * This namespace mimics the special AS3 namespace + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ +public namespace AS3 = + "http://adobe.com/AS3/2006/builtin"; +}
