mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Refactoring. Add AsyncCallback support
This commit is contained in:
parent
942542df6f
commit
3b1d6851a4
1
pom.xml
1
pom.xml
|
@ -82,6 +82,7 @@
|
||||||
<module>teavm-platform</module>
|
<module>teavm-platform</module>
|
||||||
<module>teavm-cli</module>
|
<module>teavm-cli</module>
|
||||||
<module>teavm-chrome-rdp</module>
|
<module>teavm-chrome-rdp</module>
|
||||||
|
<module>teavm-tests</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -49,6 +49,16 @@
|
||||||
<artifactId>teavm-core</artifactId>
|
<artifactId>teavm-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-jso</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-dom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
|
@ -74,34 +84,6 @@
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.teavm</groupId>
|
|
||||||
<artifactId>teavm-maven-plugin</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.teavm</groupId>
|
|
||||||
<artifactId>teavm-platform</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>generate-javascript-tests</id>
|
|
||||||
<goals>
|
|
||||||
<goal>build-test-javascript</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>process-test-classes</phase>
|
|
||||||
<configuration>
|
|
||||||
<minifying>false</minifying>
|
|
||||||
<properties>
|
|
||||||
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
|
|
||||||
</properties>
|
|
||||||
<incremental>${teavm.classlib.test.incremental}</incremental>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
@ -135,15 +117,6 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>org/teavm/platform/metadata/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.classlib.impl;
|
package org.teavm.classlib.impl;
|
||||||
|
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.javascript.ni.PreserveOriginalName;
|
import org.teavm.javascript.spi.PreserveOriginalName;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,8 @@ import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.*;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
|
@ -22,8 +22,8 @@ import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,10 +17,10 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,10 +17,10 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,10 @@ package org.teavm.classlib.java.lang;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.*;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ import java.io.IOException;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.teavm.classlib.java.lang;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.*;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.lang;
|
||||||
import org.teavm.classlib.impl.charset.UTF16Helper;
|
import org.teavm.classlib.impl.charset.UTF16Helper;
|
||||||
import org.teavm.classlib.impl.unicode.UnicodeHelper;
|
import org.teavm.classlib.impl.unicode.UnicodeHelper;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TIOException;
|
import org.teavm.classlib.java.io.TIOException;
|
||||||
import org.teavm.classlib.java.io.TOutputStream;
|
import org.teavm.classlib.java.io.TOutputStream;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TIOException;
|
import org.teavm.classlib.java.io.TIOException;
|
||||||
import org.teavm.classlib.java.io.TOutputStream;
|
import org.teavm.classlib.java.io.TOutputStream;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
import org.teavm.javascript.ni.Superclass;
|
import org.teavm.javascript.spi.Superclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.Superclass;
|
import org.teavm.javascript.spi.Superclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.teavm.classlib.java.util.THashMap;
|
||||||
import org.teavm.classlib.java.util.TMap;
|
import org.teavm.classlib.java.util.TMap;
|
||||||
import org.teavm.classlib.java.util.regex.TPattern;
|
import org.teavm.classlib.java.util.regex.TPattern;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.lang;
|
||||||
import org.teavm.classlib.java.io.TPrintStream;
|
import org.teavm.classlib.java.io.TPrintStream;
|
||||||
import org.teavm.classlib.java.lang.reflect.TArray;
|
import org.teavm.classlib.java.lang.reflect.TArray;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,14 +15,18 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.dom.browser.TimerHandler;
|
||||||
import org.teavm.runtime.Async;
|
import org.teavm.dom.browser.Window;
|
||||||
|
import org.teavm.javascript.spi.Async;
|
||||||
|
import org.teavm.jso.JS;
|
||||||
|
import org.teavm.platform.async.AsyncCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class TThread extends TObject implements TRunnable {
|
public class TThread extends TObject implements TRunnable {
|
||||||
|
private static Window window = (Window)JS.getGlobal();
|
||||||
private static TThread currentThread = new TThread(TString.wrap("main"));
|
private static TThread currentThread = new TThread(TString.wrap("main"));
|
||||||
private TString name;
|
private TString name;
|
||||||
private TRunnable target;
|
private TRunnable target;
|
||||||
|
@ -60,9 +64,16 @@ public class TThread extends TObject implements TRunnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@GeneratedBy(ThreadNativeGenerator.class)
|
|
||||||
public static native void yield();
|
public static native void yield();
|
||||||
|
|
||||||
|
private static void yield(final AsyncCallback<Void> callback) {
|
||||||
|
window.setTimeout(new TimerHandler() {
|
||||||
|
@Override public void onTimer() {
|
||||||
|
callback.complete(null);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void interrupt() {
|
public void interrupt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +97,14 @@ public class TThread extends TObject implements TRunnable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sleep(long millis) throws TInterruptedException {
|
|
||||||
sleep((double)millis);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@GeneratedBy(ThreadNativeGenerator.class)
|
public static native void sleep(long millis) throws TInterruptedException;
|
||||||
private static native void sleep(double millis) throws TInterruptedException;
|
|
||||||
|
private static void sleep(long millis, final AsyncCallback<Void> callback) {
|
||||||
|
window.setTimeout(new TimerHandler() {
|
||||||
|
@Override public void onTimer() {
|
||||||
|
callback.complete(null);
|
||||||
|
}
|
||||||
|
}, millis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TPrintStream;
|
import org.teavm.classlib.java.io.TPrintStream;
|
||||||
import org.teavm.classlib.java.util.TArrays;
|
import org.teavm.classlib.java.util.TArrays;
|
||||||
import org.teavm.javascript.ni.Remove;
|
import org.teavm.javascript.spi.Remove;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
import org.teavm.javascript.ni.Superclass;
|
import org.teavm.javascript.spi.Superclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.teavm.classlib.java.lang.reflect;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.*;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.ClassReader;
|
import org.teavm.model.ClassReader;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.lang.reflect;
|
||||||
|
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.teavm.classlib.java.lang.TException;
|
||||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||||
import org.teavm.classlib.java.lang.TNullPointerException;
|
import org.teavm.classlib.java.lang.TNullPointerException;
|
||||||
import org.teavm.classlib.java.lang.TString;
|
import org.teavm.classlib.java.lang.TString;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code URISyntaxException} will be thrown if some information could not be parsed
|
* A {@code URISyntaxException} will be thrown if some information could not be parsed
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.classlib.java.util;
|
package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.util;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.util;
|
||||||
import org.teavm.classlib.java.lang.TComparable;
|
import org.teavm.classlib.java.lang.TComparable;
|
||||||
import org.teavm.classlib.java.lang.TSystem;
|
import org.teavm.classlib.java.lang.TSystem;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||||
import org.teavm.classlib.java.lang.TIllegalStateException;
|
import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable {
|
public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable {
|
||||||
transient int elementCount;
|
transient int elementCount;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||||
import org.teavm.classlib.java.lang.TCloneable;
|
import org.teavm.classlib.java.lang.TCloneable;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.util;
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.TMath;
|
import org.teavm.classlib.java.lang.TMath;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
import org.teavm.classlib.java.lang.TString;
|
import org.teavm.classlib.java.lang.TString;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,8 +21,8 @@ import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.classlib.java.util.logging;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.util.logging;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
import org.teavm.classlib.java.util.THashMap;
|
import org.teavm.classlib.java.util.THashMap;
|
||||||
import org.teavm.classlib.java.util.TMap;
|
import org.teavm.classlib.java.util.TMap;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,5 +22,5 @@ import org.teavm.model.CallLocation;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyPlugin {
|
public interface DependencyPlugin {
|
||||||
void methodAchieved(DependencyAgent checker, MethodDependency method, CallLocation location);
|
void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ package org.teavm.javascript;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.teavm.common.*;
|
import org.teavm.common.*;
|
||||||
import org.teavm.javascript.ast.*;
|
import org.teavm.javascript.ast.*;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
import org.teavm.javascript.ni.PreserveOriginalName;
|
import org.teavm.javascript.spi.PreserveOriginalName;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.model.util.AsyncProgramSplitter;
|
import org.teavm.model.util.AsyncProgramSplitter;
|
||||||
import org.teavm.model.util.ProgramUtils;
|
import org.teavm.model.util.ProgramUtils;
|
||||||
|
|
|
@ -27,10 +27,10 @@ import org.teavm.debugging.information.DebugInformationEmitter;
|
||||||
import org.teavm.debugging.information.DeferredCallSite;
|
import org.teavm.debugging.information.DeferredCallSite;
|
||||||
import org.teavm.debugging.information.DummyDebugInformationEmitter;
|
import org.teavm.debugging.information.DummyDebugInformationEmitter;
|
||||||
import org.teavm.javascript.ast.*;
|
import org.teavm.javascript.ast.*;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +53,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
private Deque<LocationStackEntry> locationStack = new ArrayDeque<>();
|
private Deque<LocationStackEntry> locationStack = new ArrayDeque<>();
|
||||||
private DeferredCallSite lastCallSite;
|
private DeferredCallSite lastCallSite;
|
||||||
private DeferredCallSite prevCallSite;
|
private DeferredCallSite prevCallSite;
|
||||||
|
private Set<MethodReference> asyncMethods;
|
||||||
private boolean async;
|
private boolean async;
|
||||||
|
|
||||||
private static class InjectorHolder {
|
private static class InjectorHolder {
|
||||||
|
@ -76,12 +77,13 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
|
|
||||||
public Renderer(SourceWriter writer, ListableClassHolderSource classSource, ClassLoader classLoader,
|
public Renderer(SourceWriter writer, ListableClassHolderSource classSource, ClassLoader classLoader,
|
||||||
ServiceRepository services) {
|
ServiceRepository services, Set<MethodReference> asyncMethods) {
|
||||||
this.naming = writer.getNaming();
|
this.naming = writer.getNaming();
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.classSource = classSource;
|
this.classSource = classSource;
|
||||||
this.classLoader = classLoader;
|
this.classLoader = classLoader;
|
||||||
this.services = services;
|
this.services = services;
|
||||||
|
this.asyncMethods = new HashSet<>(asyncMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -695,6 +697,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
return async;
|
return async;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAsync(MethodReference method) {
|
||||||
|
return asyncMethods.contains(method);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCompleteContinuation() {
|
public String getCompleteContinuation() {
|
||||||
return "$return";
|
return "$return";
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ast;
|
package org.teavm.javascript.ast;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.runtime;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
|
@ -13,11 +13,12 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.teavm.common.ServiceRepository;
|
import org.teavm.common.ServiceRepository;
|
||||||
import org.teavm.model.ListableClassReaderSource;
|
import org.teavm.model.ListableClassReaderSource;
|
||||||
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,4 +36,6 @@ public interface GeneratorContext extends ServiceRepository {
|
||||||
boolean isAsync();
|
boolean isAsync();
|
||||||
|
|
||||||
String getCompleteContinuation();
|
String getCompleteContinuation();
|
||||||
|
|
||||||
|
boolean isAsync(MethodReference method);
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.javascript.ni;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.runtime;
|
package org.teavm.javascript.spi;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -21,10 +21,10 @@ import org.teavm.callgraph.CallGraph;
|
||||||
import org.teavm.callgraph.CallGraphNode;
|
import org.teavm.callgraph.CallGraphNode;
|
||||||
import org.teavm.callgraph.CallSite;
|
import org.teavm.callgraph.CallSite;
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.Async;
|
||||||
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
|
import org.teavm.javascript.spi.Sync;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.runtime.Async;
|
|
||||||
import org.teavm.runtime.Sync;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,9 +17,9 @@ package org.teavm.parsing;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.teavm.common.Mapper;
|
import org.teavm.common.Mapper;
|
||||||
import org.teavm.javascript.ni.Remove;
|
import org.teavm.javascript.spi.Remove;
|
||||||
import org.teavm.javascript.ni.Rename;
|
import org.teavm.javascript.spi.Rename;
|
||||||
import org.teavm.javascript.ni.Superclass;
|
import org.teavm.javascript.spi.Superclass;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.model.instructions.*;
|
import org.teavm.model.instructions.*;
|
||||||
import org.teavm.model.util.ModelUtils;
|
import org.teavm.model.util.ModelUtils;
|
||||||
|
|
|
@ -26,10 +26,10 @@ import org.teavm.diagnostics.AccumulationDiagnostics;
|
||||||
import org.teavm.diagnostics.ProblemProvider;
|
import org.teavm.diagnostics.ProblemProvider;
|
||||||
import org.teavm.javascript.*;
|
import org.teavm.javascript.*;
|
||||||
import org.teavm.javascript.ast.ClassNode;
|
import org.teavm.javascript.ast.ClassNode;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.model.instructions.*;
|
import org.teavm.model.instructions.*;
|
||||||
import org.teavm.model.util.*;
|
import org.teavm.model.util.*;
|
||||||
|
@ -396,7 +396,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
||||||
SourceWriterBuilder builder = new SourceWriterBuilder(naming);
|
SourceWriterBuilder builder = new SourceWriterBuilder(naming);
|
||||||
builder.setMinified(minifying);
|
builder.setMinified(minifying);
|
||||||
SourceWriter sourceWriter = builder.build(writer);
|
SourceWriter sourceWriter = builder.build(writer);
|
||||||
Renderer renderer = new Renderer(sourceWriter, classSet, classLoader, this);
|
Renderer renderer = new Renderer(sourceWriter, classSet, classLoader, this, asyncMethods);
|
||||||
renderer.setProperties(properties);
|
renderer.setProperties(properties);
|
||||||
if (debugEmitter != null) {
|
if (debugEmitter != null) {
|
||||||
int classIndex = 0;
|
int classIndex = 0;
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.vm.spi;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.teavm.dependency.DependencyListener;
|
import org.teavm.dependency.DependencyListener;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.model.ClassHolderTransformer;
|
import org.teavm.model.ClassHolderTransformer;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.vm.TeaVM;
|
import org.teavm.vm.TeaVM;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.teavm.jso.JSProperty;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface Window extends JSGlobal, EventTarget, StorageProvider {
|
public interface Window extends JSGlobal, EventTarget, StorageProvider, TypedArrayFactory {
|
||||||
@JSProperty
|
@JSProperty
|
||||||
HTMLDocument getDocument();
|
HTMLDocument getDocument();
|
||||||
|
|
||||||
|
@ -42,10 +42,14 @@ public interface Window extends JSGlobal, EventTarget, StorageProvider {
|
||||||
|
|
||||||
int setTimeout(TimerHandler handler, int delay);
|
int setTimeout(TimerHandler handler, int delay);
|
||||||
|
|
||||||
|
int setTimeout(TimerHandler handler, double delay);
|
||||||
|
|
||||||
void clearTimeout(int timeoutId);
|
void clearTimeout(int timeoutId);
|
||||||
|
|
||||||
int setInterval(TimerHandler handler, int delay);
|
int setInterval(TimerHandler handler, int delay);
|
||||||
|
|
||||||
|
int setInterval(TimerHandler handler, double delay);
|
||||||
|
|
||||||
void clearInterval(int timeoutId);
|
void clearInterval(int timeoutId);
|
||||||
|
|
||||||
@JSProperty("JSON")
|
@JSProperty("JSON")
|
||||||
|
@ -53,79 +57,4 @@ public interface Window extends JSGlobal, EventTarget, StorageProvider {
|
||||||
|
|
||||||
@JSConstructor("XMLHttpRequest")
|
@JSConstructor("XMLHttpRequest")
|
||||||
XMLHttpRequest createXMLHttpRequest();
|
XMLHttpRequest createXMLHttpRequest();
|
||||||
|
|
||||||
@JSConstructor("ArrayBuffer")
|
|
||||||
ArrayBuffer createArrayBuffer(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int8Array")
|
|
||||||
Int8Array createInt8Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int8Array")
|
|
||||||
Int8Array createInt8Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Int8Array")
|
|
||||||
Int8Array createInt8Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8Array")
|
|
||||||
Uint8Array createUint8Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8Array")
|
|
||||||
Uint8Array createUint8Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8Array")
|
|
||||||
Uint8Array createUint8Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8ClampedArray")
|
|
||||||
Uint8ClampedArray createUint8ClampedArray(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8ClampedArray")
|
|
||||||
Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Uint8ClampedArray")
|
|
||||||
Uint8ClampedArray createUintClamped8Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int16Array")
|
|
||||||
Int16Array createInt16Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int16Array")
|
|
||||||
Int16Array createInt16Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Int16Array")
|
|
||||||
Int16Array createInt16Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint16Array")
|
|
||||||
Uint16Array createUint16Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Uint16Array")
|
|
||||||
Uint16Array createUint16Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Uint16Array")
|
|
||||||
Uint16Array createUint16Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int32Array")
|
|
||||||
Int32Array createInt32Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Int32Array")
|
|
||||||
Int32Array createInt32Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Int32Array")
|
|
||||||
Int32Array createInt32Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Float32Array")
|
|
||||||
Float32Array createFloat32Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Float32Array")
|
|
||||||
Float32Array createFloat32Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Float32Array")
|
|
||||||
Float32Array createFloat32Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
|
|
||||||
@JSConstructor("Float64Array")
|
|
||||||
Float64Array createFloat64Array(int length);
|
|
||||||
|
|
||||||
@JSConstructor("Float64Array")
|
|
||||||
Float64Array createFloat64Array(ArrayBuffer buffer);
|
|
||||||
|
|
||||||
@JSConstructor("Float64Array")
|
|
||||||
Float64Array createFloat64Array(ArrayBuffer buffer, int offset, int length);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* Licensed 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.teavm.dom.typedarrays;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSConstructor;
|
||||||
|
import org.teavm.jso.JSObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
|
*/
|
||||||
|
public interface TypedArrayFactory extends JSObject {
|
||||||
|
@JSConstructor("ArrayBuffer")
|
||||||
|
ArrayBuffer createArrayBuffer(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int8Array")
|
||||||
|
Int8Array createInt8Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int8Array")
|
||||||
|
Int8Array createInt8Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Int8Array")
|
||||||
|
Int8Array createInt8Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8Array")
|
||||||
|
Uint8Array createUint8Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8Array")
|
||||||
|
Uint8Array createUint8Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8Array")
|
||||||
|
Uint8Array createUint8Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8ClampedArray")
|
||||||
|
Uint8ClampedArray createUint8ClampedArray(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8ClampedArray")
|
||||||
|
Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Uint8ClampedArray")
|
||||||
|
Uint8ClampedArray createUintClamped8Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int16Array")
|
||||||
|
Int16Array createInt16Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int16Array")
|
||||||
|
Int16Array createInt16Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Int16Array")
|
||||||
|
Int16Array createInt16Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint16Array")
|
||||||
|
Uint16Array createUint16Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Uint16Array")
|
||||||
|
Uint16Array createUint16Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Uint16Array")
|
||||||
|
Uint16Array createUint16Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int32Array")
|
||||||
|
Int32Array createInt32Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Int32Array")
|
||||||
|
Int32Array createInt32Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Int32Array")
|
||||||
|
Int32Array createInt32Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Float32Array")
|
||||||
|
Float32Array createFloat32Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Float32Array")
|
||||||
|
Float32Array createFloat32Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Float32Array")
|
||||||
|
Float32Array createFloat32Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
|
||||||
|
@JSConstructor("Float64Array")
|
||||||
|
Float64Array createFloat64Array(int length);
|
||||||
|
|
||||||
|
@JSConstructor("Float64Array")
|
||||||
|
Float64Array createFloat64Array(ArrayBuffer buffer);
|
||||||
|
|
||||||
|
@JSConstructor("Float64Array")
|
||||||
|
Float64Array createFloat64Array(ArrayBuffer buffer, int offset, int length);
|
||||||
|
}
|
|
@ -21,8 +21,8 @@ import net.java.html.js.JavaScriptBody;
|
||||||
import org.teavm.codegen.NamingStrategy;
|
import org.teavm.codegen.NamingStrategy;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.Renderer;
|
import org.teavm.javascript.Renderer;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.html4j;
|
||||||
|
|
||||||
import net.java.html.js.JavaScriptBody;
|
import net.java.html.js.JavaScriptBody;
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.html4j;
|
package org.teavm.html4j;
|
||||||
|
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.html4j;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,42 +43,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.teavm</groupId>
|
|
||||||
<artifactId>teavm-maven-plugin</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.teavm</groupId>
|
|
||||||
<artifactId>teavm-classlib</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>generate-javascript-tests</id>
|
|
||||||
<goals>
|
|
||||||
<goal>build-test-javascript</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>process-test-classes</phase>
|
|
||||||
<configuration>
|
|
||||||
<minifying>false</minifying>
|
|
||||||
<properties>
|
|
||||||
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.jso;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import org.teavm.dependency.PluggableDependency;
|
import org.teavm.dependency.PluggableDependency;
|
||||||
import org.teavm.javascript.ni.InjectedBy;
|
import org.teavm.javascript.spi.InjectedBy;
|
||||||
import org.teavm.jso.plugin.JSNativeGenerator;
|
import org.teavm.jso.plugin.JSNativeGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,6 +101,9 @@ public final class JS {
|
||||||
@InjectedBy(JSNativeGenerator.class)
|
@InjectedBy(JSNativeGenerator.class)
|
||||||
public static native JSObject wrap(short num);
|
public static native JSObject wrap(short num);
|
||||||
|
|
||||||
|
@InjectedBy(JSNativeGenerator.class)
|
||||||
|
public static native JSObject pass(Object obj);
|
||||||
|
|
||||||
public static <T extends JSObject> JSArray<T> wrap(T[] array) {
|
public static <T extends JSObject> JSArray<T> wrap(T[] array) {
|
||||||
JSArray<T> result = createArray(array.length);
|
JSArray<T> result = createArray(array.length);
|
||||||
for (int i = 0; i < array.length; ++i) {
|
for (int i = 0; i < array.length; ++i) {
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.teavm.jso.plugin;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@ import org.teavm.dependency.*;
|
||||||
import org.teavm.javascript.ast.ConstantExpr;
|
import org.teavm.javascript.ast.ConstantExpr;
|
||||||
import org.teavm.javascript.ast.Expr;
|
import org.teavm.javascript.ast.Expr;
|
||||||
import org.teavm.javascript.ast.InvocationExpr;
|
import org.teavm.javascript.ast.InvocationExpr;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.jso.JS;
|
import org.teavm.jso.JS;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.ClassReader;
|
import org.teavm.model.ClassReader;
|
||||||
|
@ -88,6 +88,9 @@ public class JSNativeGenerator implements Injector, DependencyPlugin {
|
||||||
}
|
}
|
||||||
writer.append("))");
|
writer.append("))");
|
||||||
break;
|
break;
|
||||||
|
case "pass":
|
||||||
|
context.writeExpr(context.getArgument(0));
|
||||||
|
break;
|
||||||
case "wrap":
|
case "wrap":
|
||||||
if (methodRef.getDescriptor().parameterType(0).isObject("java.lang.String")) {
|
if (methodRef.getDescriptor().parameterType(0).isObject("java.lang.String")) {
|
||||||
writer.append("$rt_ustr(");
|
writer.append("$rt_ustr(");
|
||||||
|
|
|
@ -17,8 +17,8 @@ package org.teavm.jso.plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.javascript.ni.PreserveOriginalName;
|
import org.teavm.javascript.spi.PreserveOriginalName;
|
||||||
import org.teavm.jso.*;
|
import org.teavm.jso.*;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.model.instructions.*;
|
import org.teavm.model.instructions.*;
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.runtime;
|
package org.teavm.platform.async;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
*/
|
*/
|
||||||
public interface AsyncCallback<T> {
|
public interface AsyncCallback<T> {
|
||||||
void complete(T value);
|
void complete(T result);
|
||||||
|
|
||||||
void error(Exception e);
|
void error(Throwable e);
|
||||||
}
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* Licensed 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.teavm.platform.plugin;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.teavm.codegen.SourceWriter;
|
||||||
|
import org.teavm.dependency.DependencyAgent;
|
||||||
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
|
import org.teavm.dependency.MethodDependency;
|
||||||
|
import org.teavm.javascript.spi.Generator;
|
||||||
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
|
import org.teavm.model.*;
|
||||||
|
import org.teavm.platform.async.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
|
*/
|
||||||
|
public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
||||||
|
private static final MethodReference completeMethod = new MethodReference(AsyncCallback.class, "complete",
|
||||||
|
Object.class, void.class);
|
||||||
|
private static final MethodReference errorMethod = new MethodReference(AsyncCallback.class, "error",
|
||||||
|
Throwable.class, void.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
|
||||||
|
MethodReference asyncRef = getAsyncReference(methodRef);
|
||||||
|
writer.append("var callback").ws().append("=").ws().append("function()").ws().append("{}").softNewLine();
|
||||||
|
writer.append("callback.").appendMethod(completeMethod).ws().append("=").ws().append("function($this,").ws()
|
||||||
|
.append("val)").ws().append("{").indent().softNewLine();
|
||||||
|
writer.append("return $return($rt_asyncResult(val));").softNewLine();
|
||||||
|
writer.outdent().append("};").softNewLine();
|
||||||
|
writer.append("callback.").appendMethod(errorMethod).ws().append("=").ws().append("function($this,").ws()
|
||||||
|
.append("e)").ws().append("{").indent().softNewLine();
|
||||||
|
writer.append("return $return($rt_asyncError(e));").softNewLine();
|
||||||
|
writer.outdent().append("};").softNewLine();
|
||||||
|
writer.append("try").ws().append("{").indent().softNewLine();
|
||||||
|
writer.append("return ").appendMethodBody(asyncRef).append('(');
|
||||||
|
ClassReader cls = context.getClassSource().get(methodRef.getClassName());
|
||||||
|
MethodReader method = cls.getMethod(methodRef.getDescriptor());
|
||||||
|
int start = method.hasModifier(ElementModifier.STATIC) ? 1 : 0;
|
||||||
|
for (int i = start; i <= methodRef.parameterCount(); ++i) {
|
||||||
|
writer.append(context.getParameterName(i));
|
||||||
|
writer.append(',').ws();
|
||||||
|
}
|
||||||
|
writer.append("callback);").softNewLine();
|
||||||
|
writer.outdent().append("}").ws().append("catch($e)").ws().append("{").indent().softNewLine();
|
||||||
|
writer.append("return $return($rt_asyncError($e));").softNewLine();
|
||||||
|
writer.outdent().append("}").softNewLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MethodReference getAsyncReference(MethodReference methodRef) {
|
||||||
|
ValueType[] signature = new ValueType[methodRef.parameterCount() + 2];
|
||||||
|
for (int i = 0; i < methodRef.parameterCount(); ++i) {
|
||||||
|
signature[i] = methodRef.getDescriptor().parameterType(i);
|
||||||
|
}
|
||||||
|
signature[methodRef.parameterCount()] = ValueType.parse(AsyncCallback.class);
|
||||||
|
signature[methodRef.parameterCount() + 1] = ValueType.VOID;
|
||||||
|
return new MethodReference(methodRef.getClassName(), methodRef.getName(), signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void methodAchieved(DependencyAgent checker, MethodDependency method, CallLocation location) {
|
||||||
|
MethodReference asyncRef = getAsyncReference(method.getReference());
|
||||||
|
MethodDependency asyncMethod = checker.linkMethod(asyncRef, location);
|
||||||
|
int paramCount = method.getReference().parameterCount();
|
||||||
|
for (int i = 0; i <= paramCount; ++i) {
|
||||||
|
method.getVariable(i).connect(asyncMethod.getVariable(i));
|
||||||
|
}
|
||||||
|
asyncMethod.use();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* Licensed 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.teavm.platform.plugin;
|
||||||
|
|
||||||
|
import org.teavm.dependency.PluggableDependency;
|
||||||
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
|
import org.teavm.javascript.spi.Async;
|
||||||
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
import org.teavm.model.*;
|
||||||
|
import org.teavm.platform.async.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
|
*/
|
||||||
|
public class AsyncMethodProcessor implements ClassHolderTransformer {
|
||||||
|
@Override
|
||||||
|
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {
|
||||||
|
for (MethodHolder method : cls.getMethods()) {
|
||||||
|
if (method.hasModifier(ElementModifier.NATIVE) &&
|
||||||
|
method.getAnnotations().get(Async.class.getName()) != null &&
|
||||||
|
method.getAnnotations().get(GeneratedBy.class.getName()) == null) {
|
||||||
|
ValueType[] signature = new ValueType[method.parameterCount() + 2];
|
||||||
|
for (int i = 0; i < method.parameterCount(); ++i) {
|
||||||
|
signature[i] = method.parameterType(i);
|
||||||
|
}
|
||||||
|
signature[method.parameterCount()] = ValueType.parse(AsyncCallback.class);
|
||||||
|
signature[method.parameterCount() + 1] = ValueType.VOID;
|
||||||
|
MethodDescriptor asyncDesc = new MethodDescriptor(method.getName(), signature);
|
||||||
|
MethodHolder asyncMethod = cls.getMethod(asyncDesc);
|
||||||
|
if (asyncMethod != null) {
|
||||||
|
if (asyncMethod.hasModifier(ElementModifier.STATIC) !=
|
||||||
|
method.hasModifier(ElementModifier.STATIC)) {
|
||||||
|
diagnostics.error(new CallLocation(method.getReference()), "Methods {{m0}} and {{m1}} must " +
|
||||||
|
"both be either static or non-static",
|
||||||
|
method.getReference(), asyncMethod.getReference());
|
||||||
|
}
|
||||||
|
AnnotationHolder annot = new AnnotationHolder(GeneratedBy.class.getName());
|
||||||
|
annot.getValues().put("value", new AnnotationValue(ValueType.parse(AsyncMethodGenerator.class)));
|
||||||
|
method.getAnnotations().add(annot);
|
||||||
|
annot = new AnnotationHolder(PluggableDependency.class.getName());
|
||||||
|
annot.getValues().put("value", new AnnotationValue(ValueType.parse(AsyncMethodGenerator.class)));
|
||||||
|
method.getAnnotations().add(annot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,8 +19,8 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.spi.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.spi.GeneratorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.platform.metadata.MetadataGenerator;
|
import org.teavm.platform.metadata.MetadataGenerator;
|
||||||
import org.teavm.platform.metadata.MetadataProvider;
|
import org.teavm.platform.metadata.MetadataProvider;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.platform.plugin;
|
package org.teavm.platform.plugin;
|
||||||
|
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.javascript.ni.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.platform.metadata.MetadataProvider;
|
import org.teavm.platform.metadata.MetadataProvider;
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,6 @@ public class PlatformPlugin implements TeaVMPlugin {
|
||||||
host.add(new ResourceTransformer());
|
host.add(new ResourceTransformer());
|
||||||
host.add(new ResourceAccessorTransformer(host));
|
host.add(new ResourceAccessorTransformer(host));
|
||||||
host.add(new ResourceAccessorDependencyListener());
|
host.add(new ResourceAccessorDependencyListener());
|
||||||
|
host.add(new AsyncMethodProcessor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.teavm.platform.plugin;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.javascript.ast.ConstantExpr;
|
import org.teavm.javascript.ast.ConstantExpr;
|
||||||
import org.teavm.javascript.ast.Expr;
|
import org.teavm.javascript.ast.Expr;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.spi.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.spi.InjectorContext;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
|
|
4
teavm-tests/.gitignore
vendored
Normal file
4
teavm-tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/target
|
||||||
|
/.settings
|
||||||
|
/.classpath
|
||||||
|
/.project
|
115
teavm-tests/pom.xml
Normal file
115
teavm-tests/pom.xml
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
<!--
|
||||||
|
Copyright 2015 Alexey Andreev.
|
||||||
|
|
||||||
|
Licensed 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm</artifactId>
|
||||||
|
<version>0.3.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>teavm-tests</artifactId>
|
||||||
|
|
||||||
|
<name>TeaVM tests</name>
|
||||||
|
<description>Project containing TeaVM tests, as it is impossible to test each module separately</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-classlib</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-platform</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-jso</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-maven-plugin</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-platform</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-javascript-tests</id>
|
||||||
|
<goals>
|
||||||
|
<goal>build-test-javascript</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-test-classes</phase>
|
||||||
|
<configuration>
|
||||||
|
<minifying>false</minifying>
|
||||||
|
<properties>
|
||||||
|
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
|
||||||
|
</properties>
|
||||||
|
<incremental>${teavm.test.incremental}</incremental>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>org/teavm/platform/**/*.java</exclude>
|
||||||
|
<exclude>org/teavm/jso/**/*.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>../checkstyle.xml</configLocation>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user