Package com.sun.tools.corba.se.idl

Examples of com.sun.tools.corba.se.idl.UnionEntry


  public int helperType (int index, String indent, TCOffsets tcoffsets,
    String name, SymtabEntry entry, PrintWriter stream)
  {
    TCOffsets innerOffsets = new TCOffsets ();
    UnionEntry u = (UnionEntry)entry;
    String discTypeCode = "_disTypeCode" + index;
    String membersName = "_members" + index;

    // Build discriminator tc
    stream.println (indent + "org.omg.CORBA.TypeCode " + discTypeCode + ';');
    index = ((JavaGenerator)u.type ().generator ()).type (index + 1, indent,
        innerOffsets, discTypeCode, u.type (), stream);
    tcoffsets.bumpCurrentOffset (innerOffsets.currentOffset ());

    stream.println (indent + "org.omg.CORBA.UnionMember[] " + membersName +
        " = new org.omg.CORBA.UnionMember [" + unionLabelSize(u) + "];");
    String tcOfMembers = "_tcOf" + membersName;
    String anyOfMembers = "_anyOf" + membersName;
    stream.println (indent + "org.omg.CORBA.TypeCode " + tcOfMembers + ';');
    stream.println (indent + "org.omg.CORBA.Any " + anyOfMembers + ';');

    innerOffsets = new TCOffsets ();
    innerOffsets.set (entry);
    int offsetForUnion = innerOffsets.currentOffset ();
    for (int i = 0; i < u.branches ().size (); ++i) {
        UnionBranch branch = (UnionBranch)u.branches ().elementAt (i);
        TypedefEntry member = branch.typedef;
        Vector labels = branch.labels;
        String memberName = Util.stripLeadingUnderscores (member.name ());

        if (labels.size() == 0) {
            stream.println ();
            stream.println (indent + "// Branch for " + memberName +
                " (Default case)" );
            SymtabEntry utype = Util.typeOf (u.type ());
            stream.println (indent + anyOfMembers + " = org.omg.CORBA.ORB.init ().create_any ();");
            // For default member, label is the zero octet (per CORBA spec.)
            stream.println (indent + anyOfMembers + ".insert_octet ((byte)0); // default member label");

            // Build typecode
            innerOffsets.bumpCurrentOffset (4); // label value
            index = ((JavaGenerator)member.generator ()).type (index, indent, innerOffsets, tcOfMembers, member, stream);
            int offsetSoFar = innerOffsets.currentOffset ();
            innerOffsets = new TCOffsets ();
            innerOffsets.set (entry);
            innerOffsets.bumpCurrentOffset (offsetSoFar - offsetForUnion);

            // Build union member
            stream.println (indent + membersName + '[' + i + "] = new org.omg.CORBA.UnionMember (");
            stream.println (indent + "  \"" + memberName + "\",");
            stream.println (indent + "  " + anyOfMembers + ',');
            stream.println (indent + "  " + tcOfMembers + ',');
            stream.println (indent + "  null);");
        } else {
            Enumeration enumeration = labels.elements() ;
            while (enumeration.hasMoreElements()) {
                Expression expr = (Expression)(enumeration.nextElement()) ;
                String elem = Util.parseExpression( expr ) ;

                stream.println ();
                stream.println (indent + "// Branch for " + memberName +
                    " (case label " + elem + ")" );

                SymtabEntry utype = Util.typeOf (u.type ());

                // Build any
                stream.println (indent + anyOfMembers + " = org.omg.CORBA.ORB.init ().create_any ();");

                if (utype instanceof PrimitiveEntry)
View Full Code Here


    }

    public int read (int index, String indent, String name,
        SymtabEntry entry, PrintWriter stream)
    {
        UnionEntry u = (UnionEntry)entry;
        String disName = "_dis" + index++;
        SymtabEntry utype = Util.typeOf (u.type ());
        Util.writeInitializer (indent, disName, "", utype, stream);

        if (utype instanceof PrimitiveEntry)
            index = ((JavaGenerator)utype.generator ()).read (index, indent, disName, utype, stream);
        else
View Full Code Here

  /**
   *
   **/
  public int write (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
  {
    UnionEntry u = (UnionEntry)entry;
    SymtabEntry utype = Util.typeOf (u.type ());
    if (utype instanceof PrimitiveEntry)
      index = ((JavaGenerator)utype.generator ()).write (index, indent, name + ".discriminator ()", utype, stream);
    else
      stream.println (indent + Util.helperName (utype, true) + ".write (ostream, " + name + ".discriminator ());"); // <d61056>
    if (utype.name ().equals ("boolean"))
View Full Code Here

      while (e.hasMoreElements ())
        addTo (importList, (String)e.nextElement ());
    }
    else if (entry instanceof UnionEntry)
    {
      UnionEntry u = (UnionEntry)entry;

      // Look at the discriminant type
      SymtabEntry utype = typeOf (u.type ());
      if (utype instanceof EnumEntry && importTypes.contains (utype))
        addTo (importList, utype.name ());

      // Look through the branches
      Enumeration branches = u.branches ().elements ();
      while (branches.hasMoreElements ())
      {
        UnionBranch branch = (UnionBranch)branches.nextElement ();
        SymtabEntry branchEntry = typeOf (branch.typedef);
        if (importTypes.contains (branchEntry))
View Full Code Here

TOP

Related Classes of com.sun.tools.corba.se.idl.UnionEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.