com.sun.tools.corba.se.idl.EnumEntry Java Examples

The following examples show how to use com.sun.tools.corba.se.idl.EnumEntry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnumGen.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #2
Source File: EnumGen.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #3
Source File: EnumGen.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #4
Source File: EnumGen.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #5
Source File: EnumGen.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #6
Source File: EnumGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #7
Source File: EnumGen.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #8
Source File: EnumGen.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #9
Source File: EnumGen.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #10
Source File: EnumGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #11
Source File: EnumGen.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #12
Source File: EnumGen.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #13
Source File: EnumGen.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #14
Source File: EnumGen.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #15
Source File: EnumGen.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
  {
    tcoffsets.set (entry);
    EnumEntry enumEntry = (EnumEntry)entry;
    StringBuffer emit = new StringBuffer ("new String[] { ");
    Enumeration e = enumEntry.elements ().elements ();
    boolean firstTime = true;
    while (e.hasMoreElements ())
    {
      if (firstTime)
        firstTime = false;
      else
        emit.append (", ");
      emit.append ('"' + Util.stripLeadingUnderscores ((String)e.nextElement ()) + '"');
    }
    emit.append ("} ");
    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().create_enum_tc ("
      + Util.helperName (enumEntry, true) + ".id (), \"" // <54697> // <d61056>
//      + "_id, \"" <54697>
      + Util.stripLeadingUnderscores (entry.name ()) + "\", "
      + new String (emit) + ");");
    return index + 1;

  }
 
Example #16
Source File: EnumGen.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate the Java code for an IDL enumeration.
 **/
public void generate (Hashtable symbolTable, EnumEntry e, PrintWriter s)
{
  this.symbolTable = symbolTable;
  this.e           = e;
  init ();

  openStream ();
  if (stream == null) return;
  generateHolder ();
  generateHelper ();
  writeHeading ();
  writeBody ();
  writeClosing ();
  closeStream ();
}
 
Example #17
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = null;");
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
}
 
Example #18
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example #19
Source File: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = null;");
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
}
 
Example #20
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
}
 
Example #21
Source File: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
}
 
Example #22
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example #23
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = null;");
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
}
 
Example #24
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
}
 
Example #25
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example #26
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = null;");
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
}
 
Example #27
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
}
 
Example #28
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example #29
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = null;");
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
}
 
Example #30
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
{
  if (entry instanceof TypedefEntry)
  {
    TypedefEntry td = (TypedefEntry)entry;
    writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
  }
  else if (entry instanceof SequenceEntry)
    writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
  else if (entry instanceof EnumEntry)
    if (arrayDcl.length () > 0)
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
  else if (entry instanceof PrimitiveEntry)
  {
    boolean array = arrayDcl.length () > 0;
    String tname = javaPrimName (entry.name ());
    if (tname.equals ("boolean"))
      stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.TypeCode"))
      stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Any"))
      stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
    else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
      stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
    else
      stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
  }
  // <f46082.51> Remove -stateful feature. This case is identical to next one
  // because javaName() supplants javaStatefulName().
  //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
  //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
  else
    stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
}