@Override public Boolean adapt(Function value) { List<Modifier> mods = value.getModifiers(); if (ModifierType.__kernel.isContainedBy(mods)) return true; if (value.getValueType() == null) return null; mods = value.getValueType().getModifiers(); return ModifierType.__kernel.isContainedBy(mods); } };
@Override public void addDeclaration(Declaration d) { implementations.addDeclaration(d); if (d instanceof Function) { Function f = (Function) d; List<Arg> args = f.getArgs(); List<TypeRef> trs = new ArrayList<TypeRef>(2); trs.add(f.getValueType()); if (!args.isEmpty()) { trs.add(args.get(0).getValueType()); } for (TypeRef tr : trs) { if (tr instanceof SimpleTypeRef) { Identifier id = ((SimpleTypeRef) tr).getName(); if (result.isFakePointer(id)) { result.addFunctionReifiableInFakePointer(id, declarations.getResolvedJavaIdentifier(), f); } } } } }
@Override public void addDeclaration(Declaration d) { implementations.addDeclaration(d); if (d instanceof Function) { Function f = (Function) d; List<Arg> args = f.getArgs(); List<TypeRef> trs = new ArrayList<TypeRef>(2); trs.add(f.getValueType()); if (!args.isEmpty()) { trs.add(args.get(0).getValueType()); } for (TypeRef tr : trs) { if (tr instanceof SimpleTypeRef) { Identifier id = ((SimpleTypeRef) tr).getName(); if (result.isFakePointer(id)) { result.addFunctionReifiableInFakePointer(id, declarations.getResolvedJavaIdentifier(), f); } } } } }
argNames = new ArrayList<String>(), argDefs = new ArrayList<String>(); String rt = getScalaType(f.getValueType()); for (Arg a : args) { String vt = getScalaType(a.getValueType());
b.append(modifiers.contains(ModifierType.Static) ? "+" : "-"); b.append("("); TypeRef t = getValueType(); if (t == null) b.append("id"); if (signatureType.hasReturnType && getValueType() != null) { TypeRef t = getValueType().clone(); erase(t); t.stripDetails();
argNames = new ArrayList<String>(), argDefs = new ArrayList<String>(); String rt = getScalaType(f.getValueType()); for (Arg a : args) { String vt = getScalaType(a.getValueType());
if (mods != null) { if (function.getValueType() == null) { function.setValueType(longShortModsToTypeRef(mods)); } else { attachLongOrShortModifiersToPointedType(function.getValueType(), mods); if (function.getValueType() != null) { moveModifiersOfType(ModifierKind.CallingConvention, function.getValueType(), function); } else { Element parent = function.getParentElement();
if (mods != null) { if (function.getValueType() == null) { function.setValueType(longShortModsToTypeRef(mods)); } else { attachLongOrShortModifiersToPointedType(function.getValueType(), mods); if (function.getValueType() != null) { moveModifiersOfType(ModifierKind.CallingConvention, function.getValueType(), function); } else { Element parent = function.getParentElement();
public static TypeRef fixReturnType(Function function) { TypeRef returnType = function.getValueType(); if (returnType == null) { returnType = RococoaUtils.ROCOCOA_ID_TYPEREF; } Struct declaringClass = function.findParentOfType(Struct.class); if (returnType.toString().equals("id")) { String pointedClassName; if (function.getName().toString().matches("^(alloc|(init|copy|mutableCopy)([A-Z].*)?)$") || RococoaUtils.methodNameMatchesObjcStaticConstructor(declaringClass, function.getName())) { pointedClassName = declaringClass.getTag().toString(); } else /// Lets subclasses redefine method return type when parent method return type is ID { pointedClassName = "NSObject"; } returnType = new TypeRef.Pointer(new TypeRef.SimpleTypeRef(pointedClassName), PointerStyle.Pointer); } return returnType; } }
public static TypeRef fixReturnType(Function function) { TypeRef returnType = function.getValueType(); if (returnType == null) { returnType = RococoaUtils.ROCOCOA_ID_TYPEREF; } Struct declaringClass = function.findParentOfType(Struct.class); if (returnType.toString().equals("id")) { String pointedClassName; if (function.getName().toString().matches("^(alloc|(init|copy|mutableCopy)([A-Z].*)?)$") || RococoaUtils.methodNameMatchesObjcStaticConstructor(declaringClass, function.getName())) { pointedClassName = declaringClass.getTag().toString(); } else /// Lets subclasses redefine method return type when parent method return type is ID { pointedClassName = "NSObject"; } returnType = new TypeRef.Pointer(new TypeRef.SimpleTypeRef(pointedClassName), PointerStyle.Pointer); } return returnType; } }
private Function createProxyCopy(Function originalMethod, Function meth) { if (isMethodExcludedFromStaticForwarding(originalMethod)) { return null; } Function proxyCopy = meth.clone(); proxyCopy.addModifiers(ModifierType.Public, ModifierType.Static); proxyCopy.reorganizeModifiers(); Expression[] args = new Expression[meth.getArgs().size()]; int i = 0; for (Arg arg : meth.getArgs()) { args[i++] = varRef(arg.getName()); } Expression val = methodCall(methodCall(null, null, classInstanceGetterName), Expression.MemberRefStyle.Dot, meth.getName().toString(), args); proxyCopy.setBody(new Block( meth.getValueType() == null || "void".equals(meth.getValueType().toString()) ? stat(val) : new Statement.Return(val))); return proxyCopy; } // protected static _class_ _CLASS_ = org.rococoa.Rococoa.createClass("NSURL", _class_.class);
private Function createProxyCopy(Function originalMethod, Function meth) { if (isMethodExcludedFromStaticForwarding(originalMethod)) { return null; } Function proxyCopy = meth.clone(); proxyCopy.addModifiers(ModifierType.Public, ModifierType.Static); proxyCopy.reorganizeModifiers(); Expression[] args = new Expression[meth.getArgs().size()]; int i = 0; for (Arg arg : meth.getArgs()) { args[i++] = varRef(arg.getName()); } Expression val = methodCall(methodCall(null, null, classInstanceGetterName), Expression.MemberRefStyle.Dot, meth.getName().toString(), args); proxyCopy.setBody(new Block( meth.getValueType() == null || "void".equals(meth.getValueType().toString()) ? stat(val) : new Statement.Return(val))); return proxyCopy; } // protected static _class_ _CLASS_ = org.rococoa.Rococoa.createClass("NSURL", _class_.class);
public MutableByDeclarator mutateType(MutableByDeclarator type) { if (type == null) return null; type = type.clone(); if (type instanceof TypeRef) type = new TypeRef.ArrayRef((TypeRef)type, deepClone(getDimensions())); else if (type instanceof Function) { Function f = (Function)type; f.setValueType(new TypeRef.ArrayRef(f.getValueType(), deepClone(getDimensions()))); type = f; } ((Element)type).importDetails(this, false); return target.mutateType(type); }
methodType = parseAndReconciliateMethods(type, type64); if (tr == null) { tr = methodType.getValueType();
methodType = parseAndReconciliateMethods(type, type64); if (tr == null) { tr = methodType.getValueType();
boolean returnsFakePointer = isFakePointerRef(result, fDirect.getValueType()); boolean needsDirect = !fakePointersLocations.isEmpty() || returnsFakePointer; if (needsDirect) { if (returnsFakePointer) { finalCall = new Expression.New(fDirect.getValueType(), varRef(indirectRetVarName)); toDirectFakePointer(result, fDirect); boolean retVoid = "void".equals(String.valueOf(f.getValueType())); if (retVoid) { f.setBody(block(stat(x)));
boolean returnsFakePointer = isFakePointerRef(result, fDirect.getValueType()); boolean needsDirect = !fakePointersLocations.isEmpty() || returnsFakePointer; if (needsDirect) { if (returnsFakePointer) { finalCall = new Expression.New(fDirect.getValueType(), varRef(indirectRetVarName)); toDirectFakePointer(result, fDirect); boolean retVoid = "void".equals(String.valueOf(f.getValueType())); if (retVoid) { f.setBody(block(stat(x)));
public void visitFunctionSignature(FunctionSignature e) { if (e.getFunction() == null) { return; } assert e.getFunction().getBody() == null; modifiersStringPrefix(e); append(e.getFunction().getValueType()).space(e.getFunction().getValueType() != null); if (e.getParentElement() instanceof TypeRef.Pointer) { append("("); modifiersStringPrefix(e.getFunction()); switch (e.getType()) { case CFunction: append("*"); break; case ObjCBlock: append("^"); break; } append(e.getFunction().getName()); append(")"); } else { append(e.getFunction().getName()); } append("("); implode(e.getFunction().getArgs(), ", "); append(")"); append(e.getModifiers().isEmpty() ? "" : " "); implode(e.getModifiers(), " "); }
public void visitFunction(Function e) { TypeRef valueType = e.getValueType(); Identifier name = e.getName(); List<Modifier> modifiers = e.getModifiers();
TypeRef javaType = convDecl.getValueType(); String pointerGetSetMethodSuffix = StringUtils.capitalize(javaType.toString());