示例#1
0
文件: C.java 项目: csdms/cca-babel
 private static boolean hasEnum(Method m) {
   boolean result = (Type.ENUM == m.getReturnType().getDetailedType());
   Iterator i = m.getArgumentList().iterator();
   while (!result && i.hasNext()) {
     Argument arg = (Argument) i.next();
     result = (arg.getType().getDetailedType() == Type.ENUM);
   }
   return result;
 }
示例#2
0
文件: C.java 项目: csdms/cca-babel
  /**
   * Generate the method's argument list.
   *
   * @param writer the language writer.
   * @param self the String representing the method's self argument name.
   * @param is_interface the boolean indicating whether working with a class or an interface.
   * @param id the <code>SymbolID</code> of the <code>Extendable</code> whose stub source is being
   *     written.
   * @param method the <code>Method</code> whose list is being output.
   * @param in_signature the boolean indicating whether the argument list is being generated in a
   *     signature.
   * @param add_type the boolean indicating whether the argument types are to be added.
   * @param exc_var the variable to be used for the exception argument; NULL if no exception
   *     argument to be generated.
   * @param do_return the boolean indicating whether the return type is to be added.
   * @param do_rarrays the boolean indicating if special raw array argument handling is needed.
   * @exception gov.llnl.babel.backend.CodeGenerationException this is a catch all exception. It can
   *     be caused by I/O trouble or violations of the data type invariants.
   */
  public static void generateArgumentList(
      LanguageWriterForC writer,
      Context context,
      String self,
      boolean is_interface,
      SymbolID id,
      Method method,
      boolean in_signature,
      boolean add_type,
      boolean obj_ptr,
      String exc_var,
      boolean do_return,
      boolean do_indices,
      boolean do_rarrays)
      throws CodeGenerationException {
    boolean doThrows = !exc_var.equals("") && !method.getThrows().isEmpty();
    String excVar = doThrows ? exc_var : "";
    Type returnType = do_return ? method.getReturnType() : null;

    List args = null;
    if (do_indices) {
      args = method.getArgumentListWithIndices();
    } else {
      args = method.getArgumentListWithOutIndices();
    }

    String m_self;
    if (in_signature) {
      if (add_type) {
        if (obj_ptr) {
          m_self = getSymbolObjectPtr(id) + " " + self;
        } else {
          m_self = getObjectName(id) + " " + self;
        }
      } else {
        m_self = self;
      }
    } else if (is_interface) {
      m_self = self + "->d_object";
    } else {
      m_self = s_self;
    }
    generateArguments(
        writer,
        context,
        m_self,
        args,
        method.isStatic(),
        excVar,
        returnType,
        add_type,
        obj_ptr,
        do_rarrays,
        false);
  }
示例#3
0
文件: C.java 项目: csdms/cca-babel
  /** Creates a Method that represents the static Exec method */
  public static Method getSExecMethod(Context context) throws CodeGenerationException {
    Method m_exec = new Method(context);
    String[] cmmnt = {"static Exec method for reflexity."};
    m_exec.setMethodName("_sexec");
    m_exec.setComment(new Comment(cmmnt));
    m_exec.setDefinitionModifier(Method.STATIC);
    m_exec.setReturnType(new Type(Type.VOID));
    Argument a = new Argument(Argument.IN, new Type(Type.STRING), "methodName");
    m_exec.addArgument(a);

    Symbol tmpSym = Utilities.lookupSymbol(context, "sidl.rmi.Call");
    a = new Argument(Argument.IN, new Type(tmpSym, context), "inArgs");
    m_exec.addArgument(a);
    tmpSym = Utilities.lookupSymbol(context, "sidl.rmi.Return");
    a = new Argument(Argument.IN, new Type(tmpSym, context), "outArgs");
    m_exec.addArgument(a);
    return m_exec;
  }
示例#4
0
文件: C.java 项目: csdms/cca-babel
 /**
  * Generate the full method name associated with the symbol id and the specified method. The
  * returned name prepends the symbol name and only one underbar to the method's name.
  *
  * @param id the <code>SymbolID</code> of the <code>Symbol</code> associated with the method.
  * @param method the <code>Method</code> whose full name is being built.
  */
 public static String getFullMethodName(SymbolID id, Method method) {
   return getSymbolName(id) + "_" + method.getLongMethodName();
 }
示例#5
0
文件: C.java 项目: csdms/cca-babel
 /**
  * Generate the skel method's name. In most cases, the skel name is the impl name except when the
  * method has an array with an ordering specification.
  *
  * @param id the <code>SymbolID</code> of the <code>Symbol</code> associated with the method.
  * @param method the method
  */
 public static String getMethodSkelName(SymbolID id, Method method) {
   return methodNeedsSkel(method)
       ? ("skel_" + getSymbolName(id) + '_' + method.getLongMethodName())
       : getMethodImplName(id, method.getLongMethodName());
 }
示例#6
0
文件: C.java 项目: csdms/cca-babel
 public static boolean methodNeedsSkel(Method method) {
   return method.hasArrayOrderSpec() || method.hasRarray() || hasEnum(method);
 }