You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/22 15:13:16 UTC
[3/6] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler.jx: externc now supports
a -named-module argument that will output JSModule metadata for classes in
the same base package as the module name
compiler.jx: externc now supports a -named-module argument that will output JSModule metadata for classes in the same base package as the module name
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/bfb462c6
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/bfb462c6
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/bfb462c6
Branch: refs/heads/feature/maven-migration-test
Commit: bfb462c6d6460d2bbace8032ba5e66867636030b
Parents: 021fa66
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 13:12:39 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 13:12:39 2016 -0700
----------------------------------------------------------------------
.../compiler/clients/ExternCConfiguration.java | 54 ++++++++++++++++++++
.../externals/reference/ClassReference.java | 30 ++++++++++-
2 files changed, 83 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bfb462c6/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
index c15786a..c6e7212 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -56,6 +56,8 @@ public class ExternCConfiguration extends Configuration
private List<ExternalFile> externals = new ArrayList<ExternalFile>();
private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
+ private List<String> namedModules = new ArrayList<String>();
+
private List<String> classToFunctions = new ArrayList<String>();
private List<ExcludedMember> excludesClass = new ArrayList<ExcludedMember>();
private List<ExcludedMember> excludesField = new ArrayList<ExcludedMember>();
@@ -295,6 +297,58 @@ public class ExternCConfiguration extends Configuration
excludesClass.add(new ExcludedMember(className, null, ""));
}
+ @Config(allowMultiple = true)
+ @Mapping("named-module")
+ @Arguments("module")
+ @InfiniteArguments
+ public void setNamedModules(ConfigurationValue cfgval, List<String> values)
+ {
+ for (String moduleName : values)
+ {
+ addNamedModule(moduleName);
+ }
+ }
+ public void addNamedModule(String moduleName)
+ {
+ namedModules.add(moduleName);
+ }
+
+ public String isNamedModule(ClassReference classReference)
+ {
+ String basePackageName = classReference.getPackageName();
+ int packageIndex = basePackageName.indexOf(".");
+ if (packageIndex != -1)
+ {
+ basePackageName = basePackageName.substring(0, packageIndex);
+ }
+ for (String module : namedModules)
+ {
+ //convert to camel case
+ String camelCaseModule = module;
+ int moduleIndex = camelCaseModule.indexOf("-");
+ while (moduleIndex != -1 && moduleIndex < camelCaseModule.length() - 1)
+ {
+ camelCaseModule = camelCaseModule.substring(0, moduleIndex)
+ + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
+ + camelCaseModule.substring(moduleIndex + 2);
+ moduleIndex = camelCaseModule.indexOf("-");
+ }
+ if(basePackageName.length() == 0)
+ {
+ if (classReference.getBaseName().equals(camelCaseModule))
+ {
+ return module;
+ }
+ continue;
+ }
+ if(basePackageName.equals(camelCaseModule))
+ {
+ return module;
+ }
+ }
+ return null;
+ }
+
public File getJsRoot()
{
return jsRoot;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bfb462c6/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index b04fb0e..fc1df39 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -41,6 +41,7 @@ public class ClassReference extends BaseReference
{
private boolean isFinal;
private boolean isDynamic;
+ private String moduleName;
private int enumConstantCounter = 0;
private Set<String> imports = new HashSet<String>();
@@ -142,6 +143,16 @@ public class ClassReference extends BaseReference
this.isFinal = isFinal;
}
+ public String getModuleName()
+ {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName)
+ {
+ this.moduleName = moduleName;
+ }
+
public final boolean isInterface()
{
return getComment().isInterface();
@@ -294,6 +305,8 @@ public class ClassReference extends BaseReference
constructor = new MethodReference(model, this, functionNode, getBaseName(), comment, false);
}
+ moduleName = model.getConfiguration().isNamedModule(this);
+
}
private static List<String> definedPackages = new ArrayList<String>();
@@ -341,6 +354,21 @@ public class ClassReference extends BaseReference
emitImports(sb);
}
+
+ if (moduleName != null)
+ {
+ sb.append("[JSModule");
+ if (packageName.length() > 0 || !getBaseName().equals(moduleName))
+ {
+ sb.append("(");
+ sb.append("name=\"");
+ sb.append(moduleName);
+ sb.append("\"");
+ sb.append(")");
+ }
+ sb.append("]");
+ sb.append("\n");
+ }
emitComment(sb);
@@ -730,7 +758,7 @@ public class ClassReference extends BaseReference
{
if (outputJS)
return;
-
+
sb.append("public ");
if (isDynamic)
{