use of org.robovm.compiler.CompilerException in project robovm by robovm.
the class ObjCMemberPlugin method transformMethod.
private void transformMethod(Config config, Clazz clazz, SootClass sootClass, SootMethod method, Set<String> selectors, Set<String> overridables, boolean extensions) {
AnnotationTag annotation = getAnnotation(method, METHOD);
if (annotation != null) {
if (extensions && !(method.isStatic() && method.isNative())) {
throw new CompilerException("Objective-C @Method method " + method + " in extension class must be static and native.");
}
transformObjCMethod(annotation, sootClass, method, selectors, overridables, extensions);
return;
}
annotation = getAnnotation(method, IBACTION);
if (annotation != null) {
if (method.isStatic() || method.isNative()) {
throw new CompilerException("Objective-C @IBAction method " + method + " must not be static or native.");
}
int paramCount = method.getParameterCount();
Type param1 = paramCount > 0 ? method.getParameterType(0) : null;
Type param2 = paramCount > 1 ? method.getParameterType(1) : null;
if (method.getReturnType() != VoidType.v() || paramCount > 2 || (param1 != null && (!isNSObject(param1) && !isNSObject(param1))) || (param2 != null && (!isUIEvent(param2) || isNSObject(param1)))) {
throw new CompilerException("Objective-C @IBAction method " + method + " does not have a supported signature. @IBAction methods" + " must return void and either take no arguments, 1 argument of type NSObject" + ", or 2 arguments of types NSObject and UIEvent.");
}
transformObjCMethod(annotation, sootClass, method, selectors, overridables, extensions);
return;
}
annotation = getAnnotation(method, PROPERTY);
if (annotation != null) {
if (extensions && !(method.isStatic() && method.isNative())) {
throw new CompilerException("Objective-C @Property method " + method + " in extension class must be static and native.");
}
transformObjCProperty(annotation, "@Property", sootClass, method, selectors, overridables, extensions);
return;
}
annotation = getAnnotation(method, IBOUTLET);
if (annotation != null) {
if (method.isStatic()) {
throw new CompilerException("Objective-C @IBOutlet method " + method + " must not be static.");
}
transformObjCProperty(annotation, "@IBOutlet", sootClass, method, selectors, overridables, extensions);
return;
}
annotation = getAnnotation(method, IBOUTLETCOLLECTION);
if (annotation != null) {
if (method.isStatic()) {
throw new CompilerException("Objective-C @IBOutletCollection method " + method + " must not be static.");
}
if (method.getReturnType() != VoidType.v() && !isNSArray(method.getReturnType()) || method.getReturnType() == VoidType.v() && method.getParameterCount() == 1 && !isNSArray(method.getParameterType(0))) {
throw new CompilerException("Objective-C @IBOutletCollection method " + method + " does not have a supported signature. " + "@IBOutletCollection getter methods must return NSArray. " + "@IBOutletCollection setter methods must have 1 parameter of type NSArray.");
}
transformObjCProperty(annotation, "@IBOutletCollection", sootClass, method, selectors, overridables, extensions);
return;
}
if (!method.isStatic() && !method.isNative() && !method.isAbstract() && !method.isPrivate() && isCustomClass(sootClass) && !hasAnnotation(method, NOT_IMPLEMENTED)) {
/*
* Create a @Callback for this method if it overrides a
* @Method/@Property method in a superclass/interface.
*/
List<SootMethod> superMethods = findOverriddenMethods(sootClass, method);
for (SootMethod superMethod : superMethods) {
if (createCustomClassCallbackIfNeeded(sootClass, method, superMethod)) {
break;
}
}
}
}
use of org.robovm.compiler.CompilerException in project robovm by robovm.
the class IOSTarget method doBuild.
@Override
protected void doBuild(File outFile, List<String> ccArgs, List<File> objectFiles, List<String> libArgs) throws IOException {
// (#195)
if (!config.getFrameworks().contains("UIKit")) {
libArgs.add("-framework");
libArgs.add("UIKit");
}
String minVersion = getMinimumOSVersion();
int majorVersionNumber = -1;
try {
majorVersionNumber = Integer.parseInt(minVersion.substring(0, minVersion.indexOf('.')));
} catch (NumberFormatException e) {
throw new CompilerException("Failed to get major version number from " + "MinimumOSVersion string '" + minVersion + "'");
}
if (isDeviceArch(arch)) {
ccArgs.add("-miphoneos-version-min=" + minVersion);
if (config.isDebug()) {
ccArgs.add("-Wl,-no_pie");
}
} else {
ccArgs.add("-mios-simulator-version-min=" + minVersion);
if (config.getArch() == Arch.x86 || config.isDebug()) {
ccArgs.add("-Wl,-no_pie");
}
}
if (majorVersionNumber >= 7) {
// On iOS 7 and higher the linker will default to link against
// libc++ which is needed for C++11 support. We need the older
// libstdc++ as our native libs are compiled against it and need to
// work on iOS 6. If an app needs C++11 support the user will need
// to link against /usr/lib/libc++.dylib explicitly.
ccArgs.add("-stdlib=libstdc++");
}
ccArgs.add("-isysroot");
ccArgs.add(sdk.getRoot().getAbsolutePath());
// specify dynamic library loading path
libArgs.add("-Xlinker");
libArgs.add("-rpath");
libArgs.add("-Xlinker");
libArgs.add("@executable_path/Frameworks");
libArgs.add("-Xlinker");
libArgs.add("-rpath");
libArgs.add("-Xlinker");
libArgs.add("@loader_path/Frameworks");
super.doBuild(outFile, ccArgs, objectFiles, libArgs);
}
Aggregations