001/*
002 * Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026#warn This file is preprocessed before being compiled
027
028class XXX {
029
030#begin
031
032#if[rw]
033
034 private $type$ get$Type$(long a) {
035 if (unaligned) {
036 $memtype$ x = unsafe.get$Memtype$(a);
037 return $fromBits$(nativeByteOrder ? x : Bits.swap(x));
038 }
039 return Bits.get$Type$(a, bigEndian);
040 }
041
042 public $type$ get$Type$() {
043 return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
044 }
045
046 public $type$ get$Type$(int i) {
047 return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
048 }
049
050#end[rw]
051
052 private ByteBuffer put$Type$(long a, $type$ x) {
053#if[rw]
054 if (unaligned) {
055 $memtype$ y = $toBits$(x);
056 unsafe.put$Memtype$(a, (nativeByteOrder ? y : Bits.swap(y)));
057 } else {
058 Bits.put$Type$(a, x, bigEndian);
059 }
060 return this ;
061#else[rw]
062 throw new ReadOnlyBufferException();
063#end[rw]
064 }
065
066 public ByteBuffer put$Type$($type$ x) {
067#if[rw]
068 put$Type$(ix(nextPutIndex($BYTES_PER_VALUE$)), x);
069 return this ;
070#else[rw]
071 throw new ReadOnlyBufferException();
072#end[rw]
073 }
074
075 public ByteBuffer put$Type$(int i, $type$ x) {
076#if[rw]
077 put$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)), x);
078 return this ;
079#else[rw]
080 throw new ReadOnlyBufferException();
081#end[rw]
082 }
083
084 public $Type$Buffer as$Type$Buffer() {
085 int off = this .position();
086 int lim = this .limit();
087 assert (off <= lim);
088 int rem = (off <= lim ? lim - off : 0);
089
090 int size = rem >> $LG_BYTES_PER_VALUE$;
091 if (!unaligned && ((address + off) % $BYTES_PER_VALUE$ != 0)) {
092 return (bigEndian
093 ? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this ,
094 -1,
095 0,
096 size,
097 size,
098 off))
099 : ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$L(this ,
100 -1,
101 0,
102 size,
103 size,
104 off)));
105 } else {
106 return (nativeByteOrder
107 ? ($Type$Buffer)(new Direct$Type$Buffer$RW$U(this ,
108 -1,
109 0,
110 size,
111 size,
112 off))
113 : ($Type$Buffer)(new Direct$Type$Buffer$RW$S(this ,
114 -1,
115 0,
116 size,
117 size,
118 off)));
119 }
120 }
121
122#end
123
124}
|