santiagopg    2002/10/21 13:40:31

  Modified:    java/src/org/apache/xalan/xsltc/compiler PositionCall.java
               java/src/org/apache/xalan/xsltc/dom
                        CurrentNodeListIterator.java DOMImpl.java
                        FilterIterator.java NthIterator.java
               java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
  Log:
  Committing patch from Henry Zongaro. This patch moves the logic from
  XPath's position() function from NodeIterator.getPosition() to
  BasisLibrary.positionF(). This change simplifies the integration
  between XSLTC and DTM.
  
  Revision  Changes    Path
  1.10      +6 -5      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java
  
  Index: PositionCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PositionCall.java 8 Oct 2002 21:44:13 -0000       1.9
  +++ PositionCall.java 21 Oct 2002 20:40:31 -0000      1.10
  @@ -90,11 +90,12 @@
        }
        else {
            final ConstantPoolGen cpg = classGen.getConstantPool();
  -         final int getPosition = cpg.addInterfaceMethodref(NODE_ITERATOR,
  -                                                           "getPosition", 
  -                                                           "()I");
  +            final int index =
  +                    cpg.addMethodref(BASIS_LIBRARY_CLASS, "positionF",
  +                                     "("+NODE_ITERATOR_SIG+")I");
  +
            il.append(methodGen.loadIterator());
  -         il.append(new INVOKEINTERFACE(getPosition, 1));
  +            il.append(new INVOKESTATIC(index));
        }
       }
   }
  
  
  
  1.10      +1 -8      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java
  
  Index: CurrentNodeListIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CurrentNodeListIterator.java      8 Oct 2002 21:44:14 -0000       1.9
  +++ CurrentNodeListIterator.java      21 Oct 2002 20:40:31 -0000      1.10
  @@ -197,13 +197,6 @@
        return this;
       }
        
  -    public int getPosition() {
  -     if (_last == -1) {
  -         _last = computePositionOfLast();
  -     }
  -     return _docOrder ? _position : _last - _position + 1;
  -    }
  -
       public int getLast() {
        if (_last == -1) {
            _last = computePositionOfLast();
  
  
  
  1.87      +1 -13     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- DOMImpl.java      8 Oct 2002 21:44:14 -0000       1.86
  +++ DOMImpl.java      21 Oct 2002 20:40:31 -0000      1.87
  @@ -1190,10 +1190,6 @@
            return resetPosition();
        }
   
  -     public int getPosition() {
  -         return getLast() - _position + 1;
  -     }
  -
        public void setMark() {
            _markedNode = _sibling;
        }
  @@ -1295,10 +1291,6 @@
            return END;
        }
   
  -     public int getPosition() {
  -         return getLast() - _position + 1;
  -     }
  -
        public NodeIterator reset() {
            _index = _ancestorOrSelf.cardinality() - 1;
            _node = _ancestorOrSelf.at(_index) + 1;
  @@ -1456,10 +1448,6 @@
   
        public int getLast() {
            return _last;
  -     }
  -
  -     public int getPosition() {
  -         return _last - _position + 1;       
        }
   
        public NodeIterator reset() {
  
  
  
  1.6       +1 -6      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java
  
  Index: FilterIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FilterIterator.java       8 Oct 2002 21:44:14 -0000       1.5
  +++ FilterIterator.java       21 Oct 2002 20:40:31 -0000      1.6
  @@ -142,11 +142,6 @@
        return this;
       }
   
  -    public int getPosition() {
  -     final int last = getLast();
  -     return _isReverse ? last - _position + 1 : _position;
  -    }
  -
       public void setMark() {
        _source.setMark();
       }
  
  
  
  1.11      +6 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
  
  Index: NthIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- NthIterator.java  8 Oct 2002 21:44:14 -0000       1.10
  +++ NthIterator.java  21 Oct 2002 20:40:31 -0000      1.11
  @@ -99,10 +99,14 @@
   
       public int next() {
        if (_ready && _position > 0) {
  +            final int pos = _source.isReverse()
  +                                       ? _source.getLast() - _position + 1
  +                                       : _position;
  +
            _ready = false;
            int node;
            while ((node = _source.next()) != END) {
  -             if (_position == _source.getPosition()) {
  +             if (pos == _source.getPosition()) {
                    return node;
                }
            }
  
  
  
  1.56      +10 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- BasisLibrary.java 17 Oct 2002 20:17:27 -0000      1.55
  +++ BasisLibrary.java 21 Oct 2002 20:40:31 -0000      1.56
  @@ -113,6 +113,15 @@
       }
   
       /**
  +     * Standard function position()
  +     */
  +    public static int positionF(NodeIterator iterator) {
  +       return iterator.isReverse()
  +                     ? iterator.getLast() - iterator.getPosition() + 1
  +                     : iterator.getPosition();
  +    }
  +
  +    /**
        * XSLT Standard function sum(node-set). 
        * stringToDouble is inlined
        */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to