コード例 #1
0
ファイル: Interface.java プロジェクト: aabykov/JacORB
  /** generate the operations Java interface (not for pseudo interfaces) */
  protected void printOperations() {
    PrintWriter ps = openOutput(name + "Operations");
    if (ps == null) {
      return;
    }

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

    ps.println("public interface " + name + "Operations");

    if (inheritanceSpec.v.size() > 0) {
      ps.print("\textends ");
      Enumeration e = inheritanceSpec.v.elements();

      do {
        ScopedName sne = (ScopedName) e.nextElement();

        // See description of abstractInterfaces for logic here.
        if (abstractInterfaces != null && abstractInterfaces.contains(sne.toString())) {
          ps.print(sne);
        } else {
          if (sne.resolvedTypeSpec() instanceof ReplyHandlerTypeSpec
              && parser.generate_ami_callback) {
            ps.print(sne + "Operations");
          } else {
            ConstrTypeSpec ts = unwindTypedefs(sne);
            ps.print(ts + "Operations");
          }
        }

        if (e.hasMoreElements()) {
          ps.print(" , ");
        }
      } while (e.hasMoreElements());

      ps.print(Environment.NL);
    }

    ps.println("{");

    if (body != null) {
      // forward declaration
      body.printConstants(ps);
      body.printOperationSignatures(ps);
    }

    ps.println("}");
    ps.close();
  }
コード例 #2
0
ファイル: Interface.java プロジェクト: aabykov/JacORB
  private ConstrTypeSpec unwindTypedefs(ScopedName scopedName) {
    TypeSpec resolvedTSpec = scopedName.resolvedTypeSpec();
    // unwind any typedefs
    while (resolvedTSpec instanceof AliasTypeSpec) {
      resolvedTSpec = ((AliasTypeSpec) resolvedTSpec).originalType();
    }

    if (!(resolvedTSpec instanceof ConstrTypeSpec)) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Illegal inheritance spec in Interface.unwindTypeDefs, not a constr. type but "
                + resolvedTSpec.getClass()
                + ", name "
                + scopedName);
      }
      parser.fatal_error(
          "Illegal inheritance spec in Interface.unwindTypeDefs (not a constr. type): "
              + inheritanceSpec,
          token);
    }

    return (ConstrTypeSpec) resolvedTSpec;
  }
コード例 #3
0
ファイル: Interface.java プロジェクト: aabykov/JacORB
  /** 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();
  }