code: ITypeDecl getDefaultInterface( ICoClassDecl t ) {
          final int count = t.countImplementedInterfaces();
          // look for the default interface first.
          for( int i=0; i<count; i++ ) {
              IImplementedInterfaceDecl impl = t.getImplementedInterface(i);
              if(impl.isSource())
                  continue;
              if(impl.isDefault()){
                IInterfaceDecl c = getCustom(impl);
                if(c!=null)
                  return c;
                IDispInterfaceDecl d = impl.getType().queryInterface(IDispInterfaceDecl.class);
                if(d != null){
                  return d;
                }
              }
          }
  
          // if none is found, look for any non-source interface
          Set<IInterfaceDecl> types = new HashSet<IInterfaceDecl>();
          for( int i=0; i<count; i++ ) {
              IImplementedInterfaceDecl impl = t.getImplementedInterface(i);
              if(impl.isSource())
                  continue;
              IInterfaceDecl c = getCustom(impl);
              if(c !=null)
                  types.add(c);
          }
  
          if(types.isEmpty())
              return null;
  
          // if T1 and T2 are in the set and T1 derives from T2, eliminate T2
          // (since returning T1 is better)
          Set<IInterfaceDecl> bases = new HashSet<IInterfaceDecl>();
          for (IInterfaceDecl ii : types) {
              for( int i=0; i<ii.countBaseInterfaces(); i++)
                  bases.add(ii.getBaseInterface(i).queryInterface(IInterfaceDecl.class));
          }
          types.removeAll(bases);
  
          return types.iterator().next();
      }
docs: Returns the primary interface for the given co-class.
  
  @return
  null if none is found.