< prev index next >

src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template

Print this page
rev 57242 : imported patch 8234049.patch


  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #warn This file is preprocessed before being compiled
  27 
  28 class XXX {
  29 
  30 #begin
  31 
  32 #if[rw]
  33 
  34     private $type$ get$Type$(long a) {
  35         try {

  36             $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
  37             return $fromBits$(x);
  38         } finally {
  39             Reference.reachabilityFence(this);
  40         }
  41     }
  42 
  43     public $type$ get$Type$() {
  44         try {
  45             return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
  46         } finally {
  47             Reference.reachabilityFence(this);
  48         }
  49     }
  50 
  51     public $type$ get$Type$(int i) {
  52         try {
  53             return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
  54         } finally {
  55             Reference.reachabilityFence(this);
  56         }
  57     }
  58 
  59 #end[rw]
  60 
  61     private ByteBuffer put$Type$(long a, $type$ x) {
  62 #if[rw]
  63         try {

  64             $memtype$ y = $toBits$(x);
  65             UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
  66         } finally {
  67             Reference.reachabilityFence(this);
  68         }
  69         return this;
  70 #else[rw]
  71         throw new ReadOnlyBufferException();
  72 #end[rw]
  73     }
  74 
  75     public ByteBuffer put$Type$($type$ x) {
  76 #if[rw]
  77         put$Type$(ix(nextPutIndex($BYTES_PER_VALUE$)), x);
  78         return this;
  79 #else[rw]
  80         throw new ReadOnlyBufferException();
  81 #end[rw]
  82     }
  83 


  87         return this;
  88 #else[rw]
  89         throw new ReadOnlyBufferException();
  90 #end[rw]
  91     }
  92 
  93     public $Type$Buffer as$Type$Buffer() {
  94         int off = this.position();
  95         int lim = this.limit();
  96         assert (off <= lim);
  97         int rem = (off <= lim ? lim - off : 0);
  98 
  99         int size = rem >> $LG_BYTES_PER_VALUE$;
 100         if (!UNALIGNED && ((address + off) % $BYTES_PER_VALUE$ != 0)) {
 101             return (bigEndian
 102                     ? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this,
 103                                                                        -1,
 104                                                                        0,
 105                                                                        size,
 106                                                                        size,
 107                                                                        address + off))
 108                     : ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$L(this,
 109                                                                        -1,
 110                                                                        0,
 111                                                                        size,
 112                                                                        size,
 113                                                                        address + off)));
 114         } else {
 115             return (nativeByteOrder
 116                     ? ($Type$Buffer)(new Direct$Type$Buffer$RW$U(this,
 117                                                                  -1,
 118                                                                  0,
 119                                                                  size,
 120                                                                  size,
 121                                                                  off))
 122                     : ($Type$Buffer)(new Direct$Type$Buffer$RW$S(this,
 123                                                                  -1,
 124                                                                  0,
 125                                                                  size,
 126                                                                  size,
 127                                                                  off)));
 128         }
 129     }
 130 
 131 #end
 132 
 133 }


  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #warn This file is preprocessed before being compiled
  27 
  28 class XXX {
  29 
  30 #begin
  31 
  32 #if[rw]
  33 
  34     private $type$ get$Type$(long a) {
  35         try {
  36             checkSegment();
  37             $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
  38             return $fromBits$(x);
  39         } finally {
  40             Reference.reachabilityFence(this);
  41         }
  42     }
  43 
  44     public $type$ get$Type$() {
  45         try {
  46             return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
  47         } finally {
  48             Reference.reachabilityFence(this);
  49         }
  50     }
  51 
  52     public $type$ get$Type$(int i) {
  53         try {
  54             return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
  55         } finally {
  56             Reference.reachabilityFence(this);
  57         }
  58     }
  59 
  60 #end[rw]
  61 
  62     private ByteBuffer put$Type$(long a, $type$ x) {
  63 #if[rw]
  64         try {
  65             checkSegment();
  66             $memtype$ y = $toBits$(x);
  67             UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
  68         } finally {
  69             Reference.reachabilityFence(this);
  70         }
  71         return this;
  72 #else[rw]
  73         throw new ReadOnlyBufferException();
  74 #end[rw]
  75     }
  76 
  77     public ByteBuffer put$Type$($type$ x) {
  78 #if[rw]
  79         put$Type$(ix(nextPutIndex($BYTES_PER_VALUE$)), x);
  80         return this;
  81 #else[rw]
  82         throw new ReadOnlyBufferException();
  83 #end[rw]
  84     }
  85 


  89         return this;
  90 #else[rw]
  91         throw new ReadOnlyBufferException();
  92 #end[rw]
  93     }
  94 
  95     public $Type$Buffer as$Type$Buffer() {
  96         int off = this.position();
  97         int lim = this.limit();
  98         assert (off <= lim);
  99         int rem = (off <= lim ? lim - off : 0);
 100 
 101         int size = rem >> $LG_BYTES_PER_VALUE$;
 102         if (!UNALIGNED && ((address + off) % $BYTES_PER_VALUE$ != 0)) {
 103             return (bigEndian
 104                     ? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this,
 105                                                                        -1,
 106                                                                        0,
 107                                                                        size,
 108                                                                        size,
 109                                                                        address + off, segment))
 110                     : ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$L(this,
 111                                                                        -1,
 112                                                                        0,
 113                                                                        size,
 114                                                                        size,
 115                                                                        address + off, segment)));
 116         } else {
 117             return (nativeByteOrder
 118                     ? ($Type$Buffer)(new Direct$Type$Buffer$RW$U(this,
 119                                                                  -1,
 120                                                                  0,
 121                                                                  size,
 122                                                                  size,
 123                                                                  off, segment))
 124                     : ($Type$Buffer)(new Direct$Type$Buffer$RW$S(this,
 125                                                                  -1,
 126                                                                  0,
 127                                                                  size,
 128                                                                  size,
 129                                                                  off, segment)));
 130         }
 131     }
 132 
 133 #end
 134 
 135 }
< prev index next >