From e5ea6b51a795ac8e03ecddf373aabe7dc76279f4 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Thu, 13 Feb 2014 17:52:56 +0400 Subject: [PATCH] Moves JSObject and others into a separate project --- pom.xml | 1 + .../teavm/javascript/JavascriptBuilder.java | 2 +- .../JavascriptProcessedClassSource.java | 18 +------ .../org/teavm/model/AnnotationContainer.java | 4 +- .../model/AnnotationContainerReader.java | 26 ++++++++++ .../org/teavm/model/AnnotationHolder.java | 13 ++++- .../org/teavm/model/AnnotationReader.java | 28 +++++++++++ .../teavm/model/ClassHolderTransformer.java | 2 +- .../java/org/teavm/model/ElementHolder.java | 1 + .../java/org/teavm/model/ElementReader.java | 2 + teavm-dom/pom.xml | 9 +++- teavm-jso/.gitignore | 4 ++ teavm-jso/pom.xml | 35 ++++++++++++++ .../main/java/org/teavm/javascript/ni/JS.java | 0 .../java/org/teavm/javascript/ni/JSArray.java | 0 .../teavm/javascript/ni/JSConstructor.java | 0 .../org/teavm/javascript/ni/JSFunction.java | 0 .../org/teavm/javascript/ni/JSFunctor.java | 0 .../org/teavm/javascript/ni/JSGlobal.java | 0 .../org/teavm/javascript/ni/JSIndexer.java | 0 .../org/teavm/javascript/ni/JSMethod.java | 0 .../javascript/ni/JSNativeGenerator.java | 0 .../org/teavm/javascript/ni/JSNumber.java | 0 .../org/teavm/javascript/ni/JSObject.java | 0 .../org/teavm/javascript/ni/JSProperty.java | 0 .../java/org/teavm/javascript/ni/JSType.java | 0 .../ni/plugin/JSObjectBuilderPlugin.java | 30 ++++++++++++ .../ni/plugin/JSObjectClassTransformer.java | 47 +++++++++++++++++++ .../ni/plugin}/JavascriptNativeProcessor.java | 22 ++++----- .../NativeJavascriptClassRepository.java | 14 +++--- ...g.teavm.javascript.JavascriptBuilderPlugin | 1 + 31 files changed, 218 insertions(+), 41 deletions(-) create mode 100644 teavm-core/src/main/java/org/teavm/model/AnnotationContainerReader.java create mode 100644 teavm-core/src/main/java/org/teavm/model/AnnotationReader.java create mode 100644 teavm-jso/.gitignore create mode 100644 teavm-jso/pom.xml rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JS.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSArray.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSConstructor.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSFunction.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSFunctor.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSGlobal.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSIndexer.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSMethod.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSNativeGenerator.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSNumber.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSObject.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSProperty.java (100%) rename {teavm-core => teavm-jso}/src/main/java/org/teavm/javascript/ni/JSType.java (100%) create mode 100644 teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectBuilderPlugin.java create mode 100644 teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectClassTransformer.java rename {teavm-core/src/main/java/org/teavm/javascript => teavm-jso/src/main/java/org/teavm/javascript/ni/plugin}/JavascriptNativeProcessor.java (96%) rename {teavm-core/src/main/java/org/teavm/javascript => teavm-jso/src/main/java/org/teavm/javascript/ni/plugin}/NativeJavascriptClassRepository.java (81%) create mode 100644 teavm-jso/src/main/resources/META-INF/services/org.teavm.javascript.JavascriptBuilderPlugin diff --git a/pom.xml b/pom.xml index 0f64cffcb..573f919be 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ teavm-maven-plugin teavm-samples teavm-dom + teavm-jso diff --git a/teavm-core/src/main/java/org/teavm/javascript/JavascriptBuilder.java b/teavm-core/src/main/java/org/teavm/javascript/JavascriptBuilder.java index 566b6da7f..1ebf70274 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/JavascriptBuilder.java +++ b/teavm-core/src/main/java/org/teavm/javascript/JavascriptBuilder.java @@ -303,7 +303,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost { } public void installPlugins() { - for (JavascriptBuilderPlugin plugin : ServiceLoader.load(JavascriptBuilderPlugin.class)) { + for (JavascriptBuilderPlugin plugin : ServiceLoader.load(JavascriptBuilderPlugin.class, classLoader)) { plugin.install(this); } } diff --git a/teavm-core/src/main/java/org/teavm/javascript/JavascriptProcessedClassSource.java b/teavm-core/src/main/java/org/teavm/javascript/JavascriptProcessedClassSource.java index 1494164a9..a5055f618 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/JavascriptProcessedClassSource.java +++ b/teavm-core/src/main/java/org/teavm/javascript/JavascriptProcessedClassSource.java @@ -20,14 +20,12 @@ import java.util.List; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderSource; import org.teavm.model.ClassHolderTransformer; -import org.teavm.model.MethodHolder; /** * * @author Alexey Andreev */ class JavascriptProcessedClassSource implements ClassHolderSource { - private ThreadLocal processor = new ThreadLocal<>(); private ClassHolderSource innerSource; private List transformers = new ArrayList<>(); @@ -49,22 +47,8 @@ class JavascriptProcessedClassSource implements ClassHolderSource { } 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) { - transformer.transformClass(cls); + transformer.transformClass(cls, innerSource); } } - - private JavascriptNativeProcessor getProcessor() { - if (processor.get() == null) { - processor.set(new JavascriptNativeProcessor(innerSource)); - } - return processor.get(); - } } diff --git a/teavm-core/src/main/java/org/teavm/model/AnnotationContainer.java b/teavm-core/src/main/java/org/teavm/model/AnnotationContainer.java index 9278ac66b..6ea7cbe17 100644 --- a/teavm-core/src/main/java/org/teavm/model/AnnotationContainer.java +++ b/teavm-core/src/main/java/org/teavm/model/AnnotationContainer.java @@ -22,7 +22,7 @@ import java.util.Map; * * @author Alexey Andreev */ -public class AnnotationContainer { +public class AnnotationContainer implements AnnotationContainerReader { private Map annotations = new HashMap<>(); public void add(AnnotationHolder annotation) { @@ -32,6 +32,7 @@ public class AnnotationContainer { annotations.put(annotation.getType(), annotation); } + @Override public AnnotationHolder get(String type) { return annotations.get(type); } @@ -48,6 +49,7 @@ public class AnnotationContainer { annotations.remove(type); } + @Override public Iterable all() { return annotations.values(); } diff --git a/teavm-core/src/main/java/org/teavm/model/AnnotationContainerReader.java b/teavm-core/src/main/java/org/teavm/model/AnnotationContainerReader.java new file mode 100644 index 000000000..146dea7b9 --- /dev/null +++ b/teavm-core/src/main/java/org/teavm/model/AnnotationContainerReader.java @@ -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 all(); +} diff --git a/teavm-core/src/main/java/org/teavm/model/AnnotationHolder.java b/teavm-core/src/main/java/org/teavm/model/AnnotationHolder.java index daa7c6f5c..78e37c05e 100644 --- a/teavm-core/src/main/java/org/teavm/model/AnnotationHolder.java +++ b/teavm-core/src/main/java/org/teavm/model/AnnotationHolder.java @@ -22,7 +22,7 @@ import java.util.Map; * Represents an annotation of Java element. * @author Alexey Andreev */ -public class AnnotationHolder { +public class AnnotationHolder implements AnnotationReader { private String type; private Map values = new HashMap<>(); @@ -30,6 +30,7 @@ public class AnnotationHolder { this.type = type; } + @Override public String getType() { return type; } @@ -37,4 +38,14 @@ public class AnnotationHolder { public Map getValues() { return values; } + + @Override + public AnnotationValue getValue(String fieldName) { + return values.get(fieldName); + } + + @Override + public Iterable getAvailableFields() { + return values.keySet(); + } } diff --git a/teavm-core/src/main/java/org/teavm/model/AnnotationReader.java b/teavm-core/src/main/java/org/teavm/model/AnnotationReader.java new file mode 100644 index 000000000..64b598a85 --- /dev/null +++ b/teavm-core/src/main/java/org/teavm/model/AnnotationReader.java @@ -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 getAvailableFields(); +} diff --git a/teavm-core/src/main/java/org/teavm/model/ClassHolderTransformer.java b/teavm-core/src/main/java/org/teavm/model/ClassHolderTransformer.java index 66b6c5b04..e55785a95 100644 --- a/teavm-core/src/main/java/org/teavm/model/ClassHolderTransformer.java +++ b/teavm-core/src/main/java/org/teavm/model/ClassHolderTransformer.java @@ -21,5 +21,5 @@ package org.teavm.model; * @author Alexey Andreev */ public interface ClassHolderTransformer { - void transformClass(ClassHolder cls); + void transformClass(ClassHolder cls, ClassReaderSource innerSource); } diff --git a/teavm-core/src/main/java/org/teavm/model/ElementHolder.java b/teavm-core/src/main/java/org/teavm/model/ElementHolder.java index 1d53dc47d..a3daae7a5 100644 --- a/teavm-core/src/main/java/org/teavm/model/ElementHolder.java +++ b/teavm-core/src/main/java/org/teavm/model/ElementHolder.java @@ -59,6 +59,7 @@ public abstract class ElementHolder implements ElementReader { return name; } + @Override public AnnotationContainer getAnnotations() { return annotations; } diff --git a/teavm-core/src/main/java/org/teavm/model/ElementReader.java b/teavm-core/src/main/java/org/teavm/model/ElementReader.java index c2239f95b..450d59760 100644 --- a/teavm-core/src/main/java/org/teavm/model/ElementReader.java +++ b/teavm-core/src/main/java/org/teavm/model/ElementReader.java @@ -29,4 +29,6 @@ public interface ElementReader { boolean hasModifier(ElementModifier modifier); String getName(); + + AnnotationContainerReader getAnnotations(); } diff --git a/teavm-dom/pom.xml b/teavm-dom/pom.xml index 4784672b0..32111a663 100644 --- a/teavm-dom/pom.xml +++ b/teavm-dom/pom.xml @@ -16,14 +16,14 @@ 4.0.0 - + org.teavm teavm 0.0.1-SNAPSHOT teavm-dom - + org.teavm @@ -31,5 +31,10 @@ 0.0.1-SNAPSHOT true + + org.teavm + teavm-jso + 0.0.1-SNAPSHOT + \ No newline at end of file diff --git a/teavm-jso/.gitignore b/teavm-jso/.gitignore new file mode 100644 index 000000000..c708c363d --- /dev/null +++ b/teavm-jso/.gitignore @@ -0,0 +1,4 @@ +/target +/.settings +/.classpath +/.project diff --git a/teavm-jso/pom.xml b/teavm-jso/pom.xml new file mode 100644 index 000000000..6a6a4b9fe --- /dev/null +++ b/teavm-jso/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + org.teavm + teavm + 0.0.1-SNAPSHOT + + teavm-jso + + + + org.teavm + teavm-core + 0.0.1-SNAPSHOT + true + + + \ No newline at end of file diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JS.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JS.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JS.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JS.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSArray.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSArray.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSArray.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSArray.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSConstructor.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSConstructor.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSConstructor.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSConstructor.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSFunction.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSFunction.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSFunction.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSFunction.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSFunctor.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSFunctor.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSFunctor.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSFunctor.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSGlobal.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSGlobal.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSGlobal.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSGlobal.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSIndexer.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSIndexer.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSIndexer.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSIndexer.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSMethod.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSMethod.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSMethod.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSMethod.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSNativeGenerator.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSNativeGenerator.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSNativeGenerator.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSNativeGenerator.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSNumber.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSNumber.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSNumber.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSNumber.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSObject.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSObject.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSObject.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSObject.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSProperty.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSProperty.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSProperty.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSProperty.java diff --git a/teavm-core/src/main/java/org/teavm/javascript/ni/JSType.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/JSType.java similarity index 100% rename from teavm-core/src/main/java/org/teavm/javascript/ni/JSType.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/JSType.java diff --git a/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectBuilderPlugin.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectBuilderPlugin.java new file mode 100644 index 000000000..2e67e26d0 --- /dev/null +++ b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectBuilderPlugin.java @@ -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()); + } +} diff --git a/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectClassTransformer.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectClassTransformer.java new file mode 100644 index 000000000..393d0f19a --- /dev/null +++ b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JSObjectClassTransformer.java @@ -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 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(); + } +} diff --git a/teavm-core/src/main/java/org/teavm/javascript/JavascriptNativeProcessor.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JavascriptNativeProcessor.java similarity index 96% rename from teavm-core/src/main/java/org/teavm/javascript/JavascriptNativeProcessor.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JavascriptNativeProcessor.java index 55729c4be..05459745a 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/JavascriptNativeProcessor.java +++ b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/JavascriptNativeProcessor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.javascript; +package org.teavm.javascript.ni.plugin; import java.util.*; import org.teavm.javascript.ni.*; @@ -25,12 +25,12 @@ import org.teavm.model.instructions.*; * @author Alexey Andreev */ class JavascriptNativeProcessor { - private ClassHolderSource classSource; + private ClassReaderSource classSource; private Program program; private List replacement = new ArrayList<>(); private NativeJavascriptClassRepository nativeRepos; - public JavascriptNativeProcessor(ClassHolderSource classSource) { + public JavascriptNativeProcessor(ClassReaderSource classSource) { this.classSource = classSource; nativeRepos = new NativeJavascriptClassRepository(classSource); } @@ -51,8 +51,8 @@ class JavascriptNativeProcessor { } private void addPreservedMethods(String ifaceName, Set methods) { - ClassHolder iface = classSource.get(ifaceName); - for (MethodHolder method : iface.getMethods()) { + ClassReader iface = classSource.get(ifaceName); + for (MethodReader method : iface.getMethods()) { methods.add(method.getDescriptor()); } for (String superIfaceName : iface.getInterfaces()) { @@ -75,7 +75,7 @@ class JavascriptNativeProcessor { continue; } replacement.clear(); - MethodHolder method = getMethod(invoke.getMethod()); + MethodReader method = getMethod(invoke.getMethod()); if (method.getAnnotations().get(JSProperty.class.getName()) != null) { if (isProperGetter(method.getDescriptor())) { String propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2) : @@ -268,7 +268,7 @@ class JavascriptNativeProcessor { private Variable wrapArgument(Variable var, ValueType type) { if (type instanceof ValueType.Object) { String className = ((ValueType.Object)type).getClassName(); - ClassHolder cls = classSource.get(className); + ClassReader cls = classSource.get(className); if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) { return wrapFunctor(var, cls); } @@ -276,7 +276,7 @@ class JavascriptNativeProcessor { 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) { throw new RuntimeException("Wrong functor: " + type.getName()); } @@ -312,9 +312,9 @@ class JavascriptNativeProcessor { return result; } - private MethodHolder getMethod(MethodReference ref) { - ClassHolder cls = classSource.get(ref.getClassName()); - MethodHolder method = cls.getMethod(ref.getDescriptor()); + private MethodReader getMethod(MethodReference ref) { + ClassReader cls = classSource.get(ref.getClassName()); + MethodReader method = cls.getMethod(ref.getDescriptor()); if (method != null) { return method; } diff --git a/teavm-core/src/main/java/org/teavm/javascript/NativeJavascriptClassRepository.java b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/NativeJavascriptClassRepository.java similarity index 81% rename from teavm-core/src/main/java/org/teavm/javascript/NativeJavascriptClassRepository.java rename to teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/NativeJavascriptClassRepository.java index e82fcf548..e76357a69 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/NativeJavascriptClassRepository.java +++ b/teavm-jso/src/main/java/org/teavm/javascript/ni/plugin/NativeJavascriptClassRepository.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.javascript; +package org.teavm.javascript.ni.plugin; import java.util.HashMap; import java.util.Map; import org.teavm.javascript.ni.JSObject; -import org.teavm.model.ClassHolder; -import org.teavm.model.ClassHolderSource; +import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; /** @@ -27,10 +27,10 @@ import org.teavm.model.ElementModifier; * @author Alexey Andreev */ class NativeJavascriptClassRepository { - private ClassHolderSource classSource; + private ClassReaderSource classSource; private Map knownJavaScriptClasses = new HashMap<>(); - public NativeJavascriptClassRepository(ClassHolderSource classSource) { + public NativeJavascriptClassRepository(ClassReaderSource classSource) { this.classSource = classSource; knownJavaScriptClasses.put(JSObject.class.getName(), true); } @@ -45,8 +45,8 @@ class NativeJavascriptClassRepository { } private boolean figureOutIfJavaScriptClass(String className) { - ClassHolder cls = classSource.get(className); - if (cls == null || !cls.getModifiers().contains(ElementModifier.INTERFACE)) { + ClassReader cls = classSource.get(className); + if (cls == null || !cls.hasModifier(ElementModifier.INTERFACE)) { return false; } for (String iface : cls.getInterfaces()) { diff --git a/teavm-jso/src/main/resources/META-INF/services/org.teavm.javascript.JavascriptBuilderPlugin b/teavm-jso/src/main/resources/META-INF/services/org.teavm.javascript.JavascriptBuilderPlugin new file mode 100644 index 000000000..59e76871c --- /dev/null +++ b/teavm-jso/src/main/resources/META-INF/services/org.teavm.javascript.JavascriptBuilderPlugin @@ -0,0 +1 @@ +org.teavm.javascript.ni.plugin.JSObjectBuilderPlugin \ No newline at end of file