use of org.robovm.compiler.clazz.Clazz in project robovm by robovm.
the class MarshalerLookup method findMarshalersOn.
private List<Marshaler> findMarshalersOn(SootClass sc, Set<String> visited, Set<String> seen) {
String internalName = getInternalName(sc);
if (visited.contains(internalName)) {
return Collections.emptyList();
}
visited.contains(internalName);
List<Marshaler> all = cache.get(sc.getName());
if (all == null) {
all = new ArrayList<>();
for (AnnotationTag tag : getMarshalerAnnotations(sc)) {
AnnotationClassElem elem = (AnnotationClassElem) getElemByName(tag, "value");
String name = getInternalNameFromDescriptor(elem.getDesc());
Clazz marshalerClazz = config.getClazzes().load(name);
if (marshalerClazz != null) {
all.add(new Marshaler(marshalerClazz));
}
}
cache.put(sc.getName(), all);
}
List<Marshaler> result = new ArrayList<>();
for (Marshaler m : all) {
String name = m.clazz.getInternalName();
if (!seen.contains(name)) {
seen.add(name);
result.add(m);
}
}
return result;
}
use of org.robovm.compiler.clazz.Clazz in project robovm by robovm.
the class ObjCProtocolProxyPlugin method generateProxyMethods.
private void generateProxyMethods(Config config, List<String> interfazes, ClassWriter cw) throws IOException {
Clazzes clazzes = config.getClazzes();
final Set<String> addedMethods = new HashSet<>();
for (String interfaze : interfazes) {
Clazz clazz = clazzes.load(interfaze);
if (clazz == null) {
continue;
}
// Copy all abstract method (we skip default methods) to the proxy
// and make them native instead of abstract.
ClassReader classReader = new ClassReader(clazz.getBytes());
classReader.accept(new ClassVisitor(ASM4, cw) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
String key = name + desc;
if ((access & ACC_ABSTRACT) > 0 && !addedMethods.contains(key)) {
access &= ~ACC_ABSTRACT;
access |= ACC_NATIVE;
addedMethods.add(key);
return super.visitMethod(access, name, desc, signature, exceptions);
}
return null;
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
// Ignored
}
@Override
public void visitEnd() {
// Ignored
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
// Ignored
return null;
}
@Override
public void visitAttribute(Attribute attr) {
// Ignored
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
// Ignored
return null;
}
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
// Ignored
}
@Override
public void visitOuterClass(String owner, String name, String desc) {
// Ignored
}
@Override
public void visitSource(String source, String debug) {
// Ignored
}
}, 0);
}
}
use of org.robovm.compiler.clazz.Clazz in project robovm by robovm.
the class AppCompilerTest method testMultipleMetainfServiceImplsAdded.
@Test
public void testMultipleMetainfServiceImplsAdded() throws Exception {
final Path impl1 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Integer");
final Path impl2 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Long");
Clazzes clazzes = createClazzes(impl1, impl2);
Clazz interfaceClazz = clazzes.load("java/lang/Number");
Set<Clazz> compiled = new HashSet<>();
Set<Clazz> queue = new LinkedHashSet<>();
AppCompiler.addMetaInfImplementations(clazzes, interfaceClazz, compiled, queue);
assertEquals("Two items added to queue: " + queue, 2, queue.size());
assertTrue("Integer in queue" + queue, queue.contains(clazzes.load("java/lang/Integer")));
assertTrue("Long in queue" + queue, queue.contains(clazzes.load("java/lang/Long")));
}
use of org.robovm.compiler.clazz.Clazz in project robovm by robovm.
the class AppCompilerTest method testMissingImplIsIgnore.
@Test
public void testMissingImplIsIgnore() throws Exception {
final Path impl1 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Integer");
final Path impl2 = new MockPath("META-INF/services/java.lang.Number", "nobody.knows.such.Class");
Clazzes clazzes = createClazzes(impl1, impl2);
Clazz interfaceClazz = clazzes.load("java/lang/Number");
Set<Clazz> compiled = new HashSet<>();
Set<Clazz> queue = new LinkedHashSet<>();
AppCompiler.addMetaInfImplementations(clazzes, interfaceClazz, compiled, queue);
assertEquals("Just one item added to queue: " + queue, 1, queue.size());
assertTrue("Integer in queue" + queue, queue.contains(clazzes.load("java/lang/Integer")));
}
use of org.robovm.compiler.clazz.Clazz in project robovm by robovm.
the class AppCompiler method getMatchingClasses.
/**
* Returns all {@link Clazz}es in all {@link Path}s matching the specified
* ANT-style pattern.
*/
private Collection<Clazz> getMatchingClasses(String pattern) {
AntPathMatcher matcher = new AntPathMatcher(pattern, ".");
Map<String, Clazz> matches = new HashMap<String, Clazz>();
for (Path path : config.getClazzes().getPaths()) {
for (Clazz clazz : path.listClasses()) {
if (!matches.containsKey(clazz.getClassName()) && matcher.matches(clazz.getClassName())) {
matches.put(clazz.getClassName(), clazz);
}
}
}
return matches.values();
}
Aggregations