User: sparre  
  Date: 01/08/10 09:14:31

  Modified:    iiop/src/main/org/jboss/iiop/rmi ContainerAnalysis.java
                        InterfaceAnalysis.java ValueAnalysis.java
  Log:
  Added support for mangling names differing only in case,
  as per section 1.3.2.7.
  
  Revision  Changes    Path
  1.3       +58 -14    contrib/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java
  
  Index: ContainerAnalysis.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContainerAnalysis.java    2001/08/08 20:19:39     1.2
  +++ ContainerAnalysis.java    2001/08/10 16:14:31     1.3
  @@ -42,7 +42,7 @@
    *  Specification", version 1.1 (01-06-07).
    *      
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.2 $
  + *  @version $Revision: 1.3 $
    */
   public abstract class ContainerAnalysis
      extends ClassAnalysis
  @@ -574,34 +574,23 @@
            if ((m_flags[i]&M_OVERLOADED) == 0)
               continue;
   
  -System.err.println("fixupOverloadedOperationNames(): method["+i+"]=\"" +
  -                   methods[i].toString() + "\".");
  -
            // Find the operation
            OperationAnalysis oa = null;
            String javaName = methods[i].getName();
            for (int opIdx = 0; oa == null && opIdx < operations.length; ++opIdx)
  -{
  -System.err.println("fixupOverloadedOperationNames(): looking at \"" +
  -                   operations[opIdx].getMethod().toString() + "\".");
  -
               if (operations[opIdx].getMethod().equals(methods[i]))
                  oa = operations[opIdx];
  -}
   
            if (oa == null)
               continue; // This method is not mapped.
   
  -System.err.println("fixupOverloadedOperationNames(): found \"" +
  -                   oa.getMethod().toString() + "\".");
  -
            // Calculate new IDL name
            ParameterAnalysis[] parms = oa.getParameters();
            StringBuffer b = new StringBuffer(oa.getIDLName());
            b.append('_');
            for (int j = 0; j < parms.length; ++j) {
               String s = parms[j].getTypeIDLName();
  -System.err.println("fixupOverloadedOperationNames(): Got name ["+s+"].");
  +
               if (s.startsWith("::"))
                  s = s.substring(2);
   
  @@ -620,11 +609,66 @@
               }
            }
   
  -System.err.println("fixupOverloadedOperationNames(): Converted to name 
["+b.toString()+"].");
            // Set new IDL name
            oa.setIDLName(b.toString());
         }
      }
  +
  +   /**
  +    *  Fixup names differing only in case.
  +    *  As specified in section 1.3.2.7.
  +    */
  +   protected void fixupCaseNames()
  +      throws RMIIIOPViolationException
  +   {
  +      ArrayList entries = getContainedEntries();
  +      boolean[] clash = new boolean[entries.size()];
  +      String[] upperNames = new String[entries.size()];
  +
  +      for (int i = 0; i < entries.size(); ++i) {
  +         AbstractAnalysis aa = (AbstractAnalysis)entries.get(i);
  +
  +         clash[i] = false;
  +         upperNames[i] = aa.getIDLName().toUpperCase();
  +
  +         for (int j = 0; j < i; ++j) {
  +            if (upperNames[i].equals(upperNames[j])) {
  +               clash[i] = true;
  +               clash[j] = true;
  +            }
  +         }
  +      }
  +
  +      for (int i = 0; i < entries.size(); ++i) {
  +         if (!clash[i])
  +            continue;
  +
  +         AbstractAnalysis aa = (AbstractAnalysis)entries.get(i);
  +         boolean noUpper = true;
  +         String name = aa.getIDLName();
  +         StringBuffer b = new StringBuffer(name);
  +         b.append('_');
  +         for (int j = 0; j < name.length(); ++j) {
  +            if (!Character.isUpperCase(name.charAt(j)))
  +               continue;
  +            if (noUpper)
  +               noUpper = false;
  +            else
  +               b.append('_');
  +            b.append(j);
  +         }
  +
  +         aa.setIDLName(b.toString());
  +      }
  +   }
  +
  +   /**
  +    *  Return a list of all the entries contained here.
  +    *
  +    *  @param entries The list of entries contained here. Entries in this list
  +    *                 must be subclasses of <code>AbstractAnalysis</code>.
  +    */
  +   abstract protected ArrayList getContainedEntries();
   
      /**
       *  Return the class hash code, as specified in "The Common Object
  
  
  
  1.3       +24 -1     contrib/iiop/src/main/org/jboss/iiop/rmi/InterfaceAnalysis.java
  
  Index: InterfaceAnalysis.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/iiop/src/main/org/jboss/iiop/rmi/InterfaceAnalysis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InterfaceAnalysis.java    2001/08/08 20:19:39     1.2
  +++ InterfaceAnalysis.java    2001/08/10 16:14:31     1.3
  @@ -42,7 +42,7 @@
    *  Specification", version 1.1 (01-06-07).
    *      
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.2 $
  + *  @version $Revision: 1.3 $
    */
   public class InterfaceAnalysis
      extends ContainerAnalysis
  @@ -88,6 +88,7 @@
   
         calculateOperationAnalysisMap();
         calculateAllTypeIds();
  +      fixupCaseNames();
      }
   
      // Public --------------------------------------------------------
  @@ -104,6 +105,28 @@
   
      // Protected -----------------------------------------------------
    
  +   /**
  +    *  Return a list of all the entries contained here.
  +    *
  +    *  @param entries The list of entries contained here. Entries in this list
  +    *                 are subclasses of <code>AbstractAnalysis</code>.
  +    */
  +   protected ArrayList getContainedEntries()
  +   {
  +      ArrayList ret = new ArrayList(constants.length +
  +                                    attributes.length +
  +                                    operations.length);
  +
  +      for (int i = 0; i < constants.length; ++i)
  +         ret.add(constants[i]);
  +      for (int i = 0; i < attributes.length; ++i)
  +         ret.add(attributes[i]);
  +      for (int i = 0; i < operations.length; ++i)
  +         ret.add(operations[i]);
  +
  +      return ret;
  +   }
  +
      /**
       *  Analyse operations.
       *  This will fill in the <code>operations</code> array.
  
  
  
  1.3       +28 -1     contrib/iiop/src/main/org/jboss/iiop/rmi/ValueAnalysis.java
  
  Index: ValueAnalysis.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/iiop/src/main/org/jboss/iiop/rmi/ValueAnalysis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValueAnalysis.java        2001/08/08 20:19:39     1.2
  +++ ValueAnalysis.java        2001/08/10 16:14:31     1.3
  @@ -18,6 +18,7 @@
   import java.io.IOException;
   import java.io.ObjectStreamField;
   
  +import java.util.ArrayList;
   import java.util.Collections;
   import java.util.SortedSet;
   import java.util.TreeSet;
  @@ -36,7 +37,7 @@
    *  Specification", version 1.1 (01-06-07).
    *      
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.2 $
  + *  @version $Revision: 1.3 $
    */
   public class ValueAnalysis
      extends ContainerAnalysis
  @@ -217,6 +218,8 @@
         if (!Serializable.class.isAssignableFrom(cls))
            abstractValue = true;
   
  +      fixupCaseNames();
  +
   System.err.println("ValueAnalysis(\""+cls.getName()+"\") done.");
      }
   
  @@ -263,7 +266,31 @@
         return (ValueMemberAnalysis[])members.clone();
      }
   
  +
      // Protected -----------------------------------------------------
  +
  +   /**
  +    *  Return a list of all the entries contained here.
  +    *
  +    *  @param entries The list of entries contained here. Entries in this list
  +    *                 are subclasses of <code>AbstractAnalysis</code>.
  +    */
  +   protected ArrayList getContainedEntries()
  +   {
  +      ArrayList ret = new ArrayList(constants.length +
  +                                    attributes.length +
  +                                    members.length);
  + 
  +      for (int i = 0; i < constants.length; ++i)
  +         ret.add(constants[i]);
  +      for (int i = 0; i < attributes.length; ++i)
  +         ret.add(attributes[i]);
  +      for (int i = 0; i < members.length; ++i)
  +         ret.add(members[i]);
  +
  +      return ret;
  +   }
  +
   
      // Private -------------------------------------------------------
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to