use of com.google.j2objc.annotations.ObjectiveCName in project j2objc by google.
the class Types method appendGenericType.
@ObjectiveCName("appendGenericType:type:")
public static void appendGenericType(StringBuilder out, Type type) {
if (type instanceof TypeVariable) {
out.append(((TypeVariable) type).getName());
} else if (type instanceof ParameterizedType) {
out.append(type.toString());
} else if (type instanceof GenericArrayType) {
Type simplified = ((GenericArrayType) type).getGenericComponentType();
appendGenericType(out, simplified);
out.append("[]");
} else if (type instanceof Class) {
Class c = (Class<?>) type;
if (c.isArray()) {
String[] as = c.getName().split("\\[");
int len = as.length - 1;
if (as[len].length() > 1) {
out.append(as[len].substring(1, as[len].length() - 1));
} else {
char ch = as[len].charAt(0);
if (ch == 'I') {
out.append("int");
} else if (ch == 'B') {
out.append("byte");
} else if (ch == 'J') {
out.append("long");
} else if (ch == 'F') {
out.append("float");
} else if (ch == 'D') {
out.append("double");
} else if (ch == 'S') {
out.append("short");
} else if (ch == 'C') {
out.append("char");
} else if (ch == 'Z') {
out.append("boolean");
} else if (ch == 'V') {
out.append("void");
}
}
for (int i = 0; i < len; i++) {
out.append("[]");
}
} else {
out.append(c.getName());
}
}
}
use of com.google.j2objc.annotations.ObjectiveCName in project j2objc by google.
the class InputFilePreprocessor method extractPackagePrefix.
private void extractPackagePrefix(InputFile file, CompilationUnit unit) {
// We should only reach here if it's a package-info.java file.
assert file.getUnitName().endsWith("package-info.java");
List<Annotation> annotations = (List<Annotation>) unit.getPackage().getAnnotations();
for (Annotation annotation : annotations) {
// getFullyQualifiedName() might not actually return a fully qualified name.
String name = annotation.getTypeName().getFullyQualifiedName();
if (name.endsWith("ObjectiveCName")) {
// Per Eclipse docs, binding resolution can be a resource hog.
if (TypeUtil.getQualifiedName(annotation.getAnnotationMirror().getAnnotationType()).equals(ObjectiveCName.class.getCanonicalName())) {
String key = unit.getPackage().getName().getFullyQualifiedName();
String val = (String) ((SingleMemberAnnotation) annotation).getValue().getConstantValue();
options.getPackagePrefixes().addPrefix(key, val);
}
}
}
}
use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.
the class IntlEngine method areSameDays.
@ObjectiveCName("areSameDaysWithA:withB:")
public boolean areSameDays(long a, long b) {
Date date1 = new Date(a);
int y1 = date1.getYear();
int m1 = date1.getMonth();
int d1 = date1.getDate();
Date date2 = new Date(b);
int y2 = date2.getYear();
int m2 = date2.getMonth();
int d2 = date2.getDate();
return y1 == y2 && m1 == m2 && d1 == d2;
}
use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.
the class GroupPermissions method setShowJoinLeaveMessages.
@ObjectiveCName("setShowJoinLeaveMessages:")
public void setShowJoinLeaveMessages(boolean showJoinLeaveMessages) {
SparseArray<Object> unmapped = settings.getUnmappedObjects();
settings = new ApiAdminSettings(settings.showAdminsToMembers(), settings.canMembersInvite(), settings.canMembersEditGroupInfo(), settings.canAdminsEditGroupInfo(), showJoinLeaveMessages);
settings.setUnmappedObjects(unmapped);
}
use of com.google.j2objc.annotations.ObjectiveCName in project actor-platform by actorapp.
the class I18nEngine method formatErrorText.
@ObjectiveCName("formatErrorTextWithError:")
public String formatErrorText(Object o) {
if (o instanceof RpcException) {
RpcException e = (RpcException) o;
String res = Errors.mapError(e.getTag(), null);
if (res != null) {
return get(res);
} else {
if (e.getMessage().equals("")) {
return e.getTag();
} else {
return e.getMessage();
}
}
} else if (o instanceof Exception) {
return ((Exception) o).getMessage();
} else {
return "" + o;
}
}
Aggregations