write (0, " ", "value", entry, stream);
} // helperWrite
public int read (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
{
TypedefEntry td = (TypedefEntry)entry;
String modifier = Util.arrayInfo (td.arrayInfo ());
if (!modifier.equals (""))
{
// arrayInfo is a vector of Expressions which indicate the
// number of array dimensions for this typedef. But what if
// this is a typedef of a sequence?
// The `new' statement being generated must know the full
// number of brackets. That can be found in td.info.
// For instance:
// typedef sequence<short> A[10][10];
// void proc (out A a);
// typeModifier = "[10][10]"
// td.info = "short[][][]";
// The first new statement generated is:
// a.value = new short[10][][];
// Note that the 3 sets of brackets come from td.info, not
// arrayInfo;
// The second new statement generated is:
// a.value[_i1] = new short[10][];
// ------------ ---- ------
// \ \ \
// name baseName arrayDcl
int closingBrackets = 0;
String loopIndex = "";
String baseName;
try
{
baseName = (String)td.dynamicVariable (Compile.typedefInfo);
}
catch (NoSuchFieldException e)
{
baseName = td.name ();
}
int startArray = baseName.indexOf ('[');
String arrayDcl = Util.sansArrayInfo (baseName.substring (startArray)) + "[]"; // Add an extra set because the first gets stripped off in the loop.
baseName = baseName.substring (0, startArray);
// For interfaces having state, e.g., valuetypes.
SymtabEntry baseEntry = (SymtabEntry)Util.symbolTable.get (baseName.replace ('.', '/'));
if (baseEntry instanceof InterfaceEntry && ((InterfaceEntry)baseEntry).state () != null)
// <f46082.51> Remove -stateful feature; javaStatefulName() obsolete.
//baseName = Util.javaStatefulName ((InterfaceEntry)baseEntry);
baseName = Util.javaName ((InterfaceEntry)baseEntry);
int end1stArray;
while (!modifier.equals (""))
{
int rbracket = modifier.indexOf (']');
String size = modifier.substring (1, rbracket);
end1stArray = arrayDcl.indexOf (']');
arrayDcl = '[' + size + arrayDcl.substring (end1stArray + 2);
stream.println (indent + name + " = new " + baseName + arrayDcl + ';');
loopIndex = "_o" + index++;
stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < (" + size + "); ++" + loopIndex + ')');
stream.println (indent + '{');
++closingBrackets;
modifier = modifier.substring (rbracket + 1);
indent = indent + " ";
name = name + '[' + loopIndex + ']';
}
end1stArray = arrayDcl.indexOf (']');
if (td.type () instanceof SequenceEntry || td.type () instanceof PrimitiveEntry || td.type () instanceof StringEntry)
index = ((JavaGenerator)td.type ().generator ()).read (index, indent, name, td.type (), stream);
else if (td.type () instanceof InterfaceEntry && td.type ().fullName ().equals ("org/omg/CORBA/Object"))
stream.println (indent + name + " = istream.read_Object ();");
else
stream.println (indent + name + " = " + Util.helperName (td.type (), true) + ".read (istream);"); // <d61056>
for (int i = 0; i < closingBrackets; ++i)
{
indent = indent.substring (2);
stream.println (indent + '}');
}
}
else
{
SymtabEntry tdtype = Util.typeOf (td.type ());
if (tdtype instanceof SequenceEntry || tdtype instanceof PrimitiveEntry || tdtype instanceof StringEntry)
index = ((JavaGenerator)tdtype.generator ()).read (index, indent, name, tdtype, stream);
else if (tdtype instanceof InterfaceEntry && tdtype.fullName ().equals ("org/omg/CORBA/Object"))
stream.println (indent + name + " = istream.read_Object ();");
else