public static String getMethodName(Function function) { StringBuilder nb = new StringBuilder(); nb.append(function.getName()); boolean firstArg = true; for (Arg arg : function.getArgs()) { if (arg.isVarArg()) { continue; } if (firstArg) { firstArg = false; } else { nb.append("_"); nb.append(arg.getSelector()); } } return nb.toString(); }
public static String getMethodName(Function function) { StringBuilder nb = new StringBuilder(); nb.append(function.getName()); boolean firstArg = true; for (Arg arg : function.getArgs()) { if (arg.isVarArg()) { continue; } if (firstArg) { firstArg = false; } else { nb.append("_"); nb.append(arg.getSelector()); } } return nb.toString(); }
@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); } } } } }
List<Arg> args = f.getArgs(); List<String> argTypes = new ArrayList<String>(), argNames = new ArrayList<String>(),
List<Arg> args = f.getArgs(); List<String> argTypes = new ArrayList<String>(), argNames = new ArrayList<String>(),
int i = 0;//, n = function.getArgs().size(); for (Arg arg : function.getArgs()) { String name = arg.getName(); if (name == null && !isNamedFunctionType(arg.getValueType())) {
int i = 0;//, n = function.getArgs().size(); for (Arg arg : function.getArgs()) { String name = arg.getName(); if (name == null && !isNamedFunctionType(arg.getValueType())) {
private void addAllocIfMissing(Struct in, String allocName) { Identifier n = in.getTag(); if (n.equals("NSObject") || n.equals("NSClass")) { return; } boolean hasAlloc = false; for (Declaration d : in.getDeclarations()) { if (d instanceof Function) { Function f = (Function) d; if (f.getArgs().isEmpty() && allocName.equals(f.getName())) { hasAlloc = true; break; } } } if (!hasAlloc) { in.addDeclaration(new Function(Function.Type.ObjCMethod, ident(allocName), typeRef(in.getTag())).addModifiers(ModifierType.Static)); } }
private void addAllocIfMissing(Struct in, String allocName) { Identifier n = in.getTag(); if (n.equals("NSObject") || n.equals("NSClass")) { return; } boolean hasAlloc = false; for (Declaration d : in.getDeclarations()) { if (d instanceof Function) { Function f = (Function) d; if (f.getArgs().isEmpty() && allocName.equals(f.getName())) { hasAlloc = true; break; } } } if (!hasAlloc) { in.addDeclaration(new Function(Function.Type.ObjCMethod, ident(allocName), typeRef(in.getTag())).addModifiers(ModifierType.Static)); } }
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 void visitFunction(Function function) { visitDeclaration(function); visit(function.getArgs()); visit(function.getThrown()); visit(function.getInitializers()); visit(function.getBody()); visit(function.getName()); }
protected void collectParamComments(Function f) { for (Arg arg : f.getArgs()) { arg.moveAllCommentsBefore(); TypeRef argType = arg.getValueType(); if (argType != null) { if (!result.config.noComments) { argType.moveAllCommentsBefore(); arg.addToCommentBefore(argType.getCommentBefore()); } argType.stripDetails(); } if (arg.getCommentBefore() != null) { if (!result.config.noComments) { f.addToCommentBefore("@param " + arg.getName() + " " + Element.cleanComment(arg.getCommentBefore())); } arg.stripDetails(); } } }
protected void collectParamComments(Function f) { for (Arg arg : f.getArgs()) { arg.moveAllCommentsBefore(); TypeRef argType = arg.getValueType(); if (argType != null) { if (!result.config.noComments) { argType.moveAllCommentsBefore(); arg.addToCommentBefore(argType.getCommentBefore()); } argType.stripDetails(); } if (arg.getCommentBefore() != null) { if (!result.config.noComments) { f.addToCommentBefore("@param " + arg.getName() + " " + Element.cleanComment(arg.getCommentBefore())); } arg.stripDetails(); } } }
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(), " "); }