mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Adds service retrieval support in metadata providers
This commit is contained in:
parent
8e521c457f
commit
5fcd66795e
|
@ -16,6 +16,7 @@
|
|||
package org.teavm.platform.metadata;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.teavm.common.ServiceRepository;
|
||||
import org.teavm.model.ListableClassReaderSource;
|
||||
import org.teavm.vm.TeaVM;
|
||||
|
||||
|
@ -25,7 +26,7 @@ import org.teavm.vm.TeaVM;
|
|||
*
|
||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
public interface MetadataGeneratorContext {
|
||||
public interface MetadataGeneratorContext extends ServiceRepository {
|
||||
/**
|
||||
* Gets the collection of all classes that were achieved by the dependency checker.
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.teavm.platform.plugin;
|
|||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Properties;
|
||||
import org.teavm.common.ServiceRepository;
|
||||
import org.teavm.model.ListableClassReaderSource;
|
||||
import org.teavm.platform.metadata.MetadataGeneratorContext;
|
||||
import org.teavm.platform.metadata.Resource;
|
||||
|
@ -32,12 +33,14 @@ class DefaultMetadataGeneratorContext implements MetadataGeneratorContext {
|
|||
private ClassLoader classLoader;
|
||||
private Properties properties;
|
||||
private BuildTimeResourceProxyBuilder proxyBuilder = new BuildTimeResourceProxyBuilder();
|
||||
private ServiceRepository services;
|
||||
|
||||
public DefaultMetadataGeneratorContext(ListableClassReaderSource classSource, ClassLoader classLoader,
|
||||
Properties properties) {
|
||||
Properties properties, ServiceRepository services) {
|
||||
this.classSource = classSource;
|
||||
this.classLoader = classLoader;
|
||||
this.properties = properties;
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,4 +74,9 @@ class DefaultMetadataGeneratorContext implements MetadataGeneratorContext {
|
|||
public <T extends Resource> ResourceMap<T> createResourceMap() {
|
||||
return new BuildTimeResourceMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getService(Class<T> type) {
|
||||
return services.getService(type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class MetadataProviderNativeGenerator implements Generator {
|
|||
e.getTargetException());
|
||||
}
|
||||
DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(),
|
||||
context.getClassLoader(), context.getProperties());
|
||||
context.getClassLoader(), context.getProperties(), context);
|
||||
|
||||
// Generate resource loader
|
||||
Resource resource = generator.generateMetadata(metadataContext, methodRef);
|
||||
|
|
Loading…
Reference in New Issue
Block a user