public void notSup(Element x, String msg) throws UnsupportedConversionException { throw new UnsupportedConversionException(x, msg); }
public void notSup(Element x, String msg) throws UnsupportedConversionException { throw new UnsupportedConversionException(x, msg); }
static TypeRef primRef(Element element, JavaPrim p) { if (p == null) { return null; } if (p.type == null) { throw new UnsupportedConversionException(element, "Primitive without known type for this runtime: " + p); } return new JavaPrimitive(p); // return new SimpleTypeRef(toString(p)); }
static TypeRef primRef(Element element, JavaPrim p) { if (p == null) { return null; } if (p.type == null) { throw new UnsupportedConversionException(element, "Primitive without known type for this runtime: " + p); } return new JavaPrimitive(p); // return new SimpleTypeRef(toString(p)); }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public int countFieldsInStruct(Struct s) throws UnsupportedConversionException { int count = 0; for (Declaration declaration : s.getDeclarations()) { if (declaration instanceof VariablesDeclaration) { count += ((VariablesDeclaration) declaration).getDeclarators().size(); } } for (SimpleTypeRef parentName : s.getParents()) { Struct parent = result.structsByName.get(parentName.getName()); if (parent == null) { throw new UnsupportedConversionException(s, "Cannot find parent " + parentName + " of struct " + s); } count += countFieldsInStruct(parent); } return count; }
public TypeRef findCallbackRef(FunctionSignature s, Identifier callerLibraryClass) { String library = s == null ? null : result.getLibrary(s); if (library == null) { return null; } // Struct parentStruct = s.findParentOfType(Struct.class); // if (parentStruct != null && (parentStruct.getType() == Struct.Type.ObjCClass || parentStruct.getType() == Struct.Type.ObjCProtocol)) { // Identifier structName = result.declarationsConverter.getActualTaggedTypeName(parentStruct); // return // typeRef(ident(structName, inferCallBackName(s, true, true))); // } Identifier identifier = s.getResolvedJavaIdentifier(); if (identifier == null) { throw new UnsupportedConversionException(s, null); } return typeRef(identifier); // return typeRef(libMember(result.getLibraryClassFullName(library), callerLibraryClass, inferCallBackName(s, true, true))); //typeRef(ident(result.getLibraryClassFullName(library), inferCallBackName(s, true))); }
public TypeRef findCallbackRef(FunctionSignature s, Identifier callerLibraryClass) { String library = s == null ? null : result.getLibrary(s); if (library == null) { return null; } // Struct parentStruct = s.findParentOfType(Struct.class); // if (parentStruct != null && (parentStruct.getType() == Struct.Type.ObjCClass || parentStruct.getType() == Struct.Type.ObjCProtocol)) { // Identifier structName = result.declarationsConverter.getActualTaggedTypeName(parentStruct); // return // typeRef(ident(structName, inferCallBackName(s, true, true))); // } Identifier identifier = s.getResolvedJavaIdentifier(); if (identifier == null) { throw new UnsupportedConversionException(s, null); } return typeRef(identifier); // return typeRef(libMember(result.getLibraryClassFullName(library), callerLibraryClass, inferCallBackName(s, true, true))); //typeRef(ident(result.getLibraryClassFullName(library), inferCallBackName(s, true))); }
Expression.Constant.Type getValueConstantType(Expression value) { if (value instanceof Expression.Cast) { return getValueConstantType(((Expression.Cast) value).getTarget()); } if (value instanceof Expression.BinaryOp) { return getValueConstantType(((Expression.BinaryOp) value).getFirstOperand()); } if (value instanceof Expression.Constant) { return ((Expression.Constant) value).getType(); } throw new UnsupportedConversionException(value, "Unknown value type"); }
Expression.Constant.Type getValueConstantType(Expression value) { if (value instanceof Expression.Cast) { return getValueConstantType(((Expression.Cast) value).getTarget()); } if (value instanceof Expression.BinaryOp) { return getValueConstantType(((Expression.BinaryOp) value).getFirstOperand()); } if (value instanceof Expression.Constant) { return ((Expression.Constant) value).getType(); } throw new UnsupportedConversionException(value, "Unknown value type"); }
public String chooseArgNameFromType(TypeRef tr) throws UnsupportedConversionException { if (tr instanceof TypeRef.SimpleTypeRef) { Identifier name = ((TypeRef.SimpleTypeRef) tr).getName(); String out; if (isNull(name)) { out = StringUtils.implode(tr.getModifiers(), ""); out = out.length() > 0 ? out.substring(0, 1) : out; } else { out = name.toString(); } return out; } else if (tr instanceof TypeRef.Pointer) { return chooseArgNameFromType(((TypeRef.Pointer) tr).getTarget()) + "Ptr"; } else if (tr instanceof TypeRef.ArrayRef) { return chooseArgNameFromType(((TypeRef.ArrayRef) tr).getTarget()) + "Arr"; } throw new UnsupportedConversionException(tr, String.valueOf(tr)); }
public String chooseArgNameFromType(TypeRef tr) throws UnsupportedConversionException { if (tr instanceof TypeRef.SimpleTypeRef) { Identifier name = ((TypeRef.SimpleTypeRef) tr).getName(); String out; if (isNull(name)) { out = StringUtils.implode(tr.getModifiers(), ""); out = out.length() > 0 ? out.substring(0, 1) : out; } else { out = name.toString(); } return out; } else if (tr instanceof TypeRef.Pointer) { return chooseArgNameFromType(((TypeRef.Pointer) tr).getTarget()) + "Ptr"; } else if (tr instanceof TypeRef.ArrayRef) { return chooseArgNameFromType(((TypeRef.ArrayRef) tr).getTarget()) + "Arr"; } throw new UnsupportedConversionException(tr, String.valueOf(tr)); }
throw new UnsupportedConversionException(mutatedType, "failed to convert type to Java"); } else if (javaType.toString().equals("void")) { throw new UnsupportedConversionException(mutatedType, "void type !");
public <M extends ModifiableElement> M annotateRawType(M element) throws UnsupportedConversionException { element.addAnnotations(annotations); if (type != null) { switch (type) { case Enum: case Primitive: case Void: break; case NativeLong: element.addAnnotation(new Annotation(typeRef(CLong.class))); break; case NativeSize: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Pointer: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Struct: case ComplexDouble: case FunctionSignature: case Default: case NativeTime: //throw new UnsupportedConversionException(typeRef, "Struct by value not supported yet"); break; default: throw new UnsupportedConversionException(typeRef, "Not supported"); } } return element; }
public <M extends ModifiableElement> M annotateRawType(M element) throws UnsupportedConversionException { element.addAnnotations(annotations); if (type != null) { switch (type) { case Enum: case Primitive: case Void: break; case NativeLong: element.addAnnotation(new Annotation(typeRef(CLong.class))); break; case NativeSize: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Pointer: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Struct: case ComplexDouble: case FunctionSignature: case Default: case NativeTime: //throw new UnsupportedConversionException(typeRef, "Struct by value not supported yet"); break; default: throw new UnsupportedConversionException(typeRef, "Not supported"); } } return element; }
try { if (result.typeConverter.isJavaKeyword(name)) { throw new UnsupportedConversionException(element, "The name '" + name + "' is invalid for a Java field.");
break; default: throw new UnsupportedConversionException(value, "Constant type not supported yet");
break; default: throw new UnsupportedConversionException(value, "Constant type not supported yet");