Tabnine Logo
Function.getName
Code IndexAdd Tabnine to your IDE (free)

How to use
getName
method
in
com.ochafik.lang.jnaerator.parser.Function

Best Java code snippets using com.ochafik.lang.jnaerator.parser.Function.getName (Showing top 20 results out of 315)

origin: com.nativelibs4java/jnaerator

public static boolean isNamedFunctionType(TypeRef tr) {
  if (!(tr instanceof FunctionSignature)) {
    return false;
  }
  FunctionSignature fs = (FunctionSignature) tr;
  Function f = fs.getFunction();
  return f != null && f.getName() != null;
}
origin: nativelibs4java/JNAerator

public static boolean isNamedFunctionType(TypeRef tr) {
  if (!(tr instanceof FunctionSignature)) {
    return false;
  }
  FunctionSignature fs = (FunctionSignature) tr;
  Function f = fs.getFunction();
  return f != null && f.getName() != null;
}
origin: nativelibs4java/JNAerator

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();
}
origin: com.nativelibs4java/jnaerator

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();
}
origin: nativelibs4java/JNAerator

public static Identifier getName(Element element) {
  if (element instanceof Function)
    return ((Function) element).getName();
  if (element instanceof TaggedTypeRefDeclaration)
    return getName(((TaggedTypeRefDeclaration) element).getTaggedTypeRef());
  if (element instanceof TypeRef.TaggedTypeRef)
    return ((TypeRef.TaggedTypeRef) element).getTag();
  return null;
}

origin: nativelibs4java/JNAerator

@Override
public void visitFunction(final Function element) {
  currentTable.defineVariable(element.getName(), element);
  currentTable = new SymbolTable(currentTable, null, element);
  try {
    super.visitFunction(element);
  } finally {
    currentTable = currentTable.parent;
  }
}
origin: com.nativelibs4java/jnaerator

public final void convertFunctions(List<Function> functions, Signatures signatures, DeclarationsHolder declarations, DeclarationsHolder implementations) {
  if (functions != null) {
    //System.err.println("FUNCTIONS " + functions);
    for (Function function : functions) {
      if (skip(function.getName() + "", result.config.skippedFunctionNames))
        continue;
      convertFunction(function, signatures, false, declarations, implementations, declarations.getResolvedJavaIdentifier(), -1);
    }
  }
}
origin: nativelibs4java/JNAerator

public final void convertFunctions(List<Function> functions, Signatures signatures, DeclarationsHolder declarations, DeclarationsHolder implementations) {
  if (functions != null) {
    //System.err.println("FUNCTIONS " + functions);
    for (Function function : functions) {
      if (skip(function.getName() + "", result.config.skippedFunctionNames))
        continue;
      convertFunction(function, signatures, false, declarations, implementations, declarations.getResolvedJavaIdentifier(), -1);
    }
  }
}
origin: com.nativelibs4java/jnaerator

@Override
public void visitFunction(final Function element) {
  currentTable.defineVariable(element.getName(), element);
  currentTable = new SymbolTable(currentTable, null, element);
  try {
    super.visitFunction(element);
  } finally {
    currentTable = currentTable.parent;
  }
}
origin: com.nativelibs4java/jnaerator

  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;
  }
}
origin: nativelibs4java/JNAerator

  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;
  }
}
origin: nativelibs4java/JNAerator

@Override
public void sourcesParsed(SourceFiles sourceFiles) {
  List<SourceFile> files = sourceFiles.getSourceFiles();
  assertTrue(pref + "Parsing failed completely", !files.isEmpty());
  //assertTrue(pref + "Expected more than one source file", files.size() > 1);
  SourceFile lastFile = files.get(files.size() - 1);
  List<Declaration> declarations = lastFile.getDeclarations();
  assertTrue(pref + "Only parsed " + declarations.size() + " declarations", declarations.size() > 1);
  Declaration d = declarations.get(declarations.size() - 1);
  assertTrue(pref + "Not a function: " + d + " (" + (d == null ? "?" : d.getClass().getName()) + ")", d instanceof Function);
  Function f = (Function)d;
  assertEquals(pref + "Didn't find " + testFunctionName, testFunctionName, f.getName() + "");
}

origin: nativelibs4java/JNAerator

protected void valueTypeAndStorageSuffix(StoredDeclarations e) {
  if (e.getValueType() instanceof FunctionSignature) {
    FunctionSignature sig = (FunctionSignature) e.getValueType();
    if (sig.getFunction() != null) {
      Identifier name = sig.getFunction().getName();
      if (name != null && e.declarators.size() == 1) {
        String stoName = e.declarators.get(0).resolveName();
        if (name.equals(stoName) || stoName == null) {
          append(sig);
          return;
        }
      }
    }
  }
  append(e.getValueType()).space(!e.getDeclarators().isEmpty()).implode(e.getDeclarators(), ", ");
}
origin: nativelibs4java/JNAerator

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));
  }
}
origin: com.nativelibs4java/jnaerator

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));
  }
}
origin: nativelibs4java/JNAerator

@Override
public boolean replaceChild(Element child, Element by) {
  if (child == getBody()) {
    setBody((Statement.Block)by);
    return true;
  }
  if (child == getName()) {
    setName((Identifier)by);
    return true;
  }
  if (replaceChild(args, Arg.class, this, child, by))
    return true;
  if (replaceChild(thrown, TypeRef.class, this, child, by))
    return true;
  if (replaceChild(initializers, FunctionCall.class, this, child, by))
    return true;
  
  return super.replaceChild(child, by);
}

origin: nativelibs4java/JNAerator

public void visitFunction(Function function) {
  visitDeclaration(function);
  visit(function.getArgs());
  visit(function.getThrown());
  visit(function.getInitializers());
  
  visit(function.getBody());
  visit(function.getName());
}
origin: nativelibs4java/JNAerator

protected void variableDeclarationToString(TypeRef e, String varName, boolean isVarArg) {
  if (e instanceof FunctionSignature) {
    FunctionSignature fs = (FunctionSignature) e;
    if (!isVarArg && fs.getFunction() != null && fs.getFunction().getName() != null) {
      append(indent);
      return;
    }
  } else if (e instanceof ArrayRef) {
    ArrayRef ar = (ArrayRef) e;
    append(ar.getTarget(), isVarArg ? "... " : " ", varName);
    bracketsToString(ar);
    return;
  }
  append(e).append(isVarArg ? "... " : " ").append(varName);
}
origin: com.nativelibs4java/jnaerator

  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);
origin: nativelibs4java/JNAerator

  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);
com.ochafik.lang.jnaerator.parserFunctiongetName

Popular methods of Function

  • <init>
  • addArg
  • addModifiers
  • getModifiers
  • getValueType
  • setBody
  • getArgs
  • getAsmName
  • getBody
  • getType
  • importDetails
  • setArgs
  • importDetails,
  • setArgs,
  • setCommentBefore,
  • setName,
  • setType,
  • setValueType,
  • accept,
  • addAnnotation,
  • addThrown

Popular in Java

  • Reactive rest calls using spring rest template
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • setRequestProperty (URLConnection)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now