Ejemplo n.º 1
0
 public static String namedValue(ScopedName sn) {
   String resolvedName = sn.resolvedName();
   if (values.containsKey(resolvedName)) {
     return (String) values.get(resolvedName);
   }
   return resolvedName;
 }
Ejemplo n.º 2
0
  public void parse() {
    const_expr.setDeclaration(this);
    try {
      NameTable.define(full_name(), IDLTypes.CONSTANT);
    } catch (NameAlreadyDefined p) {
      parser.error("Constant " + full_name() + " already defined", token);
    }
    const_type.parse();
    const_expr.parse();
    t.typeName = name;
    values.put(t.resolvedName() + (contained() ? "" : ".value"), const_expr.toString());

    if (logger.isDebugEnabled()) {
      logger.debug(
          "ConstDecl.parse, put value: "
              + t.resolvedName()
              + (contained() ? "" : ".value")
              + " , "
              + const_expr);
    }

    declarations.put(t.resolvedName(), this);
  }
Ejemplo n.º 3
0
  /**
   * If this interface inherits from classes in the unnamed package, generate explicit import
   * statements for them.
   */
  protected void printSuperclassImports(PrintWriter ps) {
    if (inheritanceSpec.v.isEmpty()) {
      return;
    }

    if ("".equals(pack_name)) {
      return;
    }

    for (final Iterator i = inheritanceSpec.v.iterator(); i.hasNext(); ) {
      final ScopedName sn = (ScopedName) i.next();

      if (sn.resolvedName().indexOf('.') < 0) {
        ps.print("import ");
        ps.print(sn.toString());
        ps.println(';');
      }
    }
  }
Ejemplo n.º 4
0
  /** generate the signature interface */
  protected void printInterface() {
    PrintWriter ps = openOutput(name);
    if (ps == null) {
      return;
    }

    printPackage(ps);
    printSuperclassImports(ps);
    printClassComment("interface", name, ps);

    if (is_pseudo) {
      ps.println("public abstract class " + name);

      if (inheritanceSpec.v.size() > 0) {
        StringBuffer pseudo_bases = new StringBuffer();
        StringBuffer regular_bases = new StringBuffer();
        String comma = " ";

        for (Enumeration e = inheritanceSpec.v.elements(); e.hasMoreElements(); ) {
          ScopedName sn = ((ScopedName) e.nextElement());
          String name = sn.resolvedName();

          if (sn.is_pseudo()) {
            pseudo_bases.append(comma + name);
          } else {
            regular_bases.append(comma + name);
          }

          if (inheritanceSpec.v.size() > 1) comma = ",";
        }

        if (pseudo_bases.length() > 0) ps.println("\textends " + pseudo_bases.toString());

        if (regular_bases.length() > 0) ps.println("\timplements " + regular_bases.toString());
      }
    } else {
      ps.println("public interface " + name);

      if (is_abstract) {
        ps.print("\textends org.omg.CORBA.portable.IDLEntity");
      } else {
        ps.print("\textends " + name + "Operations");

        if (is_local) {
          // Looking at RTF work it
          // seems a new interface 'LocalInterface' will be used for this purpose.

          ps.print(", org.omg.CORBA.LocalInterface, org.omg.CORBA.portable.IDLEntity");
        } else {
          ps.print(", org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity");
        }
      }

      if (inheritanceSpec.v.size() > 0) {
        Enumeration e = inheritanceSpec.v.elements();

        while (e.hasMoreElements()) {
          ScopedName sne = (ScopedName) e.nextElement();
          if (sne.resolvedTypeSpec() instanceof ReplyHandlerTypeSpec
              && parser.generate_ami_callback) {
            ps.print(", " + sne);
          } else {
            ConstrTypeSpec ts = unwindTypedefs(sne);
            ps.print(", " + ts);
          }
        }
      }
    }

    ps.println(Environment.NL + "{");

    if (is_pseudo) {
      printSerialVersionUID(ps);
    }

    // body can be null for forward declaration
    if (body != null) {
      body.printInterfaceMethods(ps);

      // for an abstract interface, the generated abstract class contains
      // the operation signatures since there is no separate signature
      // interface
      if (is_abstract) {
        body.printConstants(ps);
        body.printOperationSignatures(ps);
      }
    }

    ps.println("}");
    ps.close();
  }