mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Moves JSObject and others into a separate project
This commit is contained in:
parent
e13accc7e4
commit
e5ea6b51a7
1
pom.xml
1
pom.xml
|
@ -18,6 +18,7 @@
|
||||||
<module>teavm-maven-plugin</module>
|
<module>teavm-maven-plugin</module>
|
||||||
<module>teavm-samples</module>
|
<module>teavm-samples</module>
|
||||||
<module>teavm-dom</module>
|
<module>teavm-dom</module>
|
||||||
|
<module>teavm-jso</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installPlugins() {
|
public void installPlugins() {
|
||||||
for (JavascriptBuilderPlugin plugin : ServiceLoader.load(JavascriptBuilderPlugin.class)) {
|
for (JavascriptBuilderPlugin plugin : ServiceLoader.load(JavascriptBuilderPlugin.class, classLoader)) {
|
||||||
plugin.install(this);
|
plugin.install(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,12 @@ import java.util.List;
|
||||||
import org.teavm.model.ClassHolder;
|
import org.teavm.model.ClassHolder;
|
||||||
import org.teavm.model.ClassHolderSource;
|
import org.teavm.model.ClassHolderSource;
|
||||||
import org.teavm.model.ClassHolderTransformer;
|
import org.teavm.model.ClassHolderTransformer;
|
||||||
import org.teavm.model.MethodHolder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
class JavascriptProcessedClassSource implements ClassHolderSource {
|
class JavascriptProcessedClassSource implements ClassHolderSource {
|
||||||
private ThreadLocal<JavascriptNativeProcessor> processor = new ThreadLocal<>();
|
|
||||||
private ClassHolderSource innerSource;
|
private ClassHolderSource innerSource;
|
||||||
private List<ClassHolderTransformer> transformers = new ArrayList<>();
|
private List<ClassHolderTransformer> transformers = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -49,22 +47,8 @@ class JavascriptProcessedClassSource implements ClassHolderSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformClass(ClassHolder cls) {
|
private void transformClass(ClassHolder cls) {
|
||||||
JavascriptNativeProcessor processor = getProcessor();
|
|
||||||
processor.processClass(cls);
|
|
||||||
for (MethodHolder method : cls.getMethods()) {
|
|
||||||
if (method.getProgram() != null) {
|
|
||||||
processor.processProgram(method.getProgram());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ClassHolderTransformer transformer : transformers) {
|
for (ClassHolderTransformer transformer : transformers) {
|
||||||
transformer.transformClass(cls);
|
transformer.transformClass(cls, innerSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JavascriptNativeProcessor getProcessor() {
|
|
||||||
if (processor.get() == null) {
|
|
||||||
processor.set(new JavascriptNativeProcessor(innerSource));
|
|
||||||
}
|
|
||||||
return processor.get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class AnnotationContainer {
|
public class AnnotationContainer implements AnnotationContainerReader {
|
||||||
private Map<String, AnnotationHolder> annotations = new HashMap<>();
|
private Map<String, AnnotationHolder> annotations = new HashMap<>();
|
||||||
|
|
||||||
public void add(AnnotationHolder annotation) {
|
public void add(AnnotationHolder annotation) {
|
||||||
|
@ -32,6 +32,7 @@ public class AnnotationContainer {
|
||||||
annotations.put(annotation.getType(), annotation);
|
annotations.put(annotation.getType(), annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AnnotationHolder get(String type) {
|
public AnnotationHolder get(String type) {
|
||||||
return annotations.get(type);
|
return annotations.get(type);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ public class AnnotationContainer {
|
||||||
annotations.remove(type);
|
annotations.remove(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Iterable<AnnotationHolder> all() {
|
public Iterable<AnnotationHolder> all() {
|
||||||
return annotations.values();
|
return annotations.values();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 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.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public interface AnnotationContainerReader {
|
||||||
|
AnnotationHolder get(String type);
|
||||||
|
|
||||||
|
Iterable<? extends AnnotationReader> all();
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||||
* Represents an annotation of Java element.
|
* Represents an annotation of Java element.
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class AnnotationHolder {
|
public class AnnotationHolder implements AnnotationReader {
|
||||||
private String type;
|
private String type;
|
||||||
private Map<String, AnnotationValue> values = new HashMap<>();
|
private Map<String, AnnotationValue> values = new HashMap<>();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public class AnnotationHolder {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -37,4 +38,14 @@ public class AnnotationHolder {
|
||||||
public Map<String, AnnotationValue> getValues() {
|
public Map<String, AnnotationValue> getValues() {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationValue getValue(String fieldName) {
|
||||||
|
return values.get(fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<String> getAvailableFields() {
|
||||||
|
return values.keySet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 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.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public interface AnnotationReader {
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
AnnotationValue getValue(String fieldName);
|
||||||
|
|
||||||
|
Iterable<String> getAvailableFields();
|
||||||
|
}
|
|
@ -21,5 +21,5 @@ package org.teavm.model;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface ClassHolderTransformer {
|
public interface ClassHolderTransformer {
|
||||||
void transformClass(ClassHolder cls);
|
void transformClass(ClassHolder cls, ClassReaderSource innerSource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public abstract class ElementHolder implements ElementReader {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AnnotationContainer getAnnotations() {
|
public AnnotationContainer getAnnotations() {
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,6 @@ public interface ElementReader {
|
||||||
boolean hasModifier(ElementModifier modifier);
|
boolean hasModifier(ElementModifier modifier);
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
AnnotationContainerReader getAnnotations();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.teavm</groupId>
|
<groupId>org.teavm</groupId>
|
||||||
<artifactId>teavm</artifactId>
|
<artifactId>teavm</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>teavm-dom</artifactId>
|
<artifactId>teavm-dom</artifactId>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.teavm</groupId>
|
<groupId>org.teavm</groupId>
|
||||||
|
@ -31,5 +31,10 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-jso</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
4
teavm-jso/.gitignore
vendored
Normal file
4
teavm-jso/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/target
|
||||||
|
/.settings
|
||||||
|
/.classpath
|
||||||
|
/.project
|
35
teavm-jso/pom.xml
Normal file
35
teavm-jso/pom.xml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<!--
|
||||||
|
Copyright 2014 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.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>teavm-jso</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-core</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 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.javascript.ni.plugin;
|
||||||
|
|
||||||
|
import org.teavm.javascript.JavascriptBuilderHost;
|
||||||
|
import org.teavm.javascript.JavascriptBuilderPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public class JSObjectBuilderPlugin implements JavascriptBuilderPlugin {
|
||||||
|
@Override
|
||||||
|
public void install(JavascriptBuilderHost host) {
|
||||||
|
host.add(new JSObjectClassTransformer());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 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.javascript.ni.plugin;
|
||||||
|
|
||||||
|
import org.teavm.model.ClassHolder;
|
||||||
|
import org.teavm.model.ClassHolderTransformer;
|
||||||
|
import org.teavm.model.ClassReaderSource;
|
||||||
|
import org.teavm.model.MethodHolder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
class JSObjectClassTransformer implements ClassHolderTransformer {
|
||||||
|
private ThreadLocal<JavascriptNativeProcessor> processor = new ThreadLocal<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transformClass(ClassHolder cls, ClassReaderSource innerSource) {
|
||||||
|
JavascriptNativeProcessor processor = getProcessor(innerSource);
|
||||||
|
processor.processClass(cls);
|
||||||
|
for (MethodHolder method : cls.getMethods()) {
|
||||||
|
if (method.getProgram() != null) {
|
||||||
|
processor.processProgram(method.getProgram());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavascriptNativeProcessor getProcessor(ClassReaderSource innerSource) {
|
||||||
|
if (processor.get() == null) {
|
||||||
|
processor.set(new JavascriptNativeProcessor(innerSource));
|
||||||
|
}
|
||||||
|
return processor.get();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
package org.teavm.javascript.ni.plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.teavm.javascript.ni.*;
|
import org.teavm.javascript.ni.*;
|
||||||
|
@ -25,12 +25,12 @@ import org.teavm.model.instructions.*;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
class JavascriptNativeProcessor {
|
class JavascriptNativeProcessor {
|
||||||
private ClassHolderSource classSource;
|
private ClassReaderSource classSource;
|
||||||
private Program program;
|
private Program program;
|
||||||
private List<Instruction> replacement = new ArrayList<>();
|
private List<Instruction> replacement = new ArrayList<>();
|
||||||
private NativeJavascriptClassRepository nativeRepos;
|
private NativeJavascriptClassRepository nativeRepos;
|
||||||
|
|
||||||
public JavascriptNativeProcessor(ClassHolderSource classSource) {
|
public JavascriptNativeProcessor(ClassReaderSource classSource) {
|
||||||
this.classSource = classSource;
|
this.classSource = classSource;
|
||||||
nativeRepos = new NativeJavascriptClassRepository(classSource);
|
nativeRepos = new NativeJavascriptClassRepository(classSource);
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ class JavascriptNativeProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPreservedMethods(String ifaceName, Set<MethodDescriptor> methods) {
|
private void addPreservedMethods(String ifaceName, Set<MethodDescriptor> methods) {
|
||||||
ClassHolder iface = classSource.get(ifaceName);
|
ClassReader iface = classSource.get(ifaceName);
|
||||||
for (MethodHolder method : iface.getMethods()) {
|
for (MethodReader method : iface.getMethods()) {
|
||||||
methods.add(method.getDescriptor());
|
methods.add(method.getDescriptor());
|
||||||
}
|
}
|
||||||
for (String superIfaceName : iface.getInterfaces()) {
|
for (String superIfaceName : iface.getInterfaces()) {
|
||||||
|
@ -75,7 +75,7 @@ class JavascriptNativeProcessor {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
replacement.clear();
|
replacement.clear();
|
||||||
MethodHolder method = getMethod(invoke.getMethod());
|
MethodReader method = getMethod(invoke.getMethod());
|
||||||
if (method.getAnnotations().get(JSProperty.class.getName()) != null) {
|
if (method.getAnnotations().get(JSProperty.class.getName()) != null) {
|
||||||
if (isProperGetter(method.getDescriptor())) {
|
if (isProperGetter(method.getDescriptor())) {
|
||||||
String propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2) :
|
String propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2) :
|
||||||
|
@ -268,7 +268,7 @@ class JavascriptNativeProcessor {
|
||||||
private Variable wrapArgument(Variable var, ValueType type) {
|
private Variable wrapArgument(Variable var, ValueType type) {
|
||||||
if (type instanceof ValueType.Object) {
|
if (type instanceof ValueType.Object) {
|
||||||
String className = ((ValueType.Object)type).getClassName();
|
String className = ((ValueType.Object)type).getClassName();
|
||||||
ClassHolder cls = classSource.get(className);
|
ClassReader cls = classSource.get(className);
|
||||||
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
||||||
return wrapFunctor(var, cls);
|
return wrapFunctor(var, cls);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ class JavascriptNativeProcessor {
|
||||||
return wrap(var, type);
|
return wrap(var, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable wrapFunctor(Variable var, ClassHolder type) {
|
private Variable wrapFunctor(Variable var, ClassReader type) {
|
||||||
if (!type.hasModifier(ElementModifier.INTERFACE) || type.getMethods().size() != 1) {
|
if (!type.hasModifier(ElementModifier.INTERFACE) || type.getMethods().size() != 1) {
|
||||||
throw new RuntimeException("Wrong functor: " + type.getName());
|
throw new RuntimeException("Wrong functor: " + type.getName());
|
||||||
}
|
}
|
||||||
|
@ -312,9 +312,9 @@ class JavascriptNativeProcessor {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodHolder getMethod(MethodReference ref) {
|
private MethodReader getMethod(MethodReference ref) {
|
||||||
ClassHolder cls = classSource.get(ref.getClassName());
|
ClassReader cls = classSource.get(ref.getClassName());
|
||||||
MethodHolder method = cls.getMethod(ref.getDescriptor());
|
MethodReader method = cls.getMethod(ref.getDescriptor());
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
|
@ -13,13 +13,13 @@
|
||||||
* 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;
|
package org.teavm.javascript.ni.plugin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.teavm.javascript.ni.JSObject;
|
import org.teavm.javascript.ni.JSObject;
|
||||||
import org.teavm.model.ClassHolder;
|
import org.teavm.model.ClassReader;
|
||||||
import org.teavm.model.ClassHolderSource;
|
import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +27,10 @@ import org.teavm.model.ElementModifier;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
class NativeJavascriptClassRepository {
|
class NativeJavascriptClassRepository {
|
||||||
private ClassHolderSource classSource;
|
private ClassReaderSource classSource;
|
||||||
private Map<String, Boolean> knownJavaScriptClasses = new HashMap<>();
|
private Map<String, Boolean> knownJavaScriptClasses = new HashMap<>();
|
||||||
|
|
||||||
public NativeJavascriptClassRepository(ClassHolderSource classSource) {
|
public NativeJavascriptClassRepository(ClassReaderSource classSource) {
|
||||||
this.classSource = classSource;
|
this.classSource = classSource;
|
||||||
knownJavaScriptClasses.put(JSObject.class.getName(), true);
|
knownJavaScriptClasses.put(JSObject.class.getName(), true);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ class NativeJavascriptClassRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean figureOutIfJavaScriptClass(String className) {
|
private boolean figureOutIfJavaScriptClass(String className) {
|
||||||
ClassHolder cls = classSource.get(className);
|
ClassReader cls = classSource.get(className);
|
||||||
if (cls == null || !cls.getModifiers().contains(ElementModifier.INTERFACE)) {
|
if (cls == null || !cls.hasModifier(ElementModifier.INTERFACE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String iface : cls.getInterfaces()) {
|
for (String iface : cls.getInterfaces()) {
|
|
@ -0,0 +1 @@
|
||||||
|
org.teavm.javascript.ni.plugin.JSObjectBuilderPlugin
|
Loading…
Reference in New Issue
Block a user