You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/12/26 06:01:43 UTC
[royale-compiler] 08/12: get externs to work. chrome.js was removed
from the set of externs
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit d4e7db631089f93b3f8b720c61f0cb66d363c1fb
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 25 21:51:09 2018 -0800
get externs to work. chrome.js was removed from the set of externs
---
compiler-externc/src/test/build.xml | 1 -
.../src/test/config/externc-config.xml | 10 +-
.../codegen/typedefs/TestExternChrome.java | 179 ---------------------
.../test/resources/typedefs/unit_tests/missing.js | 31 ++++
4 files changed, 40 insertions(+), 181 deletions(-)
diff --git a/compiler-externc/src/test/build.xml b/compiler-externc/src/test/build.xml
index 9e11013..8c79786 100644
--- a/compiler-externc/src/test/build.xml
+++ b/compiler-externc/src/test/build.xml
@@ -88,7 +88,6 @@
<fileset dir="${compiler.externc}/target/test-classes">
<!-- externs tests -->
<include name="**/TestExternES3.class"/>
- <include name="**/TestExternChrome.class"/>
<include name="**/TestExternJSMissing.class"/>
<include name="**/TestAnnotationEnum.class"/>
<include name="**/TestCollectImports.class"/>
diff --git a/compiler-externc/src/test/config/externc-config.xml b/compiler-externc/src/test/config/externc-config.xml
index 3171696..ee1ed35 100644
--- a/compiler-externc/src/test/config/externc-config.xml
+++ b/compiler-externc/src/test/config/externc-config.xml
@@ -67,7 +67,6 @@
<path-element>../../../target/downloads/browser/whatwg_encoding.js</path-element>
- <path-element>../../../target/downloads/browser/chrome.js</path-element>
<!-- path-element>../../../target/downloads/browser/fetchapi.js</path-element>-->
<path-element>../../../target/downloads/browser/fileapi.js</path-element>
<path-element>../../../target/downloads/browser/flash.js</path-element>
@@ -107,6 +106,7 @@
<class-exclude>
<class>controlRange</class>
<class>ITemplateArray</class>
+ <class>Symbol</class>
</class-exclude>
<!-- Object.toString() is excluded by the ExternC compiler. Otherwise
@@ -156,6 +156,14 @@
<class>Document</class>
<name>createTreeWalker</name>
</exclude>
+ <exclude>
+ <class>AsyncGenerator</class>
+ <name>next</name>
+ </exclude>
+ <exclude>
+ <class>Generator</class>
+ <name>next</name>
+ </exclude>
<!-- SVG -->
<exclude><class>SVGStylable</class><name>className</name></exclude>
<exclude><class>SVGStylable</class><name>style</name></exclude>
diff --git a/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TestExternChrome.java b/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TestExternChrome.java
deleted file mode 100644
index f7bb0d3..0000000
--- a/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TestExternChrome.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * 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 org.apache.royale.compiler.internal.codegen.typedefs;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.royale.compiler.clients.ExternCConfiguration;
-import org.apache.royale.compiler.internal.codegen.typedefs.reference.ClassReference;
-import org.apache.royale.compiler.problems.ICompilerProblem;
-import org.junit.Test;
-
-import com.google.javascript.jscomp.Result;
-
-public class TestExternChrome extends TypedefsTestBase
-{
- @Test
- public void test_classes() throws IOException
- {
- client.cleanOutput();
- Result result = compile();
- assertTrue(result.success);
- if (model.problems.getProblems().size() > 0)
- {
- for (ICompilerProblem problem : model.problems.getProblems())
- System.out.println(problem.toString() + " " + problem.getSourcePath() + " " + problem.getLine());
- }
- assertEquals(0, model.problems.getProblems().size());
-
- String[] classes = {
- "chrome",
- "chrome.app",
- "chrome.webstore",
- "chrome.runtime",
- "chrome.runtime.lastError",
-
- "Port",
- "ChromeEvent",
- "ChromeStringEvent",
- "ChromeBooleanEvent",
- "ChromeNumberEvent",
- "ChromeObjectEvent",
- "ChromeStringArrayEvent",
- "ChromeStringStringEvent",
- "MessageSender",
- "Tab",
- "ChromeLoadTimes",
- "ChromeCsiInfo" };
-
- assertEquals(322, model.getClasses().size());
- for (String className : classes)
- {
- assertTrue(model.hasClass(className));
- }
-
- client.emit();
- }
-
- @Test
- public void test_members() throws IOException
- {
- client.cleanOutput();
- Result result = compile();
- assertTrue(result.success);
- if (model.problems.getProblems().size() > 0)
- {
- for (ICompilerProblem problem : model.problems.getProblems())
- System.out.println(problem.toString() + " " + problem.getSourcePath() + " " + problem.getLine());
- }
- assertEquals(0, model.problems.getProblems().size());
-
- // Port
- ClassReference Port = model.getClassReference("Port");
- assertNotNull(Port);
- assertTrue(Port.hasInstanceField("name"));
- assertTrue(Port.hasInstanceField("onDisconnect"));
- assertTrue(Port.hasInstanceField("onMessage"));
- assertTrue(Port.hasInstanceField("sender"));
-
- assertTrue(Port.hasInstanceMethod("postMessage"));
- assertTrue(Port.hasInstanceMethod("disconnect"));
-
- assertEquals("string", Port.getInstanceField("name").toTypeAnnotationString());
- assertEquals("ChromeEvent",
- Port.getInstanceField("onDisconnect").toTypeAnnotationString());
- assertEquals("ChromeEvent",
- Port.getInstanceField("onMessage").toTypeAnnotationString());
- assertEquals("(MessageSender|undefined)",
- Port.getInstanceField("sender").toTypeAnnotationString());
-
- // chrome
- ClassReference chrome = model.getClassReference("chrome");
- assertNotNull(chrome);
- assertTrue(chrome.hasStaticMethod("loadTimes"));
- assertTrue(chrome.hasStaticMethod("csi"));
- assertEquals("ChromeLoadTimes",
- chrome.getStaticMethod("loadTimes").toReturnTypeAnnotationString());
- assertEquals("ChromeCsiInfo",
- chrome.getStaticMethod("csi").toReturnTypeAnnotationString());
-
- // chrome.app
- ClassReference chrome_app = model.getClassReference("chrome.app");
- assertNotNull(chrome_app);
- assertTrue(chrome_app.hasStaticField("isInstalled"));
- assertEquals("boolean",
- chrome_app.getStaticField("isInstalled").toTypeAnnotationString());
-
- // chrome.runtime
- ClassReference chrome_runtime = model.getClassReference("chrome.runtime");
- assertNotNull(chrome_runtime);
- assertTrue(chrome_runtime.hasStaticMethod("connect"));
- assertTrue(chrome_runtime.hasStaticMethod("sendMessage"));
-
- // chrome.runtime.lastError
- ClassReference chrome_runtime_lastError = model.getClassReference("chrome.runtime.lastError");
- assertNotNull(chrome_runtime_lastError);
- assertTrue(chrome_runtime_lastError.hasStaticField("message"));
- assertEquals(
- "(string|undefined)",
- chrome_runtime_lastError.getStaticField("message").toTypeAnnotationString());
-
- // chrome.webstore
- ClassReference chrome_webstore = model.getClassReference("chrome.webstore");
- assertNotNull(chrome_webstore);
- assertTrue(chrome_webstore.hasStaticField("onInstallStageChanged"));
- assertTrue(chrome_webstore.hasStaticField("onDownloadProgress"));
- assertTrue(chrome_webstore.hasStaticMethod("install"));
-
- // Code generated
- assertTrue(chrome.hasStaticField("app"));
- assertTrue(chrome.hasStaticField("runtime"));
- assertTrue(chrome.hasStaticField("webstore"));
-
- assertTrue(chrome_runtime.hasInstanceField("lastError"));
- }
-
- @Override
- protected void configure(ExternCConfiguration install) throws IOException
- {
- TypedefsTestUtils.init();
- config.setASRoot(TypedefsTestUtils.AS_ROOT_DIR);
-
- String coreRoot = TypedefsTestUtils.TYPEDEFS_JS_DIR.getAbsolutePath();
- config.addTypedef(coreRoot + "/es3.js");
- config.addTypedef(coreRoot + "/es6.js");
- config.addTypedef(coreRoot + "/browser/chrome.js");
- config.addTypedef(coreRoot + "/browser/html5.js");
- config.addTypedef(coreRoot + "/browser/ie_dom.js");
- config.addTypedef(coreRoot + "/browser/gecko_dom.js");
- config.addTypedef(coreRoot + "/browser/w3c_css.js");
- config.addTypedef(coreRoot + "/browser/w3c_event.js");
- config.addTypedef(coreRoot + "/browser/w3c_range.js");
- config.addTypedef(coreRoot + "/browser/w3c_dom1.js");
- config.addTypedef(coreRoot + "/browser/w3c_dom2.js");
- config.addTypedef(coreRoot + "/browser/w3c_dom3.js");
- config.addTypedef(coreRoot + "/browser/w3c_xml.js");
- }
-
-}
diff --git a/compiler-externc/src/test/resources/typedefs/unit_tests/missing.js b/compiler-externc/src/test/resources/typedefs/unit_tests/missing.js
index 689f185..d868582 100644
--- a/compiler-externc/src/test/resources/typedefs/unit_tests/missing.js
+++ b/compiler-externc/src/test/resources/typedefs/unit_tests/missing.js
@@ -311,3 +311,34 @@ Date.prototype.time;
* @type {number}
*/
Date.prototype.timezoneOffset;
+
+/**
+ * @param {string} type
+ * @param {EventListener|function(!Event):*} listener
+ * @param {(boolean|!AddEventListenerOptions)=} opt_options
+ * @return {undefined}
+ * @see https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
+ */
+BaseAudioContext.prototype.addEventListener = function(type, listener, opt_options) {
+};
+
+/**
+ * @param {string} type
+ * @param {EventListener|function(!Event):*} listener
+ * @param {(boolean|!EventListenerOptions)=} opt_options
+ * @return {undefined}
+ * @see https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
+ */
+BaseAudioContext.prototype.removeEventListener = function(
+ type, listener, opt_options) {};
+
+/**
+ * @param {!Event} evt
+ * @return {boolean}
+ * @see https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
+ */
+BaseAudioContext.prototype.dispatchEvent = function(evt) {};
+
+
+
+