Repository: flex-falcon
Updated Branches:
  refs/heads/develop 6c98a0ac3 -> 500ad4e4a


added -external-externs argument to externc to add externs that are parsed but 
don't get emitted


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/0d67006e
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/0d67006e
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/0d67006e

Branch: refs/heads/develop
Commit: 0d67006e2524738068eb498011f3a0dd586e5f60
Parents: d77028a
Author: Josh Tynjala <[email protected]>
Authored: Fri Jun 26 15:25:49 2015 -0700
Committer: Josh Tynjala <[email protected]>
Committed: Fri Jun 26 15:25:49 2015 -0700

----------------------------------------------------------------------
 .../compiler/clients/ExternCConfiguration.java  | 42 ++++++++++++++++++++
 .../externals/emit/ReferenceEmitter.java        | 15 +++++++
 .../externals/pass/ReferenceCompiler.java       |  6 +++
 3 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0d67006e/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 1710958..6dbf4ac 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -30,6 +30,7 @@ import org.apache.flex.compiler.config.ConfigurationValue;
 import org.apache.flex.compiler.exceptions.ConfigurationException.CannotOpen;
 import 
org.apache.flex.compiler.exceptions.ConfigurationException.IncorrectArgumentCount;
 import 
org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler.ExternalFile;
+import 
org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
 import 
org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
 import 
org.apache.flex.compiler.internal.codegen.externals.reference.FieldReference;
 import 
org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
@@ -50,6 +51,7 @@ public class ExternCConfiguration extends Configuration
     private File asTypeDefRoot;
 
     private List<ExternalFile> externals = new ArrayList<ExternalFile>();
+    private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
 
     private List<String> classToFunctions = new ArrayList<String>();
     private List<ExcludedMemeber> excludesClass = new 
ArrayList<ExcludedMemeber>();
@@ -113,6 +115,11 @@ public class ExternCConfiguration extends Configuration
         return externals;
     }
 
+    public Collection<ExternalFile> getExternalExterns()
+    {
+        return externalExterns;
+    }
+
     public boolean isClassToFunctions(String className)
     {
         return classToFunctions.contains(className);
@@ -135,6 +142,18 @@ public class ExternCConfiguration extends Configuration
         addExternal(new File(FilenameNormalization.normalize(externalFile)));
     }
 
+    public void addExternalExtern(File file) throws IOException
+    {
+        if (!file.exists())
+            throw new IOException(file.getAbsolutePath() + " does not exist.");
+        externalExterns.add(new ExternalFile(file));
+    }
+
+    public void addExternalExtern(String externalFile) throws IOException
+    {
+        addExternalExtern(new 
File(FilenameNormalization.normalize(externalFile)));
+    }
+
     @Config(allowMultiple = true)
     @Mapping("class-to-function")
     @Arguments(Arguments.CLASS)
@@ -152,6 +171,29 @@ public class ExternCConfiguration extends Configuration
        for (String val : vals)
                addExternal(resolvePathStrict(val, cfgval));
     }
+
+    @Config(allowMultiple = true, isPath = true)
+    @Mapping("external-externs")
+    @Arguments(Arguments.PATH_ELEMENT)
+    @InfiniteArguments
+    public void setExternalExterns(ConfigurationValue cfgval, String[] vals) 
throws IOException, CannotOpen
+    {
+        for (String val : vals)
+            addExternalExtern(resolvePathStrict(val, cfgval));
+    }
+    
+    public boolean isExternalExtern(BaseReference reference)
+    {
+        String sourceFileName = reference.getNode().getSourceFileName();
+        for (ExternalFile file : externalExterns)
+        {
+            if (sourceFileName.equals("[" + file.getName() + "]"))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
     
     public ExcludedMemeber isExcludedClass(ClassReference classReference)
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0d67006e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
index 047b044..36d7827 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
@@ -62,6 +62,9 @@ public class ReferenceEmitter
             if (!reference.isInterface())
                 continue;
 
+            if (model.getConfiguration().isExternalExtern(reference))
+                continue;
+
             emit(reference, sb);
 
             File sourceFile = 
reference.getFile(model.getConfiguration().getAsInterfaceRoot());
@@ -82,6 +85,9 @@ public class ReferenceEmitter
             if (reference.isInterface())
                 continue;
 
+            if (model.getConfiguration().isExternalExtern(reference))
+                continue;
+            
             emit(reference, sb);
 
             File sourceFile = 
reference.getFile(model.getConfiguration().getAsClassRoot());
@@ -100,6 +106,9 @@ public class ReferenceEmitter
             if (model.isExcludedClass(reference) != null)
                 continue;
 
+            if (model.getConfiguration().isExternalExtern(reference))
+                continue;
+
             emit(reference, sb);
 
             File sourceFile = 
reference.getFile(model.getConfiguration().getAsTypeDefRoot());
@@ -114,6 +123,9 @@ public class ReferenceEmitter
         final StringBuilder sb = new StringBuilder();
         for (FunctionReference reference : model.getFunctions())
         {
+            if (model.getConfiguration().isExternalExtern(reference))
+                continue;
+            
             emit(reference, sb);
 
             File sourceFile = 
reference.getFile(model.getConfiguration().getAsFunctionRoot());
@@ -128,6 +140,9 @@ public class ReferenceEmitter
         final StringBuilder sb = new StringBuilder();
         for (ConstantReference reference : model.getConstants())
         {
+            if (model.getConfiguration().isExternalExtern(reference))
+                continue;
+            
             emit(reference, sb);
 
             File sourceFile = 
reference.getFile(model.getConfiguration().getAsConstantRoot());

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0d67006e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/ReferenceCompiler.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/ReferenceCompiler.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/ReferenceCompiler.java
index c50fab0..ab47767 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/ReferenceCompiler.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/ReferenceCompiler.java
@@ -97,6 +97,12 @@ public class ReferenceCompiler
             String source = FileUtils.readFileToString(externalFile.getFile());
             sources.add(SourceFile.fromCode("[" + name + "]", source));
         }
+        for (ExternalFile externalFile : 
model.getConfiguration().getExternalExterns())
+        {
+            String name = externalFile.getName();
+            String source = FileUtils.readFileToString(externalFile.getFile());
+            sources.add(SourceFile.fromCode("[" + name + "]", source));
+        }
 
         Result result = jscompiler.compile(EMPTY_EXTERNS, sources, options);
         if (!result.success)

Reply via email to