use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCMemberPlugin method createCustomClassCallbackIfNeeded.
private boolean createCustomClassCallbackIfNeeded(SootClass sootClass, SootMethod method, SootMethod superMethod) {
AnnotationTag annotation = getAnnotation(superMethod, METHOD);
if (annotation != null) {
createCallback(sootClass, method, superMethod, getObjCMethodSelectorName(annotation, superMethod, false), getReceiverType(sootClass));
return true;
} else {
annotation = getAnnotation(superMethod, PROPERTY);
if (annotation != null) {
boolean isGetter = method.getReturnType() != VoidType.v();
createCallback(sootClass, method, superMethod, getObjCPropertySelectorName(annotation, superMethod, isGetter), getReceiverType(sootClass));
return true;
}
}
return false;
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCMemberPlugin method findStrongRefGetter.
private SootMethod findStrongRefGetter(SootClass sootClass, final SootMethod method, boolean extensions) {
AnnotationTag annotation = getAnnotation(method, PROPERTY);
if (annotation == null) {
annotation = getAnnotation(method, IBOUTLET);
}
if (annotation == null) {
annotation = getAnnotation(method, IBOUTLETCOLLECTION);
}
String setterPropName = readStringElem(annotation, "name", "").trim();
if (setterPropName.length() == 0) {
String methodName = method.getName();
if (!methodName.startsWith("set") || methodName.length() == 3) {
throw new CompilerException("Failed to determine the property " + "name from the @Property method " + method + ". Either specify the name explicitly in the @Property " + "annotation or rename the method according to the Java " + "beans property setter method naming convention.");
}
setterPropName = methodName.substring(3);
setterPropName = setterPropName.substring(0, 1).toLowerCase() + setterPropName.substring(1);
}
int paramCount = extensions ? 1 : 0;
Type propType = method.getParameterType(extensions ? 1 : 0);
for (SootMethod m : sootClass.getMethods()) {
if (m != method && method.isStatic() == m.isStatic() && m.getParameterCount() == paramCount && m.getReturnType().equals(propType)) {
AnnotationTag propertyAnno = getAnnotation(m, PROPERTY);
if (propertyAnno != null) {
String getterPropName = readStringElem(propertyAnno, "name", "").trim();
if (getterPropName.length() == 0) {
String methodName = m.getName();
if (!methodName.startsWith("get") || methodName.length() == 3) {
// style getter
continue;
}
getterPropName = methodName.substring(3);
getterPropName = getterPropName.substring(0, 1).toLowerCase() + getterPropName.substring(1);
}
if (setterPropName.equals(getterPropName)) {
return m;
}
}
}
}
throw new CompilerException("Failed to determine the getter method " + "corresponding to the strong ref @Property setter method " + method + ". The getter must either specify the name explicitly in the @Property " + "annotation or be named according to the Java " + "beans property getter method naming convention.");
}
use of soot.tagkit.AnnotationTag 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 soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCMemberPlugin method addNotImplementedAnnotation.
static void addNotImplementedAnnotation(SootMethod method, String selectorName) {
AnnotationTag annotationTag = new AnnotationTag(NOT_IMPLEMENTED, 1);
annotationTag.addElem(new AnnotationStringElem(selectorName, 's', "value"));
addRuntimeVisibleAnnotation(method, annotationTag);
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCMemberPlugin method addBindSelectorAnnotation.
static void addBindSelectorAnnotation(SootMethod method, String selectorName) {
AnnotationTag annotationTag = new AnnotationTag(BIND_SELECTOR, 1);
annotationTag.addElem(new AnnotationStringElem(selectorName, 's', "value"));
addRuntimeVisibleAnnotation(method, annotationTag);
}
Aggregations